@stratusjs/angular 0.8.5 → 0.9.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 (76) hide show
  1. package/dist/angular.bundle.js +4884 -5856
  2. package/dist/angular.bundle.min.js +1 -1
  3. package/package.json +1 -1
  4. package/src/app.module.js +8 -2
  5. package/src/app.module.js.map +1 -1
  6. package/src/app.module.min.js +1 -1
  7. package/src/app.module.ts +4 -0
  8. package/src/base/base.component.min.js +1 -1
  9. package/src/confirm-dialog/confirm-dialog.component.min.js +1 -1
  10. package/src/core/root.component.min.js +1 -1
  11. package/src/editor/citation-dialog.component.min.js +1 -1
  12. package/src/editor/code-view-dialog.component.min.js +1 -1
  13. package/src/editor/editor.component.min.js +1 -1
  14. package/src/editor/link-dialog.component.min.js +1 -1
  15. package/src/editor/media-dialog.component.min.js +1 -1
  16. package/src/editor/quill-break-blot.plugin.js +38 -0
  17. package/src/editor/quill-break-blot.plugin.js.map +1 -0
  18. package/src/editor/quill-break-blot.plugin.min.js +1 -0
  19. package/src/editor/quill-html-edit.plugin.js +164 -0
  20. package/src/editor/quill-html-edit.plugin.js.map +1 -0
  21. package/src/editor/quill-html-edit.plugin.min.js +1 -0
  22. package/src/editor/quill-image-format.plugin.js +50 -0
  23. package/src/editor/quill-image-format.plugin.js.map +1 -0
  24. package/src/editor/quill-image-format.plugin.min.js +1 -0
  25. package/src/editor/quill-input-button.plugin.js +98 -0
  26. package/src/editor/quill-input-button.plugin.js.map +1 -0
  27. package/src/editor/quill-input-button.plugin.min.js +1 -0
  28. package/src/froala/editor/froala-editor.directive.js +328 -0
  29. package/src/froala/editor/froala-editor.directive.js.map +1 -0
  30. package/src/froala/editor/froala-editor.directive.min.js +1 -0
  31. package/src/froala/editor/froala-editor.module.js +37 -0
  32. package/src/froala/editor/froala-editor.module.js.map +1 -0
  33. package/src/froala/editor/froala-editor.module.min.js +1 -0
  34. package/src/froala/editor/index.js +22 -0
  35. package/src/froala/editor/index.js.map +1 -0
  36. package/src/froala/editor/index.min.js +1 -0
  37. package/src/froala/plugins/citationManager.min.js +1 -1
  38. package/src/froala/plugins/image_manager.js +364 -0
  39. package/src/froala/plugins/image_manager.js.map +1 -0
  40. package/src/froala/plugins/image_manager.min.js +1 -0
  41. package/src/froala/plugins/inputButton.min.js +1 -1
  42. package/src/froala/plugins/mediaManager.min.js +1 -1
  43. package/src/froala/plugins/menuButton.min.js +1 -1
  44. package/src/froala/view/froala-view.directive.js +49 -0
  45. package/src/froala/view/froala-view.directive.js.map +1 -0
  46. package/src/froala/view/froala-view.directive.min.js +1 -0
  47. package/src/froala/view/froala-view.module.js +37 -0
  48. package/src/froala/view/froala-view.module.js.map +1 -0
  49. package/src/froala/view/froala-view.module.min.js +1 -0
  50. package/src/froala/view/index.js +22 -0
  51. package/src/froala/view/index.js.map +1 -0
  52. package/src/froala/view/index.min.js +1 -0
  53. package/src/media-selector/media-selector.component.min.js +1 -1
  54. package/src/quill-plugins/quill-html-edit.plugin.min.js +1 -1
  55. package/src/quill-plugins/quill-image-format.plugin.min.js +1 -1
  56. package/src/root/root.component.js +43 -0
  57. package/src/root/root.component.js.map +1 -0
  58. package/src/root/root.component.min.js +1 -0
  59. package/src/selector/selector.component.min.js +1 -1
  60. package/src/test/test.directive.min.js +1 -1
  61. package/src/timezone-selector/timezone-selector.component.html +11 -0
  62. package/src/timezone-selector/timezone-selector.component.js +240 -0
  63. package/src/timezone-selector/timezone-selector.component.js.map +1 -0
  64. package/src/timezone-selector/timezone-selector.component.min.html +1 -0
  65. package/src/timezone-selector/timezone-selector.component.min.js +1 -0
  66. package/src/timezone-selector/timezone-selector.component.ts +271 -0
  67. package/src/tree/tree-dialog.component.min.js +1 -1
  68. package/src/tree/tree-node.component.min.js +1 -1
  69. package/src/tree/tree.component.min.js +1 -1
  70. package/src/core/dialog.interface.js.map +0 -1
  71. package/src/json/json.component.css +0 -2
  72. package/src/json/json.component.css.map +0 -1
  73. package/src/json/json.component.js +0 -257
  74. package/src/json/json.component.js.map +0 -1
  75. package/src/json/json.component.min.css +0 -0
  76. package/src/json/json.component.min.js +0 -1
@@ -0,0 +1,271 @@
1
+ // Angular Core
2
+ import {
3
+ ChangeDetectionStrategy,
4
+ ChangeDetectorRef,
5
+ Component,
6
+ ElementRef,
7
+ Input,
8
+ OnInit
9
+ } from '@angular/core'
10
+ import {DomSanitizer} from '@angular/platform-browser'
11
+ import {FormControl} from '@angular/forms'
12
+ import {
13
+ Observable,
14
+ ObservableInput,
15
+ Subject,
16
+ Subscriber,
17
+ timer
18
+ } from 'rxjs'
19
+ import {catchError, debounce, map, startWith} from 'rxjs/operators'
20
+ import Toastify from 'toastify-js'
21
+ import {keys} from 'ts-transformer-keys'
22
+ import {safeUniqueId} from '@stratusjs/core/misc'
23
+ import {Stratus} from '@stratusjs/runtime/stratus'
24
+ import {cookie} from '@stratusjs/core/environment'
25
+ import {EventManager} from '@stratusjs/core/events/eventManager'
26
+ import {RootComponent} from '../core/root.component'
27
+ import {isEmpty} from 'lodash'
28
+
29
+ // AngularJS Classes
30
+ import {Registry} from '@stratusjs/angularjs/services/registry'
31
+ import {Model} from '@stratusjs/angularjs/services/model'
32
+ import {Collection} from '@stratusjs/angularjs/services/collection'
33
+
34
+ // Local Setup
35
+ const systemDir = '@stratusjs/angular'
36
+ const moduleName = 'timezone-selector'
37
+ const min = !cookie('env') ? '.min' : ''
38
+ const localDir = `${Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '').replace(/\/dist\/$/, '/src/')}`
39
+
40
+
41
+ /**
42
+ * @title Media Selector with Drag & Drop Uploads and Sorting
43
+ */
44
+ @Component({
45
+ selector: `sa-${moduleName}`,
46
+ // TODO: Add the ability to change the templateUrl to others, based on a cookie.
47
+ templateUrl: `${localDir}/${moduleName}/${moduleName}.component${min}.html`,
48
+ // FIXME: This doesn't work, as it seems Angular attempts to use a System.js import instead of their own, so it will
49
+ // require the steal-css module
50
+ // styleUrls: [
51
+ // `${localDir}/${moduleName}/${moduleName}.component${min}.css`
52
+ // ],
53
+ changeDetection: ChangeDetectionStrategy.OnPush
54
+ })
55
+
56
+ export class TimezoneSelectorComponent extends RootComponent implements OnInit { // implements OnInit, OnChanges {
57
+
58
+ // Basic Component Settings
59
+ title = moduleName + '_component'
60
+ uid: string
61
+
62
+ // Registry Attributes
63
+ @Input() target: string
64
+ @Input() targetSuffix: string
65
+ @Input() id: number
66
+ @Input() manifest: boolean
67
+ @Input() decouple: boolean
68
+ @Input() direct: boolean
69
+ @Input() api: object
70
+ @Input() urlRoot: string
71
+ // @Input() registryModel: boolean | string // inputs are strings.. // false will disable Registry
72
+
73
+ // Component Attributes
74
+ @Input() type: string
75
+ @Input() property: string
76
+ @Input() endpoint: string
77
+
78
+ // Dependencies
79
+ Stratus = Stratus
80
+ /*fieldName = 'timezoneSelector'
81
+ fieldNameId = 'timezoneSelectorId'
82
+ form: FormGroup = this.fb.group({
83
+ [this.fieldName]: new FormControl(), // optionally disabled on init to avoid known issues
84
+ [this.fieldNameId]: new FormControl({disabled: true})
85
+ })*/
86
+
87
+ // Stratus Data Connectivity
88
+ registry = new Registry()
89
+ fetched: Promise<boolean|Collection|Model>
90
+ data: any
91
+ // collection?: EventBase
92
+ // @Output() model: any
93
+ model?: Model
94
+
95
+ // Observable Connection
96
+ dataSub: Observable<[]>
97
+ onChange = new Subject()
98
+ subscriber: Subscriber<any>
99
+ // Note: It may be better to LifeCycle::tick(), but this works for now
100
+
101
+ // Multi-Framework Event Connectivity
102
+ label = 'Select Timezone'
103
+ timezone: string
104
+ currentTimezone: string
105
+ inputTimezone = new FormControl('')
106
+ timezoneList: string[] = []
107
+ filteredTimezones: Observable<string[]>
108
+
109
+ // UI Flags
110
+ initialized = false
111
+
112
+ // Construct
113
+ constructor(
114
+ private elementRef: ElementRef,
115
+ protected ref: ChangeDetectorRef,
116
+ private sanitizer: DomSanitizer,
117
+ ) {
118
+ // Chain constructor
119
+ super()
120
+
121
+ // Initialization
122
+ this.uid = safeUniqueId('sa', moduleName, 'component')
123
+ Stratus.Instances[this.uid] = this
124
+
125
+ // Prepare all possible timezones
126
+ this.timezoneList = (Intl as any).supportedValuesOf('timeZone')
127
+
128
+ // Get our own timezone
129
+ this.currentTimezone = (Intl as any).DateTimeFormat().resolvedOptions().timeZone
130
+
131
+ // Hydrate Root App Inputs
132
+ this.hydrate(elementRef, sanitizer, keys<TimezoneSelectorComponent>())
133
+
134
+ this.filteredTimezones = this.inputTimezone.valueChanges.pipe(
135
+ startWith(''),
136
+ // tap(value => console.log(`filteredTimezones piping {value}`)),
137
+ map(value => this._filter(value || '')),
138
+ )
139
+
140
+ /** Data Connections with Stratus model initiated */
141
+ this.fetchData()
142
+ .then(data => {
143
+ if (!data || !(data instanceof EventManager)) {
144
+ console.warn('Unable to bind data from Registry!')
145
+ return
146
+ }
147
+ // Manually render upon model change
148
+ const onDataChange = () => {
149
+ if (!data.completed) {
150
+ return
151
+ }
152
+ this.dataDefer(this.subscriber)
153
+ }
154
+ data.on('change', onDataChange)
155
+ onDataChange()
156
+ })
157
+
158
+ // Declare Observable with Subscriber (Only Happens Once)
159
+ this.dataSub = new Observable(subscriber => {
160
+ return this.dataDefer(subscriber)
161
+ })
162
+ // When the model updates, this will update the input field
163
+ this.dataSub.pipe(
164
+ debounce(() => timer(500)),
165
+ catchError(this.handleObservableError)
166
+ ).subscribe(evt => {
167
+ if (this.inputTimezone.value === evt) {
168
+ if (this.initialized) {
169
+ this.refresh().then()
170
+ }
171
+ return
172
+ }
173
+ this.timezone = evt
174
+ this.updateLabel()
175
+ this.inputTimezone.setValue(this.timezone)
176
+ this.refresh().then()
177
+ })
178
+ }
179
+ async ngOnInit() {
180
+ // Watch for input box changes
181
+ this.inputTimezone.valueChanges.forEach((value?: string) => this.valueChanged(value)).then()
182
+ this.updateLabel()
183
+ this.initialized = true
184
+ }
185
+
186
+ private updateLabel() {
187
+ if (isEmpty(this.timezone) || this.timezone === 'local') {
188
+ this.label = `(local - Currently displayed in ${this.currentTimezone})`
189
+ } else {
190
+ this.label = 'Select Timezone'
191
+ }
192
+ }
193
+
194
+ /** Filter the inout box and output similar possible options */
195
+ private _filter(value: string): string[] {
196
+ const filterValue = value.toLowerCase()
197
+ return this.timezoneList.filter(timezone => timezone.toLowerCase().includes(filterValue))
198
+ }
199
+
200
+ /** Connect to Stratus Model and sync */
201
+ fetchData() {
202
+ if (this.fetched) {
203
+ return this.fetched
204
+ }
205
+ return this.fetched = this.registry.fetch(
206
+ Stratus.Select(this.elementRef.nativeElement),
207
+ this
208
+ )
209
+ }
210
+
211
+ /** Ensures Data is populated before hitting the Subscriber */
212
+ dataDefer(subscriber: Subscriber<any>) {
213
+ this.subscriber = this.subscriber || subscriber
214
+ if (!this.subscriber) {
215
+ return
216
+ }
217
+ const dataString = this.dataRef()
218
+ this.subscriber.next(dataString)
219
+ }
220
+
221
+ /** Return the value on the Stratus model */
222
+ dataRef(): string {
223
+ if (!this.model) {
224
+ return ''
225
+ }
226
+ return this.model.get(this.property)
227
+ }
228
+
229
+ /** Any time the value of the input box is changed */
230
+ valueChanged(value: string) {
231
+ if (!value) {
232
+ return
233
+ }
234
+ // Update the field to allow external apps to read
235
+ this.timezone = value
236
+ this.updateLabel()
237
+ this.inputTimezone.setValue(this.timezone)
238
+ if (!this.model || !this.model.completed) {
239
+ return
240
+ }
241
+
242
+ // Save the qualified change to the model directly!
243
+ this.model.set(
244
+ this.property,
245
+ this.timezone // value
246
+ )
247
+ }
248
+
249
+ /** Toastify Errors */
250
+ handleObservableError(err: ObservableInput<any>): ObservableInput<any> {
251
+ console.error(err)
252
+ Toastify({
253
+ text: err.toString(),
254
+ duration: 3000,
255
+ close: true,
256
+ stopOnFocus: true,
257
+ style: {
258
+ background: '#E14D45',
259
+ }
260
+ }).showToast()
261
+ return err
262
+ }
263
+
264
+ /** When a timezone option is clicked, process it by manually noting that it changed */
265
+ timezoneSelected(value?: string) {
266
+ if(!value) {
267
+ return
268
+ }
269
+ this.valueChanged(value)
270
+ }
271
+ }
@@ -1 +1 @@
1
- System.register(["@angular/core","@angular/forms","@angular/cdk/drag-drop","@angular/material/dialog","rxjs/operators","lodash","@stratusjs/runtime/stratus","@stratusjs/core/environment","../core/responsive.component"],function(t,e){"use strict";var i,n,s,o,r,a,l,d,u,h,c,f,g=this&&this.__decorate||function(t,e,i,n){var s,o=arguments.length,r=o<3?e:null===n?n=Object.getOwnPropertyDescriptor(e,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,i,n);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,i,r):s(e,i))||r);return o>3&&r&&Object.defineProperty(e,i,r),r},p=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},y=this&&this.__param||function(t,e){return function(i,n){e(i,n,t)}};e&&e.id;return{setters:[function(t){i=t},function(t){n=t},function(t){s=t},function(t){o=t},function(t){r=t},function(t){a=t},function(t){l=t},function(t){d=t},function(t){u=t}],execute:function(){"@stratusjs/angular","tree-dialog","tree",h=d.cookie("env")?"":".min",c=`${l.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,f=class extends u.ResponsiveComponent{constructor(t,e,i,n){super(),this.dialogRef=t,this.data=e,this.fb=i,this.ref=n,this.title="tree-dialog_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this._=a.default,this.Stratus=l.Stratus,this.apiBase="/Api/Content",this.isSingleContentLoading=!1,this.limit=20,this.isContentLoading=!1,this.isContentLoaded=!1,this.basicContentQueryAttributes="options[isContent]=null&options[isCollection]=null&options[showRoutable]=true&options[showRouting]=true"}ngOnInit(){this.uid=a.default.uniqueId(`sa_${a.default.snakeCase("tree-dialog")}_component_`),l.Stratus.Instances[this.uid]=this,l.Stratus.Internals.CssLoader(`${c}/tree/tree-dialog.component${h}.css`).then(()=>{this.isStyled=!0}).catch(t=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(t),this.isStyled=!0}),this.tree=this.data.tree,this.treeNode=this.data.treeNode,this.browserTarget=null!==this.data.browserTarget,this.backend=this.data.backend,this.iconRegistry=this.data.iconRegistry,this.dialogContentForm=this.fb.group({contentSelectorInput:this.data.content||null}),this.dialogContentForm.get("contentSelectorInput").valueChanges.pipe(r.debounceTime(300),r.tap(()=>this.isContentLoading=!0),r.switchMap(t=>(a.default.isString(t)?this.lastContentSelectorQuery=this.getQueryUrl(t):(this.data.content=t,this.data.url=null),this.backend.get(this.lastContentSelectorQuery||this.getQueryUrl()).pipe(r.finalize(()=>{this.isContentLoading=!1,this.isContentLoaded=!0}))))).subscribe(t=>this.handleContent(t)),this.backend.get(this.getQueryUrl()).pipe(r.finalize(()=>this.isContentLoading=!1)).subscribe(t=>this.handleContent(t)),this.data.content&&this.data.content.id&&(this.isSingleContentLoading=!0,this.backend.get(this.getQueryUrl(null,this.data.content.id)).pipe(r.finalize(()=>this.isSingleContentLoading=!1)).subscribe(t=>{if(!t.ok||200!==t.status||a.default.isEmpty(t.body))return null;const e=a.default.get(t.body,"payload")||t.body;return a.default.isEmpty(e)||Array.isArray(e)||!a.default.isObject(e)?null:(this.contentEntity=e,this.isSingleContentLoading=!1,this.dialogContentForm.get("contentSelectorInput").patchValue(this.contentEntity),this.refresh(),this.contentEntity)})),this.isInitialized=!0}ngOnDestroy(){this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(t=>t()):super.refresh()}onCancelClick(){this.dialogRef.close()}onBrowserTargetChange(t){this.data.browserTarget=t.checked?"_blank":null}displayContentText(t){if(!t)return;const e=a.default.get(t,"routing[0].url"),i=a.default.isUndefined(e)?" (No route!)":` (/${e})`,n=a.default.get(t,"id"),s=a.default.isUndefined(n)?null:"Content: "+n;return(a.default.get(t,"version.title")||s)+i}handleContent(t){if(!t.ok||200!==t.status||a.default.isEmpty(t.body))return this.filteredContent=[],this.filteredContent;const e=a.default.get(t.body,"payload")||t.body;return a.default.isEmpty(e)||!Array.isArray(e)?(this.filteredContent=[],this.filteredContent):(this.filteredContent=e,this.filteredContent)}destroy(){this.treeNode.destroy().afterClosed().subscribe(t=>{t&&this.onCancelClick()})}toggleStatus(){this.treeNode.toggleStatus()}addChild(){this.treeNode.addChild()}isSelected(t){return!!this.data.content&&this.data.content.id===t.id}getSvg(t,e){return this.tree.getSvg(t,e)}getQueryUrl(t,e){return t=!a.default.isString(t)||a.default.isEmpty(t)?"":t,e=a.default.isString(e)||a.default.isNumber(e)?"/"+e:"",`${this.apiBase}${e}?limit=${this.limit}&${this.basicContentQueryAttributes}&q=${t}`}selectedOnTop(t,e){if(!t||!t.length)return t;if(!e||!e.id)return t;const i=a.default.clone(t),n=t.findIndex(t=>t.id===e.id);return-1===n?(i.unshift(e),i):(s.moveItemInArray(i,n,0),i)}},f=g([i.Component({selector:"sa-tree-dialog",templateUrl:`${c}/tree/tree-dialog.component${h}.html`}),y(1,i.Inject(o.MAT_DIALOG_DATA)),p("design:paramtypes",[o.MatDialogRef,Object,n.FormBuilder,i.ChangeDetectorRef])],f),t("TreeDialogComponent",f)}}});
1
+ System.register(["@angular/core","@angular/forms","@angular/cdk/drag-drop","@angular/material/dialog","rxjs/operators","lodash","@stratusjs/runtime/stratus","@stratusjs/core/environment","../core/responsive.component"],function(t,e){"use strict";var n,i,s,o,r,a,l,d,u,h,c,f,g,p,y=this&&this.__decorate||function(t,e,n,i){var s,o=arguments.length,r=o<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)r=Reflect.decorate(t,e,n,i);else for(var a=t.length-1;a>=0;a--)(s=t[a])&&(r=(o<3?s(r):o>3?s(e,n,r):s(e,n))||r);return o>3&&r&&Object.defineProperty(e,n,r),r},C=this&&this.__metadata||function(t,e){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(t,e)},b=this&&this.__param||function(t,e){return function(n,i){e(n,i,t)}};e&&e.id;return{setters:[function(t){n=t},function(t){i=t},function(t){s=t},function(t){o=t},function(t){r=t},function(t){a=t},function(t){l=t},function(t){d=t},function(t){u=t}],execute:function(){"@stratusjs/angular",h="tree-dialog",c="tree",f=d.cookie("env")?"":".min",g=`${l.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,p=class extends u.ResponsiveComponent{constructor(t,e,n,i){super(),this.dialogRef=t,this.data=e,this.fb=n,this.ref=i,this.title=h+"_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this._=a.default,this.Stratus=l.Stratus,this.apiBase="/Api/Content",this.isSingleContentLoading=!1,this.limit=20,this.isContentLoading=!1,this.isContentLoaded=!1,this.basicContentQueryAttributes="options[isContent]=null&options[isCollection]=null&options[showRoutable]=true&options[showRouting]=true"}ngOnInit(){this.uid=a.default.uniqueId(`sa_${a.default.snakeCase(h)}_component_`),l.Stratus.Instances[this.uid]=this,l.Stratus.Internals.CssLoader(`${g}/${c}/${h}.component${f}.css`).then(()=>{this.isStyled=!0}).catch(t=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(t),this.isStyled=!0}),this.tree=this.data.tree,this.treeNode=this.data.treeNode,this.browserTarget=null!==this.data.browserTarget,this.backend=this.data.backend,this.iconRegistry=this.data.iconRegistry,this.dialogContentForm=this.fb.group({contentSelectorInput:this.data.content||null}),this.dialogContentForm.get("contentSelectorInput").valueChanges.pipe(r.debounceTime(300),r.tap(()=>this.isContentLoading=!0),r.switchMap(t=>(a.default.isString(t)?this.lastContentSelectorQuery=this.getQueryUrl(t):(this.data.content=t,this.data.url=null),this.backend.get(this.lastContentSelectorQuery||this.getQueryUrl()).pipe(r.finalize(()=>{this.isContentLoading=!1,this.isContentLoaded=!0}))))).subscribe(t=>this.handleContent(t)),this.backend.get(this.getQueryUrl()).pipe(r.finalize(()=>this.isContentLoading=!1)).subscribe(t=>this.handleContent(t)),this.data.content&&this.data.content.id&&(this.isSingleContentLoading=!0,this.backend.get(this.getQueryUrl(null,this.data.content.id)).pipe(r.finalize(()=>this.isSingleContentLoading=!1)).subscribe(t=>{if(!t.ok||200!==t.status||a.default.isEmpty(t.body))return null;const e=a.default.get(t.body,"payload")||t.body;return a.default.isEmpty(e)||Array.isArray(e)||!a.default.isObject(e)?null:(this.contentEntity=e,this.isSingleContentLoading=!1,this.dialogContentForm.get("contentSelectorInput").patchValue(this.contentEntity),this.refresh(),this.contentEntity)})),this.isInitialized=!0}ngOnDestroy(){this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(t=>t()):super.refresh()}onCancelClick(){this.dialogRef.close()}onBrowserTargetChange(t){this.data.browserTarget=t.checked?"_blank":null}displayContentText(t){if(!t)return;const e=a.default.get(t,"routing[0].url"),n=a.default.isUndefined(e)?" (No route!)":` (/${e})`,i=a.default.get(t,"id"),s=a.default.isUndefined(i)?null:`Content: ${i}`;return(a.default.get(t,"version.title")||s)+n}handleContent(t){if(!t.ok||200!==t.status||a.default.isEmpty(t.body))return this.filteredContent=[],this.filteredContent;const e=a.default.get(t.body,"payload")||t.body;return a.default.isEmpty(e)||!Array.isArray(e)?(this.filteredContent=[],this.filteredContent):(this.filteredContent=e,this.filteredContent)}destroy(){this.treeNode.destroy().afterClosed().subscribe(t=>{t&&this.onCancelClick()})}toggleStatus(){this.treeNode.toggleStatus()}addChild(){this.treeNode.addChild()}isSelected(t){return!!this.data.content&&this.data.content.id===t.id}getSvg(t,e){return this.tree.getSvg(t,e)}getQueryUrl(t,e){return t=!a.default.isString(t)||a.default.isEmpty(t)?"":t,e=a.default.isString(e)||a.default.isNumber(e)?`/${e}`:"",`${this.apiBase}${e}?limit=${this.limit}&${this.basicContentQueryAttributes}&q=${t}`}selectedOnTop(t,e){if(!t||!t.length)return t;if(!e||!e.id)return t;const n=a.default.clone(t),i=t.findIndex(t=>t.id===e.id);return-1===i?(n.unshift(e),n):(s.moveItemInArray(n,i,0),n)}},p=y([n.Component({selector:`sa-${h}`,templateUrl:`${g}/${c}/${h}.component${f}.html`}),b(1,n.Inject(o.MAT_DIALOG_DATA)),C("design:paramtypes",[o.MatDialogRef,Object,i.FormBuilder,n.ChangeDetectorRef])],p),t("TreeDialogComponent",p)}}});
@@ -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=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},p=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","tree-node","tree",c=l.cookie("env")?"":".min",u=`${a.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,m=class extends h.ResponsiveComponent{constructor(e,t){super(),this.dialog=e,this.ref=t,this.title="tree-node_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this._=d.default,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.default.uniqueId(`sa_${d.default.snakeCase("tree-node")}_component_`),a.Stratus.Instances[this.uid]=this,a.Stratus.Internals.CssLoader(`${u}/tree/tree-node.component${c}.css`).then(()=>{this.isStyled=!0,this.refresh()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh()}),this.node.meta.component=this,this.isInitialized=!0,this.refresh(),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()}),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()):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.default.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",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();const t=this;e.afterClosed().subscribe(e=>{if(!e||d.default.isEmpty(e))return;this.tree.unsettled=!0;["name","content","url","priority","browserTarget"].forEach(t=>{if(d.default.has(e,t))if("content"!==t)this.node.model.set(t,d.default.get(e,t));else{const n=d.default.get(e,t);this.node.model.set(t,n?{id:d.default.get(n,"id")}:null)}}),t.refresh(),t.tree.refresh(),this.node.model.save(),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()}addChild(){let e=d.default.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})}},g([n.Input(),p("design:type",i.TreeComponent)],m.prototype,"tree",void 0),g([n.Input(),p("design:type",Object)],m.prototype,"parent",void 0),g([n.Input(),p("design:type",Object)],m.prototype,"node",void 0),m=g([n.Component({selector:"sa-tree-node",templateUrl:`${u}/tree/tree-node.component${c}.html`}),p("design:paramtypes",[o.MatDialog,n.ChangeDetectorRef])],m),e("TreeNodeComponent",m)}}});
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,p,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",g=`${a.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,p=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._=d.default,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.default.uniqueId(`sa_${d.default.snakeCase(c)}_component_`),a.Stratus.Instances[this.uid]=this,a.Stratus.Internals.CssLoader(`${g}/${u}/${c}.component${m}.css`).then(()=>{this.isStyled=!0,this.refresh()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh()}),this.node.meta.component=this,this.isInitialized=!0,this.refresh(),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()}),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()):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.default.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",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();const t=this;e.afterClosed().subscribe(e=>{if(!e||d.default.isEmpty(e))return;this.tree.unsettled=!0;["name","content","url","priority","browserTarget"].forEach(t=>{if(d.default.has(e,t))if("content"!==t)this.node.model.set(t,d.default.get(e,t));else{const n=d.default.get(e,t);this.node.model.set(t,n?{id:d.default.get(n,"id")}:null)}}),t.refresh(),t.tree.refresh(),this.node.model.save(),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()}addChild(){let e=d.default.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)],p.prototype,"tree",void 0),f([n.Input(),y("design:type",Object)],p.prototype,"parent",void 0),f([n.Input(),y("design:type",Object)],p.prototype,"node",void 0),p=f([n.Component({selector:`sa-${c}`,templateUrl:`${g}/${u}/${c}.component${m}.html`}),y("design:paramtypes",[o.MatDialog,n.ChangeDetectorRef])],p),e("TreeNodeComponent",p)}}});
@@ -1 +1 @@
1
- System.register(["@angular/core","@angular/cdk/drag-drop","@angular/cdk/tree","@angular/platform-browser","@angular/material/icon","rxjs","@stratusjs/runtime/stratus","lodash","@agentepsilon/decko","../core/root.component","../backend.service","@stratusjs/angularjs/services/registry","@stratusjs/core/events/eventManager","@stratusjs/core/environment","@stratusjs/core/misc","@angular/common"],function(e,t){"use strict";var i,s,r,o,n,a,d,c,l,h,p,u,g,f,m,y,D,v,b,S=this&&this.__decorate||function(e,t,i,s){var r,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},I=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},M=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};t&&t.id;return{setters:[function(e){i=e},function(e){s=e},function(e){r=e},function(e){o=e},function(e){n=e},function(e){a=e},function(e){d=e},function(e){c=e},function(e){l=e},function(e){h=e},function(e){p=e},function(e){u=e},function(e){g=e},function(e){f=e},function(e){m=e},function(e){y=e}],execute:function(){"@stratusjs/angular","tree",D=f.cookie("env")?"":".min",v=`${d.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,b=class extends h.RootComponent{constructor(e,t,i,s,o,n){super(),this.iconRegistry=e,this.sanitizer=t,this.backend=i,this.ref=s,this.elementRef=o,this.document=n,this.title="tree_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this._=c.default,this.Stratus=d.Stratus,this.registry=new u.Registry,this.onChange=new a.Subject,this.unsettled=!1,this.svgIcons={},this.dblClickWait=500,this.dropLists=[],this.dropListIdMap={},this.dropListMap={},this.expandedNodeSet=new Set,this.dragging=!1,this.expandDelay=1e3,this.dropData=null,this.cdkDropListSortingDisabled=!0,this.treeControl=new r.NestedTreeControl(e=>e.children||[]),this.isBorder=!1,this.isDebug=!1}ngOnInit(){this.uid=c.default.uniqueId(`sa_${c.default.snakeCase("tree")}_component_`),d.Stratus.Instances[this.uid]=this,this.hydrate(this.elementRef,this.sanitizer,["title","uid","isInitialized","isDestroyed","isStyled","target","targetSuffix","id","manifest","decouple","direct","api","urlRoot","type","property","_","Stratus","registry","fetched","data","collection","model","dataSub","onChange","subscriber","unsettled","svgIcons","isSingleClick","dblClickWait","dropLists","dropListIdMap","dropListMap","expandedNodeSet","dragging","expandTimeout","expandDelay","dropData","cdkDropListSortingDisabled","tree","treeMap","metaMap","dataSource","treeControl","isBorder","isDebug","iconRegistry","sanitizer","backend","ref","elementRef","document","ngOnInit","ngOnDestroy","refresh","remove","removeNode","nodeIsEqual","fetchData","dataDefer","dataRef","trackDropLists","setExpanded","setExpandedClick","setExpandedDblClick","onDragDrop","onDragMove","showDragData","clearDragData","buildNodePatch","getSvg","addSvgIcon","hydrate","disableRefresh","stagger","reloading"]),d.Stratus.Internals.CssLoader(`${v}/tree/tree.component${D}.css`).then(()=>{this.isStyled=!0,this.refresh()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh()}),c.default.forEach({tree_check:d.Stratus.BaseUrl+"sitetheorycore/images/icons/check.svg",tree_add:d.Stratus.BaseUrl+"sitetheorycore/images/icons/actionButtons/add.svg",tree_delete:d.Stratus.BaseUrl+"sitetheorycore/images/icons/actionButtons/delete.svg",tree_edit:d.Stratus.BaseUrl+"sitetheorycore/images/icons/actionButtons/edit.svg",tree_visibility:d.Stratus.BaseUrl+"sitetheorycore/images/icons/actionButtons/visibility.svg"},(e,t)=>this.iconRegistry.addSvgIcon(t,this.sanitizer.bypassSecurityTrustResourceUrl(e)).getNamedSvgIcon(t)),this.fetchData().then(e=>{if(!(e&&e instanceof g.EventManager))return void console.warn("Unable to bind data from Registry!");const t=()=>{!this.unsettled&&e.completed&&(this.dataDefer(this.subscriber),this.refresh())};e.on("change",t),t(),e.on("add",(e,t)=>{let i=!1;const s=()=>{if(!t.completed)return;if(i)return;if(i=!0,!(t.getIdentifier()in this.treeMap))return void t.meta.set("postPersist",!0);const e=this.treeMap[t.getIdentifier()];e.meta.component&&"openDialog"in e.meta.component?e.meta.component.openDialog():t.meta.set("postPersist",!0)};t.on("change",s),s()})}),this.dataSub=new a.Observable(e=>this.dataDefer(e)),this.dropListIdMap[this.uid+"_parent_drop_list"]=!0,this.trackDropLists();const e=f.cookie("tree-node-border");e&&m.isJSON(e)&&(this.isBorder=JSON.parse(e));const t=f.cookie("tree-debug");t&&m.isJSON(t)&&(this.isDebug=JSON.parse(t)),this.isInitialized=!0,this.refresh()}ngOnDestroy(){this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(e=>e()):(c.default.forEach(this.metaMap,e=>{e.component&&"refresh"in e.component&&e.component.refresh()}),super.refresh())}remove(e){}removeNode(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}nodeIsEqual(e,t){return e&&t?e.id===t.id:e===t}async fetchData(){return this.fetched?this.fetched:this.fetched=this.registry.fetch(d.Stratus.Select(this.elementRef.nativeElement),this)}dataDefer(e){if(this.subscriber=this.subscriber||e,!this.subscriber||!this.collection||!this.collection.completed)return void setTimeout(()=>{this.dataDefer(e)},500);const t=this.dataRef(!0);t&&t.length?e.next(t):setTimeout(()=>this.dataDefer(e),200)}dataRef(e=!1){if(!this.collection)return[];if(!e&&this.tree&&this.tree.length>0)return this.tree;let t=this.collection.models;return t&&c.default.isArray(t)&&t.length?(t=c.default.sortBy(t,["data.priority"]),this.metaMap=this.metaMap||{},this.treeMap={},this.tree=[],c.default.forEach(t,e=>{const t=c.default.get(e,"data.id"),i=c.default.get(e,"data.nestParent.id");this.dropListIdMap[`${this.uid}_node_${t}_drop_list`]=!0,c.default.has(this.metaMap,t)||(this.metaMap[t]={id:t,expanded:!0}),c.default.has(this.treeMap,t)||(this.treeMap[t]={id:t,model:e,children:[],meta:this.metaMap[t]}),this.treeMap[t].model=e,this.treeMap[t].meta=this.metaMap[t],i?(c.default.has(this.treeMap,i)||(this.treeMap[i]={id:i,model:null,children:[],meta:null}),this.treeMap[i].children.push(this.treeMap[t])):this.tree.push(this.treeMap[t])}),this.trackDropLists(),this.tree):[]}trackDropLists(){this.dropLists=[],c.default.forEach(this.dropListIdMap,(e,t)=>{if(!e)return;const i=t in this.dropListMap,s=i?this.dropListMap[t]:document.getElementById(t);s&&(this.dropLists.push(t),i||(this.dropListMap[t]=s))})}setExpanded(e){this.metaMap&&c.default.size(this.metaMap)&&(c.default.forEach(this.metaMap,t=>{t.expanded=e}),this.refresh())}setExpandedClick(e){this.isSingleClick=!0,setTimeout(()=>{this.isSingleClick&&this.setExpanded(e)},this.dblClickWait)}setExpandedDblClick(e){this.isSingleClick=!1,this.setExpanded(e)}async onDragDrop(e){if(!e.isPointerOverContainer)return;const t=e.item.data;if(!t)return;let i=e.container.data;const r=e.previousContainer.data,o=i?i.children:this.dataRef();if(!o)return;this.unsettled=!0;const n=this.dropData.targetId&&this.dropData.targetId in this.treeMap?this.treeMap[c.default.toNumber(this.dropData.targetId)]:null;if(f.cookie("env")&&this.isDebug&&(console.group("onDragDrop()"),c.default.forEach(["model drop: "+t.model.get("name"),`list shift: ${e.container.element.nativeElement.id} -> ${e.previousContainer.element.nativeElement.id}`,`index change (event): ${e.previousIndex} -> ${e.currentIndex}`,"current priority: "+t.model.get("priority"),"target drop action: "+this.dropData.action],e=>console.log(e))),n&&!this.nodeIsEqual(i,n)){if(f.cookie("env")&&this.isDebug&&(console.log(`target drop node differs: ${n.id} -> ${n.model.get("name")}`),console.log("target drop node is the same as target node:",t.id===n.id)),t.id!==n.id)switch(this.dropData.action){case"before":case"after":const e=n.model.get("nestParent.id");i=e&&e in this.treeMap?this.treeMap[e]:null;break;case"inside":i=n}f.cookie("env")&&this.isDebug&&console.log("target drop node selected:",i?`${i.id} -> ${i.model.get("name")}`:"none")}if(!this.nodeIsEqual(i,r)){if(i){switch(this.dropData.action){case"before":case"after":let e=i.children.findIndex(e=>e.id===t.id);"after"===this.dropData.action&&e++,i.children.splice(e,0,t);break;case"inside":i.children.push(t)}i.meta.expanded=!0}r&&this.removeNode(r.children,t),t.model.set("nestParent",this.buildNodePatch(i)),f.cookie("env")&&this.isDebug&&console.log("new parent: "+(t.model.get("nestParent.name")||null))}const a=i?i.children:o;let d=e.currentIndex;if(this.cdkDropListSortingDisabled)switch(d=null,this.dropData.action){case"before":case"after":d=a.findIndex(e=>e.id===n.id),"after"===this.dropData.action&&d++,f.cookie("env")&&this.isDebug&&console.log("index change (drop node):",`${e.previousIndex} -> ${d}`)}if(c.default.isNumber(d)){s.moveItemInArray(a,e.previousIndex,d);let i=0;c.default.forEach(a,e=>{e.model&&e.model.set&&e.model.set("priority",i++)}),f.cookie("env")&&this.isDebug&&console.log("new priority:",t.model.get("priority"))}f.cookie("env")&&this.isDebug&&console.groupEnd(),await t.model.save(),this.unsettled=!1,this.collection.throttleTrigger("change")}onDragMove(e){const t=this.document.elementFromPoint(e.pointerPosition.x,e.pointerPosition.y);if(!t)return void this.clearDragData();const i=t.classList.contains("tree-node-content")?t:t.closest(".tree-node-content");if(!i)return void this.clearDragData();this.dropData={targetId:i.getAttribute("data-id")};const s=i.getBoundingClientRect(),r=s.height/3;e.pointerPosition.y-s.top<r?this.dropData.action="before":e.pointerPosition.y-s.top>2*r?this.dropData.action="after":this.dropData.action="inside",this.showDragData()}showDragData(){this.clearDragData(),this.dropData&&this.document.getElementById("node-"+this.dropData.targetId).classList.add("drop-"+this.dropData.action)}clearDragData(e=!1){e&&(this.dropData=null),this.document.querySelectorAll(".drop-before").forEach(e=>e.classList.remove("drop-before")),this.document.querySelectorAll(".drop-after").forEach(e=>e.classList.remove("drop-after")),this.document.querySelectorAll(".drop-inside").forEach(e=>e.classList.remove("drop-inside"))}buildNodePatch(e=null){if(!e||!e.model)return null;const t={};return c.default.forEach(["id","name"],i=>{const s=e.model.get(i);s&&c.default.set(t,i,s)}),t}getSvg(e,t){const i=this.addSvgIcon(e,t);return new a.Observable(t=>{this.iconRegistry.getNamedSvgIcon(i).subscribe({error(t){console.error(`getSvg(${e}): ${t}`)},complete(){t.next(i)}})})}addSvgIcon(e,t){if(e in this.svgIcons)return this.svgIcons[e];t||(t={});const i=this.svgIcons[e]=c.default.uniqueId("selector_svg");return this.iconRegistry.addSvgIcon(i,this.sanitizer.bypassSecurityTrustResourceUrl(e),t),i}},S([i.Input(),I("design:type",String)],b.prototype,"target",void 0),S([i.Input(),I("design:type",String)],b.prototype,"targetSuffix",void 0),S([i.Input(),I("design:type",Number)],b.prototype,"id",void 0),S([i.Input(),I("design:type",Boolean)],b.prototype,"manifest",void 0),S([i.Input(),I("design:type",Boolean)],b.prototype,"decouple",void 0),S([i.Input(),I("design:type",Boolean)],b.prototype,"direct",void 0),S([i.Input(),I("design:type",Object)],b.prototype,"api",void 0),S([i.Input(),I("design:type",String)],b.prototype,"urlRoot",void 0),S([i.Input(),I("design:type",String)],b.prototype,"type",void 0),S([i.Input(),I("design:type",String)],b.prototype,"property",void 0),S([l.debounce(50),I("design:type",Function),I("design:paramtypes",[Object]),I("design:returntype",void 0)],b.prototype,"onDragMove",null),b=S([i.Component({selector:"sa-tree",templateUrl:`${v}/tree/tree.component${D}.html`}),M(5,i.Inject(y.DOCUMENT)),I("design:paramtypes",[n.MatIconRegistry,o.DomSanitizer,p.BackendService,i.ChangeDetectorRef,i.ElementRef,Document])],b),e("TreeComponent",b)}}});
1
+ System.register(["@angular/core","@angular/cdk/drag-drop","@angular/cdk/tree","@angular/platform-browser","@angular/material/icon","rxjs","@stratusjs/runtime/stratus","lodash","@agentepsilon/decko","../core/root.component","../backend.service","@stratusjs/angularjs/services/registry","@stratusjs/core/events/eventManager","@stratusjs/core/environment","@stratusjs/core/misc","@angular/common"],function(e,t){"use strict";var i,s,r,o,n,a,d,c,l,h,p,u,g,f,m,y,D,v,b,S,I=this&&this.__decorate||function(e,t,i,s){var r,o=arguments.length,n=o<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,i):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,i,s);else for(var a=e.length-1;a>=0;a--)(r=e[a])&&(n=(o<3?r(n):o>3?r(t,i,n):r(t,i))||n);return o>3&&n&&Object.defineProperty(t,i,n),n},M=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},$=this&&this.__param||function(e,t){return function(i,s){t(i,s,e)}};t&&t.id;return{setters:[function(e){i=e},function(e){s=e},function(e){r=e},function(e){o=e},function(e){n=e},function(e){a=e},function(e){d=e},function(e){c=e},function(e){l=e},function(e){h=e},function(e){p=e},function(e){u=e},function(e){g=e},function(e){f=e},function(e){m=e},function(e){y=e}],execute:function(){"@stratusjs/angular",D="tree",v=f.cookie("env")?"":".min",b=`${d.Stratus.BaseUrl}${boot.configuration.paths["@stratusjs/angular/*"].replace(/[^/]*$/,"").replace(/\/dist\/$/,"/src/")}`,S=class extends h.RootComponent{constructor(e,t,i,s,o,n){super(),this.iconRegistry=e,this.sanitizer=t,this.backend=i,this.ref=s,this.elementRef=o,this.document=n,this.title=D+"_component",this.isInitialized=!1,this.isDestroyed=!1,this.isStyled=!1,this._=c.default,this.Stratus=d.Stratus,this.registry=new u.Registry,this.onChange=new a.Subject,this.unsettled=!1,this.svgIcons={},this.dblClickWait=500,this.dropLists=[],this.dropListIdMap={},this.dropListMap={},this.expandedNodeSet=new Set,this.dragging=!1,this.expandDelay=1e3,this.dropData=null,this.cdkDropListSortingDisabled=!0,this.treeControl=new r.NestedTreeControl(e=>e.children||[]),this.isBorder=!1,this.isDebug=!1}ngOnInit(){this.uid=c.default.uniqueId(`sa_${c.default.snakeCase(D)}_component_`),d.Stratus.Instances[this.uid]=this,this.hydrate(this.elementRef,this.sanitizer,["title","uid","isInitialized","isDestroyed","isStyled","target","targetSuffix","id","manifest","decouple","direct","api","urlRoot","type","property","_","Stratus","registry","fetched","data","collection","model","dataSub","onChange","subscriber","unsettled","svgIcons","isSingleClick","dblClickWait","dropLists","dropListIdMap","dropListMap","expandedNodeSet","dragging","expandTimeout","expandDelay","dropData","cdkDropListSortingDisabled","tree","treeMap","metaMap","dataSource","treeControl","isBorder","isDebug","iconRegistry","sanitizer","backend","ref","elementRef","document","ngOnInit","ngOnDestroy","refresh","remove","removeNode","nodeIsEqual","fetchData","dataDefer","dataRef","trackDropLists","setExpanded","setExpandedClick","setExpandedDblClick","onDragDrop","onDragMove","showDragData","clearDragData","buildNodePatch","getSvg","addSvgIcon","hydrate","disableRefresh","stagger","reloading"]),d.Stratus.Internals.CssLoader(`${b}/${D}/${D}.component${v}.css`).then(()=>{this.isStyled=!0,this.refresh()}).catch(e=>{console.warn("Issue detected in CSS Loader for Component:",this),console.error(e),this.isStyled=!0,this.refresh()}),c.default.forEach({tree_check:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/check.svg`,tree_add:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/add.svg`,tree_delete:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/delete.svg`,tree_edit:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/edit.svg`,tree_visibility:`${d.Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/visibility.svg`},(e,t)=>this.iconRegistry.addSvgIcon(t,this.sanitizer.bypassSecurityTrustResourceUrl(e)).getNamedSvgIcon(t)),this.fetchData().then(e=>{if(!(e&&e instanceof g.EventManager))return void console.warn("Unable to bind data from Registry!");const t=()=>{!this.unsettled&&e.completed&&(this.dataDefer(this.subscriber),this.refresh())};e.on("change",t),t(),e.on("add",(e,t)=>{let i=!1;const s=()=>{if(!t.completed)return;if(i)return;if(i=!0,!(t.getIdentifier()in this.treeMap))return void t.meta.set("postPersist",!0);const e=this.treeMap[t.getIdentifier()];e.meta.component&&"openDialog"in e.meta.component?e.meta.component.openDialog():t.meta.set("postPersist",!0)};t.on("change",s),s()})}),this.dataSub=new a.Observable(e=>this.dataDefer(e)),this.dropListIdMap[`${this.uid}_parent_drop_list`]=!0,this.trackDropLists();const e=f.cookie("tree-node-border");e&&m.isJSON(e)&&(this.isBorder=JSON.parse(e));const t=f.cookie("tree-debug");t&&m.isJSON(t)&&(this.isDebug=JSON.parse(t)),this.isInitialized=!0,this.refresh()}ngOnDestroy(){this.isDestroyed=!0}refresh(){return this.isDestroyed?new Promise(e=>e()):(c.default.forEach(this.metaMap,e=>{e.component&&"refresh"in e.component&&e.component.refresh()}),super.refresh())}remove(e){}removeNode(e,t){const i=e.indexOf(t);return-1!==i&&(e.splice(i,1),!0)}nodeIsEqual(e,t){return e&&t?e.id===t.id:e===t}async fetchData(){return this.fetched?this.fetched:this.fetched=this.registry.fetch(d.Stratus.Select(this.elementRef.nativeElement),this)}dataDefer(e){if(this.subscriber=this.subscriber||e,!this.subscriber||!this.collection||!this.collection.completed)return void setTimeout(()=>{this.dataDefer(e)},500);const t=this.dataRef(!0);t&&t.length?e.next(t):setTimeout(()=>this.dataDefer(e),200)}dataRef(e=!1){if(!this.collection)return[];if(!e&&this.tree&&this.tree.length>0)return this.tree;let t=this.collection.models;return t&&c.default.isArray(t)&&t.length?(t=c.default.sortBy(t,["data.priority"]),this.metaMap=this.metaMap||{},this.treeMap={},this.tree=[],c.default.forEach(t,e=>{const t=c.default.get(e,"data.id"),i=c.default.get(e,"data.nestParent.id");this.dropListIdMap[`${this.uid}_node_${t}_drop_list`]=!0,c.default.has(this.metaMap,t)||(this.metaMap[t]={id:t,expanded:!0}),c.default.has(this.treeMap,t)||(this.treeMap[t]={id:t,model:e,children:[],meta:this.metaMap[t]}),this.treeMap[t].model=e,this.treeMap[t].meta=this.metaMap[t],i?(c.default.has(this.treeMap,i)||(this.treeMap[i]={id:i,model:null,children:[],meta:null}),this.treeMap[i].children.push(this.treeMap[t])):this.tree.push(this.treeMap[t])}),this.trackDropLists(),this.tree):[]}trackDropLists(){this.dropLists=[],c.default.forEach(this.dropListIdMap,(e,t)=>{if(!e)return;const i=t in this.dropListMap,s=i?this.dropListMap[t]:document.getElementById(t);s&&(this.dropLists.push(t),i||(this.dropListMap[t]=s))})}setExpanded(e){this.metaMap&&c.default.size(this.metaMap)&&(c.default.forEach(this.metaMap,t=>{t.expanded=e}),this.refresh())}setExpandedClick(e){this.isSingleClick=!0,setTimeout(()=>{this.isSingleClick&&this.setExpanded(e)},this.dblClickWait)}setExpandedDblClick(e){this.isSingleClick=!1,this.setExpanded(e)}async onDragDrop(e){if(!e.isPointerOverContainer)return;const t=e.item.data;if(!t)return;let i=e.container.data;const r=e.previousContainer.data,o=i?i.children:this.dataRef();if(!o)return;this.unsettled=!0;const n=this.dropData.targetId&&this.dropData.targetId in this.treeMap?this.treeMap[c.default.toNumber(this.dropData.targetId)]:null;if(f.cookie("env")&&this.isDebug&&(console.group("onDragDrop()"),c.default.forEach([`model drop: ${t.model.get("name")}`,`list shift: ${e.container.element.nativeElement.id} -> ${e.previousContainer.element.nativeElement.id}`,`index change (event): ${e.previousIndex} -> ${e.currentIndex}`,`current priority: ${t.model.get("priority")}`,`target drop action: ${this.dropData.action}`],e=>console.log(e))),n&&!this.nodeIsEqual(i,n)){if(f.cookie("env")&&this.isDebug&&(console.log(`target drop node differs: ${n.id} -> ${n.model.get("name")}`),console.log("target drop node is the same as target node:",t.id===n.id)),t.id!==n.id)switch(this.dropData.action){case"before":case"after":const e=n.model.get("nestParent.id");i=e&&e in this.treeMap?this.treeMap[e]:null;break;case"inside":i=n}f.cookie("env")&&this.isDebug&&console.log("target drop node selected:",i?`${i.id} -> ${i.model.get("name")}`:"none")}if(!this.nodeIsEqual(i,r)){if(i){switch(this.dropData.action){case"before":case"after":let e=i.children.findIndex(e=>e.id===t.id);"after"===this.dropData.action&&e++,i.children.splice(e,0,t);break;case"inside":i.children.push(t)}i.meta.expanded=!0}r&&this.removeNode(r.children,t),t.model.set("nestParent",this.buildNodePatch(i)),f.cookie("env")&&this.isDebug&&console.log(`new parent: ${t.model.get("nestParent.name")||null}`)}const a=i?i.children:o;let d=e.currentIndex;if(this.cdkDropListSortingDisabled)switch(d=null,this.dropData.action){case"before":case"after":d=a.findIndex(e=>e.id===n.id),"after"===this.dropData.action&&d++,f.cookie("env")&&this.isDebug&&console.log("index change (drop node):",`${e.previousIndex} -> ${d}`)}if(c.default.isNumber(d)){s.moveItemInArray(a,e.previousIndex,d);let i=0;c.default.forEach(a,e=>{e.model&&e.model.set&&e.model.set("priority",i++)}),f.cookie("env")&&this.isDebug&&console.log("new priority:",t.model.get("priority"))}f.cookie("env")&&this.isDebug&&console.groupEnd(),await t.model.save(),this.unsettled=!1,this.collection.throttleTrigger("change")}onDragMove(e){const t=this.document.elementFromPoint(e.pointerPosition.x,e.pointerPosition.y);if(!t)return void this.clearDragData();const i="tree-node-content",s=t.classList.contains(i)?t:t.closest(`.${i}`);if(!s)return void this.clearDragData();this.dropData={targetId:s.getAttribute("data-id")};const r=s.getBoundingClientRect(),o=r.height/3;e.pointerPosition.y-r.top<o?this.dropData.action="before":e.pointerPosition.y-r.top>2*o?this.dropData.action="after":this.dropData.action="inside",this.showDragData()}showDragData(){this.clearDragData(),this.dropData&&this.document.getElementById(`node-${this.dropData.targetId}`).classList.add(`drop-${this.dropData.action}`)}clearDragData(e=!1){e&&(this.dropData=null),this.document.querySelectorAll(".drop-before").forEach(e=>e.classList.remove("drop-before")),this.document.querySelectorAll(".drop-after").forEach(e=>e.classList.remove("drop-after")),this.document.querySelectorAll(".drop-inside").forEach(e=>e.classList.remove("drop-inside"))}buildNodePatch(e=null){if(!e||!e.model)return null;const t={};return c.default.forEach(["id","name"],i=>{const s=e.model.get(i);s&&c.default.set(t,i,s)}),t}getSvg(e,t){const i=this.addSvgIcon(e,t);return new a.Observable(t=>{this.iconRegistry.getNamedSvgIcon(i).subscribe({error(t){console.error(`getSvg(${e}): ${t}`)},complete(){t.next(i)}})})}addSvgIcon(e,t){if(e in this.svgIcons)return this.svgIcons[e];t||(t={});const i=this.svgIcons[e]=c.default.uniqueId("selector_svg");return this.iconRegistry.addSvgIcon(i,this.sanitizer.bypassSecurityTrustResourceUrl(e),t),i}},I([i.Input(),M("design:type",String)],S.prototype,"target",void 0),I([i.Input(),M("design:type",String)],S.prototype,"targetSuffix",void 0),I([i.Input(),M("design:type",Number)],S.prototype,"id",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"manifest",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"decouple",void 0),I([i.Input(),M("design:type",Boolean)],S.prototype,"direct",void 0),I([i.Input(),M("design:type",Object)],S.prototype,"api",void 0),I([i.Input(),M("design:type",String)],S.prototype,"urlRoot",void 0),I([i.Input(),M("design:type",String)],S.prototype,"type",void 0),I([i.Input(),M("design:type",String)],S.prototype,"property",void 0),I([l.debounce(50),M("design:type",Function),M("design:paramtypes",[Object]),M("design:returntype",void 0)],S.prototype,"onDragMove",null),S=I([i.Component({selector:`sa-${D}`,templateUrl:`${b}/${D}/${D}.component${v}.html`}),$(5,i.Inject(y.DOCUMENT)),M("design:paramtypes",[n.MatIconRegistry,o.DomSanitizer,p.BackendService,i.ChangeDetectorRef,i.ElementRef,Document])],S),e("TreeComponent",S)}}});
@@ -1 +0,0 @@
1
- {"version":3,"sources":["dialog.interface.ts"],"names":[],"mappings":"","file":"dialog.interface.js"}
@@ -1,2 +0,0 @@
1
-
2
- /*# sourceMappingURL=json.component.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"names":[],"mappings":"","file":"json.component.css","sourcesContent":[]}