diff --git a/CHANGELOG.md b/CHANGELOG.md index 9bf20b93a..ee9a4f528 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ - Remove no longer used code; adjust item list slightly ([#1651](../../pull/1651)) - Reduce updates when showing item lists; add a waiting spinner ([#1653](../../pull/1653)) - Update item lists check for large images when toggling recurse ([#1654](../../pull/1654)) +- Support named item lists ([#1665](../../pull/1665)) ### Changes diff --git a/docs/girder_config_options.rst b/docs/girder_config_options.rst index 601504624..720aa56a0 100644 --- a/docs/girder_config_options.rst +++ b/docs/girder_config_options.rst @@ -183,6 +183,45 @@ This is used to specify how items appear in item lists. There are two settings, If there are no large images in a folder, none of the image columns will appear. +Named Item Lists +................ + +Multiple item lists can be stored with specific names. A default item list can be specified. + +:: + + --- + # If present and the value is a key in the namedItemLists section, that + # list will be shown unless the URL routes to a different list. + defaultItemList: images + # Any number of items can be in the namedItemLists section. Each name + # must be distinct. The system can show the specific list by routing to + # ?namedList= as part of the url after the folder id. + namedItemLists: + image: + layout: + mode: list + columns: + - + type: image + value: thumbnail + title: Thumbnail + - + type: image + value: label + title: Slide Label + - + # The "record" type is from the default item record. The value is + # one of "name", "size", or "controls". + type: record + value: name + - + type: record + value: size + - + type: record + value: controls + Item Metadata ............. diff --git a/girder/girder_large_image/web_client/views/itemList.js b/girder/girder_large_image/web_client/views/itemList.js index 8282c726e..86d55ffd5 100644 --- a/girder/girder_large_image/web_client/views/itemList.js +++ b/girder/girder_large_image/web_client/views/itemList.js @@ -61,6 +61,32 @@ wrap(ItemListWidget, 'initialize', function (initialize, settings) { const result = initialize.call(this, settings); delete this._hasAnyLargeImage; + this._confList = () => { + let list; + if (!this._liconfig) { + return undefined; + } + const namedList = this._namedList || this._liconfig.defaultItemList; + if (this.$el.closest('.modal-dialog').length) { + list = this._liconfig.itemListDialog; + } else if (namedList && this._liconfig.namedItemLists && this._liconfig.namedItemLists[namedList]) { + list = this._liconfig.namedItemLists[namedList]; + } else { + list = this._liconfig.itemList; + } + if (list.group) { + let group = list.group; + group = !group.keys ? {keys: group} : group; + group.keys = Array.isArray(group.keys) ? group.keys : [group.keys]; + group.keys = group.keys.filter((g) => !g.includes(',') && !g.includes(':')); + if (!group.keys.length) { + group = undefined; + } + list.group = group; + } + return list; + }; + largeImageConfig.getConfigFile(settings.folderId, true, (val) => { if (!settings.folderId) { this._liconfig = val; @@ -75,6 +101,7 @@ wrap(ItemListWidget, 'initialize', function (initialize, settings) { const curRoute = Backbone.history.fragment; const routeParts = splitRoute(curRoute); const query = parseQueryString(routeParts.name); + this._namedList = query.namedList || undefined; let update = false; if (query.sort) { this._lastSort = query.sort.split(',').map((chunk) => { @@ -150,10 +177,6 @@ wrap(ItemListWidget, 'render', function (render) { } } - this._confList = () => { - return this._liconfig ? (this.$el.closest('.modal-dialog').length ? this._liconfig.itemListDialog : this._liconfig.itemList) : undefined; - }; - /** * Set sort on the collection and perform a debounced re-fetch. */ @@ -178,7 +201,6 @@ wrap(ItemListWidget, 'render', function (render) { return item.has('largeImage'); }); this._inFetch = false; - itemListRender.apply(this, _.rest(arguments)); if (oldPages !== pages || this.collection.offset !== this.collection.size()) { this.collection.offset = this.collection.size(); this.trigger('g:paginated');