Skip to content

Commit

Permalink
Support named item lists
Browse files Browse the repository at this point in the history
  • Loading branch information
manthey committed Oct 4, 2024
1 parent 0f124ea commit 1e3c8b8
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
39 changes: 39 additions & 0 deletions docs/girder_config_options.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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=<name> 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
.............

Expand Down
32 changes: 27 additions & 5 deletions girder/girder_large_image/web_client/views/itemList.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) => {
Expand Down Expand Up @@ -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.
*/
Expand All @@ -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');
Expand Down

0 comments on commit 1e3c8b8

Please sign in to comment.