From 07610dca1abfbb94da6d51296eecf0da104a4f29 Mon Sep 17 00:00:00 2001 From: Martin Nicholson Date: Sun, 29 Dec 2019 00:42:11 +0100 Subject: [PATCH 01/15] Bump Handlebars to 4.5.3 --- build/rollup.config.js | 20 ++++++------- package-lock.json | 64 ++++++++++++++++++++++++++++-------------- package.json | 2 +- 3 files changed, 54 insertions(+), 32 deletions(-) diff --git a/build/rollup.config.js b/build/rollup.config.js index c7141685..e3026354 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -33,16 +33,16 @@ const Handlebars = require('handlebars'); * Support of handlebars 1.3.0 * TODO remove once migrated to hbs >= 3.0.0 */ -const originalVisitor = Handlebars.Visitor; -Handlebars.Visitor = function() { - return originalVisitor.call(this); -}; -Handlebars.Visitor.prototype = Object.create(originalVisitor.prototype); -Handlebars.Visitor.prototype.accept = function() { - try { - originalVisitor.prototype.accept.apply(this, arguments); - } catch (e) {} -}; +// const originalVisitor = Handlebars.Visitor; +// Handlebars.Visitor = function() { +// return originalVisitor.call(this); +// }; +// Handlebars.Visitor.prototype = Object.create(originalVisitor.prototype); +// Handlebars.Visitor.prototype.accept = function() { +// try { +// originalVisitor.prototype.accept.apply(this, arguments); +// } catch (e) {} +// }; /* --------------------------------------------------------- */ const inputs = glob.sync(path.join(srcDir, '**', '*.js')); diff --git a/package-lock.json b/package-lock.json index c8f14b47..44913f7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -2272,13 +2272,23 @@ "dev": true }, "handlebars": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-1.3.0.tgz", - "integrity": "sha1-npsTCpPjiUkTItl1zz7BgYw3zjQ=", + "version": "4.5.3", + "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.5.3.tgz", + "integrity": "sha512-3yPecJoJHK/4c6aZhSvxOyG4vJKDshV36VHp0iVCDVh7o9w2vwi3NSnL2MMPj3YdduqaBcu7cGbggJQM0br9xA==", "dev": true, "requires": { - "optimist": "~0.3", - "uglify-js": "~2.3" + "neo-async": "^2.6.0", + "optimist": "^0.6.1", + "source-map": "^0.6.1", + "uglify-js": "^3.1.4" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", + "dev": true + } } }, "har-schema": { @@ -3568,12 +3578,21 @@ } }, "optimist": { - "version": "0.3.7", - "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.3.7.tgz", - "integrity": "sha1-yQlBrVnkJzMokjB00s8ufLxuwNk=", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/optimist/-/optimist-0.6.1.tgz", + "integrity": "sha1-2j6nRob6IaGaERwybpDrFaAZZoY=", "dev": true, "requires": { + "minimist": "~0.0.1", "wordwrap": "~0.0.2" + }, + "dependencies": { + "minimist": { + "version": "0.0.10", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.10.tgz", + "integrity": "sha1-3j+YVD2/lggr5IrRoMfNqDYwHc8=", + "dev": true + } } }, "os-homedir": { @@ -5006,26 +5025,29 @@ "dev": true }, "uglify-js": { - "version": "2.3.6", - "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-2.3.6.tgz", - "integrity": "sha1-+gmEdwtCi3qbKoBY9GNV0U/vIRo=", + "version": "3.7.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.7.3.tgz", + "integrity": "sha512-7tINm46/3puUA4hCkKYo4Xdts+JDaVC9ZPRcG8Xw9R4nhO/gZgUM3TENq8IF4Vatk8qCig4MzP/c8G4u2BkVQg==", "dev": true, "optional": true, "requires": { - "async": "~0.2.6", - "optimist": "~0.3.5", - "source-map": "~0.1.7" + "commander": "~2.20.3", + "source-map": "~0.6.1" }, "dependencies": { + "commander": { + "version": "2.20.3", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz", + "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==", + "dev": true, + "optional": true + }, "source-map": { - "version": "0.1.43", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.1.43.tgz", - "integrity": "sha1-wkvBRspRfBRx9drL4lcbK3+eM0Y=", + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true, - "optional": true, - "requires": { - "amdefine": ">=0.0.4" - } + "optional": true } } }, diff --git a/package.json b/package.json index 32f2387b..b96c6e02 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "fs-extra": "^8.0.1", "gamp": "^0.2.1", "glob": "^7.1.4", - "handlebars": "1.3.0", + "handlebars": "4.5.3", "interactjs": "1.3.4", "jquery": "1.9.1", "jquery-mockjax": "^2.5.0", From b88ffd10afa3983f588e28c88a4cda5b8ff4c9c5 Mon Sep 17 00:00:00 2001 From: Martin Nicholson Date: Fri, 3 Jan 2020 12:32:41 +0100 Subject: [PATCH 02/15] Handlebars build config --- build/path.js | 5 ++++- build/rollup.config.js | 16 ---------------- 2 files changed, 4 insertions(+), 17 deletions(-) diff --git a/build/path.js b/build/path.js index 275ca371..dcb76d6d 100644 --- a/build/path.js +++ b/build/path.js @@ -32,6 +32,9 @@ module.exports = { testOutputDir: path.resolve(rootPath, 'test'), aliases: { ui: srcDir, - build: path.resolve(rootPath, 'build') + build: path.resolve(rootPath, 'build'), + // Hardcoded paths to partial Handlebars templates (prevents unresolved template dependencies) + 'ui-generis-widget-label.tpl': path.resolve(srcDir, 'generis/widget/widget.tpl'), + 'ui-form-widget-label.tpl': path.resolve(srcDir, 'form/widget/tpl/label.tpl') } }; diff --git a/build/rollup.config.js b/build/rollup.config.js index e3026354..35fb9b01 100644 --- a/build/rollup.config.js +++ b/build/rollup.config.js @@ -29,22 +29,6 @@ import wildcardExternal from '@oat-sa/rollup-plugin-wildcard-external'; const { srcDir, outputDir, aliases } = require('./path'); const Handlebars = require('handlebars'); -/** - * Support of handlebars 1.3.0 - * TODO remove once migrated to hbs >= 3.0.0 - */ -// const originalVisitor = Handlebars.Visitor; -// Handlebars.Visitor = function() { -// return originalVisitor.call(this); -// }; -// Handlebars.Visitor.prototype = Object.create(originalVisitor.prototype); -// Handlebars.Visitor.prototype.accept = function() { -// try { -// originalVisitor.prototype.accept.apply(this, arguments); -// } catch (e) {} -// }; -/* --------------------------------------------------------- */ - const inputs = glob.sync(path.join(srcDir, '**', '*.js')); /** From ee4d014052ab7f4cf64b4a92f82a4db4c4c1393f Mon Sep 17 00:00:00 2001 From: Martin Nicholson Date: Fri, 3 Jan 2020 13:08:02 +0100 Subject: [PATCH 03/15] Fix templates containing ../ --- src/datalist/tpl/list.tpl | 16 ++++------- src/datatable/tpl/layout.tpl | 54 +++++++++++++++++------------------- src/listbox/tpl/list.tpl | 2 +- 3 files changed, 33 insertions(+), 39 deletions(-) diff --git a/src/datalist/tpl/list.tpl b/src/datalist/tpl/list.tpl index bcf87b3b..7a875570 100644 --- a/src/datalist/tpl/list.tpl +++ b/src/datalist/tpl/list.tpl @@ -1,23 +1,19 @@ {{#each list}} - {{#if ../selectable}} + {{#if @root.selectable}} {{/if}} {{label}} - {{#if ../actions}} + {{#if @root.actions}} - {{#each ../../actions}} - {{#with ../../line}} - {{#unless ../hidden}} - {{#with ../../this}} + {{#each @root.actions}} + {{#unless hidden}} - {{/with}} - {{/unless}} - {{/with}} - {{/each}} + {{/unless}} + {{/each}} {{/if}} diff --git a/src/datatable/tpl/layout.tpl b/src/datatable/tpl/layout.tpl index f9d6555b..fd849e45 100644 --- a/src/datatable/tpl/layout.tpl +++ b/src/datatable/tpl/layout.tpl @@ -10,12 +10,12 @@
{{#with options.status}}

- + - {{#if loading}}{{loading}}{{else}}{{../../options.labels.loading}}{{/if}}... + {{#if loading}}{{loading}}{{else}}{{@root.options.labels.loading}}{{/if}}...

{{/with}} @@ -83,27 +83,25 @@ - {{#each dataset.data}} + {{#each dataset.data as |row|}} - {{#if ../options.selectable}} + {{#if @root.options.selectable}} {{/if}} - {{#each ../options.model}} + {{#each @root.options.model as |column|}} {{#if type}} - {{#each ../actions}} + {{#each column.actions}} {{#if id}} - {{#with ../../../../this}} - {{#unless ../hidden}} - {{/unless}} - {{/with}} {{else}} {{/unless}} - {{/with}} + {{!/with}} {{else}} {{/if}} - {{/each}} + {{!/each}} - {{/with}} + {{/each}} {{/each}} diff --git a/src/listbox/tpl/list.tpl b/src/listbox/tpl/list.tpl index ad8b9837..d06faf6f 100644 --- a/src/listbox/tpl/list.tpl +++ b/src/listbox/tpl/list.tpl @@ -1,6 +1,6 @@