UX: caches icon picker full icon's list (#8862)

This commit is contained in:
Joffrey JAFFEUX
2020-02-05 09:22:11 +01:00
committed by GitHub
parent a9f1652131
commit d7dffbb13c

View File

@@ -8,14 +8,34 @@ export default MultiSelectComponent.extend({
pluginApiIdentifiers: ["icon-picker"], pluginApiIdentifiers: ["icon-picker"],
classNames: ["icon-picker"], classNames: ["icon-picker"],
init() {
this._super(...arguments);
this._cachedIconsList = null;
},
content: computed("value.[]", function() { content: computed("value.[]", function() {
return makeArray(this.value).map(this._processIcon); return makeArray(this.value).map(this._processIcon);
}), }),
search(filter = "") { search(filter = "") {
return ajax("/svg-sprite/picker-search", { data: { filter } }).then(icons => if (
icons.map(this._processIcon) filter === "" &&
); this._cachedIconsList &&
this._cachedIconsList.length
) {
return this._cachedIconsList;
} else {
return ajax("/svg-sprite/picker-search", {
data: { filter }
}).then(icons => {
icons = icons.map(this._processIcon);
if (filter === "") {
this._cachedIconsList = icons;
}
return icons;
});
}
}, },
_processIcon(icon) { _processIcon(icon) {
@@ -48,6 +68,8 @@ export default MultiSelectComponent.extend({
willDestroyElement() { willDestroyElement() {
$("#svg-sprites .ajax-icon-holder").remove(); $("#svg-sprites .ajax-icon-holder").remove();
this._super(...arguments); this._super(...arguments);
this._cachedIconsList = null;
}, },
actions: { actions: {