@esri/hub-common 9.26.2 → 9.27.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es2017/search/_internal/index.js +3 -0
- package/dist/es2017/search/_internal/index.js.map +1 -0
- package/dist/es2017/search/_internal/state.js +147 -0
- package/dist/es2017/search/_internal/state.js.map +1 -0
- package/dist/es2017/search/_searchContent.js +11 -4
- package/dist/es2017/search/_searchContent.js.map +1 -1
- package/dist/es2017/search/_searchGroups.js.map +1 -1
- package/dist/es2017/search/collectionState.js +60 -0
- package/dist/es2017/search/collectionState.js.map +1 -0
- package/dist/es2017/search/content-utils.js +14 -7
- package/dist/es2017/search/content-utils.js.map +1 -1
- package/dist/es2017/search/index.js +2 -1
- package/dist/es2017/search/index.js.map +1 -1
- package/dist/es2017/search/types/ICatalog.js +1 -0
- package/dist/es2017/search/types/ICatalog.js.map +1 -0
- package/dist/es2017/search/types/ICollection.js +1 -0
- package/dist/es2017/search/types/ICollection.js.map +1 -0
- package/dist/es2017/search/types/IFacet.js +1 -0
- package/dist/es2017/search/types/IFacet.js.map +1 -0
- package/dist/es2017/search/types/IFacetOption.js +1 -0
- package/dist/es2017/search/types/IFacetOption.js.map +1 -0
- package/dist/es2017/search/types/index.js +6 -0
- package/dist/es2017/search/types/index.js.map +1 -0
- package/dist/es2017/search/{types.js → types/types.js} +0 -0
- package/dist/{node/search → es2017/search/types}/types.js.map +1 -1
- package/dist/es2017/search/utils.js.map +1 -1
- package/dist/esm/search/_internal/index.js +3 -0
- package/dist/esm/search/_internal/index.js.map +1 -0
- package/dist/esm/search/_internal/state.js +147 -0
- package/dist/esm/search/_internal/state.js.map +1 -0
- package/dist/esm/search/_searchContent.js +12 -5
- package/dist/esm/search/_searchContent.js.map +1 -1
- package/dist/esm/search/_searchGroups.js.map +1 -1
- package/dist/esm/search/collectionState.js +61 -0
- package/dist/esm/search/collectionState.js.map +1 -0
- package/dist/esm/search/content-utils.js +15 -7
- package/dist/esm/search/content-utils.js.map +1 -1
- package/dist/esm/search/index.js +2 -1
- package/dist/esm/search/index.js.map +1 -1
- package/dist/esm/search/types/ICatalog.js +1 -0
- package/dist/esm/search/types/ICatalog.js.map +1 -0
- package/dist/esm/search/types/ICollection.js +1 -0
- package/dist/esm/search/types/ICollection.js.map +1 -0
- package/dist/esm/search/types/IFacet.js +1 -0
- package/dist/esm/search/types/IFacet.js.map +1 -0
- package/dist/esm/search/types/IFacetOption.js +1 -0
- package/dist/esm/search/types/IFacetOption.js.map +1 -0
- package/dist/esm/search/types/index.js +6 -0
- package/dist/esm/search/types/index.js.map +1 -0
- package/dist/esm/search/{types.js → types/types.js} +0 -0
- package/dist/{es2017/search → esm/search/types}/types.js.map +1 -1
- package/dist/esm/search/utils.js.map +1 -1
- package/dist/node/search/_internal/index.js +6 -0
- package/dist/node/search/_internal/index.js.map +1 -0
- package/dist/node/search/_internal/state.js +158 -0
- package/dist/node/search/_internal/state.js.map +1 -0
- package/dist/node/search/_searchContent.js +13 -6
- package/dist/node/search/_searchContent.js.map +1 -1
- package/dist/node/search/_searchGroups.js.map +1 -1
- package/dist/node/search/collectionState.js +65 -0
- package/dist/node/search/collectionState.js.map +1 -0
- package/dist/node/search/content-utils.js +14 -7
- package/dist/node/search/content-utils.js.map +1 -1
- package/dist/node/search/index.js +2 -1
- package/dist/node/search/index.js.map +1 -1
- package/dist/node/search/types/ICatalog.js +3 -0
- package/dist/node/search/types/ICatalog.js.map +1 -0
- package/dist/node/search/types/ICollection.js +3 -0
- package/dist/node/search/types/ICollection.js.map +1 -0
- package/dist/node/search/types/IFacet.js +3 -0
- package/dist/node/search/types/IFacet.js.map +1 -0
- package/dist/node/search/types/IFacetOption.js +3 -0
- package/dist/node/search/types/IFacetOption.js.map +1 -0
- package/dist/node/search/types/index.js +9 -0
- package/dist/node/search/types/index.js.map +1 -0
- package/dist/node/search/{types.js → types/types.js} +0 -0
- package/dist/{esm/search → node/search/types}/types.js.map +1 -1
- package/dist/node/search/utils.js.map +1 -1
- package/dist/types/core/types/IHubEntityManager.d.ts +1 -1
- package/dist/types/search/_internal/index.d.ts +2 -0
- package/dist/types/search/_internal/searchContentEntities.d.ts +1 -1
- package/dist/types/search/_internal/state.d.ts +62 -0
- package/dist/types/search/_searchGroups.d.ts +2 -1
- package/dist/types/search/collectionState.d.ts +19 -0
- package/dist/types/search/content-utils.d.ts +6 -4
- package/dist/types/search/index.d.ts +2 -1
- package/dist/types/search/types/ICatalog.d.ts +76 -0
- package/dist/types/search/types/ICollection.d.ts +14 -0
- package/dist/types/search/types/IFacet.d.ts +15 -0
- package/dist/types/search/types/IFacetOption.d.ts +8 -0
- package/dist/types/search/types/index.d.ts +5 -0
- package/dist/types/search/{types.d.ts → types/types.d.ts} +23 -86
- package/dist/types/search/utils.d.ts +1 -1
- package/dist/umd/common.umd.js +219 -12
- package/dist/umd/common.umd.js.map +1 -1
- package/dist/umd/common.umd.min.js +1 -1
- package/dist/umd/common.umd.min.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { UserSession } from "@esri/arcgis-rest-auth";
|
|
2
|
-
import { IHubContent, IModel } from "
|
|
2
|
+
import { IHubContent, IModel } from "../..";
|
|
3
|
+
import { IFacet } from "./IFacet";
|
|
3
4
|
/**
|
|
4
5
|
* Generic filter used with various search functions.
|
|
5
6
|
*
|
|
@@ -139,82 +140,6 @@ export interface IEventFilterDefinition {
|
|
|
139
140
|
orgid?: string | string[] | IMatchOptions;
|
|
140
141
|
title?: string | string[] | IMatchOptions;
|
|
141
142
|
}
|
|
142
|
-
export interface IFacet {
|
|
143
|
-
label: string;
|
|
144
|
-
attribute?: string;
|
|
145
|
-
type: "single-select" | "multi-select" | "date-range" | "histogram";
|
|
146
|
-
options?: IFacetOption[];
|
|
147
|
-
accordionClosed?: boolean;
|
|
148
|
-
pageSize?: number;
|
|
149
|
-
}
|
|
150
|
-
export interface IFacetOption {
|
|
151
|
-
label: string;
|
|
152
|
-
value: string;
|
|
153
|
-
count?: number;
|
|
154
|
-
selected: boolean;
|
|
155
|
-
filter: Filter<FilterType>;
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Catalog is the definition which powers what options
|
|
159
|
-
* are available in a Gallery. It controls not only
|
|
160
|
-
* the scoping of the search, but also the options
|
|
161
|
-
* available to the UX.
|
|
162
|
-
*
|
|
163
|
-
* Thus the lower-level `searchContent`, `searchUser`, `searchGroup` functions
|
|
164
|
-
* do not take Catalogs, rather they accept [Filters](../Filter)
|
|
165
|
-
*
|
|
166
|
-
* ```ts
|
|
167
|
-
* const simpleCatalog:Catalog = {
|
|
168
|
-
* title: "Select Map",
|
|
169
|
-
* filter: {
|
|
170
|
-
* filterType: "content",
|
|
171
|
-
* type: "Web Map",
|
|
172
|
-
* owner: "jsmith"
|
|
173
|
-
* }
|
|
174
|
-
* }
|
|
175
|
-
* ```
|
|
176
|
-
*
|
|
177
|
-
* ## Collections
|
|
178
|
-
* The key feature of a Catalog is the ability to defined [Collections](../Collection).
|
|
179
|
-
* These are essentially sub-sets of content, typically organized around
|
|
180
|
-
* generalized content types, i.e. "Datasets", vs "Maps", vs "Documents"
|
|
181
|
-
*
|
|
182
|
-
*
|
|
183
|
-
* ```ts
|
|
184
|
-
* const complex:Catalog = {
|
|
185
|
-
* filter: {
|
|
186
|
-
* type: "content",
|
|
187
|
-
* groups: ["3ef", "bc4"]
|
|
188
|
-
* },
|
|
189
|
-
* collections: [
|
|
190
|
-
* {
|
|
191
|
-
* label: "Documents",
|
|
192
|
-
* filter: {
|
|
193
|
-
* filterType: "content",
|
|
194
|
-
* type: ["Microsoft Word", "PDF", "Microsoft Excel"]
|
|
195
|
-
* }
|
|
196
|
-
* },
|
|
197
|
-
* {
|
|
198
|
-
* label: "Datasets",
|
|
199
|
-
* filter: {
|
|
200
|
-
* filterType: "content",
|
|
201
|
-
* type: ["Feature Layer", "Feature Service", "Map Service", "CSV"]
|
|
202
|
-
* }
|
|
203
|
-
* }
|
|
204
|
-
* ]
|
|
205
|
-
* }
|
|
206
|
-
* ```
|
|
207
|
-
*/
|
|
208
|
-
export interface ICatalog {
|
|
209
|
-
/**
|
|
210
|
-
* Title for the Gallery
|
|
211
|
-
*/
|
|
212
|
-
title?: string;
|
|
213
|
-
filter: Filter<FilterType>;
|
|
214
|
-
sort?: ISortOption[];
|
|
215
|
-
collections?: ICollection[];
|
|
216
|
-
facets?: IFacet[];
|
|
217
|
-
}
|
|
218
143
|
/**
|
|
219
144
|
* Sort Option to be displayed in a UI
|
|
220
145
|
*/
|
|
@@ -224,14 +149,6 @@ export interface ISortOption {
|
|
|
224
149
|
defaultOrder: string;
|
|
225
150
|
order: string;
|
|
226
151
|
}
|
|
227
|
-
/**
|
|
228
|
-
* A Filter that defines a subset of a Catalog, aka a Collection
|
|
229
|
-
*/
|
|
230
|
-
export interface ICollection {
|
|
231
|
-
label: string;
|
|
232
|
-
filter: Filter<FilterType>;
|
|
233
|
-
facets?: IFacet[];
|
|
234
|
-
}
|
|
235
152
|
/**
|
|
236
153
|
* Defines a span of time by specifying a `from` and `to` Date
|
|
237
154
|
* as either a number or a ISO string
|
|
@@ -288,10 +205,12 @@ export interface IHubSearchOptions {
|
|
|
288
205
|
page?: string;
|
|
289
206
|
start?: number;
|
|
290
207
|
num?: number;
|
|
291
|
-
|
|
208
|
+
aggFields?: string[];
|
|
209
|
+
aggLimit?: number;
|
|
292
210
|
bbox?: string;
|
|
293
211
|
fields?: string;
|
|
294
212
|
api?: NamedApis | IApiDefinition;
|
|
213
|
+
aggregations?: string[];
|
|
295
214
|
}
|
|
296
215
|
/**
|
|
297
216
|
* searchContent return
|
|
@@ -318,3 +237,21 @@ export interface IApiDefinition {
|
|
|
318
237
|
type: "arcgis" | "arcgis-hub";
|
|
319
238
|
authentication?: UserSession;
|
|
320
239
|
}
|
|
240
|
+
export interface IFacetState {
|
|
241
|
+
[key: string]: string;
|
|
242
|
+
}
|
|
243
|
+
export interface ICollectionState {
|
|
244
|
+
query?: string;
|
|
245
|
+
sort?: string;
|
|
246
|
+
[key: string]: string;
|
|
247
|
+
}
|
|
248
|
+
export interface ICatalogState {
|
|
249
|
+
collection: string;
|
|
250
|
+
collectionState?: ICollectionState;
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Generic key/value type for storing component state
|
|
254
|
+
*/
|
|
255
|
+
export interface IComponentState {
|
|
256
|
+
[key: string]: string;
|
|
257
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IUser } from "@esri/arcgis-rest-auth";
|
|
2
2
|
import { IGroup, ISearchOptions } from "@esri/arcgis-rest-portal";
|
|
3
3
|
import { ISearchResponse } from "../types";
|
|
4
|
-
import { IMatchOptions, IDateRange, IRelativeDate, IWellKnownApis, IApiDefinition, NamedApis } from "./types";
|
|
4
|
+
import { IMatchOptions, IDateRange, IRelativeDate, IWellKnownApis, IApiDefinition, NamedApis } from "./types/types";
|
|
5
5
|
/**
|
|
6
6
|
* Well known APIs
|
|
7
7
|
* Short-forms for specifying common APIs
|
package/dist/umd/common.umd.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* @preserve
|
|
2
|
-
* @esri/hub-common - v9.26.
|
|
2
|
+
* @esri/hub-common - v9.26.2 - Mon Apr 11 2022 15:58:14 GMT+0000 (Coordinated Universal Time)
|
|
3
3
|
* Copyright (c) 2022 Environmental Systems Research Institute, Inc.
|
|
4
4
|
* Apache-2.0
|
|
5
5
|
*/
|
|
@@ -12110,29 +12110,37 @@
|
|
|
12110
12110
|
};
|
|
12111
12111
|
/**
|
|
12112
12112
|
* @private
|
|
12113
|
-
* Convert portal search response to
|
|
12113
|
+
* Convert portal search response to facets
|
|
12114
|
+
* Note: Only applicable to a "content" search
|
|
12114
12115
|
* @param response
|
|
12115
12116
|
* @returns
|
|
12116
12117
|
*/
|
|
12117
|
-
function convertPortalResponseToFacets(response) {
|
|
12118
|
+
function convertPortalResponseToFacets(response, operation) {
|
|
12118
12119
|
var _a;
|
|
12120
|
+
if (operation === void 0) { operation = "OR"; }
|
|
12119
12121
|
var result = [];
|
|
12120
12122
|
if ((_a = response.aggregations) === null || _a === void 0 ? void 0 : _a.counts) {
|
|
12121
12123
|
response.aggregations.counts.forEach(function (entry) {
|
|
12122
12124
|
var facet = {
|
|
12123
12125
|
label: entry.fieldName,
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
+
key: entry.fieldName,
|
|
12127
|
+
aggField: entry.fieldName,
|
|
12128
|
+
display: "multi-select",
|
|
12126
12129
|
};
|
|
12127
12130
|
var options = [];
|
|
12128
12131
|
entry.fieldValues.forEach(function (fv) {
|
|
12129
12132
|
var filter = {
|
|
12130
12133
|
filterType: "content",
|
|
12131
12134
|
};
|
|
12132
|
-
filter
|
|
12135
|
+
// construct the filter based on the operation
|
|
12136
|
+
var matchKey = operation === "OR" ? "any" : "all";
|
|
12137
|
+
var filterMatchOption = {};
|
|
12138
|
+
filterMatchOption[matchKey] = [fv.value];
|
|
12139
|
+
filter[entry.fieldName] = filterMatchOption;
|
|
12140
|
+
// construct the FacetOption
|
|
12133
12141
|
var fo = {
|
|
12134
|
-
label: fv.value,
|
|
12135
|
-
|
|
12142
|
+
label: fv.value + " (" + fv.count + ")",
|
|
12143
|
+
key: fv.value,
|
|
12136
12144
|
count: fv.count,
|
|
12137
12145
|
selected: false,
|
|
12138
12146
|
filter: filter,
|
|
@@ -14781,10 +14789,10 @@
|
|
|
14781
14789
|
* @param options
|
|
14782
14790
|
*/
|
|
14783
14791
|
function _searchContent(filter, options) {
|
|
14784
|
-
var _a;
|
|
14792
|
+
var _a, _b;
|
|
14785
14793
|
return __awaiter(this, void 0, void 0, function () {
|
|
14786
14794
|
var expanded, api, searchPromise, so_1, props;
|
|
14787
|
-
return __generator(this, function (
|
|
14795
|
+
return __generator(this, function (_c) {
|
|
14788
14796
|
expanded = expandContentFilter(filter);
|
|
14789
14797
|
api = expandApi(options.api || "arcgis");
|
|
14790
14798
|
// Portal Search
|
|
@@ -14808,10 +14816,17 @@
|
|
|
14808
14816
|
if (!so_1.authentication) {
|
|
14809
14817
|
so_1.portal = api.url + "/sharing/rest";
|
|
14810
14818
|
}
|
|
14811
|
-
//
|
|
14819
|
+
// DEPRECATION
|
|
14812
14820
|
if ((_a = options.aggregations) === null || _a === void 0 ? void 0 : _a.length) {
|
|
14821
|
+
// tslint:disable-next-line:no-console
|
|
14822
|
+
console.warn("IHubSearchOptions.aggregations is deprecated. Please use .aggFields instead.");
|
|
14813
14823
|
so_1.countFields = options.aggregations.join(",");
|
|
14814
|
-
so_1.countSize =
|
|
14824
|
+
so_1.countSize = options.aggLimit || 10;
|
|
14825
|
+
}
|
|
14826
|
+
// Aggregations
|
|
14827
|
+
if ((_b = options.aggFields) === null || _b === void 0 ? void 0 : _b.length) {
|
|
14828
|
+
so_1.countFields = options.aggFields.join(",");
|
|
14829
|
+
so_1.countSize = options.aggLimit || 10;
|
|
14815
14830
|
}
|
|
14816
14831
|
searchPromise = searchPortal(so_1);
|
|
14817
14832
|
}
|
|
@@ -15042,6 +15057,196 @@
|
|
|
15042
15057
|
});
|
|
15043
15058
|
}
|
|
15044
15059
|
|
|
15060
|
+
/**
|
|
15061
|
+
* Apply the sortState to SortOptions
|
|
15062
|
+
*
|
|
15063
|
+
* @param sortOptions
|
|
15064
|
+
* @param sortState
|
|
15065
|
+
* @returns
|
|
15066
|
+
*/
|
|
15067
|
+
function applySortState(sortOptions, sortState) {
|
|
15068
|
+
var updated = cloneObject$1(sortOptions);
|
|
15069
|
+
if (sortState) {
|
|
15070
|
+
var _a = sortState.split("|"), label = _a[0], attribute = _a[1], order = _a[2];
|
|
15071
|
+
updated.label = label;
|
|
15072
|
+
updated.attribute = attribute;
|
|
15073
|
+
updated.order = order;
|
|
15074
|
+
}
|
|
15075
|
+
return updated;
|
|
15076
|
+
}
|
|
15077
|
+
/**
|
|
15078
|
+
* Apply FacetState to a Facet
|
|
15079
|
+
* @param facet
|
|
15080
|
+
* @param state
|
|
15081
|
+
* @returns
|
|
15082
|
+
*/
|
|
15083
|
+
function applyFacetState(facet, state) {
|
|
15084
|
+
var updated = cloneObject$1(facet);
|
|
15085
|
+
switch (facet.display) {
|
|
15086
|
+
case "single-select":
|
|
15087
|
+
updated = applySingleSelectFacetState(facet, state);
|
|
15088
|
+
break;
|
|
15089
|
+
case "multi-select":
|
|
15090
|
+
updated = applyMultiSelectFacetState(facet, state);
|
|
15091
|
+
break;
|
|
15092
|
+
}
|
|
15093
|
+
return updated;
|
|
15094
|
+
}
|
|
15095
|
+
/**
|
|
15096
|
+
* Apply the Facet State onto a single-select facet
|
|
15097
|
+
*
|
|
15098
|
+
* Intentionally mutates the facet.
|
|
15099
|
+
* @param facet
|
|
15100
|
+
* @param state
|
|
15101
|
+
* @returns
|
|
15102
|
+
*/
|
|
15103
|
+
function applySingleSelectFacetState(facet, state) {
|
|
15104
|
+
var updated = cloneObject$1(facet);
|
|
15105
|
+
updated.options = updated.options.map(function (o) {
|
|
15106
|
+
o.selected = o.key === state[facet.key];
|
|
15107
|
+
return o;
|
|
15108
|
+
});
|
|
15109
|
+
return updated;
|
|
15110
|
+
}
|
|
15111
|
+
/**
|
|
15112
|
+
* Serialize single-select facet into IFacetState
|
|
15113
|
+
* @param facet
|
|
15114
|
+
* @returns
|
|
15115
|
+
*/
|
|
15116
|
+
function serializeSingleSelectFacetState(facet) {
|
|
15117
|
+
var state = {};
|
|
15118
|
+
var selected = facet.options.find(function (o) { return o.selected; });
|
|
15119
|
+
if (selected) {
|
|
15120
|
+
state[facet.key] = selected.key;
|
|
15121
|
+
}
|
|
15122
|
+
else {
|
|
15123
|
+
state[facet.key] = null;
|
|
15124
|
+
}
|
|
15125
|
+
return state;
|
|
15126
|
+
}
|
|
15127
|
+
/**
|
|
15128
|
+
* Apply the Facet State onto a multi-select Facet
|
|
15129
|
+
*
|
|
15130
|
+
* Intentionally mutates the facet.
|
|
15131
|
+
* @param facet
|
|
15132
|
+
* @param state
|
|
15133
|
+
* @returns
|
|
15134
|
+
*/
|
|
15135
|
+
function applyMultiSelectFacetState(facet, state) {
|
|
15136
|
+
var _a;
|
|
15137
|
+
var updated = cloneObject$1(facet);
|
|
15138
|
+
var selectedKeys = ((_a = state[facet.key]) === null || _a === void 0 ? void 0 : _a.split(",")) || [];
|
|
15139
|
+
updated.options = updated.options.map(function (o) {
|
|
15140
|
+
o.selected = selectedKeys.includes(o.key);
|
|
15141
|
+
return o;
|
|
15142
|
+
});
|
|
15143
|
+
return updated;
|
|
15144
|
+
}
|
|
15145
|
+
/**
|
|
15146
|
+
* Serialize multi-select facet into IFacetState
|
|
15147
|
+
* @param facet
|
|
15148
|
+
* @returns
|
|
15149
|
+
*/
|
|
15150
|
+
function serializeMultiSelectFacetState(facet) {
|
|
15151
|
+
var state = {};
|
|
15152
|
+
var selected = facet.options.filter(function (o) { return o.selected; });
|
|
15153
|
+
var value = selected.map(function (o) { return o.key; }).join(",");
|
|
15154
|
+
if (value.length) {
|
|
15155
|
+
state[facet.key] = value;
|
|
15156
|
+
}
|
|
15157
|
+
else {
|
|
15158
|
+
state[facet.key] = null;
|
|
15159
|
+
}
|
|
15160
|
+
return state;
|
|
15161
|
+
}
|
|
15162
|
+
/**
|
|
15163
|
+
* Serialize the state of the SortOption into a key/value pair
|
|
15164
|
+
*
|
|
15165
|
+
* Called from the Sort component
|
|
15166
|
+
* @param sort
|
|
15167
|
+
* @returns
|
|
15168
|
+
*/
|
|
15169
|
+
function serializeSortState(sort) {
|
|
15170
|
+
return sort.label + "|" + sort.attribute + "|" + sort.order;
|
|
15171
|
+
}
|
|
15172
|
+
/**
|
|
15173
|
+
* Serialize the state of a facet into a key/value pair
|
|
15174
|
+
*
|
|
15175
|
+
* Called from the various facet components
|
|
15176
|
+
* @param facet
|
|
15177
|
+
* @returns
|
|
15178
|
+
*/
|
|
15179
|
+
function serializeFacetState(facet) {
|
|
15180
|
+
var state = {};
|
|
15181
|
+
switch (facet.display) {
|
|
15182
|
+
case "single-select":
|
|
15183
|
+
state = serializeSingleSelectFacetState(facet);
|
|
15184
|
+
break;
|
|
15185
|
+
case "multi-select":
|
|
15186
|
+
state = serializeMultiSelectFacetState(facet);
|
|
15187
|
+
break;
|
|
15188
|
+
}
|
|
15189
|
+
return state;
|
|
15190
|
+
}
|
|
15191
|
+
|
|
15192
|
+
/**
|
|
15193
|
+
* Apply ICollectionState to an ICollection
|
|
15194
|
+
*
|
|
15195
|
+
* Typically used in a Gallery or Catalog component to
|
|
15196
|
+
* set the inital state, based on values deserialized
|
|
15197
|
+
* from a query string
|
|
15198
|
+
* @param collection
|
|
15199
|
+
* @param state
|
|
15200
|
+
* @returns
|
|
15201
|
+
*/
|
|
15202
|
+
function applyCollectionState(collection, state) {
|
|
15203
|
+
var updated = cloneObject$1(collection);
|
|
15204
|
+
// Apply default query
|
|
15205
|
+
if (state.query) {
|
|
15206
|
+
updated.defaultQuery = state.query;
|
|
15207
|
+
}
|
|
15208
|
+
// Apply Sort State
|
|
15209
|
+
updated.sortOption = applySortState(updated.sortOption, state.sort);
|
|
15210
|
+
// Look for state props for the facets and apply them
|
|
15211
|
+
updated.facets = updated.facets.map(function (facet) {
|
|
15212
|
+
// see if there is a key for this facet on the state
|
|
15213
|
+
if (Object.keys(state).includes(facet.key)) {
|
|
15214
|
+
var facetState = {};
|
|
15215
|
+
facetState[facet.key] = state[facet.key];
|
|
15216
|
+
return applyFacetState(facet, facetState);
|
|
15217
|
+
}
|
|
15218
|
+
else {
|
|
15219
|
+
// Ensure all options are not selected
|
|
15220
|
+
// because they were not included in the state
|
|
15221
|
+
facet.options.forEach(function (opt) {
|
|
15222
|
+
opt.selected = false;
|
|
15223
|
+
});
|
|
15224
|
+
return facet;
|
|
15225
|
+
}
|
|
15226
|
+
});
|
|
15227
|
+
//
|
|
15228
|
+
return updated;
|
|
15229
|
+
}
|
|
15230
|
+
/**
|
|
15231
|
+
* Serialize the current state of a collection into a hash that
|
|
15232
|
+
* can be converted into a query string
|
|
15233
|
+
* @param collection
|
|
15234
|
+
* @returns
|
|
15235
|
+
*/
|
|
15236
|
+
function serializeCollectionState(collection) {
|
|
15237
|
+
var state = {};
|
|
15238
|
+
if (collection.defaultQuery) {
|
|
15239
|
+
state.query = collection.defaultQuery;
|
|
15240
|
+
}
|
|
15241
|
+
if (collection.sortOption) {
|
|
15242
|
+
state.sort = serializeSortState(collection.sortOption);
|
|
15243
|
+
}
|
|
15244
|
+
var facetState = collection.facets.reduce(function (s, facet) {
|
|
15245
|
+
return __assign(__assign({}, s), serializeFacetState(facet));
|
|
15246
|
+
}, {});
|
|
15247
|
+
return __assign(__assign({}, state), facetState);
|
|
15248
|
+
}
|
|
15249
|
+
|
|
15045
15250
|
/**
|
|
15046
15251
|
* Add telemetry config object
|
|
15047
15252
|
* @private
|
|
@@ -16862,6 +17067,7 @@
|
|
|
16862
17067
|
exports.addSiteDomains = addSiteDomains;
|
|
16863
17068
|
exports.addSolutionResourceUrlToAssets = addSolutionResourceUrlToAssets;
|
|
16864
17069
|
exports.addUsersToGroup = addUsersToGroup;
|
|
17070
|
+
exports.applyCollectionState = applyCollectionState;
|
|
16865
17071
|
exports.applyPropertiesToItems = applyPropertiesToItems;
|
|
16866
17072
|
exports.arrayToObject = arrayToObject;
|
|
16867
17073
|
exports.atob = abab.atob;
|
|
@@ -17060,6 +17266,7 @@
|
|
|
17060
17266
|
exports.saveSession = saveSession;
|
|
17061
17267
|
exports.searchProjects = searchProjects;
|
|
17062
17268
|
exports.searchSites = searchSites;
|
|
17269
|
+
exports.serializeCollectionState = serializeCollectionState;
|
|
17063
17270
|
exports.serializeContentFilterForPortal = serializeContentFilterForPortal;
|
|
17064
17271
|
exports.serializeDateRange = serializeDateRange;
|
|
17065
17272
|
exports.serializeGroupFilterForPortal = serializeGroupFilterForPortal;
|