Skip to content

Commit 3e215fe

Browse files
committed
feat: add configurable memberSort for collection/object listings
Add memberSort option to collection and object config schemas, defaulting to 'name' for backwards compatibility. This replaces the hardcoded sort field in CollectionMembers and ObjectView.
1 parent cd38fae commit 3e215fe

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

src/components/CollectionMembers.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@ if (!api) {
88
throw new Error('API instance not provided');
99
}
1010
11-
const { title, id, entityType, routePath } = defineProps<{
11+
const { title, id, entityType, routePath, sort } = defineProps<{
1212
title: string;
1313
id: string;
1414
entityType: string;
1515
routePath: string;
16+
sort: string;
1617
}>();
1718
1819
const items = ref<EntityType[]>([]);
@@ -26,7 +27,7 @@ const setMembers = async () => {
2627
memberOf: id,
2728
entityType,
2829
limit: pageSize.value,
29-
sort: 'name',
30+
sort,
3031
order: 'asc',
3132
};
3233

src/configuration.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,10 +74,12 @@ const metaSchema = z.discriminatedUnion('mode', [
7474

7575
const collectionSchema = z.strictObject({
7676
meta: metaSchema,
77+
memberSort: z.string().optional().default('name'),
7778
});
7879

7980
const objectSchema = z.object({
8081
meta: metaSchema,
82+
memberSort: z.string().optional().default('name'),
8183
});
8284

8385
export type CollectionConfig = z.infer<typeof collectionSchema>;

src/views/CollectionView.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,14 +126,14 @@ onMounted(fetchData);
126126
<el-row>
127127
<el-col>
128128
<CollectionMembers :title="t('collection.subCollections')" :id="id"
129-
entityType="http://pcdm.org/models#Collection" routePath="collection" />
129+
entityType="http://pcdm.org/models#Collection" routePath="collection" :sort="config.memberSort" />
130130
</el-col>
131131
</el-row>
132132

133133
<el-row>
134134
<el-col>
135135
<CollectionMembers :title="t('collection.objectsInCollection')" :id="id"
136-
entityType="http://pcdm.org/models#Object" routePath="object" />
136+
entityType="http://pcdm.org/models#Object" routePath="object" :sort="config.memberSort" />
137137
</el-col>
138138
</el-row>
139139
</el-col>

src/views/ObjectView.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ const fetchMembers = async () => {
111111
memberOf: entity.value.memberOf.id,
112112
entityType: 'http://pcdm.org/models#Object',
113113
limit: FETCH_LIMIT,
114-
sort: 'name',
114+
sort: config.memberSort,
115115
order: 'asc',
116116
};
117117

0 commit comments

Comments
 (0)