@esri/solutions-components 0.2.0 → 0.2.1

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.
Files changed (34) hide show
  1. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +1 -1
  2. package/dist/cjs/solution-configuration.cjs.entry.js +1086 -2
  3. package/dist/cjs/solution-configuration.cjs.entry.js.map +1 -1
  4. package/dist/cjs/solution-contents_3.cjs.entry.js +1 -1
  5. package/dist/cjs/{solution-store-f0547fe7.js → solution-store-e2fc11ac.js} +6 -1
  6. package/dist/cjs/solution-store-e2fc11ac.js.map +1 -0
  7. package/dist/collection/components/solution-configuration/solution-configuration.js +5 -9
  8. package/dist/collection/components/solution-configuration/solution-configuration.js.map +1 -1
  9. package/dist/components/solution-configuration.js +1086 -2
  10. package/dist/components/solution-configuration.js.map +1 -1
  11. package/dist/components/solution-store.js +1 -1
  12. package/dist/components/solution-store.js.map +1 -1
  13. package/dist/esm/calcite-shell-panel_14.entry.js +1 -1
  14. package/dist/esm/solution-configuration.entry.js +1086 -2
  15. package/dist/esm/solution-configuration.entry.js.map +1 -1
  16. package/dist/esm/solution-contents_3.entry.js +1 -1
  17. package/dist/esm/{solution-store-c1f6173a.js → solution-store-b3c65467.js} +2 -2
  18. package/dist/esm/solution-store-b3c65467.js.map +1 -0
  19. package/dist/solutions-components/{p-0e7a0839.entry.js → p-542189bc.entry.js} +2 -2
  20. package/dist/solutions-components/{p-0e7a0839.entry.js.map → p-542189bc.entry.js.map} +0 -0
  21. package/dist/solutions-components/{p-ee9be0ef.entry.js → p-638738f2.entry.js} +2 -2
  22. package/dist/solutions-components/{p-ee9be0ef.entry.js.map → p-638738f2.entry.js.map} +0 -0
  23. package/dist/solutions-components/p-7e8985f2.entry.js +1979 -0
  24. package/dist/solutions-components/p-7e8985f2.entry.js.map +1 -0
  25. package/dist/solutions-components/{p-065830b8.js → p-b25f6ebe.js} +2 -2
  26. package/dist/solutions-components/p-b25f6ebe.js.map +1 -0
  27. package/dist/solutions-components/solutions-components.esm.js +1 -1
  28. package/dist/solutions-components_commit.txt +5 -6
  29. package/package.json +1 -1
  30. package/dist/cjs/solution-store-f0547fe7.js.map +0 -1
  31. package/dist/esm/solution-store-c1f6173a.js.map +0 -1
  32. package/dist/solutions-components/p-065830b8.js.map +0 -1
  33. package/dist/solutions-components/p-401541a5.entry.js +0 -895
  34. package/dist/solutions-components/p-401541a5.entry.js.map +0 -1
@@ -1,895 +0,0 @@
1
- /*!
2
- * Copyright 2022 Esri
3
- * Licensed under the Apache License, Version 2.0
4
- * http://www.apache.org/licenses/LICENSE-2.0
5
- */
6
- import { r as registerInstance, h, H as Host, g as getElement } from './p-58c69df2.js';
7
- import { g as getProp, s as state } from './p-065830b8.js';
8
- import { g as getLocaleComponentStrings } from './p-20bdf42f.js';
9
- import './p-f759a6e7.js';
10
- import './p-6b9dc092.js';
11
- import './p-3b010ce1.js';
12
-
13
- /** @license
14
- * Copyright 2022 Esri
15
- *
16
- * Licensed under the Apache License, Version 2.0 (the "License");
17
- * you may not use this file except in compliance with the License.
18
- * You may obtain a copy of the License at
19
- *
20
- * http://www.apache.org/licenses/LICENSE-2.0
21
- *
22
- * Unless required by applicable law or agreed to in writing, software
23
- * distributed under the License is distributed on an "AS IS" BASIS,
24
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
- * See the License for the specific language governing permissions and
26
- * limitations under the License.
27
- */
28
- //--------------------------------------------------------------------------
29
- //
30
- // Public Functions
31
- //
32
- //--------------------------------------------------------------------------
33
- /**
34
- * Sort the solution items
35
- *
36
- * @param templates a list of item templates from the solution
37
- *
38
- * @returns a sorted list of solution items
39
- */
40
- function getInventoryItems(templates) {
41
- const hierarchy = getItemHierarchy(templates);
42
- const ids = hierarchy.reduce((prev, cur) => {
43
- prev.push(cur.id);
44
- return prev;
45
- }, []);
46
- return templates.reduce((prev, cur) => {
47
- if (ids.indexOf(cur.itemId) > -1) {
48
- const hierarchyItems = hierarchy.filter(hi => hi.id === cur.itemId);
49
- prev.push(_getItemFromTemplate(cur, templates, hierarchyItems[0].dependencies));
50
- }
51
- return prev;
52
- }, []);
53
- }
54
- /**
55
- * Create item hierarchy that will avoid issues from cylical dependencies
56
- *
57
- * @param templates a list of item templates from the solution
58
- *
59
- * @returns a hierarchy for item and item dependency display
60
- */
61
- function getItemHierarchy(templates) {
62
- const hierarchy = [];
63
- // Get the template specified by id out of a list of templates
64
- function getTemplateInSolution(templates, id) {
65
- const iTemplate = templates.findIndex((template) => id === template.itemId);
66
- return iTemplate >= 0 ? templates[iTemplate] : null;
67
- }
68
- // Hierarchically list the dependencies of specified node
69
- function traceItemId(id, accumulatedHierarchy, alreadyVisitedIds = []) {
70
- // Get the dependencies of the node
71
- const template = getTemplateInSolution(templates, id);
72
- /* istanbul ignore else */
73
- if (template) {
74
- const templateEntry = {
75
- id,
76
- dependencies: []
77
- };
78
- // Visit each dependency, but only if this template is not in the alreadyVisitedIds list to avoid infinite loops
79
- /* istanbul ignore else */
80
- if (alreadyVisitedIds.indexOf(id) < 0) {
81
- // Add dependency to alreadyVisitedIds list
82
- alreadyVisitedIds.push(id);
83
- template.dependencies.forEach((dependencyId) => {
84
- // Remove dependency from list of templates to visit in the top-level loop
85
- const iDependencyTemplate = templateItemIds.indexOf(dependencyId);
86
- /* istanbul ignore else */
87
- if (iDependencyTemplate >= 0) {
88
- templateItemIds.splice(iDependencyTemplate, 1);
89
- }
90
- traceItemId(dependencyId, templateEntry.dependencies, alreadyVisitedIds);
91
- });
92
- }
93
- accumulatedHierarchy.push(templateEntry);
94
- }
95
- }
96
- // Start with top-level nodes and add in the rest of the nodes to catch cycles without top-level nodes
97
- let templateItemIds = _getTopLevelItemIds(templates);
98
- const otherItems = templates
99
- .filter((template) => templateItemIds.indexOf(template.itemId) < 0) // only keep non-top-level nodes
100
- .sort((a, b) => b.dependencies.length - a.dependencies.length); // sort so that nodes with more dependencies come first--reduces stubs
101
- templateItemIds = templateItemIds.concat(otherItems.map((template) => template.itemId));
102
- // Step through the list of nodes; we'll also remove nodes as we visit them
103
- let itemId = templateItemIds.shift();
104
- while (typeof itemId !== "undefined") {
105
- traceItemId(itemId, hierarchy);
106
- itemId = templateItemIds.shift();
107
- }
108
- return hierarchy;
109
- }
110
- /**
111
- * Explore the solution item templates for variables we will allow users to insert at runtime
112
- *
113
- * @param templates a list of item templates from the solution
114
- * @param translations nls translation object
115
- *
116
- * @returns a list of variables from the solution item templates
117
- */
118
- function getSolutionVariables(templates, translations) {
119
- const vars = [];
120
- templates.forEach(t => {
121
- const item = {
122
- id: t.itemId,
123
- title: t.item.title || t.item.name,
124
- type: t.type,
125
- value: undefined,
126
- dependencies: [{
127
- id: t.itemId,
128
- title: translations.itemId,
129
- value: `{{${t.itemId}.itemId}}`,
130
- }]
131
- };
132
- if (t.item.url) {
133
- item.dependencies.push({
134
- id: t.itemId,
135
- title: translations.url,
136
- value: `{{${t.itemId}.url}}`,
137
- });
138
- }
139
- if (t.type === "Feature Service") {
140
- // TODO need to set source service name var...
141
- // TODO need to set soure service shape field name "{{d05b3cf1ffcb4a4fa677627dfb18609e.name}}.Shape"
142
- item.dependencies.push({
143
- id: t.itemId,
144
- title: translations.solutionExtent,
145
- value: `{{${t.itemId}.solutionExtent}}`,
146
- });
147
- _addLayersOrTables(t.properties.layers || [], item, t, translations);
148
- _addLayersOrTables(t.properties.tables || [], item, t, translations);
149
- }
150
- vars.push(item);
151
- });
152
- return vars;
153
- }
154
- /**
155
- * Set key organization variables we will allow users to insert at runtime
156
- *
157
- * @param translations nls translation object
158
- *
159
- * @returns a list of variables for the organization
160
- */
161
- function getOrganizationVariables(translations) {
162
- const orgVars = [{
163
- id: "",
164
- title: translations.geocodeUrl,
165
- value: "{{organization.helperServices.geocode:getDefaultLocatorURL}}"
166
- }, {
167
- id: "",
168
- title: translations.geometryUrl,
169
- value: "{{organization.helperServices.geometry.url}}"
170
- }, {
171
- id: "",
172
- title: translations.portalBaseUrl,
173
- value: "{{portalBaseUrl}}"
174
- }, {
175
- id: "",
176
- title: translations.routeUrl,
177
- value: "{{organization.helperServices.route.url}}"
178
- }, {
179
- id: "",
180
- title: translations.solutionItemExtent,
181
- value: "{{solutionItemExtent}}"
182
- }];
183
- return orgVars;
184
- }
185
- //--------------------------------------------------------------------------
186
- //
187
- // Private Functions
188
- //
189
- //--------------------------------------------------------------------------
190
- /**
191
- * Explore a solution item template for variables we will allow users to insert at runtime.
192
- * This function will update the item argument that is passed in with the var details.
193
- *
194
- * @param children a list of layers or tables from a template
195
- * @param item an object that store key details for a given variable
196
- * @param template one of the templates from the current solution
197
- * @param translations nls translations object
198
- *
199
- */
200
- function _addLayersOrTables(children, item, template, translations) {
201
- children.forEach(l => {
202
- const name = l.name && l.name.indexOf("||") > -1 ? l.name.split("||")[1].replace("}}", "").trim() : l.name;
203
- item.dependencies.push({
204
- id: template.itemId,
205
- title: `${name} (${translations.id})`,
206
- value: `{{${template.itemId}.layer${l.id}.id}}`,
207
- });
208
- item.dependencies.push({
209
- id: template.itemId,
210
- title: `${name} (${translations.name})`,
211
- value: `{{${template.itemId}.layer${l.id}.name||${name}}}`,
212
- });
213
- });
214
- }
215
- /**
216
- * Capture key details from the solution item template
217
- *
218
- * @param template one of the templates from the current solution
219
- * @param templates full list of templates
220
- * @param dependencies list of hierarchical dependencies
221
- *
222
- * @returns an IInventoryItem that is used by other components to work with this template
223
- */
224
- function _getItemFromTemplate(template, templates, dependencies) {
225
- return {
226
- id: template.itemId || "",
227
- title: template.item.title || "",
228
- dependencies: _getDependencies(dependencies, templates),
229
- type: template.item.type || "",
230
- typeKeywords: template.item.typeKeywords || [] /*,
231
- solutionItem: {
232
- itemId: template.itemId,
233
- itemDetails: _getItemDetails(template.item, template.type === "Group"),
234
- isResource: _getIsResource(template),
235
- data: template.data,
236
- properties: template.properties,
237
- type: template.type,
238
- groupDetails: _getGroupDetails(template, templates)
239
- }*/
240
- };
241
- }
242
- /**
243
- * Capture key details from the solution item template
244
- *
245
- * @param dependencies list of dependencies from a template
246
- * @param templates full list of templates
247
- *
248
- * @returns a list of IInventoryItem that are used by other components to work with the templates
249
- */
250
- function _getDependencies(dependencies, templates) {
251
- const dependencyItems = [];
252
- const depIds = dependencies.reduce((prev, cur) => {
253
- prev.push(cur.id);
254
- dependencyItems.push(cur);
255
- return prev;
256
- }, []);
257
- return templates.reduce((prev, curr) => {
258
- const i = depIds.indexOf(curr.itemId);
259
- if (i > -1) {
260
- prev.push(_getItemFromTemplate(curr, templates, dependencyItems[i].dependencies));
261
- }
262
- return prev;
263
- }, []);
264
- }
265
- /**
266
- * Capture the key item details for a given template
267
- *
268
- * @param item the templates item
269
- * @param isGroup boolean to indicate if the item is a group
270
- * @param itemId the item id of the template
271
- *
272
- * @returns a IItemDetails object for the current item
273
- */
274
- /*
275
- function _getItemDetails(
276
- item: any,
277
- isGroup: boolean
278
- ): IItemDetails {
279
- return {
280
- title: item.title || "",
281
- snippet: item.snippet || "",
282
- description: item.description || "",
283
- tags: item.tags || [],
284
- accessInformation: !isGroup ? item.accessInformation || "" : "",
285
- licenseInfo: !isGroup ? item.licenseInfo || "" : ""
286
- };
287
- }
288
- */
289
- /**
290
- * Capture the key item details for a given group template
291
- *
292
- * @param template one of the templates from the current solution
293
- * @param templates full list of templates
294
- *
295
- * @returns a list of IItemShare objects
296
- */
297
- /*
298
- function _getGroupDetails(
299
- template: any,
300
- templates: any[]
301
- ): IItemShare[] {
302
- return template.type === "Group" ? templates.reduce((prev, cur) => {
303
- if (cur.itemId !== template.itemId && cur.type !== "Group") {
304
- prev.push({
305
- id: cur.itemId,
306
- title: cur.item.name || cur.item.title,
307
- isShared: (cur.groups || []).indexOf(template.itemId) > -1,
308
- shareItem: (cur.groups || []).indexOf(template.itemId) > -1,
309
- type: cur.type,
310
- typeKeywords: cur.item.typeKeywords
311
- });
312
- }
313
- return prev;
314
- }, []) : [];
315
- }
316
- */
317
- /**
318
- * Used to understand if we are dealing with a binary object that will support upload/download
319
- *
320
- * @param template one of the templates from the current solution
321
- *
322
- * @returns true if this item supports upload/download
323
- */
324
- /*
325
- function _getIsResource(
326
- template: any
327
- ): boolean {
328
- return template.type !== "Group" && template.resources.some(r => r.indexOf("_info_thumbnail") < 0) &&
329
- (template.data === null || JSON.stringify(template.data) === "{}");
330
- }
331
- */
332
- /**
333
- * Sort the template ids based on their dependencies
334
- *
335
- * @param templates full list of templates
336
- *
337
- * @returns a list of Itop level item ids
338
- */
339
- function _getTopLevelItemIds(templates) {
340
- // Find the top-level nodes. Start with all nodes, then remove those that other nodes depend on
341
- const topLevelItemCandidateIds = templates.map((template) => template.itemId);
342
- templates.forEach((template) => {
343
- (template.dependencies || []).forEach((dependencyId) => {
344
- const iNode = topLevelItemCandidateIds.indexOf(dependencyId);
345
- if (iNode >= 0) {
346
- // Node is somebody's dependency, so remove the node from the list of top-level nodes
347
- // If iNode == -1, then it's a shared dependency and it has already been removed
348
- topLevelItemCandidateIds.splice(iNode, 1);
349
- }
350
- });
351
- });
352
- return topLevelItemCandidateIds;
353
- }
354
-
355
- const solutionConfigurationCss = ".configuration-container{position:relative;height:100%;width:100%}.configuration{position:absolute;top:0px;right:0px;bottom:0px;left:0px;display:flex;padding:0.5rem;border:1px #808080 solid}.config-tabs{width:100%}.config-tab{width:100%}.config-solution{position:absolute;top:3.5rem;right:-1px;bottom:-1px;left:-1px;display:flex;padding:0.5rem}.config-inventory{display:inline;max-width:-moz-min-content;max-width:min-content;flex-grow:0;overflow-y:auto}.config-inventory-hide{display:none;max-width:-moz-min-content;max-width:min-content;flex-grow:0;overflow-y:auto}.config-item{position:relative;display:inline;flex-grow:1;overflow-y:auto;-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}solution-contents{position:relative;height:100%}solution-item{position:relative;height:100%}solution-spatial-ref{position:relative;height:100%;width:100%;overflow-y:auto}";
356
-
357
- const SolutionConfiguration = class {
358
- //--------------------------------------------------------------------------
359
- //
360
- // Lifecycle
361
- //
362
- //--------------------------------------------------------------------------
363
- constructor(hostRef) {
364
- registerInstance(this, hostRef);
365
- this._solutionStoreHasChanges = false;
366
- this._solutionEditorHasChanges = false;
367
- this._solutionEditorHasErrors = false;
368
- this._canSave = false;
369
- this.authentication = undefined;
370
- this.solutionItemId = "";
371
- this.showLoading = false;
372
- this._currentEditItemId = "";
373
- this._organizationVariables = "";
374
- this._solutionContentsComponent = undefined;
375
- this._solutionIsLoaded = false;
376
- this._solutionVariables = "";
377
- this._templateHierarchy = [];
378
- this._translations = undefined;
379
- this._treeOpen = true;
380
- void this._loadSolution(this.solutionItemId);
381
- window.addEventListener("solutionStoreHasChanges", (evt) => {
382
- this._updateSaveability(this._solutionStoreHasChanges = evt.detail, this._solutionEditorHasChanges, this._solutionEditorHasErrors);
383
- });
384
- window.addEventListener("solutionEditorHasChanges", (evt) => {
385
- this._updateSaveability(this._solutionStoreHasChanges, this._solutionEditorHasChanges = evt.detail, this._solutionEditorHasErrors);
386
- });
387
- window.addEventListener("solutionEditorHasErrors", (evt) => {
388
- this._updateSaveability(this._solutionStoreHasChanges, this._solutionEditorHasChanges, this._solutionEditorHasErrors = evt.detail);
389
- });
390
- }
391
- async valueWatchHandler() {
392
- await this._loadSolution(this.solutionItemId);
393
- }
394
- /**
395
- * StencilJS: Called once just after the component is first connected to the DOM.
396
- *
397
- * @returns Promise when complete
398
- */
399
- async componentWillLoad() {
400
- return this._getTranslations();
401
- }
402
- /**
403
- * Renders the component.
404
- */
405
- render() {
406
- const wkid = getProp(state.getStoreInfo("spatialReferenceInfo"), "spatialReference");
407
- const hasServices = state.getStoreInfo("featureServices").length > 0;
408
- return (h(Host, null, !this._solutionIsLoaded
409
- ? h("calcite-loader", { active: true, label: '' })
410
- : null, h("div", { class: "configuration-container" }, h("div", { class: "configuration" }, h("calcite-tabs", { class: "config-tabs" }, h("calcite-tab-nav", { slot: "tab-nav" }, h("calcite-tab-title", null, this._translations.definitionTab), hasServices ?
411
- h("calcite-tab-title", null, this._translations.spatialReferenceTab) :
412
- null), h("calcite-tab", { active: true, class: "config-tab" }, h("div", { class: "config-solution" }, h("div", { class: this._treeOpen ? "config-inventory" : "config-inventory-hide" }, h("solution-contents", { id: "configInventory", key: `${this.solutionItemId}-contents`, ref: (el) => (this._solutionContentsComponent = el) })), h("calcite-button", { appearance: "transparent", class: "collapse-btn", "icon-start": this._treeOpen ? "chevrons-left" : "chevrons-right", id: "collapse-vars", onClick: () => this._toggleTree(), scale: "s", title: this._treeOpen ? this._translations.collapse : this._translations.expand }), h("div", { class: "config-item" }, h("solution-item", { authentication: this.authentication, "item-id": this._currentEditItemId, key: `${this.solutionItemId}-item`, "organization-variables": this._organizationVariables, "solution-item-id": this.solutionItemId, "solution-variables": this._solutionVariables })))), hasServices
413
- ? h("calcite-tab", { class: "config-tab" }, h("div", { class: "config-solution" }, h("solution-spatial-ref", { defaultWkid: wkid, id: "configure-solution-spatial-ref", key: `${this.solutionItemId}-spatial-ref`, locked: !wkid, services: state.getStoreInfo("featureServices").map(fs => fs.name) })))
414
- : null)))));
415
- }
416
- //--------------------------------------------------------------------------
417
- //
418
- // Event Listeners
419
- //
420
- //--------------------------------------------------------------------------
421
- _solutionItemSelected(event) {
422
- this._currentEditItemId = event.detail;
423
- }
424
- //--------------------------------------------------------------------------
425
- //
426
- // Events
427
- //
428
- //--------------------------------------------------------------------------
429
- //--------------------------------------------------------------------------
430
- //
431
- // Public Methods (async)
432
- //
433
- //--------------------------------------------------------------------------
434
- /*
435
- @Method()
436
- async getEditModels(): Promise<ISolutionItems> {
437
- return Promise.resolve(state.items);
438
- }
439
- */
440
- async getSpatialReferenceInfo() {
441
- return Promise.resolve(state.getStoreInfo("spatialReferenceInfo"));
442
- }
443
- /*
444
- @Method()
445
- async getSourceTemplates(): Promise<any> {
446
- return Promise.resolve(this._templates);
447
- }
448
- */
449
- async saveSolution() {
450
- this._solutionIsLoaded = false;
451
- await state.saveSolution();
452
- this._solutionIsLoaded = true;
453
- this.solutionItemId = null;
454
- }
455
- async unloadSolution() {
456
- this.solutionItemId = null;
457
- }
458
- //--------------------------------------------------------------------------
459
- //
460
- // Private Methods
461
- //
462
- //--------------------------------------------------------------------------
463
- /**
464
- * Update the store with the initial values
465
- *
466
- * @param templates the solution items templates
467
- * @param isReset (defaults to false) indicates if we are resetting the controls after save
468
- */
469
- /*
470
- protected _initState(
471
- templates: any[],
472
- isReset = false
473
- ): Promise<any> {
474
- return new Promise((resolve, reject) => {
475
- if (isReset) {
476
- // clear models and state so we can refresh after save
477
- this.modelsSet = false;
478
- state.reset();
479
- }
480
- getModels(templates, this.authentication, this.solutionItemId).then(models => {
481
- state.models = models;
482
-
483
- state.featureServices = getFeatureServices(templates);
484
- state.getStoreInfo("spatialReferenceInfo") = getSpatialReferenceInfo(state.featureServices, this._sourceItemData);
485
-
486
- if (isReset) {
487
- // reset for undo/redo stack and diff editor tracking
488
- const jsonEditors = Array.from(this.el.getElementsByTagName("json-editor"));
489
- // eslint-disable-next-line @typescript-eslint/no-floating-promises
490
- jsonEditors.forEach(e => void e.reset());
491
- }
492
-
493
- this.modelsSet = true;
494
- resolve(true);
495
- }, () => reject);
496
- });
497
- }
498
- */
499
- /**
500
- * Set Props with the initial values
501
- *
502
- * @protected
503
- */
504
- _initProps() {
505
- const solutionData = state.getStoreInfo("solutionData");
506
- this._solutionVariables = JSON.stringify(getSolutionVariables(solutionData.templates, this._translations));
507
- this._organizationVariables = JSON.stringify(getOrganizationVariables(this._translations));
508
- this._templateHierarchy = [...getInventoryItems(solutionData.templates)];
509
- if (this._solutionContentsComponent) {
510
- this._solutionContentsComponent.templateHierarchy = this._templateHierarchy;
511
- }
512
- let firstItem;
513
- if (this._templateHierarchy.length > 0) {
514
- // Start with the first item in the contents
515
- firstItem = state.getItemInfo(this._templateHierarchy[0].id);
516
- }
517
- this._currentEditItemId = firstItem ? firstItem.itemId : "";
518
- }
519
- /**
520
- * Loads a solution.
521
- *
522
- * @param solutionItemId AGO id of solution to load
523
- *
524
- * @returns Resolved promise when task is done
525
- *
526
- * @protected
527
- */
528
- async _loadSolution(solutionItemId) {
529
- if (solutionItemId) {
530
- this._solutionIsLoaded = false;
531
- await state.loadSolution(solutionItemId, this.authentication);
532
- this._initProps();
533
- this._solutionIsLoaded = true;
534
- }
535
- else {
536
- this._reset();
537
- }
538
- return Promise.resolve();
539
- }
540
- /**
541
- * Resets internal variables.
542
- *
543
- * @protected
544
- */
545
- _reset() {
546
- this._currentEditItemId = "";
547
- this._organizationVariables = "";
548
- this._solutionVariables = "";
549
- this._templateHierarchy = [];
550
- }
551
- /**
552
- * Toggle _treeOpen prop to show/hide content tree.
553
- *
554
- * @protected
555
- */
556
- _toggleTree() {
557
- this._treeOpen = !this._treeOpen;
558
- }
559
- /**
560
- * Dispatches an event indicating if the configuration is saveable or not. It's not saveable if there are no
561
- * changes or if there's an error in the JSON editor.
562
- *
563
- * @param solutionStoreHasChanges Are there changes in the configuration editor's internal store?
564
- * @param solutionEditorHasChanges Are there changes in the configuration editor's JSON editor?
565
- * @param solutionEditorHasErrors Are there errors in the configuration editor's JSON editor?
566
- *
567
- * @protected
568
- */
569
- _updateSaveability(solutionStoreHasChanges, solutionEditorHasChanges, solutionEditorHasErrors) {
570
- const updateSaveability = (solutionStoreHasChanges || solutionEditorHasChanges) && !solutionEditorHasErrors;
571
- if (this._canSave !== updateSaveability) {
572
- window.dispatchEvent(new CustomEvent("solutionCanSave", {
573
- detail: updateSaveability,
574
- bubbles: true,
575
- cancelable: false,
576
- composed: true
577
- }));
578
- }
579
- this._canSave = updateSaveability;
580
- }
581
- /**
582
- * Save all edits from the current configuration
583
- *
584
- * @returns a response that will indicate success or failure and any associated messages
585
- */
586
- /*
587
- protected async _save() {
588
- const templateUpdates = await this._updateTemplates();
589
- const data = this._setSrInfo(templateUpdates.templates);
590
- return templateUpdates.errors.length === 0 ? save(
591
- this.solutionItemId,
592
- data,
593
- state.models,
594
- this.authentication,
595
- this._translations
596
- ).then(saveResult => {
597
- // need to trigger re-render...and re-fetch
598
- this._fetchData = true;
599
- this.modelsSet = false;
600
- return Promise.resolve(saveResult)
601
- }).catch(e => Promise.reject(e)) : Promise.reject({
602
- success: false,
603
- message: `The following templates have errors: ${templateUpdates.errors.join(", ")}`
604
- } as IResponse);
605
- }
606
- */
607
- /**
608
- * Update the solutions templates based on the stored changes
609
- *
610
- * @returns an object that contains the updated templates as well as any errors that were found
611
- */
612
- /*
613
- protected async _updateTemplates(): Promise<IUpdateTemplateResponse> {
614
- const errors = [];
615
- const models = await this.getEditModels();
616
- let templates = this._updateGroupDependencies(models, this._templates);
617
- Object.keys(models).forEach(k => {
618
- const m = models[k];
619
- templates = templates.map(t => {
620
- if (t.itemId === m.itemId) {
621
- this._setItem(t, m);
622
- const hasDataError = this._setData(t, m);
623
- const hasPropError = this._setProps(t, m);
624
- if (hasDataError || hasPropError) {
625
- errors.push(m.itemId);
626
- }
627
- }
628
- return t;
629
- });
630
- });
631
- errors.concat(window.monaco.editor.getModelMarkers({}));
632
- return Promise.resolve({
633
- templates,
634
- errors
635
- });
636
- }
637
- */
638
- /**
639
- * Review all models and store itemIds that should be added or removed from group dependencies
640
- *
641
- * @param models the corresponding models for the current templates
642
- *
643
- * @returns group info (an object with keys of groupIds and
644
- * arrays of itemIds that should be added or removed from group dependencies)
645
- */
646
- /*
647
- protected _getGroupInfo(
648
- models: any
649
- ): any {
650
- const groupInfo = {}
651
- Object.keys(models).forEach(k => {
652
- const m = models[k];
653
- if (m.shareInfo) {
654
- const groupId = m.shareInfo.groupId;
655
- const type = m.shareInfo.shared ? "share" : "unshare";
656
- if (groupInfo[groupId]) {
657
- groupInfo[groupId][type].push(m.itemId);
658
- } else {
659
- groupInfo[groupId] = {};
660
- groupInfo[groupId][type] = [m.itemId];
661
- if (m.shareInfo.shared) {
662
- groupInfo[groupId]["unshare"] = [];
663
- } else {
664
- groupInfo[groupId]["share"] = [];
665
- }
666
- }
667
- }
668
- });
669
- return groupInfo;
670
- }
671
- */
672
- /**
673
- * Updates group dependency arrays by adding or removing itemIds
674
- *
675
- * @param templates the current templates to update
676
- * @param models the corresponding models for the current templates
677
- *
678
- * @returns updated templates array
679
- */
680
- /*
681
- protected _updateGroupDependencies(
682
- models: any,
683
- templates: any[]
684
- ): any[] {
685
- const groupInfo = this._getGroupInfo(models);
686
- Object.keys(groupInfo).forEach(k => {
687
- templates.some(t => {
688
- if (t.itemId === k) {
689
- // add share items as deps
690
- groupInfo[k].share.forEach(s => {
691
- if (t.dependencies.indexOf(s) < 0) {
692
- t.dependencies.push(s);
693
- }
694
- });
695
-
696
- // remove unshare items from deps
697
- groupInfo[k].unshare.forEach(s => {
698
- const index = t.dependencies.indexOf(s);
699
- if (index > -1) {
700
- t.dependencies.splice(index, 1);
701
- }
702
- });
703
- return true;
704
- } else {
705
- return false;
706
- }
707
- })
708
- })
709
- return templates;
710
- }
711
- */
712
- /**
713
- * Add group IDs to items that should be shared
714
- * This function will update the provided template when shareInfo is available
715
- *
716
- * @param template the current template to update
717
- * @param shareInfo the corresponding shareInfo from the model for the current template
718
- *
719
- */
720
- /*
721
- protected _updateItemGroups(
722
- template: any,
723
- shareInfo: any
724
- ): void {
725
- if (shareInfo) {
726
- const groupIndex = template.groups.indexOf(shareInfo.groupId);
727
- if (groupIndex < 0 && shareInfo.shared) {
728
- template.groups.push(shareInfo.groupId);
729
- }
730
- if (groupIndex > -1 && !shareInfo.shared) {
731
- template.groups.splice(groupIndex, 1);
732
- }
733
- }
734
- }
735
- */
736
- /**
737
- * Set a templates data property with changes from the models
738
- *
739
- * @param template the current template to update
740
- * @param model the corresponding model for the current template (stores any user changes)
741
- *
742
- * @returns a boolean that indicates if any errors were detected
743
- */
744
- /*
745
- protected _setData(
746
- template: any,
747
- model: any
748
- ): boolean {
749
- return this._setTemplateProp(
750
- template,
751
- model.dataOriginalValue,
752
- model.dataCurrentValue,
753
- "data"
754
- );
755
- }
756
- */
757
- /**
758
- * Set a templates properties property with changes from the models
759
- *
760
- * @param template the current template to update
761
- * @param model the corresponding model for the current template (stores any user changes)
762
- *
763
- * @returns a boolean that indicates if any errors were detected
764
- */
765
- /*
766
- protected _setProps(
767
- template: any,
768
- model: any
769
- ): boolean {
770
- return this._setTemplateProp(
771
- template,
772
- model.propsOriginalValue,
773
- model.propsCurrentValue,
774
- "properties"
775
- );
776
- }
777
- */
778
- /**
779
- * Generic function used to set properties or data property on a given template
780
- *
781
- * @param template the current template to update
782
- * @param originValue the original value from the solution template
783
- * @param modelValue the current value from the model (will contain any edits that have been made)
784
- * @param path the path to the property we should update if any changes are found
785
- *
786
- * @returns a boolean that indicates if any errors were detected
787
- */
788
- /*
789
- protected _setTemplateProp(
790
- template: any,
791
- originValue: any,
792
- modelValue: any,
793
- path: string
794
- ): boolean {
795
- let hasError = false;
796
- try {
797
- const _originValue = JSON.parse(originValue);
798
- const _modelValue = JSON.parse(modelValue);
799
-
800
- if (_originValue && _modelValue && (JSON.stringify(_originValue) !== JSON.stringify(_modelValue))) {
801
- setProp(template, path, _modelValue);
802
- }
803
- } catch (e) {
804
- console.error(e);
805
- hasError = true;
806
- }
807
- return hasError;
808
- }
809
- */
810
- /**
811
- * Set a templates item property with changes from the models
812
- *
813
- * @param template the current template to update
814
- * @param model the corresponding model for the current template (stores any user changes)
815
- *
816
- * This function will update the template argument when edits are found
817
- */
818
- /*
819
- protected _setItem(
820
- template: any,
821
- model: any
822
- ): void {
823
- this._updateItemGroups(template, model.shareInfo);
824
- if (model.updateItemValues && Object.keys(model.updateItemValues).length > 0) {
825
- Object.keys(model.updateItemValues).forEach(k => {
826
- template.item[k] = model.updateItemValues[k];
827
- });
828
- }
829
- }
830
- */
831
- /**
832
- * Set spatial reference info in the solutions data
833
- *
834
- * @param templates a list of item templates from the solution
835
- *
836
- * @returns a cloned copy of the solutions data that has been updated with spatial reference info
837
- *
838
- */
839
- /*
840
- protected _setSrInfo(
841
- templates: any[]
842
- ): any {
843
- const srInfo: any = state.getStoreInfo("spatialReferenceInfo");
844
-
845
- const serviceEnabled = typeof srInfo?.services === "undefined" ?
846
- false : Object.keys(srInfo.services).some(k => srInfo.services[k]);
847
-
848
- const data = cloneObject(this._sourceItemData);
849
- data.templates = templates;
850
- if (srInfo && srInfo.enabled && serviceEnabled) {
851
- const wkid = srInfo.spatialReference.wkid.toString();
852
-
853
- const wkidParam = {
854
- "label": "Spatial Reference",
855
- "default": wkid,
856
- "valueType": "spatialReference",
857
- "attributes": {
858
- "required": "true"
859
- }
860
- };
861
-
862
- const params = getProp(data, "params");
863
- const hasWkid = params && params.wkid;
864
- setCreateProp(
865
- data,
866
- hasWkid ? "params.wkid.default" : "params.wkid",
867
- hasWkid ? wkid : params ? wkidParam : wkid
868
- );
869
- } else if (!srInfo.enabled) {
870
- if (getProp(data, "params.wkid")) {
871
- delete (data.params.wkid);
872
- }
873
- }
874
- return data;
875
- }
876
- */
877
- /**
878
- * Fetches the component's translations
879
- *
880
- * @protected
881
- */
882
- async _getTranslations() {
883
- const translations = await getLocaleComponentStrings(this.el);
884
- this._translations = translations[0];
885
- }
886
- get el() { return getElement(this); }
887
- static get watchers() { return {
888
- "solutionItemId": ["valueWatchHandler"]
889
- }; }
890
- };
891
- SolutionConfiguration.style = solutionConfigurationCss;
892
-
893
- export { SolutionConfiguration as solution_configuration };
894
-
895
- //# sourceMappingURL=p-401541a5.entry.js.map