diff --git a/storybook/src/elements/nuxeo-actions-menu/nuxeo-actions-menu.stories.js b/storybook/src/elements/nuxeo-actions-menu/nuxeo-actions-menu.stories.js index 1d4e2394c..496b4eb3b 100644 --- a/storybook/src/elements/nuxeo-actions-menu/nuxeo-actions-menu.stories.js +++ b/storybook/src/elements/nuxeo-actions-menu/nuxeo-actions-menu.stories.js @@ -28,7 +28,7 @@ storiesOf('UI/nuxeo-actions-menu', module).add('Default', () => { ${list.map( (i) => html` - + `, )} diff --git a/ui/import-href.js b/ui/import-href.js index d2c3f32a1..b95206343 100644 --- a/ui/import-href.js +++ b/ui/import-href.js @@ -104,12 +104,14 @@ export const importHref = function(href, onload, onerror, optAsync) { */ export const importHTML = (html) => { const tmpl = document.createElement('template'); + const nuxeoNonceValue = Nuxeo && Nuxeo.UI && Nuxeo.UI.config && Nuxeo.UI.config.nonce || '' tmpl.innerHTML = html; [...tmpl.content.children].forEach((el) => { if (el.tagName === 'SCRIPT' && !el.src) { const script = document.createElement('script'); [...el.attributes].forEach((attr) => script.setAttribute(attr.name, attr.value)); script.setAttribute('src', `data:text/javascript;charset=utf-8,${encodeURIComponent(el.textContent)}`); + script.setAttribute("nonce", nuxeoNonceValue); el = script; } document.head.appendChild(el); diff --git a/ui/nuxeo-aggregation/nuxeo-checkbox-aggregation.js b/ui/nuxeo-aggregation/nuxeo-checkbox-aggregation.js index 180fc4d01..221a197d2 100644 --- a/ui/nuxeo-aggregation/nuxeo-checkbox-aggregation.js +++ b/ui/nuxeo-aggregation/nuxeo-checkbox-aggregation.js @@ -146,9 +146,9 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js'; noink checked="{{item.checked}}" on-change="_computeValues" - aria-label$="[[item.label]] ([[item.docCount]])" + aria-label$="[[item.label]] ([[_formatDocCount(item.docCount)]])" > - [[item.label]] ([[item.docCount]]) + [[item.label]] ([[_formatDocCount(item.docCount)]]) @@ -179,15 +179,15 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js'; noink checked="{{item.checked}}" on-change="_computeValues" - aria-label$="[[item.label]] ([[item.docCount]])" + aria-label$="[[item.label]] ([[_formatDocCount(item.docCount)]])" > - [[item.label]] ([[item.docCount]]) + [[item.label]] ([[_formatDocCount(item.docCount)]]) - + [[_computeShowMoreLabel(_showAll, i18n)]] @@ -257,6 +257,16 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js'; this.setAttribute('tabindex', 0); } + _formatDocCount(docCount) { + // Fetch the property value from web-ui-properties.xml + const isNumberFormattingEnabled = + (Nuxeo && Nuxeo.UI && Nuxeo.UI.config && Nuxeo.UI.config.numberFormattingEnabled) || false; + if (isNumberFormattingEnabled) { + return new Intl.NumberFormat().format(docCount); // Apply formatting if enabled + } + return docCount; // Return if formatting is disabled + } + _computeVisibleBuckets(buckets, visibleItems, _showAll) { if (!buckets || buckets.length === 0) { return []; @@ -272,7 +282,8 @@ import { AggregationBehavior } from './nuxeo-aggregation-behavior.js'; return `hardware:keyboard-arrow-${opened ? 'up' : 'down'}`; } - _toggleShow() { + _toggleShow(e) { + e.preventDefault(); this._set_showAll(!this._showAll); } diff --git a/ui/nuxeo-data-table/data-table-cell.js b/ui/nuxeo-data-table/data-table-cell.js index b3e93fee6..05cbf1d4e 100644 --- a/ui/nuxeo-data-table/data-table-cell.js +++ b/ui/nuxeo-data-table/data-table-cell.js @@ -12,7 +12,8 @@ import './data-table-templatizer-behavior.js'; return html` `; diff --git a/ui/nuxeo-data-table/data-table-column-sort.js b/ui/nuxeo-data-table/data-table-column-sort.js index d90dc1fdc..34a2a5eb5 100644 --- a/ui/nuxeo-data-table/data-table-column-sort.js +++ b/ui/nuxeo-data-table/data-table-column-sort.js @@ -49,9 +49,14 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior.js'; right: 4px; bottom: 8px; } + + #sortContainer { + position: relative; + width: 40px; + } -
+
-
[[column.name]]
+
+ [[column.name]] +
`; } diff --git a/ui/nuxeo-filter.js b/ui/nuxeo-filter.js index 642b814f5..90976c3d0 100644 --- a/ui/nuxeo-filter.js +++ b/ui/nuxeo-filter.js @@ -18,7 +18,6 @@ limitations under the License. import '@polymer/polymer/polymer-legacy.js'; import '@nuxeo/nuxeo-elements/nuxeo-element.js'; -import { config } from '@nuxeo/nuxeo-elements'; import { Debouncer } from '@polymer/polymer/lib/utils/debounce.js'; import { microTask } from '@polymer/polymer/lib/utils/async.js'; import { enqueueDebouncer } from '@polymer/polymer/lib/utils/flush.js'; @@ -185,29 +184,25 @@ import Interpreter from './js-interpreter/interpreter.js'; let res = false; try { - if (!config.get('expressions.eval', true)) { - const js = new Interpreter(expression, (interpreter, scope) => { - // set scope - interpreter.setProperty(scope, 'this', interpreter.nativeToPseudo(FiltersBehavior)); - Object.entries({ document, user }).forEach(([k, obj]) => { - const v = {}; - // filter out private properties - Object.getOwnPropertyNames(obj) - .filter((p) => !p.startsWith('_')) - .forEach((p) => { - v[p] = obj[p]; - }); - interpreter.setProperty(scope, k, interpreter.nativeToPseudo(v)); - }); - // XXX: 'this' in the scope of native functions is the interpreter instance - Object.assign(interpreter, FiltersBehavior); + const js = new Interpreter(expression, (interpreter, scope) => { + // set scope + interpreter.setProperty(scope, 'this', interpreter.nativeToPseudo(FiltersBehavior)); + Object.entries({ document, user }).forEach(([k, obj]) => { + const v = {}; + // filter out private properties + Object.getOwnPropertyNames(obj) + .filter((p) => !p.startsWith('_')) + .forEach((p) => { + v[p] = obj[p]; + }); + interpreter.setProperty(scope, k, interpreter.nativeToPseudo(v)); }); - js.run(); - res = js.value; - } else { - const fn = new Function(['document', 'user'], `return ${expression};`); - res = fn.apply(this, [document, user]); - } + // XXX: 'this' in the scope of native functions is the interpreter instance + Object.assign(interpreter, FiltersBehavior); + }); + js.run(); + res = js.value; + return res; } catch (err) { console.error(`${err} in expression "${expression}"`); diff --git a/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js b/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js index 6357d0655..7e63596e1 100644 --- a/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js +++ b/ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js @@ -99,7 +99,7 @@ import { FormatBehavior } from '../nuxeo-format-behavior.js'; @@ -112,6 +112,7 @@ import { FormatBehavior } from '../nuxeo-format-behavior.js'; on-focus="_onFocus" disabled$="[[disabled]]" no-label-float + title="[[value]]" > `; diff --git a/ui/widgets/nuxeo-selectivity.js b/ui/widgets/nuxeo-selectivity.js index 622113668..a1f959d43 100644 --- a/ui/widgets/nuxeo-selectivity.js +++ b/ui/widgets/nuxeo-selectivity.js @@ -2435,7 +2435,11 @@ typedArrayTags[weakMapTag] = false; let resultsHtml = isFilteredResultNotEmpty ? this.renderItems(filteredResults) : ''; if (options.hasMore) { resultsHtml += this.selectivity.template('loadMore'); - } else if (value && Array.isArray(value) && value.includes(options.term)) { + } else if ( + value && + Array.isArray(value) && + value.includes(options && options.term ? options.term.toLowerCase() : null) + ) { resultsHtml = this.selectivity.template('tagExists'); } else if (!resultsHtml && !options.add) { resultsHtml = this.selectivity.template('noResults', { term: options.term }); @@ -6932,7 +6936,7 @@ typedArrayTags[weakMapTag] = false; border: none; float: left; font: inherit; - max-width: 100%; + width: 100%; outline: 0; padding: 0; padding-top: 1px; diff --git a/ui/widgets/nuxeo-tag-suggestion.js b/ui/widgets/nuxeo-tag-suggestion.js index 63070d193..f3c4e8b1a 100644 --- a/ui/widgets/nuxeo-tag-suggestion.js +++ b/ui/widgets/nuxeo-tag-suggestion.js @@ -237,6 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js'; } _newEntryFormatter(term) { + term = term ? term.toLowerCase() : null; return { id: term, displayLabel: term, newTag: true }; }