@stratusjs/angular 0.9.3 → 0.10.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.
- package/dist/angular.bundle.js +655 -630
- package/dist/angular.bundle.min.js +1 -1
- package/package.json +3 -3
- package/src/selector/selector-autocomplete.component.html +4 -4
- package/src/selector/selector-autocomplete.component.min.html +1 -1
- package/src/selector/selector.component.html +15 -15
- package/src/selector/selector.component.js +37 -24
- package/src/selector/selector.component.js.map +1 -1
- package/src/selector/selector.component.min.html +1 -1
- package/src/selector/selector.component.min.js +1 -1
- package/src/selector/selector.component.ts +53 -28
- package/src/tree/tree-dialog.component.html +2 -2
- package/src/tree/tree-dialog.component.js +31 -22
- package/src/tree/tree-dialog.component.js.map +1 -1
- package/src/tree/tree-dialog.component.min.html +1 -1
- package/src/tree/tree-dialog.component.min.js +1 -1
- package/src/tree/tree-dialog.component.ts +48 -25
- package/src/tree/tree-node.component.js +19 -19
- package/src/tree/tree-node.component.js.map +1 -1
- package/src/tree/tree-node.component.min.js +1 -1
- package/src/tree/tree-node.component.ts +28 -20
- package/src/tree/tree.component.js +27 -28
- package/src/tree/tree.component.js.map +1 -1
- package/src/tree/tree.component.min.js +1 -1
- package/src/tree/tree.component.ts +45 -33
|
@@ -39,7 +39,18 @@ import {
|
|
|
39
39
|
} from 'rxjs/operators'
|
|
40
40
|
|
|
41
41
|
// External
|
|
42
|
-
import
|
|
42
|
+
import {
|
|
43
|
+
assignIn,
|
|
44
|
+
clone,
|
|
45
|
+
get,
|
|
46
|
+
isEmpty,
|
|
47
|
+
isObject,
|
|
48
|
+
isNumber,
|
|
49
|
+
isString,
|
|
50
|
+
isUndefined,
|
|
51
|
+
snakeCase,
|
|
52
|
+
uniqueId
|
|
53
|
+
} from 'lodash'
|
|
43
54
|
import {Stratus} from '@stratusjs/runtime/stratus'
|
|
44
55
|
import {cookie} from '@stratusjs/core/environment'
|
|
45
56
|
|
|
@@ -67,6 +78,7 @@ import {
|
|
|
67
78
|
import {
|
|
68
79
|
ResponsiveComponent
|
|
69
80
|
} from '../core/responsive.component'
|
|
81
|
+
import {serializeUrlParams} from '@stratusjs/core/misc'
|
|
70
82
|
|
|
71
83
|
// Data Types
|
|
72
84
|
export interface DialogData {
|
|
@@ -80,6 +92,7 @@ export interface DialogData {
|
|
|
80
92
|
level: string
|
|
81
93
|
content: any
|
|
82
94
|
url: string
|
|
95
|
+
api: object
|
|
83
96
|
model: Model
|
|
84
97
|
collection: Collection
|
|
85
98
|
parent: any
|
|
@@ -116,7 +129,8 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
116
129
|
isStyled = false
|
|
117
130
|
|
|
118
131
|
// Dependencies
|
|
119
|
-
_ = _
|
|
132
|
+
// _ = _
|
|
133
|
+
get = get
|
|
120
134
|
Stratus = Stratus
|
|
121
135
|
|
|
122
136
|
// Root Component
|
|
@@ -142,7 +156,15 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
142
156
|
isContentLoading = false
|
|
143
157
|
isContentLoaded = false
|
|
144
158
|
lastContentSelectorQuery: string
|
|
159
|
+
/*
|
|
145
160
|
basicContentQueryAttributes = 'options[isContent]=null&options[isCollection]=null&options[showRoutable]=true&options[showRouting]=true'
|
|
161
|
+
*/
|
|
162
|
+
basicContentQueryAttributesObject: LooseObject = {
|
|
163
|
+
isContent: true,
|
|
164
|
+
isCollection: null,
|
|
165
|
+
showRoutable: true,
|
|
166
|
+
showRouting: true
|
|
167
|
+
}
|
|
146
168
|
contentEntity: ContentEntity
|
|
147
169
|
|
|
148
170
|
// Normalized Data
|
|
@@ -170,7 +192,7 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
170
192
|
// TODO: Consider making the Custom Link field the default
|
|
171
193
|
ngOnInit() {
|
|
172
194
|
// Initialization
|
|
173
|
-
this.uid =
|
|
195
|
+
this.uid = uniqueId(`sa_${snakeCase(moduleName)}_component_`)
|
|
174
196
|
Stratus.Instances[this.uid] = this
|
|
175
197
|
|
|
176
198
|
// TODO: Assess & Possibly Remove when the System.js ecosystem is complete
|
|
@@ -218,7 +240,7 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
218
240
|
debounceTime(300),
|
|
219
241
|
tap(() => this.isContentLoading = true),
|
|
220
242
|
switchMap((value: any) => {
|
|
221
|
-
if (
|
|
243
|
+
if (isString(value)) {
|
|
222
244
|
this.lastContentSelectorQuery = this.getQueryUrl(value)
|
|
223
245
|
} else {
|
|
224
246
|
// console.log('switchMap value is not a string:', value)
|
|
@@ -264,11 +286,11 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
264
286
|
finalize(() => this.isSingleContentLoading = false),
|
|
265
287
|
)
|
|
266
288
|
.subscribe((response: HttpResponse<Convoy<ContentEntity>>) => {
|
|
267
|
-
if (!response.ok || response.status !== 200 ||
|
|
289
|
+
if (!response.ok || response.status !== 200 || isEmpty(response.body)) {
|
|
268
290
|
return null
|
|
269
291
|
}
|
|
270
|
-
const payload =
|
|
271
|
-
if (
|
|
292
|
+
const payload = get(response.body, 'payload') || response.body
|
|
293
|
+
if (isEmpty(payload) || Array.isArray(payload) || !isObject(payload)) {
|
|
272
294
|
return null
|
|
273
295
|
}
|
|
274
296
|
// @ts-ignore
|
|
@@ -277,7 +299,7 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
277
299
|
this.dialogContentForm
|
|
278
300
|
.get('contentSelectorInput')
|
|
279
301
|
.patchValue(this.contentEntity)
|
|
280
|
-
this.refresh()
|
|
302
|
+
this.refresh().then()
|
|
281
303
|
return this.contentEntity
|
|
282
304
|
})
|
|
283
305
|
}
|
|
@@ -294,7 +316,7 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
294
316
|
// debounceTime(300),
|
|
295
317
|
// tap(() => this.isParentLoading = true),
|
|
296
318
|
// switchMap(value => {
|
|
297
|
-
// if (
|
|
319
|
+
// if (isString(value)) {
|
|
298
320
|
// this.lastParentSelectorQuery = `/Api/MenuLink?q=${value}`
|
|
299
321
|
// } else {
|
|
300
322
|
// this.data.nestParent = value
|
|
@@ -307,11 +329,11 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
307
329
|
// )
|
|
308
330
|
// )
|
|
309
331
|
// .subscribe(response => {
|
|
310
|
-
// if (!response.ok || response.status !== 200 ||
|
|
332
|
+
// if (!response.ok || response.status !== 200 || isEmpty(response.body)) {
|
|
311
333
|
// return this.filteredParentOptions = []
|
|
312
334
|
// }
|
|
313
|
-
// const payload =
|
|
314
|
-
// if (
|
|
335
|
+
// const payload = get(response.body, 'payload') || response.body
|
|
336
|
+
// if (isEmpty(payload) || !Array.isArray(payload)) {
|
|
315
337
|
// return this.filteredParentOptions = []
|
|
316
338
|
// }
|
|
317
339
|
// return this.filteredParentOptions = payload
|
|
@@ -353,31 +375,31 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
353
375
|
return
|
|
354
376
|
}
|
|
355
377
|
// Routing Display
|
|
356
|
-
const routing =
|
|
357
|
-
const routingText = !
|
|
378
|
+
const routing = get(content, 'routing[0].url')
|
|
379
|
+
const routingText = !isUndefined(routing) ? ` (/${routing})` : ' (No route!)'
|
|
358
380
|
// ContentId Fallback
|
|
359
|
-
const contentId =
|
|
360
|
-
const contentIdText = !
|
|
381
|
+
const contentId = get(content, 'id')
|
|
382
|
+
const contentIdText = !isUndefined(contentId) ? `Content: ${contentId}` : null
|
|
361
383
|
// Return Version Title or Fallback Text
|
|
362
|
-
return (
|
|
384
|
+
return (get(content, 'version.title') || contentIdText) + routingText
|
|
363
385
|
}
|
|
364
386
|
|
|
365
387
|
// displayName(option: any) {
|
|
366
388
|
// if (option) {
|
|
367
|
-
// return
|
|
389
|
+
// return get(option, 'name')
|
|
368
390
|
// }
|
|
369
391
|
// }
|
|
370
392
|
|
|
371
393
|
private handleContent(response: HttpResponse<Convoy<ContentEntity>>) {
|
|
372
|
-
if (!response.ok || response.status !== 200 ||
|
|
394
|
+
if (!response.ok || response.status !== 200 || isEmpty(response.body)) {
|
|
373
395
|
this.filteredContent = []
|
|
374
396
|
// FIXME: We have to go in this roundabout way to force changes to be detected since the
|
|
375
397
|
// Dialog Sub-Components don't seem to have the right timing for ngOnInit
|
|
376
398
|
// this.refresh()
|
|
377
399
|
return this.filteredContent
|
|
378
400
|
}
|
|
379
|
-
const payload =
|
|
380
|
-
if (
|
|
401
|
+
const payload = get(response.body, 'payload') || response.body
|
|
402
|
+
if (isEmpty(payload) || !Array.isArray(payload)) {
|
|
381
403
|
this.filteredContent = []
|
|
382
404
|
// FIXME: We have to go in this roundabout way to force changes to be detected since the
|
|
383
405
|
// Dialog Sub-Components don't seem to have the right timing for ngOnInit
|
|
@@ -423,9 +445,10 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
423
445
|
}
|
|
424
446
|
|
|
425
447
|
getQueryUrl(query?: string, id?: string|number): string {
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
448
|
+
const fullApiOptions = { options: assignIn(this.basicContentQueryAttributesObject, this.data.api)}
|
|
449
|
+
query = (!isString(query) || isEmpty(query)) ? '' : query
|
|
450
|
+
id = !isString(id) && !isNumber(id) ? '' : `/${id}`
|
|
451
|
+
return `${this.apiBase}${id}?limit=${this.limit}&${serializeUrlParams(fullApiOptions)}&q=${query}`
|
|
429
452
|
}
|
|
430
453
|
|
|
431
454
|
selectedOnTop(list?: Array<ContentEntity>, selected?: ContentEntity): Array<ContentEntity> {
|
|
@@ -435,7 +458,7 @@ export class TreeDialogComponent extends ResponsiveComponent implements OnInit,
|
|
|
435
458
|
if (!selected || !selected.id) {
|
|
436
459
|
return list
|
|
437
460
|
}
|
|
438
|
-
const orderedList =
|
|
461
|
+
const orderedList = clone(list)
|
|
439
462
|
const index = list.findIndex((v) => v.id === selected.id)
|
|
440
463
|
if (index === -1) {
|
|
441
464
|
// If Selected is not present, inject as first element
|
|
@@ -56,28 +56,27 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
56
56
|
this.isInitialized = false;
|
|
57
57
|
this.isDestroyed = false;
|
|
58
58
|
this.isStyled = false;
|
|
59
|
-
this._ = lodash_1.default;
|
|
60
59
|
this.Stratus = stratus_1.Stratus;
|
|
61
60
|
this.hasChild = (node) => node.children && node.children.length > 0;
|
|
62
61
|
this.isExpanded = (node) => node.meta ? node.meta.expanded : true;
|
|
63
62
|
}
|
|
64
63
|
ngOnInit() {
|
|
65
|
-
this.uid = lodash_1.
|
|
64
|
+
this.uid = lodash_1.uniqueId(`sa_${lodash_1.snakeCase(moduleName)}_component_`);
|
|
66
65
|
stratus_1.Stratus.Instances[this.uid] = this;
|
|
67
66
|
stratus_1.Stratus.Internals.CssLoader(`${localDir}/${parentModuleName}/${moduleName}.component${min}.css`)
|
|
68
67
|
.then(() => {
|
|
69
68
|
this.isStyled = true;
|
|
70
|
-
this.refresh();
|
|
69
|
+
this.refresh().then();
|
|
71
70
|
})
|
|
72
71
|
.catch((err) => {
|
|
73
72
|
console.warn('Issue detected in CSS Loader for Component:', this);
|
|
74
73
|
console.error(err);
|
|
75
74
|
this.isStyled = true;
|
|
76
|
-
this.refresh();
|
|
75
|
+
this.refresh().then();
|
|
77
76
|
});
|
|
78
77
|
this.node.meta.component = this;
|
|
79
78
|
this.isInitialized = true;
|
|
80
|
-
this.refresh();
|
|
79
|
+
this.refresh().then();
|
|
81
80
|
this.onPostPersist();
|
|
82
81
|
}
|
|
83
82
|
ngOnDestroy() {
|
|
@@ -121,7 +120,7 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
121
120
|
if (!this.node || !this.node.model) {
|
|
122
121
|
return;
|
|
123
122
|
}
|
|
124
|
-
this.node.model.destroy();
|
|
123
|
+
this.node.model.destroy().then();
|
|
125
124
|
});
|
|
126
125
|
return dialog;
|
|
127
126
|
}
|
|
@@ -140,7 +139,7 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
140
139
|
return;
|
|
141
140
|
}
|
|
142
141
|
this.node.meta.expanded = !this.node.meta.expanded;
|
|
143
|
-
this.refresh();
|
|
142
|
+
this.refresh().then();
|
|
144
143
|
}
|
|
145
144
|
toggleExpandedClick() {
|
|
146
145
|
this.isSingleClick = true;
|
|
@@ -156,7 +155,7 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
156
155
|
this.toggleExpanded();
|
|
157
156
|
}
|
|
158
157
|
openDialog() {
|
|
159
|
-
if (!this.node.model || !lodash_1.
|
|
158
|
+
if (!this.node.model || !lodash_1.has(this.node.model, 'data')) {
|
|
160
159
|
return;
|
|
161
160
|
}
|
|
162
161
|
const dialogRef = this.dialog.open(tree_dialog_component_1.TreeDialogComponent, {
|
|
@@ -172,6 +171,7 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
172
171
|
id: this.node.model.data.id || null,
|
|
173
172
|
name: this.node.model.data.name || '',
|
|
174
173
|
target: this.node.model.data.url ? 'url' : 'content',
|
|
174
|
+
api: this.tree.api,
|
|
175
175
|
content: this.node.model.data.content || null,
|
|
176
176
|
url: this.node.model.data.url || null,
|
|
177
177
|
browserTarget: this.node.model.data.browserTarget || null,
|
|
@@ -181,10 +181,10 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
181
181
|
nestParent: this.node.model.data.nestParent || null,
|
|
182
182
|
}
|
|
183
183
|
});
|
|
184
|
-
this.refresh();
|
|
184
|
+
this.refresh().then();
|
|
185
185
|
const that = this;
|
|
186
186
|
dialogRef.afterClosed().subscribe((result) => {
|
|
187
|
-
if (!result || lodash_1.
|
|
187
|
+
if (!result || lodash_1.isEmpty(result)) {
|
|
188
188
|
return;
|
|
189
189
|
}
|
|
190
190
|
this.tree.unsettled = true;
|
|
@@ -196,19 +196,19 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
196
196
|
'browserTarget'
|
|
197
197
|
];
|
|
198
198
|
attrs.forEach(attr => {
|
|
199
|
-
if (!lodash_1.
|
|
199
|
+
if (!lodash_1.has(result, attr)) {
|
|
200
200
|
return;
|
|
201
201
|
}
|
|
202
202
|
if ('content' === attr) {
|
|
203
|
-
const value = lodash_1.
|
|
204
|
-
this.node.model.set(attr, !value ? null : { id: lodash_1.
|
|
203
|
+
const value = lodash_1.get(result, attr);
|
|
204
|
+
this.node.model.set(attr, !value ? null : { id: lodash_1.get(value, 'id') });
|
|
205
205
|
return;
|
|
206
206
|
}
|
|
207
|
-
this.node.model.set(attr, lodash_1.
|
|
207
|
+
this.node.model.set(attr, lodash_1.get(result, attr));
|
|
208
208
|
});
|
|
209
|
-
that.refresh();
|
|
210
|
-
that.tree.refresh();
|
|
211
|
-
this.node.model.save();
|
|
209
|
+
that.refresh().then();
|
|
210
|
+
that.tree.refresh().then();
|
|
211
|
+
this.node.model.save().then();
|
|
212
212
|
this.tree.unsettled = false;
|
|
213
213
|
});
|
|
214
214
|
}
|
|
@@ -234,10 +234,10 @@ System.register(["@angular/core", "@angular/material/dialog", "./tree.component"
|
|
|
234
234
|
}
|
|
235
235
|
const model = this.node.model;
|
|
236
236
|
model.set('status', model.get('status') ? 0 : 1);
|
|
237
|
-
model.save();
|
|
237
|
+
model.save().then();
|
|
238
238
|
}
|
|
239
239
|
addChild() {
|
|
240
|
-
let priority = lodash_1.
|
|
240
|
+
let priority = lodash_1.max(this.tree.collection.models.filter((model) => {
|
|
241
241
|
const nestParent = model.get('nestParent');
|
|
242
242
|
if (!nestParent) {
|
|
243
243
|
return false;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["tree-node.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"sources":["tree-node.component.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAwDM,SAAS,GAAG,oBAAoB,CAAA;Y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;oBACP,IAAI,OAAO,QAAQ,KAAK,QAAQ,EAAE;wBAC9B,QAAQ,EAAE,CAAA;qBACb;oBACD,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC;wBACrB,IAAI,EAAC,gBAAgB;wBACrB,MAAM,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM;wBACnC,UAAU,EAAE;4BACR,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE;yBAC9B;wBACD,QAAQ;qBACX,EAAE;wBACC,IAAI,EAAE,IAAI;wBACV,OAAO,EAAE,IAAI;qBAChB,CAAC,CAAA;gBACN,CAAC;aACJ,CAAA;YA9QG;gBAAC,YAAK,EAAE;0CAAO,8BAAa;2DAAA;YAC5B;gBAAC,YAAK,EAAE;;6DAAa;YACrB;gBAAC,YAAK,EAAE;;2DAAW;YAjBV,iBAAiB;gBAL7B,gBAAS,CAAC;oBACP,QAAQ,EAAE,MAAM,UAAU,EAAE;oBAC5B,WAAW,EAAE,GAAG,QAAQ,IAAI,gBAAgB,IAAI,UAAU,aAAa,GAAG,OAAO;iBAEpF,CAAC;iDA4BqB,kBAAS;oBACT,wBAAiB;eA5B3B,iBAAiB,CA6R7B;;QACD,CAAC","file":"tree-node.component.js"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
System.register(["@angular/core","@angular/material/dialog","./tree.component","./tree-dialog.component","../confirm-dialog/confirm-dialog.component","lodash","@stratusjs/runtime/stratus","@stratusjs/core/environment","../core/responsive.component"],function(e,t){"use strict";var n,o,i,s,r,d,a,l,h,c,u,m,g,
|
|
1
|
+
System.register(["@angular/core","@angular/material/dialog","./tree.component","./tree-dialog.component","../confirm-dialog/confirm-dialog.component","lodash","@stratusjs/runtime/stratus","@stratusjs/core/environment","../core/responsive.component"],function(e,t){"use strict";var n,o,i,s,r,d,a,l,h,c,u,m,p,g,f=this&&this.__decorate||function(e,t,n,o){var i,s=arguments.length,r=s<3?t:null===o?o=Object.getOwnPropertyDescriptor(t,n):o;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(e,t,n,o);else for(var d=e.length-1;d>=0;d--)(i=e[d])&&(r=(s<3?i(r):s>3?i(t,n,r):i(t,n))||r);return s>3&&r&&Object.defineProperty(t,n,r),r},y=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)};t&&t.id;return{setters:[function(e){n=e},function(e){o=e},function(e){i=e},function(e){s=e},function(e){r=e},function(e){d=e},function(e){a=e},function(e){l=e},function(e){h=e}],execute:function(){"@stratusjs/angular",c="tree-node",u="tree",m=l.cookie("env")?"":".min",p=`${a.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,g=class extends h.ResponsiveComponent{constructor(e,t){super(),this.dialog=e,this.ref=t,this.title=c+"_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this.Stratus=a.Stratus,this.hasChild=e=>e.children&&e.children.length>0,this.isExpanded=e=>!e.meta||e.meta.expanded}ngOnInit(){this.uid=d.uniqueId(`sa_${d.snakeCase(c)}_component_`),a.Stratus.Instances[this.uid]=this,a.Stratus.Internals.CssLoader(`${p}/${u}/${c}.component${m}.css`).then(()=>{this.isStyled=!0,this.refresh().then()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh().then()}),this.node.meta.component=this,this.isInitialized=!0,this.refresh().then(),this.onPostPersist()}ngOnDestroy(){this.node.meta.component=null,this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(e=>e()):super.refresh()}onPostPersist(){this.node&&this.node.model&&this.node.model.meta.get("postPersist")&&(this.node.model.meta.set("postPersist",!1),this.openDialog())}destroy(){const e=this.dialog.open(r.ConfirmDialogComponent,{maxWidth:"400px",data:{title:"Delete MenuLink",message:"Are you sure you want to do this?"}});return e.afterClosed().subscribe(e=>{e&&this.node&&this.node.model&&this.node.model.destroy().then()}),e}getName(){return this.node.model&&this.node.model.get&&this.node.model.get("name")?this.node.model.get("name"):"Untitled"}getDragPreview(){return`name: ${this.getName()}<br>children: ${this.node.children?this.node.children.length:0}`}toggleExpanded(){this.node.meta?(this.node.meta.expanded=!this.node.meta.expanded,this.refresh().then()):console.error("node meta not found:",this.node)}toggleExpandedClick(){this.isSingleClick=!0,setTimeout(()=>{this.isSingleClick&&this.toggleExpanded()},this.tree.dblClickWait)}toggleExpandedDblClick(){this.isSingleClick=!1,this.toggleExpanded()}openDialog(){if(!this.node.model||!d.has(this.node.model,"data"))return;const e=this.dialog.open(s.TreeDialogComponent,{width:"400px",autoFocus:!0,disableClose:!0,restoreFocus:!1,data:{tree:this.tree,treeNode:this,backend:this.tree.backend,iconRegistry:this.tree.iconRegistry,id:this.node.model.data.id||null,name:this.node.model.data.name||"",target:this.node.model.data.url?"url":"content",api:this.tree.api,content:this.node.model.data.content||null,url:this.node.model.data.url||null,browserTarget:this.node.model.data.browserTarget||null,model:this.node.model||null,collection:this.tree.collection||null,parent:this.node.model.data.parent||null,nestParent:this.node.model.data.nestParent||null}});this.refresh().then();const t=this;e.afterClosed().subscribe(e=>{if(!e||d.isEmpty(e))return;this.tree.unsettled=!0;["name","content","url","priority","browserTarget"].forEach(t=>{if(d.has(e,t))if("content"!==t)this.node.model.set(t,d.get(e,t));else{const n=d.get(e,t);this.node.model.set(t,n?{id:d.get(n,"id")}:null)}}),t.refresh().then(),t.tree.refresh().then(),this.node.model.save().then(),this.tree.unsettled=!1})}openDialogClick(){this.isSingleClick=!0,setTimeout(()=>{this.isSingleClick&&this.openDialog()},this.tree.dblClickWait)}openDialogDblClick(){this.isSingleClick=!1,this.openDialog()}getSvg(e,t){return this.tree.getSvg(e,t)}toggleStatus(){if(!this.node||!this.node.model)return;const e=this.node.model;e.set("status",e.get("status")?0:1),e.save().then()}addChild(){let e=d.max(this.tree.collection.models.filter(e=>{const t=e.get("nestParent");return!!t&&t.id===this.node.id}).map(e=>e.get("priority")))||-1;"number"==typeof e&&e++,this.tree.collection.add({name:"Untitled Child",parent:this.node.model.data.parent,nestParent:{id:this.node.model.data.id},priority:e},{save:!0,trigger:!0})}},f([n.Input(),y("design:type",i.TreeComponent)],g.prototype,"tree",void 0),f([n.Input(),y("design:type",Object)],g.prototype,"parent",void 0),f([n.Input(),y("design:type",Object)],g.prototype,"node",void 0),g=f([n.Component({selector:`sa-${c}`,templateUrl:`${p}/${u}/${c}.component${m}.html`}),y("design:paramtypes",[o.MatDialog,n.ChangeDetectorRef])],g),e("TreeNodeComponent",g)}}});
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
|
|
17
17
|
// Components
|
|
18
18
|
// TODO: We may want to move these imports to interface files to avoid circular references
|
|
19
|
+
// being a bundled import, circular references are generally not an issue
|
|
19
20
|
import {
|
|
20
21
|
Node,
|
|
21
22
|
TreeComponent
|
|
@@ -34,7 +35,14 @@ import {
|
|
|
34
35
|
} from '@stratusjs/angularjs/services/model'
|
|
35
36
|
|
|
36
37
|
// External
|
|
37
|
-
import
|
|
38
|
+
import {
|
|
39
|
+
get,
|
|
40
|
+
has,
|
|
41
|
+
isEmpty,
|
|
42
|
+
max,
|
|
43
|
+
snakeCase,
|
|
44
|
+
uniqueId
|
|
45
|
+
} from 'lodash'
|
|
38
46
|
import {Stratus} from '@stratusjs/runtime/stratus'
|
|
39
47
|
import {cookie} from '@stratusjs/core/environment'
|
|
40
48
|
import {IconOptions} from '@angular/material/icon'
|
|
@@ -74,7 +82,6 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
74
82
|
isStyled = false
|
|
75
83
|
|
|
76
84
|
// Dependencies
|
|
77
|
-
_ = _
|
|
78
85
|
Stratus = Stratus
|
|
79
86
|
|
|
80
87
|
// Inputs
|
|
@@ -105,7 +112,7 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
105
112
|
|
|
106
113
|
ngOnInit() {
|
|
107
114
|
// Initialization
|
|
108
|
-
this.uid =
|
|
115
|
+
this.uid = uniqueId(`sa_${snakeCase(moduleName)}_component_`)
|
|
109
116
|
Stratus.Instances[this.uid] = this
|
|
110
117
|
|
|
111
118
|
// TODO: Assess & Possibly Remove when the System.js ecosystem is complete
|
|
@@ -113,13 +120,13 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
113
120
|
Stratus.Internals.CssLoader(`${localDir}/${parentModuleName}/${moduleName}.component${min}.css`)
|
|
114
121
|
.then(() => {
|
|
115
122
|
this.isStyled = true
|
|
116
|
-
this.refresh()
|
|
123
|
+
this.refresh().then()
|
|
117
124
|
})
|
|
118
125
|
.catch((err: any) => {
|
|
119
126
|
console.warn('Issue detected in CSS Loader for Component:', this)
|
|
120
127
|
console.error(err)
|
|
121
128
|
this.isStyled = true
|
|
122
|
-
this.refresh()
|
|
129
|
+
this.refresh().then()
|
|
123
130
|
})
|
|
124
131
|
|
|
125
132
|
// Attach Component to Node Meta
|
|
@@ -129,7 +136,7 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
129
136
|
this.isInitialized = true
|
|
130
137
|
|
|
131
138
|
// Force UI Redraw
|
|
132
|
-
this.refresh()
|
|
139
|
+
this.refresh().then()
|
|
133
140
|
|
|
134
141
|
// Handle Post-Persist
|
|
135
142
|
this.onPostPersist()
|
|
@@ -180,7 +187,7 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
180
187
|
if (!this.node || !this.node.model) {
|
|
181
188
|
return
|
|
182
189
|
}
|
|
183
|
-
this.node.model.destroy()
|
|
190
|
+
this.node.model.destroy().then()
|
|
184
191
|
})
|
|
185
192
|
return dialog
|
|
186
193
|
}
|
|
@@ -202,7 +209,7 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
202
209
|
return
|
|
203
210
|
}
|
|
204
211
|
this.node.meta.expanded = !this.node.meta.expanded
|
|
205
|
-
this.refresh()
|
|
212
|
+
this.refresh().then()
|
|
206
213
|
}
|
|
207
214
|
|
|
208
215
|
public toggleExpandedClick(): void {
|
|
@@ -222,7 +229,7 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
222
229
|
|
|
223
230
|
// TODO: Move things like toggle to this TreeNodeComponent, so it can be used in the template as well as the Dialog
|
|
224
231
|
public openDialog(): void {
|
|
225
|
-
if (!this.node.model || !
|
|
232
|
+
if (!this.node.model || !has(this.node.model, 'data')) {
|
|
226
233
|
return
|
|
227
234
|
}
|
|
228
235
|
const dialogRef = this.dialog.open(TreeDialogComponent, {
|
|
@@ -238,6 +245,7 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
238
245
|
id: this.node.model.data.id || null,
|
|
239
246
|
name: this.node.model.data.name || '',
|
|
240
247
|
target: this.node.model.data.url ? 'url' : 'content',
|
|
248
|
+
api: this.tree.api,
|
|
241
249
|
// level: this.node.model.data.nestParent === null ? 'top' : 'child',
|
|
242
250
|
content: this.node.model.data.content || null,
|
|
243
251
|
url: this.node.model.data.url || null,
|
|
@@ -249,11 +257,11 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
249
257
|
nestParent: this.node.model.data.nestParent || null,
|
|
250
258
|
}
|
|
251
259
|
})
|
|
252
|
-
this.refresh()
|
|
260
|
+
this.refresh().then()
|
|
253
261
|
|
|
254
262
|
const that = this
|
|
255
263
|
dialogRef.afterClosed().subscribe((result: DialogData) => {
|
|
256
|
-
if (!result ||
|
|
264
|
+
if (!result || isEmpty(result)) {
|
|
257
265
|
return
|
|
258
266
|
}
|
|
259
267
|
// Disable Listeners
|
|
@@ -268,23 +276,23 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
268
276
|
]
|
|
269
277
|
// Persist to Model
|
|
270
278
|
attrs.forEach(attr => {
|
|
271
|
-
if (!
|
|
279
|
+
if (!has(result, attr)) {
|
|
272
280
|
return
|
|
273
281
|
}
|
|
274
282
|
// Normalize Content
|
|
275
283
|
if ('content' === attr) {
|
|
276
|
-
const value =
|
|
277
|
-
this.node.model.set(attr, !value ? null : {id:
|
|
284
|
+
const value = get(result, attr)
|
|
285
|
+
this.node.model.set(attr, !value ? null : {id: get(value, 'id')})
|
|
278
286
|
return
|
|
279
287
|
}
|
|
280
|
-
this.node.model.set(attr,
|
|
288
|
+
this.node.model.set(attr, get(result, attr))
|
|
281
289
|
})
|
|
282
290
|
// Refresh Component
|
|
283
|
-
that.refresh()
|
|
291
|
+
that.refresh().then()
|
|
284
292
|
// Refresh Parent Tree
|
|
285
|
-
that.tree.refresh()
|
|
293
|
+
that.tree.refresh().then()
|
|
286
294
|
// Start XHR
|
|
287
|
-
this.node.model.save()
|
|
295
|
+
this.node.model.save().then()
|
|
288
296
|
// Enable Listeners
|
|
289
297
|
this.tree.unsettled = false
|
|
290
298
|
})
|
|
@@ -315,13 +323,13 @@ export class TreeNodeComponent extends ResponsiveComponent implements OnInit, On
|
|
|
315
323
|
}
|
|
316
324
|
const model = this.node.model
|
|
317
325
|
model.set('status', model.get('status') ? 0 : 1)
|
|
318
|
-
model.save()
|
|
326
|
+
model.save().then()
|
|
319
327
|
}
|
|
320
328
|
|
|
321
329
|
// TODO: Have this spawn off a new Tree Dialog with a new function addChild() on the TreeDialogComponent Class
|
|
322
330
|
// TODO: Use the tree map to call node.openDialog after creating the new item
|
|
323
331
|
public addChild(): void {
|
|
324
|
-
let priority =
|
|
332
|
+
let priority = max(
|
|
325
333
|
this.tree.collection.models.filter(
|
|
326
334
|
(model: Model) => {
|
|
327
335
|
const nestParent = model.get('nestParent')
|