Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest changes from 3.1.x to lts-2025 #1025

Merged
merged 11 commits into from
Jan 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ storiesOf('UI/nuxeo-actions-menu', module).add('Default', () => {
<nuxeo-actions-menu>
${list.map(
(i) => html`
<nuxeo-link-button href="javascript:void(0)" icon=${i} label=${i}> </nuxeo-link-button>
<nuxeo-link-button href="#" icon=${i} label=${i}> </nuxeo-link-button>
`,
)}
</nuxeo-actions-menu>
Expand Down
2 changes: 2 additions & 0 deletions ui/import-href.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 17 additions & 6 deletions ui/nuxeo-aggregation/nuxeo-checkbox-aggregation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)]])
</paper-checkbox>
</div>
</template>
Expand Down Expand Up @@ -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)]])
</paper-checkbox>
</div>
</template>
</dom-repeat>
<span hidden$="[[_hideShowMoreButton(buckets, visibleItems)]]" class="show-more-button">
<a href="javascript:void(0);" on-tap="_toggleShow">
<a href="#" on-tap="_toggleShow">
[[_computeShowMoreLabel(_showAll, i18n)]]
</a>
</span>
Expand Down Expand Up @@ -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 [];
Expand All @@ -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);
}

Expand Down
12 changes: 11 additions & 1 deletion ui/nuxeo-data-table/data-table-cell.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ import './data-table-templatizer-behavior.js';
return html`
<style>
:host {
flex: 1 0 100px;
flex: 1 0 120px;
flex-basis: 120px;
padding: 0 24px;
min-height: 48px;
display: flex;
Expand All @@ -34,6 +35,15 @@ import './data-table-templatizer-behavior.js';
:host([header]) ::slotted(*) {
min-width: 0;
}

:host([header]) ::slotted(#columnHeader) {
flex: 1 1 70px;
min-width: 70px;
max-width: 120px;
overflow: hidden;
text-overflow: ellipsis;
text-align: start;
}
</style>
<slot></slot>
`;
Expand Down
7 changes: 6 additions & 1 deletion ui/nuxeo-data-table/data-table-column-sort.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,14 @@ import { I18nBehavior } from '../nuxeo-i18n-behavior.js';
right: 4px;
bottom: 8px;
}

#sortContainer {
position: relative;
width: 40px;
}
</style>

<div style="position: relative">
<div id="sortContainer">
<paper-icon-button
id="sortIcon"
on-click="_sort"
Expand Down
4 changes: 3 additions & 1 deletion ui/nuxeo-data-table/data-table-column.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ import './data-table-column-filter.js';
role="columnheader"
>
</nuxeo-data-table-column-filter>
<div hidden$="[[column.filterBy]]" role="columnheader">[[column.name]]</div>
<div id="columnHeader" title="[[column.name]]" hidden$="[[column.filterBy]]" role="columnheader">
[[column.name]]
</div>
</template>
`;
}
Expand Down
41 changes: 18 additions & 23 deletions ui/nuxeo-filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 <nuxeo-filter> expression "${expression}"`);
Expand Down
3 changes: 2 additions & 1 deletion ui/nuxeo-path-suggestion/nuxeo-path-suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ import { FormatBehavior } from '../nuxeo-format-behavior.js';

<dom-if if="[[label]]">
<template>
<label>[[label]]</label>
<label title="[[labelTooltip]]">[[label]]</label>
</template>
</dom-if>

Expand All @@ -112,6 +112,7 @@ import { FormatBehavior } from '../nuxeo-format-behavior.js';
on-focus="_onFocus"
disabled$="[[disabled]]"
no-label-float
title="[[value]]"
>
</paper-typeahead>
`;
Expand Down
8 changes: 6 additions & 2 deletions ui/widgets/nuxeo-selectivity.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions ui/widgets/nuxeo-tag-suggestion.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ import { escapeHTML } from './nuxeo-selectivity.js';
}

_newEntryFormatter(term) {
term = term ? term.toLowerCase() : null;
return { id: term, displayLabel: term, newTag: true };
}

Expand Down
Loading