Giter Site home page Giter Site logo

ccali / a2jdat Goto Github PK

View Code? Open in Web Editor NEW
3.0 16.0 1.0 50.3 MB

This repo hosts the distributable production version of the A2J Document Assembly Tool (DAT). The document assembly tool is an optional piece of software used for producing pdf documents at the end of A2J Author Guided Interviews.

Home Page: https://www.a2jauthor.org

License: Other

HTML 54.33% JavaScript 15.97% CSS 7.86% Less 20.66% Mustache 1.17%
justice a2j access-to-justice legal legaltech

a2jdat's Introduction

A2JDAT

This repo is part of the A2J Author Project which consists of four repos...
3. A2J Document Automation Tool - https://github.com/CCALI/a2jdat
4. A2J Dependencies - https://github.com/CCALI/a2jdeps

This repo hosts the distributable production version of the A2J Document Assembly Tool (DAT). The document assembly tool is an optional piece of software used for producing pdf documents at the end of interviews. It requires the A2Jviewer, wkhtmltopdf and nodejs 12+ to run properly. The recommended additional tools for windows are volta and pm2-windows-service and volta for *nix.

Within this repo and releases you'll find a .zip file containing the minified JavaScript source for the DAT and sample configuration files

NOTE: By downloading this application, you are agreeing to the terms included in the user license LICENSE.md.

Hosting

The DAT requires nodejs 16.17.0+. Any system supporting nodejs 16.17.0+ is supported. It has been tested on ubuntu 18, centos, and Windows Server 2016 on Azure with apache and IIS

While other server environments may work, they have not been tested. Should you get another hosting environment working, please do a Pull Request at the hosted A2J DAT repo to let us know any steps taken so that we may share with others.

Current release

if installing through git, the current release version is always in the production branch. This is identical to the zipped source package in the releases page.

Upgrade notes/summary from node A2JDAT v2

The folder structure has changed. It is recommended that your current setup is backed up. This means at a minimum, config.json and ecosystem.config.js. Alternatively you may checkout/unzip this repo into a new folder.

The folder structure has changed such that the DAT is no longer a sub folder.

Old structure

Containing Folder
-A2JDAT
--DAT
-config.js
-ecosystem.js

Current required structure:

Containing Folder
-config.js
-ecosystem.config.js
-A2JDAT (this DAT repo)

The WKHTMLTOPDF_ZOOM settings have changed. YOU MUST SET THIS CORRECTLY TO MATCH PDFs GENERATED ON A2JAUTHOR.ORG On most *nix systems this should be 1.6711 and on most windows systems this should be 1.5709.

Assuming you have all up-to-date dependencies (wkhtmltopdf, node, npm, pm2, volta) you can run npm run deploy and skip to step 13 of installation instructions for calibration. Otherwise you must start from step 0.

General Installation instructions

All Platforms + common solutions to common problems

For all platforms this document should work as written. You can skip to step 4 of Installation Instructions for systems with working DAT setup. Starting from step 1 may upgrade those DAT subdependencies which is expected to cause no issues.

This document should work as written but some components will likely need to be recompiled for the current node 16.

if the DAT does not properly start after using these instructions, the likely culprit is muhammara. This will be indicated by running pm2 logs and seeing a node version error. To confirm this, run pm2 logs which will yield something like

2|dev-hydr | was compiled against a different Node.js version using
2|dev-hydr | NODE_MODULE_VERSION 72. This version of Node.js requires
2|dev-hydr | NODE_MODULE_VERSION 93. Please try re-compiling or re-installing
2|dev-hydr | the module (for instance, using `npm rebuild` or `npm install`).
2|dev-hydr |     at Object.Module._extensions..node (node:internal/modules/cjs/loader:1183:18)
2|dev-hydr |     at Module.load (node:internal/modules/cjs/loader:981:32)
2|dev-hydr |     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
2|dev-hydr |     at Module.require (node:internal/modules/cjs/loader:1005:19)
2|dev-hydr |     at Module.Hook._require.Module.require (/home/a2jprod/.volta/tools/image/packages/pm2/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39)
2|dev-hydr |     at require (node:internal/modules/cjs/helpers:102:18)
2|dev-hydr |     at Object.<anonymous> (/vol/data/sites/hydra.a2jauthor.org/a2jdat/node_modules/re2/re2.js:3:13)
2|dev-hydr |     at Module._compile (node:internal/modules/cjs/loader:1101:14)
2|dev-hydr |     at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
2|dev-hydr |     at Module.load (node:internal/modules/cjs/loader:981:32)

To rectify follow the instructions below:

1.) go to the a2jdat folder

2.) run npm install muhammara in a command line

3.) restart DAT process and test

if that doesn't work try below:

1.) cd node_modules/muhammara

2.) node-pre-gyp rebuild

3.) restart DAT process and test

Installation instructions

0.) NVM is no longer supported and should be uninstalled and replced with voltajs. For *nix users uninstall nvm if installed

rm -rf #NVM_HOME

1.) Install voltajs (https://github.com/volta-cli/volta). The DAT is a simple restful API that requires nodejs to serve endpoints. Though, you are free to install the node version that the DAT targets and manage it manually, the recommended method is to use a node version manager which will allow the simultaneous installation of multiple versions of node and mitigates several administration issues.

Obtain volta here: https://docs.volta.sh/guide/getting-started

For *nix, per the instructions above run : curl https://get.volta.sh | bash

For Windows Users:

Ensure Node is in PATH:

The node installer might not always set the PATH variable correctly. Check Environment variables to ensure that there is an entry for the folder containing node.exe. For this tutorial that folder is C:\Program Files\nodejs.

Configure Node Permissions:

Node.exe must be added to the IIS_IUSRS group in order to be allowed to handle requests. This must occur every time the node executable is switched through nvm or volta. Open a command prompt and run as administrator and run icacls “%programfiles%\nodejs\node.exe” /grant IIS_IUSRS:rx

For all users

2.) Install node through volta navigate to the root folder of the DAT (contains a2jdat folder) and type the following commands in the terminal to install the required node version

volta install [email protected]

check that the install was successful by typing

node -v

which should produce the version number of node we installed, 16.17.0

navigate to the a2jdat subdiectory and check the node version in volta Which should automatically download the right version as it is pinned in package.json by running

volta list

check that the install was successful by typing

node -v

which should produce the version number of node we installed, 16.17.0

3.) Install global DAT dependencies and subdependencies:

Git is a source control manager and required for npm. This can be obtained through most *nix package managers. For windows, install Git by downloading latest from https://git-scm.com/download/win As of this documents writing, the latest version for the system in the azure demo environment is located at: https://github.com/git-for-windows/git/releases/download/v2.37.3.windows.1/Git-2.37.3-64-bit.exe

for windows, this README will use Git Bash for terminal commands

for windows, this README will use Git Bash for terminal commands

4.) Install build tools:

The node sub-dependencies for the DAT must be built locally on the target system and requires build tools for languages other than node. Run the command below to install the necessary build tools:

For windows

use the command below to install npm --add-python-to-path='true' --debug install --global windows-build-tools

install python 3 https://www.python.org/downloads/release/python-3104/

This requires administrator access. This is a very lengthy install- it can take over an hour even on a fast machine with a fantastic connection.

For all platforms run the command below

npm install @mapbox/node-pre-gyp node-gyp babel-cli steal-tools@1 -g

5.) Install wkhtmltopdf WKHTMLTOPDF is the engine used to transform interview data into PDF from an intermediate HTML file. Download the latest stable version from https://wkhtmltopdf.org/downloads.html and install it in the environment. Make a note of the install path.

6.) Install node process manager The node process manager handles automatic restarts, memory mangement, monitoring, and error logging.

For All platforms: The recommended process manager is pm2 (http://pm2.keymetrics.io/). Install it with the following command

npm install pm2 -g

Windows users, install pm2 windows service

npm i pm2-windows-service -g pm2-service-install -n PM2

Notes to Windows users about iisnode:

a.) Older versions of this project used iisnode (https://github.com/tjanczuk/iisnode) iisnode is no longer supported. For migration instructions go here: https://www.a2jauthor.org/content/migrate-pm2-iis. To make pm2 independent of logouts follow the instructions here to install pm2-windows-service.

Notes to Windows users if pm2-windows-service fails. Run the command below (from jon-hall/pm2-windows-service#56):
npm install -g npm-check-updates
cd %USERPROFILE%\AppData\Roaming\npm\node_modules\pm2-windows-service
ncu inquirer -u
npm install

then pm2-service-install -n PM2

The correct PM2 executable path for volta must point to pm2 node_modules folder for default pm2 installs in volta this path is %USERPROFILE%\AppData\Local\Volta\tools\image\packages\pm2\node_modules\pm2. This corresponds to the PM2_SERVICE_PM2_DIR environment variable.

7.) Download the latest DAT from repo through git or from https://github.com/CCALI/A2JDAT/releases into your webroot or preferred directory on your web server.

8.) Compile from source instructions

navigate to the downloaded location in a terminal and run either the following commands in sequence

cd a2jdat
npm run deploy

or the equivalent

cd a2jdat
npm install
npm run build
npm run build:server

if you encounter an error in this step it can often be resolved by deleting the node_modules folder in the a2jdat folder and repeating the step. If that does not work, re-clone into a brand new directory and run the commands in that directory.

if you encounter EINTEGRITY errors delete package-lock.json and rerun npm run deploy

9.) Configure DAT Since the A2J software can run on many platforms, there is a small amount of platform specific configuration that is necessary. Navigate to a2jdat\samples.configs\. There are two samples for config.json (config.json.nix.sample and config.json.win.sample) that will need to be edited and saved to the containing folder of the a2jdat as config.json. Edit and save the sample appropriate to your platform (config.json.nix.sample for *NIX systems and config.json.win.sample for Windows systems).

The Most important keys are: GUIDES_DIR- required to establish location of templates GUIDES_URL- relative web location of guides WKHTMLTOPDF_PATH- path to binary of WKHTMLTOPDF VIEWER_PATH- path to folder containing guides folder. For most standalone installs this will be the path to the extracted viewer which should enclose a guides folder. For A2JAuthor installations this will be the folder containing userfiles WKHTMLTOPDF_DPI- desired default dpi to render pdfs. CALI recommends minimum of 300 WKHTMLTOPDF_ZOOM- The correction factor used to render text pdfs. This is necessary to standardize rendering across all platforms. On most *nix systems this should be 1.6711 and on most windows systems this should be 1.5709.

All other keys must be present but the value is irrelevant.

Ensure that the value for the key WKHTMLTOPDF_PATH matches the path noted above where WKHTMLTOPDF is installed. Backslashes are special characters in json so each backslash must be typed twice to escape them and work properly.

a sample config.json for Windows is below:

{
  "GUIDES_DIR": "C:\\inetpub\\wwwroot\\a2j-viewer\\guides",
  "GUIDES_URL": "../a2j-viewer/guides",
  "VIEWER_PATH": "C:\\inetpub\\wwwroot\\a2j-viewer\\viewer\\",
  "WKHTMLTOPDF_PATH": "C:\\Program Files\\wkhtmltopdf\\bin\\wkhtmltopdf",
  "WKHTMLTOPDF_DPI": 300,
  "WKHTMLTOPDF_ZOOM": 1.5709
}

a sample config.json for Linux is below:

{
  "GUIDES_DIR": "/var/www/mysite.tld/a2j-viewer/guides",
  "GUIDES_URL": "../a2j-viewer/guides",
  "VIEWER_PATH": "/vol/data/sites/viewer.mysite.tld/a2jviewer/viewer",
  "WKHTMLTOPDF_PATH": "/usr/bin/local/wkhtmltopdf",
  "WKHTMLTOPDF_DPI": 300,
  "WKHTMLTOPDF_ZOOM": 1.6711
}

10.) Configure the server

The DAT is a simple restful interface with endpoints located at /api/. Requests must be routed through the node /bin/www target. We will setup a reverse proxy to accomplish this.

Reverse proxy for windows (IIS)

for IIS Advanced Request Routing will need to be setup. Follow the instructions here: https://docs.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing#configuring-rules-for-the-reverse-proxy

for IIS/Windows below is an example web.config

<?xml version="1.0" encoding="UTF-8"?>
<!--
     This is an exampe configuration file for using the DAT with pm2
-->
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="ReverseProxyInboundRule1" stopProcessing="true">
                    <match url="(api/.*)" />
                    <action type="Rewrite" url="http://localhost:3000/{R:1}" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

IIS will need to be restarted before these changes take effect

Reverse proxy for Apache (Linux)

for apache add the following directives to your site config

ProxyPass /api http://localhost:3000/api
ProxyPassReverse /api http://localhost:3000/api
ProxyBadHeader Ignore
Reverse proxy for nginx (Linux)

for nginx add the following directives

Location /api {
    Proxy_pass http://127.0.0.1:3000/
}

11.) Edit ecosystem.config.js

we have created a script to allow pm2 to manage memory and multiple instances of the DAT. The default script will run a cluster of 4 processes and restart a process if it uses more than 768MB.

12.) Start the node process navigate to the DAT folder in a terminal

pm2 start ecosystem.config.js

Configure auto-restart of pm2

To configure pm2 to autoload on startup run the following command with the desired pm2 processes running pm2 save

Calibrate

13.) Testing and calibration To ensure that the documents produced are identical to a2jauthor, run and generate a pdf through the DAT calibration guide provided in /calibration folder. With the PDF viewed at actual size and captured in screenshot The letter height of the Arial text should be 68pixels. A canonical png and pdf is included in the /calibration folder for comparison.

Security Note

This software uses software with dependencies with a few known security vulnerabilities. The features required to exploit this vulnerability are not used in this software in normal production and hence it is not an issue.

More info

To find out more about A2J Viewer and A2J Author® please see our website, www.a2jauthor.org

Ever growing backend documentation including tutorials and examples can be found at https://www.a2jauthor.org/content/a2j-selfhosting-and-backend

For questions, contact Tobias Nteireho at [email protected]

License

GNU AGPLv3

a2jdat's People

Contributors

anubhavdhingra avatar jessicafrank avatar johnmayer avatar tobiasnteireho avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

mikemitchel

a2jdat's Issues

can-view-scope::attr is deprecated

This warning as well, which will most likely go away as CanJS packages are updated, but we should find which specific one is logging this warning:

can-view-scope::attr is deprecated, please use peek, get or set

from CAJA, @tobiasnteireho comments
this is showing up in the latest dat on windows 10 but not in linux.
this is being observed in linux on prod and may be linked to occasional failures to produce non-blank documents.

throw explicit unhandled exceptions for bad configs. No magic defaults.

Having no magic defaults would make administration considerably more easy.

These are the keys that should throw an error. Minimum should throw an error on missing or empty keys. Ideal would also throw error on key that does not make sense, e.g. path does not actually contain expected item.

GUIDES_DIR
GUIDES_URL
VIEWER_PATH
WKHTMLTOPDF_PATH
WKHTMLTOPDF_DPI
WKHTMLTOPDF_ZOOM

related to https://github.com/CCALI/CAJA/issues/1962

Requirements Doc for DAT Accessibility

This issue is for planning and scoping the DAT Accessibility project (TIG 20042). Feel free to add to this issue with brainstorming ideas. When ideas have formed into distinct tasks, we'll break them off into separate issues.

"As a user I should be able to..."

  • verify my answers before my final printable document is generated

"As an author I should be able to..."

  • learn about making my underlying PDF accessible from the A2J Authoring Guide
  • watch a video that explains how to make my underlying PDF accessible on the A2J Author YouTube Channel
  • learn about making my underlying text template accessible from the A2J Authoring Guide
  • watch a video that explains how to make my text template accessible on the A2J Author YouTube Channel

New guides not always creating templates.json

When in author creating new, valid guides not always creating templates.json resulting in blank screen in templates tab and ENOENT in error log. Failure to create templates.json is not being recorded in logs

Grouped, repeating vars aren't generating correctly in Hydra

Created a simple test interview for addendumlabel testing on hydra attached below.

Loaded it into hydra and ran a test with a repeat loop that should contain four items: Car, House, Toy, and Ball as seen here in the screenshot I took before I hit the assemble command.

image

The output of the document showed car car and house. Toy and Ball are missing. The template is set up to append to an addendum, just the overflow. I purposely did not give it an addendum label.

image
Test for AddendumLabel Template Issue 4 26 2021.zip

The output PDF with the errors is attached as well.
test-for-addendum-label-template-issue-4-26-2021 (1).pdf

Allow font size granularity down to a single variable

Feature request from an author -

Allow authors to set the font size for a single variable to be different from the entirety of the template. The author wants one variable to be larger than the rest to fit with a court form.

Set the language of the generated page

As a screen reader user, I want the page to have the lang attribute, so that the page is read with the correct accent.

Currently, no lang attribute is provided for the preview page. This should probably be set to en-US.

Header does not render variable values

Using ckeditor to insert a variable in the text template header does not render any value associated with that variable during assembly/test assembly.

header vars

text templates failing on azure

text templates are not rendering and yielding the following error on one azure box

3|CALI A2JDAT  | can-view-scope::attr is deprecated, please use peek, get or set
3|CALI A2JDAT  | Failed promise: TypeError: Cannot read property 'TEXT_NODE' of undefined
3|CALI A2JDAT  |     at Object.live.text (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-view-live/lib/text.js:19:27)
3|CALI A2JDAT  |     at Text.branchRenderer (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-stache/src/mustache_core.js:406:11)
3|CALI A2JDAT  |     at Comment.callback (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-view-target/can-view-target.js:223:18)
3|CALI A2JDAT  |     at hydrateCallbacks (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-view-target/can-view-target.js:262:39)
3|CALI A2JDAT  |     at Object.hydrate (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-view-target/can-view-target.js:284:4)
3|CALI A2JDAT  |     at HelperOptions.convertedRenderer (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-stache/src/utils.js:80:17)
3|CALI A2JDAT  |     at HelperOptions.fn (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-observation-recorder/can-observation-recorder.js:87:18)
3|CALI A2JDAT  |     at A2JVariableVM.ifHelper (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-stache/helpers/core.js:215:26)
3|CALI A2JDAT  |     at {{if(canShowAnswer)}} (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-stache/expressions/call.js:110:16)
3|CALI A2JDAT  |     at Observation.onBound (file:C:/inetpub/wwwroot/a2jdat-20201118/a2jdat/node_modules/can-observation/can-observation.js:87:27)

Investigating

Need to update DAT zoom setting

Staging had zoom setting at 1.0 which was causing text templates to produce fonts that were too small for their set size. Mike and I tested it and he found the 1.6 setting most closely matches expected font sizes in PDFs.

need to update the zoom setting to 1.6 in all environments and restart

Set up automated accessibility testing for the preview page

As a developer, I want to have automated accessibility testing set up for the preview page, so that I can catch errors faster and avoid regressions.


We can use axe-core for integration testing the generated html page, in addition to unit tests in the individual repos.

If we use axe-core, then I think we might need to:

Fix validation errors

As a user of assistive technology (AT), I do not want the preview document to include validation errors, so that my AT can accurately interpret and parse content.

Handle `templates.json` index errors

If there is an issue creating a template file, or if there is a reference to a template ID number in the templates.json file that doesn't exist, A2J should handle that cleanup, or prompt the author to remove the reference. Currently if the templates.json index file points to a template that doesn't exist, it causes the templates page to not load at all, and requires an Author to publish the interview and re-upload it to fix those references.

Should handle:

  • templates.json file doe not exist, but template files do (template1.json, template2.json, template2.pdf)
  • templates.json references a template ID # that no longer exists
  • moved to #69

Author option to change double spaced lines

CKEditor defaults to double space on hitting the enter key, and will single space only if you hit shift+enter. There's likely a toolbar button for changing this option that we are not showing, and should add it.

odd errors and blank pages after long uptimes

observed on production a2j.org that mixed templates were occasionaly failing to properly assemble. Errors are generated but not useful with some examples below occurring on multiple lines. Unreproduceable after updating pm2 and restarting process set.

The most salient likely being

(node:13244) Warning: Accessing non-existent property 'current' of module exports inside circular dependency

with occasional appearances of below which would also accompany good documents

can-view-scope::attr is deprecated, please use peek, get or set

done-autorender didn't receive route definitions.For Server-Side-Rendering you have to provide an initialized can-route.See the guide for information. https
://canjs.com/doc/can-route.html and https://donejs.com/Apis.html#can-route

Variables not in alphabetical order

When searching for variables to insert into a template, the variables are listed in no apparent order.

image

Tested in staging v 6.0 2020-07-29

Create `/preview` route to support Text template previews

This is related to the Viewer issue to allow Text template previews CCALI/a2jviewer#170

  • add a /preview route and pair with a function to handle generating the html preview
  • refactor any current functionality in the /assemble route/function to allow sharing of reused code for this new feature
  • make sure the preview does not change or break the assemble code

Fix ECONNREFUSED error when running the /api/preview tests

Slack thread for context: https://cali.slack.com/archives/C069V9TTN/p1639757244068800

Steps to reproduce:

  1. Remove the .skip from a preview test, e.g.

    // TODO: this test is skipped due to the issue described in https://github.com/CCALI/a2jdat/issues/100
    it.skip('previews basic templates correctly', function (done) {

  2. Run the tests (npm test)

Expected results: tests would pass.

Actual results: all the tests pass except this preview test.

Note that if you skip this test, then the preview test will pass:

it('assembles basic templates correctly', function (done) {
// Set a longer timeout, otherwise the PDF generation will fail
this.timeout(5000)
const fileDataUrl = path.join(__dirname, '..', 'data', 'DEV', 'guides', 'Guide1262')
request(app)
.post('/api/assemble')
.send({
answers: '{}',
fileDataUrl
})
.expect(200)
.end(function (err) {
if (err) return done(err)
done()
})
})

What I observed with @tobiasnteireho is that when a document is rendered with SSR for assembly or preview, it works the first time, but subsequent calls fail because the server has been torn down.

I am happy to pair with whoever picks this up so I can help them reproduce it.

Regular margin is lost when footer is added

Generally a text template has a 1 inch-ish looking margin around the entire border of the document.

image

When a custom footer is added, the margin goes down to nothing/zero inch

image

When a custom header is added, the margin appears to come back
image

Please check if there is a margin setting that isn't triggered when the footer is added or is changed when a footer is added. @AnubhavDhingra

Here's a basic interview with a template that has a header and a footer to demonstrate the issue.
My Interview (8-25-2021).zip

***Note to myself: contact Gail Pals when issue is resolved.

Template Options not applying correctly

The Template Options do not seem to be applying correctly when a document is generated.

In the below examples, there is a header/footer, section heading, and some regular text in the body. The header, footer, and body are all set to use "Normal" paragraph format and the "(Default)" font and size (which I presume should come from the Template Options)

Example 1: Set Font Family to Times New Roman and size 14.

  • The resulting PDF is all in Times New Roman (yay!)
  • The header/footer are 9.60 and the body is 8.45.

Example 2: Set Font Family to Arial and size 10.

  • The header is Times New Roman size 9.6
  • The section title and body are in Arial, but size 5.95

The header/footer seem to be 'stuck' at Times New Roman size 9.6, and the body is coming out around 60% the expected size.

Being that I am not terribly familiar with the DAT, this could be user error or some settings I am missing, but if so, those are not obvious to me and may be easily missed by other users.

Tested in staging v 6.0 2020-07-29. Interview/templates and examples are attached.

Example 1.pdf
Brett's component split test 1.zip
Example 2.pdf

joi.js library validation errors are not clear

When there are template errors from validation, it shows a list of errors that may or may not be directly related to the problem. In the below error case, the actual error was that the child "overflow" fails because [child "addendumLabel" fails because ["addendumLabel" is not allowed to be empty]]. Should see if one error is polluting or causing another, or if it's just reporting 'all the errors' because of a bad config or bad error condition defintion.

UnhandledPromiseRejectionWarning: ValidationError: child "patches" fails because ["patches" at position 35 fails because [child "type" fails because ["type" must be one of [text]], child "overflow" fails because [child "addendumLabel" fails because ["addendumLabel" is not allowed to be empty]], child "type" fails because ["type" must be one of [table-text]], child "type" fails because ["type" must be one of [checkmark]]]]

Improved error messages for PDF templates

Incorporate error messages from the joi library to display a more verbose error message.

The validate function in validate.js returns an error object for a failed request.
This object has a details array which can be used to display relevant messages to make debugging easier.

Unicode title causes DAT to fail assembly

lsnj reports that Changing title of GI to unicode characters (arabic observed) causes DAT to fail to assemble. This is related but separate to #71. If the title only contains roman chars but the content is in unicode assembly works

Header hides first 3 lines

The text template header does not print the first 2-3 lines of text in the final document. Putting blank spaces does allow header text to show, which seems to indicate it's a CSS or done-ssr rendering issue with the template header.

Screen Shot 2020-11-06 at 4 41 01 PM

checkboxes and radio buttons on text templates

It looks like CKEditor allows display of checkboxes and radio buttons, and we can likely hook into that with a custom plugin to allow a GI variable to check or select those boxes on render.

Update the page title to be more meaningful

As a user, I want the page title to be more descriptive, so I can more easily understand what the preview page is when it’s opened and I perceive it in my list of browser tabs/windows.

Currently, “A2J Test Assemble” is the page’s title. If possible, this title should be changed to be more meaningful.

update docs for upgrading from node 8.9.4 to node 12 to include pm2-windows-service upgrade error mitigations

Manju D J from marlabs reports pm2-windows-service has issues with node 12 on azure. including:

1.) Earlier installed pm2 windows service was pointing to older version of nvm folder which was not valid.

2.) System variable “PM2_SERVICE_PM2_DIR” was pointing to wrong nvm location.

3.) Inquirer module was not updated to newer version to support latest npm version.

3 is resolved with jon-hall/pm2-windows-service#56

Need to update docs.

Set custom margins for templates

PDF templates can set the margins for Addendum pages, but have had request to be able to set margins in text templates as well. Should look into global setting vs page by page setting, likely having both options with warnings if updating a global setting does not match an already set local page.

Show current date on header/template

Feature request to be able to show the current date with a simple setting/tick in the template(s). I think currently we can display a variable, but that will only grab the current date via logic for the day the GI was taken, not the date the form was printed.

nvm-windows is broken by windows update and/or npm repo change. Invesigate new version managers

unable to install or manage npm with nvm after runnning latest windows system update.

getting errors such as coreybutler/nvm-windows#580

Downloading node.js version 12.22.1 (64-bit)...
Complete
Downloading npm version 6.14.12... Download failed. Rolling Back.
Rollback failed. remove C:\Users\a2j\AppData\Roaming\nvm\temp\npm-v6.14.12.zip: The process cannot access the file because it is being used by another process.
Could not download npm for node v12.22.1.
Please visit https://github.com/npm/npm/releases/tag/v6.14.12 to download npm.
It should be extracted to C:\Users\a2j\AppData\Roaming\nvm\v12.22.1

reinstalling nv, and disabling windows defender does not fix and in at least one case has made the problem worse resulting in this error occasionally occuirring

ERROR open \settings.txt: [...]

coreybutler/nvm-windows#22.

nvm-windows latest release is from 2018 and appears to be under less active development. Investigating alternatives such as nvs (https://github.com/jasongin/nvs) and linkedin's volta (https://github.com/volta-cli/volta#installing-volta)

DAT zoom changed again

current good zoom on linux looks to be closer to 1.600 based on cal. this has changed before #37 . Is this due to deps?

Rendered text template styles.css not loaded in production

Found a bug where unanswered variables in text templates were rendering the variable name instead of being blank as expected. Turned out to be that the done-css/steal-css compiled css stylesheet was not being read/loaded and so the final html to be rendered via wkhtmltopdf did not have the styles need to hide that unanswered variable name.

Could be one of these problems:

  1. the wrong path is generated - unlikely as there is also a manually created link that has the right path
  2. it's silently failing to read/load that css file sheet
  3. the path and ability to read are there, but some race condition prevents the styles from being inserted in time

Currently we are running the development version of the DAT in production, which is working but not ideal.

Grouped variables on PDF templates fail without addendum label

When you have a text variable grouped with Ignore text overflow checked, but don't fill in an addendumLabel it will fail the assembly saying it's required in an error thrown in the DAT / Node console. If you add a label it will render/work, even though it should not care about a label.

Likely needs to be fixed in the patcher, or in code that calls the patchMultilineText() function call:

function patchMultilineText (pdf, patch, {fonts}) {

Breakpoint for checking the patches and if they have an addendumLabel provided and are of type multi-line-text is here:

return joi.validate(overlay, Overlay).error

Sometimes other instances of grouped text variables have an addendumLabel set in the patch (matching the variable name) but don't show or render anything in the Variable modal. This may be a separate issue/edge case.

Attached sample of failing Variable setup:
Screen Shot 2021-04-19 at 11 54 00 AM

Update folder structure

Update the development branch folder structure to more closely match the current main branch for easier deploys.

Text Templates assemble as blank documents when condition on the template isn't satisfied.

Have a GI with a conditional text template (or several conditional text templates). If the condition for that text template isn't satisfied, a blank page is included in the assembled document in the spot the template would have been.

This is generally an odd, but workable solution, until you get multiple conditional text templates in a document assembly package. It creates confusion among end users as to why something blank came out with their documents and makes it look like something went wrong.

This only happens with text templates. Does not happen with PDF templates. If a PDF template's condition isn't satisfied, it just does nothing. That's the expected behavior and should be what text templates do as well.

Text GI
Assembly test for DAT (July 2020).zip

Conditions are [Have children TF] = true for second text template to assemble and [Client first name TE] = JessBob for PDF Template to assemble.

Test answer files: answer (63).zip

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.