@@ -2,6 +2,93 @@ import { EntityType, targetEntities } from "../../../search/types/IHubCatalog";
2
2
import { IConfigurationSchema } from "../types" ;
3
3
import { CARD_TITLE_TAGS , CORNERS , DROP_SHADOWS } from "./enums" ;
4
4
5
+ /**
6
+ * JSON schema for the appearance of a gallery display
7
+ * This can be for a catalog, a collection, a gallery card, etc
8
+ */
9
+ export const GalleryDisplayConfigSchema : IConfigurationSchema = {
10
+ type : "object" ,
11
+ properties : {
12
+ hidden : { type : "boolean" , default : false } ,
13
+ layout : {
14
+ type : "string" ,
15
+ enum : [
16
+ "list" ,
17
+ "grid" ,
18
+ "grid-filled" ,
19
+ "table" ,
20
+ "map" ,
21
+ "compact" ,
22
+ "calendar" ,
23
+ ] ,
24
+ default : "list" ,
25
+ } ,
26
+ cardTitleTag : {
27
+ type : "string" ,
28
+ enum : Object . keys ( CARD_TITLE_TAGS ) ,
29
+ default : CARD_TITLE_TAGS . h3 ,
30
+ } ,
31
+ showThumbnail : {
32
+ type : "string" ,
33
+ enum : [ "show" , "hide" , "grid" ] ,
34
+ default : "show" ,
35
+ } ,
36
+ corners : {
37
+ type : "string" ,
38
+ enum : Object . keys ( CORNERS ) ,
39
+ default : CORNERS . square ,
40
+ } ,
41
+ shadow : {
42
+ type : "string" ,
43
+ enum : Object . keys ( DROP_SHADOWS ) ,
44
+ default : DROP_SHADOWS . none ,
45
+ } ,
46
+ showLinkButton : { type : "boolean" , default : false } ,
47
+ linkButtonStyle : {
48
+ type : "string" ,
49
+ enum : [ "outline" , "outline-filled" ] ,
50
+ default : "outline-filled" ,
51
+ } ,
52
+ linkButtonText : { type : "string" , default : "Explore" } ,
53
+ sort : {
54
+ type : "string" ,
55
+ enum : [ "relevance" , "title" , "created" , "modified" ] ,
56
+ default : "relevance" ,
57
+ } ,
58
+ filters : {
59
+ type : "array" ,
60
+ items : {
61
+ type : "object" ,
62
+ properties : {
63
+ key : {
64
+ type : "string" ,
65
+ enum : [
66
+ "location" ,
67
+ "type" ,
68
+ "source" ,
69
+ "event-occurrence" ,
70
+ "event-from" ,
71
+ "event-attendance" ,
72
+ "tags" ,
73
+ "categories" ,
74
+ "license" ,
75
+ "modified" ,
76
+ "access" ,
77
+ "group-role" ,
78
+ "group-type" ,
79
+ "group-access" ,
80
+ "event-access" ,
81
+ "event-date" ,
82
+ ] ,
83
+ } ,
84
+ hidden : { type : "boolean" } ,
85
+ label : { type : "string" } ,
86
+ } ,
87
+ } ,
88
+ } ,
89
+ } ,
90
+ } ;
91
+
5
92
/** JSON schema for an IPredicate */
6
93
export const PredicateSchema : IConfigurationSchema = {
7
94
type : "object" ,
@@ -53,49 +140,7 @@ export const CollectionSchema: IConfigurationSchema = {
53
140
type : "string" ,
54
141
} ,
55
142
scope : QuerySchema ,
56
- } ,
57
- } ;
58
-
59
- /**
60
- * JSON schema for the appearance of a gallery display
61
- * This can be for a catalog, a collection, a gallery card, etc
62
- */
63
- export const GalleryDisplayConfigSchema : IConfigurationSchema = {
64
- type : "object" ,
65
- properties : {
66
- hidden : { type : "boolean" , default : false } ,
67
- layout : {
68
- type : "string" ,
69
- enum : [ "list" , "grid" , "table" , "map" , "compact" ] ,
70
- default : "list" ,
71
- } ,
72
- cardTitleTag : {
73
- type : "string" ,
74
- enum : Object . keys ( CARD_TITLE_TAGS ) ,
75
- default : CARD_TITLE_TAGS . h3 ,
76
- } ,
77
- showThumbnail : {
78
- type : "string" ,
79
- enum : [ "show" , "hide" , "grid" ] ,
80
- default : "show" ,
81
- } ,
82
- corners : {
83
- type : "string" ,
84
- enum : Object . keys ( CORNERS ) ,
85
- default : CORNERS . square ,
86
- } ,
87
- shadow : {
88
- type : "string" ,
89
- enum : Object . keys ( DROP_SHADOWS ) ,
90
- default : DROP_SHADOWS . none ,
91
- } ,
92
- showLinkButton : { type : "boolean" , default : false } ,
93
- linkButtonStyle : {
94
- type : "string" ,
95
- enum : [ "outline" , "outline-filled" ] ,
96
- default : "outline-filled" ,
97
- } ,
98
- linkButtonText : { type : "string" , default : "Explore" } ,
143
+ displayConfig : GalleryDisplayConfigSchema ,
99
144
} ,
100
145
} ;
101
146
@@ -120,16 +165,15 @@ export const CatalogSchema: IConfigurationSchema = {
120
165
type : "array" ,
121
166
items : CollectionSchema ,
122
167
} ,
123
- displayConfig : GalleryDisplayConfigSchema ,
124
- } ,
125
- } ;
126
-
127
- /**
128
- * JSON schema for the appearance of an IHubCollection
129
- */
130
- export const CollectionAppearanceSchema : IConfigurationSchema = {
131
- type : "object" ,
132
- properties : {
133
- displayConfig : GalleryDisplayConfigSchema ,
168
+ displayConfig : {
169
+ type : "object" ,
170
+ properties : targetEntities . reduce (
171
+ ( acc : Record < EntityType , any > , targetEntity : EntityType ) => {
172
+ acc [ targetEntity ] = GalleryDisplayConfigSchema ;
173
+ return acc ;
174
+ } ,
175
+ { } as Record < EntityType , any >
176
+ ) ,
177
+ } ,
134
178
} ,
135
179
} ;
0 commit comments