@stratusjs/angular 0.8.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/angular.bundle.js +10454 -11439
  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 +224 -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 +254 -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,254 @@
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
+
28
+ // AngularJS Classes
29
+ import {Registry} from '@stratusjs/angularjs/services/registry'
30
+ import {Model} from '@stratusjs/angularjs/services/model'
31
+ import {Collection} from '@stratusjs/angularjs/services/collection'
32
+
33
+ // Local Setup
34
+ const systemDir = '@stratusjs/angular'
35
+ const moduleName = 'timezone-selector'
36
+ const min = !cookie('env') ? '.min' : ''
37
+ const localDir = `${Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '').replace(/\/dist\/$/, '/src/')}`
38
+
39
+
40
+ /**
41
+ * @title Media Selector with Drag & Drop Uploads and Sorting
42
+ */
43
+ @Component({
44
+ selector: `sa-${moduleName}`,
45
+ // TODO: Add the ability to change the templateUrl to others, based on a cookie.
46
+ templateUrl: `${localDir}/${moduleName}/${moduleName}.component${min}.html`,
47
+ // FIXME: This doesn't work, as it seems Angular attempts to use a System.js import instead of their own, so it will
48
+ // require the steal-css module
49
+ // styleUrls: [
50
+ // `${localDir}/${moduleName}/${moduleName}.component${min}.css`
51
+ // ],
52
+ changeDetection: ChangeDetectionStrategy.OnPush
53
+ })
54
+
55
+ export class TimezoneSelectorComponent extends RootComponent implements OnInit { // implements OnInit, OnChanges {
56
+
57
+ // Basic Component Settings
58
+ title = moduleName + '_component'
59
+ uid: string
60
+
61
+ // Registry Attributes
62
+ @Input() target: string
63
+ @Input() targetSuffix: string
64
+ @Input() id: number
65
+ @Input() manifest: boolean
66
+ @Input() decouple: boolean
67
+ @Input() direct: boolean
68
+ @Input() api: object
69
+ @Input() urlRoot: string
70
+ // @Input() registryModel: boolean | string // inputs are strings.. // false will disable Registry
71
+
72
+ // Component Attributes
73
+ @Input() type: string
74
+ @Input() property: string
75
+ @Input() endpoint: string
76
+
77
+ // Dependencies
78
+ Stratus = Stratus
79
+ /*fieldName = 'timezoneSelector'
80
+ fieldNameId = 'timezoneSelectorId'
81
+ form: FormGroup = this.fb.group({
82
+ [this.fieldName]: new FormControl(), // optionally disabled on init to avoid known issues
83
+ [this.fieldNameId]: new FormControl({disabled: true})
84
+ })*/
85
+
86
+ // Stratus Data Connectivity
87
+ registry = new Registry()
88
+ fetched: Promise<boolean|Collection|Model>
89
+ data: any
90
+ // collection?: EventBase
91
+ // @Output() model: any
92
+ model?: Model
93
+
94
+ // Observable Connection
95
+ dataSub: Observable<[]>
96
+ onChange = new Subject()
97
+ subscriber: Subscriber<any>
98
+ // Note: It may be better to LifeCycle::tick(), but this works for now
99
+
100
+ // Multi-Framework Event Connectivity
101
+ timezone: string
102
+ inputTimezone = new FormControl('')
103
+ timezoneList: string[] = []
104
+ filteredTimezones: Observable<string[]>
105
+
106
+ // UI Flags
107
+ initialized = false
108
+
109
+ // Construct
110
+ constructor(
111
+ private elementRef: ElementRef,
112
+ protected ref: ChangeDetectorRef,
113
+ private sanitizer: DomSanitizer,
114
+ ) {
115
+ // Chain constructor
116
+ super()
117
+
118
+ // Initialization
119
+ this.uid = safeUniqueId('sa', moduleName, 'component')
120
+ Stratus.Instances[this.uid] = this
121
+
122
+ // Prepare all possible timezones
123
+ this.timezoneList = (Intl as any).supportedValuesOf('timeZone')
124
+
125
+ // Hydrate Root App Inputs
126
+ this.hydrate(elementRef, sanitizer, keys<TimezoneSelectorComponent>())
127
+
128
+ this.filteredTimezones = this.inputTimezone.valueChanges.pipe(
129
+ startWith(''),
130
+ // tap(value => console.log(`filteredTimezones piping {value}`)),
131
+ map(value => this._filter(value || '')),
132
+ )
133
+
134
+ /** Data Connections with Stratus model initiated */
135
+ this.fetchData()
136
+ .then(data => {
137
+ if (!data || !(data instanceof EventManager)) {
138
+ console.warn('Unable to bind data from Registry!')
139
+ return
140
+ }
141
+ // Manually render upon model change
142
+ const onDataChange = () => {
143
+ if (!data.completed) {
144
+ return
145
+ }
146
+ this.dataDefer(this.subscriber)
147
+ }
148
+ data.on('change', onDataChange)
149
+ onDataChange()
150
+ })
151
+
152
+ // Declare Observable with Subscriber (Only Happens Once)
153
+ this.dataSub = new Observable(subscriber => {
154
+ return this.dataDefer(subscriber)
155
+ })
156
+ // When the model updates, this will update the input field
157
+ this.dataSub.pipe(
158
+ debounce(() => timer(500)),
159
+ catchError(this.handleObservableError)
160
+ ).subscribe(evt => {
161
+ if (this.inputTimezone.value === evt) {
162
+ if (this.initialized) {
163
+ this.refresh().then()
164
+ }
165
+ return
166
+ }
167
+ this.timezone = evt
168
+ this.inputTimezone.setValue(this.timezone)
169
+ this.refresh().then()
170
+ })
171
+ }
172
+ async ngOnInit() {
173
+ // Watch for input box changes
174
+ this.inputTimezone.valueChanges.forEach((value?: string) => this.valueChanged(value)).then()
175
+ this.initialized = true
176
+ }
177
+
178
+ /** Filter the inout box and output similar possible options */
179
+ private _filter(value: string): string[] {
180
+ const filterValue = value.toLowerCase()
181
+ return this.timezoneList.filter(timezone => timezone.toLowerCase().includes(filterValue))
182
+ }
183
+
184
+ /** Connect to Stratus Model and sync */
185
+ fetchData() {
186
+ if (this.fetched) {
187
+ return this.fetched
188
+ }
189
+ return this.fetched = this.registry.fetch(
190
+ Stratus.Select(this.elementRef.nativeElement),
191
+ this
192
+ )
193
+ }
194
+
195
+ /** Ensures Data is populated before hitting the Subscriber */
196
+ dataDefer(subscriber: Subscriber<any>) {
197
+ this.subscriber = this.subscriber || subscriber
198
+ if (!this.subscriber) {
199
+ return
200
+ }
201
+ const dataString = this.dataRef()
202
+ this.subscriber.next(dataString)
203
+ }
204
+
205
+ /** Return the value on the Stratus model */
206
+ dataRef(): string {
207
+ if (!this.model) {
208
+ return ''
209
+ }
210
+ return this.model.get(this.property)
211
+ }
212
+
213
+ /** Any time the value of the inout box is changed */
214
+ valueChanged(value: string) {
215
+ if (!value) {
216
+ return
217
+ }
218
+ // Update the field to allow external apps to read
219
+ this.timezone = value
220
+ this.inputTimezone.setValue(this.timezone)
221
+ if (!this.model || !this.model.completed) {
222
+ return
223
+ }
224
+
225
+ // Save the qualified change to the model directly!
226
+ this.model.set(
227
+ this.property,
228
+ this.timezone // value
229
+ )
230
+ }
231
+
232
+ /** Toastify Errors */
233
+ handleObservableError(err: ObservableInput<any>): ObservableInput<any> {
234
+ console.error(err)
235
+ Toastify({
236
+ text: err.toString(),
237
+ duration: 3000,
238
+ close: true,
239
+ stopOnFocus: true,
240
+ style: {
241
+ background: '#E14D45',
242
+ }
243
+ }).showToast()
244
+ return err
245
+ }
246
+
247
+ /** When a timezone option is clicked, process it by manually noting that it changed */
248
+ timezoneSelected(value?: string) {
249
+ if(!value) {
250
+ return
251
+ }
252
+ this.valueChanged(value)
253
+ }
254
+ }
@@ -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":[]}
@@ -1,257 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { ChangeDetectorRef, Component, ElementRef, Input } from '@angular/core';
11
- import { DomSanitizer } from '@angular/platform-browser';
12
- import { Stratus } from '@stratusjs/runtime/stratus';
13
- import _, { has } from 'lodash';
14
- import { cookie } from '@stratusjs/core/environment';
15
- import { RootComponent } from '../core/root.component';
16
- import { Observable, Subject, timer } from 'rxjs';
17
- import { FormBuilder, FormControl } from '@angular/forms';
18
- import { MatDialog } from '@angular/material/dialog';
19
- import { EventManager } from '@stratusjs/core/events/eventManager';
20
- import { catchError, debounce } from 'rxjs/operators';
21
- import { Registry } from '@stratusjs/angularjs/services/registry';
22
- const systemDir = '@stratusjs/angular';
23
- const moduleName = 'json';
24
- const min = !cookie('env') ? '.min' : '';
25
- const localDir = `${Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '').replace(/\/dist\/$/, '/src/')}`;
26
- let JsonComponent = class JsonComponent extends RootComponent {
27
- constructor(sanitizer, ref, elementRef, fb, dialog) {
28
- super();
29
- this.sanitizer = sanitizer;
30
- this.ref = ref;
31
- this.elementRef = elementRef;
32
- this.fb = fb;
33
- this.dialog = dialog;
34
- this.title = `${moduleName}_component`;
35
- this.dev = !!cookie('env');
36
- this.debug = !!cookie(`debug_${moduleName}`);
37
- this._ = _;
38
- this.has = has;
39
- this.log = console.log;
40
- this.Stratus = Stratus;
41
- this.registry = new Registry();
42
- this.onChange = new Subject();
43
- this.svgIcons = {};
44
- this.initialized = false;
45
- this.styled = false;
46
- this.blurred = false;
47
- this.focused = false;
48
- this.form = this.fb.group({
49
- dataString: new FormControl(),
50
- });
51
- this.dataChangeLog = [];
52
- this.incomingData = '';
53
- this.outgoingData = '';
54
- this.debounceSave = true;
55
- this.debounceTime = 5000;
56
- this.forceSave = false;
57
- this.uid = _.uniqueId(`sa_${_.snakeCase(moduleName)}_component_`);
58
- Stratus.Instances[this.uid] = this;
59
- Stratus.Internals.LoadCss([
60
- `${localDir}${moduleName}/${moduleName}.component${min}.css`,
61
- ]).then(() => {
62
- this.styled = true;
63
- this.refresh();
64
- }).catch((e) => {
65
- console.error(e);
66
- console.warn('Issue detected in CSS Loader for Component:', this.uid);
67
- this.styled = true;
68
- this.refresh();
69
- });
70
- this.hydrate(elementRef, sanitizer, ["title", "uid", "dev", "debug", "target", "targetSuffix", "id", "manifest", "decouple", "direct", "api", "urlRoot", "type", "property", "endpoint", "_", "has", "log", "Stratus", "registry", "fetched", "data", "collection", "model", "dataSub", "onChange", "subscriber", "svgIcons", "initialized", "styled", "blurred", "focused", "codeViewIsOpen", "form", "dataChangeLog", "incomingData", "outgoingData", "debounceSave", "debounceTime", "forceSave", "sanitizer", "ref", "elementRef", "fb", "dialog", "ngOnInit", "handleError", "fetchData", "dataDefer", "dataRef", "onDataChange", "modelSave", "hydrate", "disableRefresh", "stagger", "reloading", "refresh", "ngOnDestroy"]);
71
- this.fetchData()
72
- .then(data => {
73
- if (!data || !(data instanceof EventManager)) {
74
- console.warn('Unable to bind data from Registry!');
75
- return;
76
- }
77
- const onDataChange = () => {
78
- if (!data.completed) {
79
- return;
80
- }
81
- this.dataDefer(this.subscriber);
82
- };
83
- data.on('change', onDataChange);
84
- onDataChange();
85
- });
86
- this.dataSub = new Observable(subscriber => {
87
- if (this.dev) {
88
- console.warn(`[observable] creating subscriber on ${this.uid}`, subscriber);
89
- }
90
- return this.dataDefer(subscriber);
91
- });
92
- this.dataSub.pipe(debounce(() => timer(250)), catchError(this.handleError)).subscribe(evt => {
93
- if (this.focused) {
94
- if (this.dev) {
95
- console.warn(`[subscriber] waiting on updates due to focus on ${this.uid}`);
96
- }
97
- return;
98
- }
99
- const dataControl = this.form.get('dataString');
100
- if (dataControl.value === evt) {
101
- if (this.initialized) {
102
- this.refresh();
103
- }
104
- return;
105
- }
106
- dataControl.patchValue(evt);
107
- this.refresh();
108
- });
109
- }
110
- ngOnInit() {
111
- this.initialized = true;
112
- const dataControl = this.form.get('dataString');
113
- if (this.debounceSave) {
114
- dataControl.valueChanges.pipe(debounce(() => timer(this.debounceTime)), catchError(this.handleError)).subscribe((evt) => this.modelSave(evt));
115
- dataControl.valueChanges.pipe(debounce(() => timer(250)), catchError(this.handleError)).subscribe((evt) => {
116
- if (this.model.changedExternal) {
117
- return;
118
- }
119
- this.model.changedExternal = true;
120
- this.model.trigger('change');
121
- });
122
- dataControl.valueChanges.forEach((value) => this.outgoingData = value);
123
- }
124
- else {
125
- dataControl.valueChanges.forEach((value) => this.modelSave(value));
126
- }
127
- }
128
- handleError(err) {
129
- console.error(err);
130
- return err;
131
- }
132
- fetchData() {
133
- if (this.fetched) {
134
- return this.fetched;
135
- }
136
- return this.fetched = this.registry.fetch(Stratus.Select(this.elementRef.nativeElement), this);
137
- }
138
- dataDefer(subscriber) {
139
- this.subscriber = this.subscriber || subscriber;
140
- if (!this.subscriber) {
141
- if (this.dev) {
142
- console.warn(`[defer] debouncing due to empty subscriber on ${this.uid}`);
143
- }
144
- setTimeout(() => {
145
- if (this.dev) {
146
- console.warn(`[defer] debounced subscriber returned on ${this.uid}`);
147
- }
148
- this.dataDefer(subscriber);
149
- }, 250);
150
- return;
151
- }
152
- const prevString = _.clone(this.incomingData);
153
- const dataString = this.dataRef();
154
- if (prevString === dataString) {
155
- return;
156
- }
157
- if (!dataString && (!this.data || !this.data.completed)) {
158
- if (this.dev) {
159
- console.warn(`[defer] debouncing subscriber due to unavailable data on ${this.uid}`, this.data);
160
- }
161
- setTimeout(() => {
162
- if (this.dev) {
163
- console.warn(`[defer] debounced subscriber returned on ${this.uid}`);
164
- }
165
- this.dataDefer(subscriber);
166
- }, 250);
167
- return;
168
- }
169
- if (prevString === dataString) {
170
- return;
171
- }
172
- if (this.dev) {
173
- console.warn(`[subscriber] new value submitted on ${this.uid}:`, dataString);
174
- }
175
- this.subscriber.next(dataString);
176
- }
177
- dataRef() {
178
- if (!this.model) {
179
- return '';
180
- }
181
- return this.incomingData = this.model.get(this.property);
182
- }
183
- onDataChange() {
184
- this.dataDefer(this.subscriber);
185
- this.refresh();
186
- }
187
- modelSave(value) {
188
- if (!this.model.completed) {
189
- return;
190
- }
191
- this.model.set(this.property, value);
192
- if (this.debounceSave) {
193
- this.model.changedExternal = false;
194
- }
195
- if (this.forceSave && !_.isEmpty(this.model.getIdentifier())) {
196
- this.model.save();
197
- }
198
- }
199
- };
200
- __decorate([
201
- Input(),
202
- __metadata("design:type", String)
203
- ], JsonComponent.prototype, "target", void 0);
204
- __decorate([
205
- Input(),
206
- __metadata("design:type", String)
207
- ], JsonComponent.prototype, "targetSuffix", void 0);
208
- __decorate([
209
- Input(),
210
- __metadata("design:type", Number)
211
- ], JsonComponent.prototype, "id", void 0);
212
- __decorate([
213
- Input(),
214
- __metadata("design:type", Boolean)
215
- ], JsonComponent.prototype, "manifest", void 0);
216
- __decorate([
217
- Input(),
218
- __metadata("design:type", Boolean)
219
- ], JsonComponent.prototype, "decouple", void 0);
220
- __decorate([
221
- Input(),
222
- __metadata("design:type", Boolean)
223
- ], JsonComponent.prototype, "direct", void 0);
224
- __decorate([
225
- Input(),
226
- __metadata("design:type", Object)
227
- ], JsonComponent.prototype, "api", void 0);
228
- __decorate([
229
- Input(),
230
- __metadata("design:type", String)
231
- ], JsonComponent.prototype, "urlRoot", void 0);
232
- __decorate([
233
- Input(),
234
- __metadata("design:type", String)
235
- ], JsonComponent.prototype, "type", void 0);
236
- __decorate([
237
- Input(),
238
- __metadata("design:type", String)
239
- ], JsonComponent.prototype, "property", void 0);
240
- __decorate([
241
- Input(),
242
- __metadata("design:type", String)
243
- ], JsonComponent.prototype, "endpoint", void 0);
244
- JsonComponent = __decorate([
245
- Component({
246
- selector: 'sa-json',
247
- templateUrl: `${localDir}/${moduleName}/${moduleName}.component${min}.html`,
248
- }),
249
- __metadata("design:paramtypes", [DomSanitizer,
250
- ChangeDetectorRef,
251
- ElementRef,
252
- FormBuilder,
253
- MatDialog])
254
- ], JsonComponent);
255
- export { JsonComponent };
256
-
257
- //# sourceMappingURL=json.component.js.map