@stratusjs/angular 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/angular.bundle.js +30609 -2673
- package/dist/angular.bundle.min.js +1 -1
- package/package.json +5 -4
- package/src/angular.modules.js +18 -33
- package/src/angular.modules.js.map +1 -1
- package/src/app.module.js +181 -227
- package/src/app.module.js.map +1 -1
- package/src/app.module.min.js +1 -1
- package/src/app.module.ts +17 -17
- package/src/backend.service.js +66 -87
- package/src/backend.service.js.map +1 -1
- package/src/base/base.component.js +101 -124
- package/src/base/base.component.js.map +1 -1
- package/src/boot.js +42 -55
- package/src/boot.js.map +1 -1
- package/src/confirm-dialog/confirm-dialog.component.js +41 -60
- package/src/confirm-dialog/confirm-dialog.component.js.map +1 -1
- package/src/core/base.interface.js +1 -9
- package/src/core/base.interface.js.map +1 -1
- package/src/core/dialog.interface.js.map +1 -0
- package/src/core/refresh.interface.js +1 -9
- package/src/core/refresh.interface.js.map +1 -1
- package/src/core/responsive.component.js +40 -58
- package/src/core/responsive.component.js.map +1 -1
- package/src/core/responsive.interface.js +1 -9
- package/src/core/responsive.interface.js.map +1 -1
- package/src/core/root.component.js +24 -43
- package/src/core/root.component.js.map +1 -1
- package/src/core/trigger.interface.js +1 -9
- package/src/core/trigger.interface.js.map +1 -1
- package/src/data/contact-meta.interface.js +1 -9
- package/src/data/contact-meta.interface.js.map +1 -1
- package/src/data/content.interface.js +1 -9
- package/src/data/content.interface.js.map +1 -1
- package/src/data/convoy.interface.js +1 -9
- package/src/data/convoy.interface.js.map +1 -1
- package/src/editor/citation-dialog.component.js +174 -207
- package/src/editor/citation-dialog.component.js.map +1 -1
- package/src/editor/code-mirror-bridge.js +63 -0
- package/src/editor/code-mirror-bridge.js.map +1 -0
- package/src/editor/code-mirror-bridge.min.js +1 -0
- package/src/editor/code-mirror-bridge.ts +85 -0
- package/src/editor/code-view-dialog.component.js +87 -116
- package/src/editor/code-view-dialog.component.js.map +1 -1
- package/src/editor/editor.component.js +903 -925
- package/src/editor/editor.component.js.map +1 -1
- package/src/editor/editor.component.min.js +1 -1
- package/src/editor/editor.component.ts +60 -21
- package/src/editor/link-dialog.component.js +356 -395
- package/src/editor/link-dialog.component.js.map +1 -1
- package/src/editor/media-dialog.component.js +270 -303
- package/src/editor/media-dialog.component.js.map +1 -1
- package/src/froala/plugins/citationManager.js +170 -191
- package/src/froala/plugins/citationManager.js.map +1 -1
- package/src/froala/plugins/inputButton.js +122 -138
- package/src/froala/plugins/inputButton.js.map +1 -1
- package/src/froala/plugins/linkManager.js +89 -104
- package/src/froala/plugins/linkManager.js.map +1 -1
- package/src/froala/plugins/mediaManager.js +72 -87
- package/src/froala/plugins/mediaManager.js.map +1 -1
- package/src/froala/plugins/menuButton.js +71 -86
- package/src/froala/plugins/menuButton.js.map +1 -1
- package/src/main.js +13 -33
- package/src/main.js.map +1 -1
- package/src/material.js +99 -194
- package/src/material.js.map +1 -1
- package/src/media-selector/media-selector.component.js +406 -441
- package/src/media-selector/media-selector.component.js.map +1 -1
- package/src/polyfills.js +3 -16
- package/src/polyfills.js.map +1 -1
- package/src/quill-plugins/quill-break-blot.plugin.js +19 -35
- package/src/quill-plugins/quill-break-blot.plugin.js.map +1 -1
- package/src/quill-plugins/quill-html-edit.plugin.js +140 -153
- package/src/quill-plugins/quill-html-edit.plugin.js.map +1 -1
- package/src/quill-plugins/quill-image-format.plugin.js +33 -47
- package/src/quill-plugins/quill-image-format.plugin.js.map +1 -1
- package/src/quill-plugins/quill-input-button.plugin.js +77 -95
- package/src/quill-plugins/quill-input-button.plugin.js.map +1 -1
- package/src/selector/selector.component.js +241 -276
- package/src/selector/selector.component.js.map +1 -1
- package/src/test/test.directive.js +49 -66
- package/src/test/test.directive.js.map +1 -1
- package/src/tree/tree-dialog.component.js +202 -231
- package/src/tree/tree-dialog.component.js.map +1 -1
- package/src/tree/tree-node.component.js +253 -279
- package/src/tree/tree-node.component.js.map +1 -1
- package/src/tree/tree-node.component.min.js +1 -1
- package/src/tree/tree-node.component.ts +10 -18
- package/src/tree/tree.component.js +531 -568
- package/src/tree/tree.component.js.map +1 -1
- package/src/tree/tree.component.min.js +1 -1
- package/src/tree/tree.component.ts +7 -10
|
@@ -1,402 +1,363 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
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
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
import { ChangeDetectorRef, Component, Inject } from '@angular/core';
|
|
14
|
+
import { FormBuilder } from '@angular/forms';
|
|
15
|
+
import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog';
|
|
16
|
+
import { MatSnackBar } from '@angular/material/snack-bar';
|
|
17
|
+
import { Observable } from 'rxjs';
|
|
18
|
+
import { debounceTime, finalize, switchMap, tap } from 'rxjs/operators';
|
|
19
|
+
import _ from 'lodash';
|
|
20
|
+
import { Stratus } from '@stratusjs/runtime/stratus';
|
|
21
|
+
import { cookie } from '@stratusjs/core/environment';
|
|
22
|
+
import { BackendService } from '../backend.service';
|
|
23
|
+
import { Model } from '@stratusjs/angularjs/services/model';
|
|
24
|
+
import { ResponsiveComponent } from '../core/responsive.component';
|
|
25
|
+
import { MatIconRegistry } from '@angular/material/icon';
|
|
26
|
+
import { DomSanitizer } from '@angular/platform-browser';
|
|
27
|
+
const systemDir = '@stratusjs/angular';
|
|
28
|
+
const moduleName = 'link-dialog';
|
|
29
|
+
const parentModuleName = 'editor';
|
|
30
|
+
const min = !cookie('env') ? '.min' : '';
|
|
31
|
+
const localDir = `${Stratus.BaseUrl}${boot.configuration.paths[`${systemDir}/*`].replace(/[^/]*$/, '').replace(/\/dist\/$/, '/src/')}`;
|
|
32
|
+
let LinkDialogComponent = class LinkDialogComponent extends ResponsiveComponent {
|
|
33
|
+
constructor(dialogRef, data, fb, backend, snackBar, iconRegistry, sanitizer, ref) {
|
|
34
|
+
super();
|
|
35
|
+
this.dialogRef = dialogRef;
|
|
36
|
+
this.data = data;
|
|
37
|
+
this.fb = fb;
|
|
38
|
+
this.backend = backend;
|
|
39
|
+
this.snackBar = snackBar;
|
|
40
|
+
this.iconRegistry = iconRegistry;
|
|
41
|
+
this.sanitizer = sanitizer;
|
|
42
|
+
this.ref = ref;
|
|
43
|
+
this.title = moduleName + '_component';
|
|
44
|
+
this._ = _;
|
|
45
|
+
this.Stratus = Stratus;
|
|
46
|
+
this.apiBase = '/Api/Content';
|
|
47
|
+
this.contentEntities = [];
|
|
48
|
+
this.isContentLoading = true;
|
|
49
|
+
this.isSingleContentLoading = false;
|
|
50
|
+
this.limit = 20;
|
|
51
|
+
this.eventInsert = true;
|
|
52
|
+
this.isListView = false;
|
|
53
|
+
this.selected = [];
|
|
54
|
+
this.linkType = '';
|
|
55
|
+
this.linkText = '';
|
|
56
|
+
this.linkURL = '';
|
|
57
|
+
this.linkTarget = false;
|
|
58
|
+
this.svgIcons = {};
|
|
59
|
+
this.isInitialized = false;
|
|
60
|
+
this.isDestroyed = false;
|
|
61
|
+
this.isStyled = false;
|
|
62
|
+
}
|
|
63
|
+
ngOnInit() {
|
|
64
|
+
this.uid = _.uniqueId(`sa_${_.snakeCase(moduleName)}_component_`);
|
|
65
|
+
Stratus.Instances[this.uid] = this;
|
|
66
|
+
Stratus.Internals.CssLoader(`${localDir}${parentModuleName}/${moduleName}.component${min}.css`)
|
|
67
|
+
.then(() => {
|
|
68
|
+
this.isStyled = true;
|
|
69
|
+
this.refresh();
|
|
70
|
+
})
|
|
71
|
+
.catch((err) => {
|
|
72
|
+
console.warn('Issue detected in CSS Loader for Component:', this);
|
|
73
|
+
console.error(err);
|
|
74
|
+
this.isStyled = true;
|
|
75
|
+
this.refresh();
|
|
76
|
+
});
|
|
77
|
+
_.forEach({
|
|
78
|
+
selector_delete: `${Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/delete.svg`,
|
|
79
|
+
selector_edit: `${Stratus.BaseUrl}sitetheorycore/images/icons/actionButtons/edit.svg`
|
|
80
|
+
}, (value, key) => this.iconRegistry.addSvgIcon(key, this.sanitizer.bypassSecurityTrustResourceUrl(value)).getNamedSvgIcon(key));
|
|
81
|
+
this.model = this.data.model;
|
|
82
|
+
this.property = this.data.property;
|
|
83
|
+
this.editor = this.data.editor;
|
|
84
|
+
this.eventManager = this.data.eventManager;
|
|
85
|
+
this.element = this.data.element;
|
|
86
|
+
if (_.isBoolean(this.data.eventInsert)) {
|
|
87
|
+
this.eventInsert = this.data.eventInsert;
|
|
88
|
+
}
|
|
89
|
+
this.dialogContentForm = this.fb.group({
|
|
90
|
+
contentSelectorInput: '',
|
|
91
|
+
linkTypeRadio: '',
|
|
92
|
+
linkTextInput: '',
|
|
93
|
+
linkURLInput: '',
|
|
94
|
+
linkTargetCheckbox: ''
|
|
95
|
+
});
|
|
96
|
+
this.dialogContentForm
|
|
97
|
+
.get('contentSelectorInput')
|
|
98
|
+
.valueChanges
|
|
99
|
+
.pipe(debounceTime(300), tap(() => this.isContentLoading = true), switchMap((value) => {
|
|
100
|
+
if (_.isUndefined(value)) {
|
|
101
|
+
return this.getQuery();
|
|
60
102
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
}, (value, key) => this.iconRegistry.addSvgIcon(key, this.sanitizer.bypassSecurityTrustResourceUrl(value)).getNamedSvgIcon(key));
|
|
117
|
-
this.model = this.data.model;
|
|
118
|
-
this.property = this.data.property;
|
|
119
|
-
this.editor = this.data.editor;
|
|
120
|
-
this.eventManager = this.data.eventManager;
|
|
121
|
-
this.element = this.data.element;
|
|
122
|
-
if (lodash_1.default.isBoolean(this.data.eventInsert)) {
|
|
123
|
-
this.eventInsert = this.data.eventInsert;
|
|
124
|
-
}
|
|
125
|
-
this.dialogContentForm = this.fb.group({
|
|
126
|
-
contentSelectorInput: '',
|
|
127
|
-
linkTypeRadio: '',
|
|
128
|
-
linkTextInput: '',
|
|
129
|
-
linkURLInput: '',
|
|
130
|
-
linkTargetCheckbox: ''
|
|
131
|
-
});
|
|
132
|
-
this.dialogContentForm
|
|
133
|
-
.get('contentSelectorInput')
|
|
134
|
-
.valueChanges
|
|
135
|
-
.pipe(operators_1.debounceTime(300), operators_1.tap(() => this.isContentLoading = true), operators_1.switchMap((value) => {
|
|
136
|
-
if (lodash_1.default.isUndefined(value)) {
|
|
137
|
-
return this.getQuery();
|
|
138
|
-
}
|
|
139
|
-
if (!lodash_1.default.isString(value)) {
|
|
140
|
-
this.content = value;
|
|
141
|
-
return this.getQuery();
|
|
142
|
-
}
|
|
143
|
-
return this.getQuery(value);
|
|
144
|
-
}))
|
|
145
|
-
.subscribe((response) => this.processContent(response));
|
|
146
|
-
this.backend
|
|
147
|
-
.get(this.getQueryUrl())
|
|
148
|
-
.pipe(operators_1.finalize(() => this.isContentLoading = false))
|
|
149
|
-
.subscribe((response) => this.processContent(response));
|
|
150
|
-
this.dialogContentForm
|
|
151
|
-
.get('linkTypeRadio')
|
|
152
|
-
.valueChanges
|
|
153
|
-
.pipe(operators_1.debounceTime(300))
|
|
154
|
-
.subscribe((response) => this.linkType = response);
|
|
155
|
-
this.linkType = this.element && this.element.hasAttribute('data-content-id') ? 'content' : 'url';
|
|
156
|
-
this.dialogContentForm
|
|
157
|
-
.get('linkTypeRadio')
|
|
158
|
-
.patchValue(this.linkType);
|
|
159
|
-
this.dialogContentForm
|
|
160
|
-
.get('linkTextInput')
|
|
161
|
-
.valueChanges
|
|
162
|
-
.pipe(operators_1.debounceTime(300))
|
|
163
|
-
.subscribe((response) => this.linkText = response);
|
|
164
|
-
this.linkText = this.element ? this.element.textContent : '';
|
|
165
|
-
this.dialogContentForm
|
|
166
|
-
.get('linkTextInput')
|
|
167
|
-
.patchValue(this.linkText);
|
|
168
|
-
this.dialogContentForm
|
|
169
|
-
.get('linkURLInput')
|
|
170
|
-
.valueChanges
|
|
171
|
-
.pipe(operators_1.debounceTime(300))
|
|
172
|
-
.subscribe((response) => this.linkURL = response);
|
|
173
|
-
this.linkURL = this.element && this.element.hasAttribute('href') ? this.element.getAttribute('href') : '';
|
|
174
|
-
this.dialogContentForm
|
|
175
|
-
.get('linkURLInput')
|
|
176
|
-
.patchValue(this.linkURL);
|
|
177
|
-
this.dialogContentForm
|
|
178
|
-
.get('linkTargetCheckbox')
|
|
179
|
-
.valueChanges
|
|
180
|
-
.pipe(operators_1.debounceTime(300))
|
|
181
|
-
.subscribe((response) => this.linkTarget = response);
|
|
182
|
-
this.linkTarget = this.element ? this.element.hasAttribute('target') : false;
|
|
183
|
-
this.dialogContentForm
|
|
184
|
-
.get('linkTargetCheckbox')
|
|
185
|
-
.patchValue(this.linkTarget);
|
|
186
|
-
if (this.element && this.element.hasAttribute('data-content-id')) {
|
|
187
|
-
this.isSingleContentLoading = true;
|
|
188
|
-
this.backend
|
|
189
|
-
.get(this.getQueryUrl(null, this.element.getAttribute('data-content-id')))
|
|
190
|
-
.pipe(operators_1.finalize(() => this.isSingleContentLoading = false))
|
|
191
|
-
.subscribe((response) => {
|
|
192
|
-
if (!response.ok || response.status !== 200 || lodash_1.default.isEmpty(response.body)) {
|
|
193
|
-
return null;
|
|
194
|
-
}
|
|
195
|
-
const payload = lodash_1.default.get(response.body, 'payload') || response.body;
|
|
196
|
-
if (lodash_1.default.isEmpty(payload) || Array.isArray(payload) || !lodash_1.default.isObject(payload)) {
|
|
197
|
-
return null;
|
|
198
|
-
}
|
|
199
|
-
this.contentEntity = payload;
|
|
200
|
-
this.isSingleContentLoading = false;
|
|
201
|
-
this.dialogContentForm
|
|
202
|
-
.get('contentSelectorInput')
|
|
203
|
-
.patchValue(this.contentEntity);
|
|
204
|
-
this.refresh();
|
|
205
|
-
return this.contentEntity;
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
this.isInitialized = true;
|
|
209
|
-
}
|
|
210
|
-
ngOnDestroy() {
|
|
211
|
-
this.isDestroyed = true;
|
|
212
|
-
}
|
|
213
|
-
refresh() {
|
|
214
|
-
if (this.isDestroyed) {
|
|
215
|
-
return new Promise(resolve => resolve());
|
|
216
|
-
}
|
|
217
|
-
return super.refresh();
|
|
218
|
-
}
|
|
219
|
-
onCancelClick() {
|
|
220
|
-
this.dialogRef.close();
|
|
221
|
-
this.refresh();
|
|
222
|
-
}
|
|
223
|
-
onPage(event) {
|
|
224
|
-
this.pageEvent = event;
|
|
225
|
-
this.getQuery(this.lastContentQuery).subscribe((response) => this.processContent(response));
|
|
226
|
-
}
|
|
227
|
-
getQueryUrl(query, id) {
|
|
228
|
-
query = (!lodash_1.default.isString(query) || lodash_1.default.isEmpty(query)) ? '' : `"${query}"`;
|
|
229
|
-
id = lodash_1.default.isEmpty(id) ? '' : `/${id}`;
|
|
230
|
-
return `${this.apiBase}${id}?limit=${this.limit}&options[isContent]=null&options[isCollection]=null&options[showRoutable]=true&options[showRouting]=true&q=${query}`;
|
|
231
|
-
}
|
|
232
|
-
getQuery(query) {
|
|
233
|
-
this.lastContentQuery = query;
|
|
234
|
-
this.isContentLoading = true;
|
|
235
|
-
return this.backend.get(this.getQueryUrl(query))
|
|
236
|
-
.pipe(operators_1.finalize(() => this.isContentLoading = false));
|
|
237
|
-
}
|
|
238
|
-
processContent(response) {
|
|
239
|
-
if (!response.ok || response.status !== 200 || lodash_1.default.isEmpty(response.body)) {
|
|
240
|
-
this.meta = {};
|
|
241
|
-
this.contentEntities = [];
|
|
242
|
-
this.refresh();
|
|
243
|
-
return this.contentEntities;
|
|
244
|
-
}
|
|
245
|
-
this.meta = lodash_1.default.get(response.body, 'meta') || {};
|
|
246
|
-
const payload = lodash_1.default.get(response.body, 'payload') || response.body;
|
|
247
|
-
if (lodash_1.default.isEmpty(payload) || !Array.isArray(payload)) {
|
|
248
|
-
this.contentEntities = [];
|
|
249
|
-
this.isContentLoading = false;
|
|
250
|
-
this.refresh();
|
|
251
|
-
return this.contentEntities;
|
|
252
|
-
}
|
|
253
|
-
this.contentEntities = payload;
|
|
254
|
-
this.isContentLoading = false;
|
|
255
|
-
this.refresh();
|
|
256
|
-
return this.contentEntities;
|
|
257
|
-
}
|
|
258
|
-
onAcceptClick() {
|
|
259
|
-
const link = this.linkType === 'content' ? this.createLink(this.content) : {
|
|
260
|
-
url: this.linkURL,
|
|
261
|
-
text: this.linkText,
|
|
262
|
-
target: this.linkTarget,
|
|
263
|
-
};
|
|
264
|
-
if (!link) {
|
|
265
|
-
const identifier = this.content && this.content.id ? `for Content ID: ${this.content.id}.` : 'without Content Selected or URL Input.';
|
|
266
|
-
console.warn(`${moduleName}: unable to build link ${identifier}`);
|
|
267
|
-
this.snackBar.open(`Unable to build link ${identifier}`, 'dismiss', {
|
|
268
|
-
duration: 5000,
|
|
269
|
-
horizontalPosition: 'right',
|
|
270
|
-
verticalPosition: 'bottom'
|
|
271
|
-
});
|
|
272
|
-
return;
|
|
273
|
-
}
|
|
274
|
-
if (this.content && this.content.id) {
|
|
275
|
-
this.selected.push(this.content.id);
|
|
276
|
-
}
|
|
277
|
-
if (!this.eventInsert) {
|
|
278
|
-
if (!(this.model instanceof model_1.Model)) {
|
|
279
|
-
console.warn(`${moduleName}: event manager not available.`);
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
if (!lodash_1.default.isString(this.property)) {
|
|
283
|
-
console.warn(`${moduleName}: event manager not available.`);
|
|
284
|
-
return;
|
|
285
|
-
}
|
|
286
|
-
console.warn(`${moduleName}: disabling eventInsert is not recommended.`);
|
|
287
|
-
this.model.set(this.property, this.model.get(this.property) + link);
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
if (!this.eventManager) {
|
|
291
|
-
console.warn(`${moduleName}: event manager is not set.`);
|
|
292
|
-
return;
|
|
293
|
-
}
|
|
294
|
-
this.eventManager.trigger('insert', link, this.editor);
|
|
295
|
-
this.onCancelClick();
|
|
296
|
-
}
|
|
297
|
-
isSelected(content) {
|
|
298
|
-
if (lodash_1.default.isUndefined(content)) {
|
|
299
|
-
return;
|
|
300
|
-
}
|
|
301
|
-
return lodash_1.default.includes(this.selected, content.id);
|
|
302
|
-
}
|
|
303
|
-
createLink(content) {
|
|
304
|
-
if (!content) {
|
|
305
|
-
console.warn(`${moduleName}: unable to create link for empty content`);
|
|
306
|
-
return null;
|
|
307
|
-
}
|
|
308
|
-
if (!content.id) {
|
|
309
|
-
console.warn(`${moduleName}: unable to find content id for content:`, content);
|
|
310
|
-
return null;
|
|
311
|
-
}
|
|
312
|
-
if (!content.contentType || !content.contentType.name) {
|
|
313
|
-
console.warn(`${moduleName}: unable to find content type for content id: ${content.id}`);
|
|
314
|
-
return null;
|
|
315
|
-
}
|
|
316
|
-
if (!content.routing || !content.routing.length || !content.routing[0]) {
|
|
317
|
-
console.warn(`${moduleName}: unable to find routing for ${content.contentType.name} id: ${content.id}`);
|
|
318
|
-
return null;
|
|
319
|
-
}
|
|
320
|
-
if (!content.routing[0].url) {
|
|
321
|
-
console.warn(`${moduleName}: unable to find url for ${content.contentType.name} id: ${content.id}`);
|
|
322
|
-
return null;
|
|
323
|
-
}
|
|
324
|
-
if (!content.version) {
|
|
325
|
-
console.warn(`${moduleName}: unable to find content version for ${content.contentType.name} id: ${content.id}`);
|
|
326
|
-
return null;
|
|
327
|
-
}
|
|
328
|
-
if (!content.version.title || !content.version.title.length) {
|
|
329
|
-
console.warn(`${moduleName}: unable to find title for ${content.contentType.name} id: ${content.id}`);
|
|
330
|
-
return null;
|
|
331
|
-
}
|
|
332
|
-
return {
|
|
333
|
-
url: `/${content.routing[0].url}`,
|
|
334
|
-
title: content.version.title,
|
|
335
|
-
text: this.linkText,
|
|
336
|
-
target: this.linkTarget,
|
|
337
|
-
id: content.id
|
|
338
|
-
};
|
|
339
|
-
}
|
|
340
|
-
getSvg(url, options) {
|
|
341
|
-
const uid = this.addSvgIcon(url, options);
|
|
342
|
-
return new rxjs_1.Observable((subscriber) => {
|
|
343
|
-
this.iconRegistry
|
|
344
|
-
.getNamedSvgIcon(uid)
|
|
345
|
-
.subscribe({
|
|
346
|
-
error(err) {
|
|
347
|
-
console.error(`getSvg(${url}): ${err}`);
|
|
348
|
-
},
|
|
349
|
-
complete() {
|
|
350
|
-
subscriber.next(uid);
|
|
351
|
-
}
|
|
352
|
-
});
|
|
353
|
-
});
|
|
354
|
-
}
|
|
355
|
-
addSvgIcon(url, options) {
|
|
356
|
-
if (url in this.svgIcons) {
|
|
357
|
-
return this.svgIcons[url];
|
|
358
|
-
}
|
|
359
|
-
if (!options) {
|
|
360
|
-
options = {};
|
|
361
|
-
}
|
|
362
|
-
const uid = this.svgIcons[url] = lodash_1.default.uniqueId('selector_svg');
|
|
363
|
-
this.iconRegistry.addSvgIcon(uid, this.sanitizer.bypassSecurityTrustResourceUrl(url), options);
|
|
364
|
-
return uid;
|
|
103
|
+
if (!_.isString(value)) {
|
|
104
|
+
this.content = value;
|
|
105
|
+
return this.getQuery();
|
|
106
|
+
}
|
|
107
|
+
return this.getQuery(value);
|
|
108
|
+
}))
|
|
109
|
+
.subscribe((response) => this.processContent(response));
|
|
110
|
+
this.backend
|
|
111
|
+
.get(this.getQueryUrl())
|
|
112
|
+
.pipe(finalize(() => this.isContentLoading = false))
|
|
113
|
+
.subscribe((response) => this.processContent(response));
|
|
114
|
+
this.dialogContentForm
|
|
115
|
+
.get('linkTypeRadio')
|
|
116
|
+
.valueChanges
|
|
117
|
+
.pipe(debounceTime(300))
|
|
118
|
+
.subscribe((response) => this.linkType = response);
|
|
119
|
+
this.linkType = this.element && this.element.hasAttribute('data-content-id') ? 'content' : 'url';
|
|
120
|
+
this.dialogContentForm
|
|
121
|
+
.get('linkTypeRadio')
|
|
122
|
+
.patchValue(this.linkType);
|
|
123
|
+
this.dialogContentForm
|
|
124
|
+
.get('linkTextInput')
|
|
125
|
+
.valueChanges
|
|
126
|
+
.pipe(debounceTime(300))
|
|
127
|
+
.subscribe((response) => this.linkText = response);
|
|
128
|
+
this.linkText = this.element ? this.element.textContent : '';
|
|
129
|
+
this.dialogContentForm
|
|
130
|
+
.get('linkTextInput')
|
|
131
|
+
.patchValue(this.linkText);
|
|
132
|
+
this.dialogContentForm
|
|
133
|
+
.get('linkURLInput')
|
|
134
|
+
.valueChanges
|
|
135
|
+
.pipe(debounceTime(300))
|
|
136
|
+
.subscribe((response) => this.linkURL = response);
|
|
137
|
+
this.linkURL = this.element && this.element.hasAttribute('href') ? this.element.getAttribute('href') : '';
|
|
138
|
+
this.dialogContentForm
|
|
139
|
+
.get('linkURLInput')
|
|
140
|
+
.patchValue(this.linkURL);
|
|
141
|
+
this.dialogContentForm
|
|
142
|
+
.get('linkTargetCheckbox')
|
|
143
|
+
.valueChanges
|
|
144
|
+
.pipe(debounceTime(300))
|
|
145
|
+
.subscribe((response) => this.linkTarget = response);
|
|
146
|
+
this.linkTarget = this.element ? this.element.hasAttribute('target') : false;
|
|
147
|
+
this.dialogContentForm
|
|
148
|
+
.get('linkTargetCheckbox')
|
|
149
|
+
.patchValue(this.linkTarget);
|
|
150
|
+
if (this.element && this.element.hasAttribute('data-content-id')) {
|
|
151
|
+
this.isSingleContentLoading = true;
|
|
152
|
+
this.backend
|
|
153
|
+
.get(this.getQueryUrl(null, this.element.getAttribute('data-content-id')))
|
|
154
|
+
.pipe(finalize(() => this.isSingleContentLoading = false))
|
|
155
|
+
.subscribe((response) => {
|
|
156
|
+
if (!response.ok || response.status !== 200 || _.isEmpty(response.body)) {
|
|
157
|
+
return null;
|
|
365
158
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
}
|
|
370
|
-
const routing = lodash_1.default.get(content, 'routing[0].url');
|
|
371
|
-
const routingText = !lodash_1.default.isUndefined(routing) ? ` (/${routing})` : ' (No route!)';
|
|
372
|
-
const contentId = lodash_1.default.get(content, 'id');
|
|
373
|
-
const contentIdText = !lodash_1.default.isUndefined(contentId) ? `Content: ${contentId}` : null;
|
|
374
|
-
return (lodash_1.default.get(content, 'version.title') || contentIdText) + routingText;
|
|
159
|
+
const payload = _.get(response.body, 'payload') || response.body;
|
|
160
|
+
if (_.isEmpty(payload) || Array.isArray(payload) || !_.isObject(payload)) {
|
|
161
|
+
return null;
|
|
375
162
|
}
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
163
|
+
this.contentEntity = payload;
|
|
164
|
+
this.isSingleContentLoading = false;
|
|
165
|
+
this.dialogContentForm
|
|
166
|
+
.get('contentSelectorInput')
|
|
167
|
+
.patchValue(this.contentEntity);
|
|
168
|
+
this.refresh();
|
|
169
|
+
return this.contentEntity;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
this.isInitialized = true;
|
|
173
|
+
}
|
|
174
|
+
ngOnDestroy() {
|
|
175
|
+
this.isDestroyed = true;
|
|
176
|
+
}
|
|
177
|
+
refresh() {
|
|
178
|
+
if (this.isDestroyed) {
|
|
179
|
+
return new Promise(resolve => resolve());
|
|
180
|
+
}
|
|
181
|
+
return super.refresh();
|
|
182
|
+
}
|
|
183
|
+
onCancelClick() {
|
|
184
|
+
this.dialogRef.close();
|
|
185
|
+
this.refresh();
|
|
186
|
+
}
|
|
187
|
+
onPage(event) {
|
|
188
|
+
this.pageEvent = event;
|
|
189
|
+
this.getQuery(this.lastContentQuery).subscribe((response) => this.processContent(response));
|
|
190
|
+
}
|
|
191
|
+
getQueryUrl(query, id) {
|
|
192
|
+
query = (!_.isString(query) || _.isEmpty(query)) ? '' : `"${query}"`;
|
|
193
|
+
id = _.isEmpty(id) ? '' : `/${id}`;
|
|
194
|
+
return `${this.apiBase}${id}?limit=${this.limit}&options[isContent]=null&options[isCollection]=null&options[showRoutable]=true&options[showRouting]=true&q=${query}`;
|
|
195
|
+
}
|
|
196
|
+
getQuery(query) {
|
|
197
|
+
this.lastContentQuery = query;
|
|
198
|
+
this.isContentLoading = true;
|
|
199
|
+
return this.backend.get(this.getQueryUrl(query))
|
|
200
|
+
.pipe(finalize(() => this.isContentLoading = false));
|
|
201
|
+
}
|
|
202
|
+
processContent(response) {
|
|
203
|
+
if (!response.ok || response.status !== 200 || _.isEmpty(response.body)) {
|
|
204
|
+
this.meta = {};
|
|
205
|
+
this.contentEntities = [];
|
|
206
|
+
this.refresh();
|
|
207
|
+
return this.contentEntities;
|
|
208
|
+
}
|
|
209
|
+
this.meta = _.get(response.body, 'meta') || {};
|
|
210
|
+
const payload = _.get(response.body, 'payload') || response.body;
|
|
211
|
+
if (_.isEmpty(payload) || !Array.isArray(payload)) {
|
|
212
|
+
this.contentEntities = [];
|
|
213
|
+
this.isContentLoading = false;
|
|
214
|
+
this.refresh();
|
|
215
|
+
return this.contentEntities;
|
|
216
|
+
}
|
|
217
|
+
this.contentEntities = payload;
|
|
218
|
+
this.isContentLoading = false;
|
|
219
|
+
this.refresh();
|
|
220
|
+
return this.contentEntities;
|
|
221
|
+
}
|
|
222
|
+
onAcceptClick() {
|
|
223
|
+
const link = this.linkType === 'content' ? this.createLink(this.content) : {
|
|
224
|
+
url: this.linkURL,
|
|
225
|
+
text: this.linkText,
|
|
226
|
+
target: this.linkTarget,
|
|
227
|
+
};
|
|
228
|
+
if (!link) {
|
|
229
|
+
const identifier = this.content && this.content.id ? `for Content ID: ${this.content.id}.` : 'without Content Selected or URL Input.';
|
|
230
|
+
console.warn(`${moduleName}: unable to build link ${identifier}`);
|
|
231
|
+
this.snackBar.open(`Unable to build link ${identifier}`, 'dismiss', {
|
|
232
|
+
duration: 5000,
|
|
233
|
+
horizontalPosition: 'right',
|
|
234
|
+
verticalPosition: 'bottom'
|
|
235
|
+
});
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
if (this.content && this.content.id) {
|
|
239
|
+
this.selected.push(this.content.id);
|
|
240
|
+
}
|
|
241
|
+
if (!this.eventInsert) {
|
|
242
|
+
if (!(this.model instanceof Model)) {
|
|
243
|
+
console.warn(`${moduleName}: event manager not available.`);
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
if (!_.isString(this.property)) {
|
|
247
|
+
console.warn(`${moduleName}: event manager not available.`);
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
console.warn(`${moduleName}: disabling eventInsert is not recommended.`);
|
|
251
|
+
this.model.set(this.property, this.model.get(this.property) + link);
|
|
252
|
+
return;
|
|
253
|
+
}
|
|
254
|
+
if (!this.eventManager) {
|
|
255
|
+
console.warn(`${moduleName}: event manager is not set.`);
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
this.eventManager.trigger('insert', link, this.editor);
|
|
259
|
+
this.onCancelClick();
|
|
260
|
+
}
|
|
261
|
+
isSelected(content) {
|
|
262
|
+
if (_.isUndefined(content)) {
|
|
263
|
+
return;
|
|
264
|
+
}
|
|
265
|
+
return _.includes(this.selected, content.id);
|
|
266
|
+
}
|
|
267
|
+
createLink(content) {
|
|
268
|
+
if (!content) {
|
|
269
|
+
console.warn(`${moduleName}: unable to create link for empty content`);
|
|
270
|
+
return null;
|
|
271
|
+
}
|
|
272
|
+
if (!content.id) {
|
|
273
|
+
console.warn(`${moduleName}: unable to find content id for content:`, content);
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
if (!content.contentType || !content.contentType.name) {
|
|
277
|
+
console.warn(`${moduleName}: unable to find content type for content id: ${content.id}`);
|
|
278
|
+
return null;
|
|
279
|
+
}
|
|
280
|
+
if (!content.routing || !content.routing.length || !content.routing[0]) {
|
|
281
|
+
console.warn(`${moduleName}: unable to find routing for ${content.contentType.name} id: ${content.id}`);
|
|
282
|
+
return null;
|
|
283
|
+
}
|
|
284
|
+
if (!content.routing[0].url) {
|
|
285
|
+
console.warn(`${moduleName}: unable to find url for ${content.contentType.name} id: ${content.id}`);
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
if (!content.version) {
|
|
289
|
+
console.warn(`${moduleName}: unable to find content version for ${content.contentType.name} id: ${content.id}`);
|
|
290
|
+
return null;
|
|
291
|
+
}
|
|
292
|
+
if (!content.version.title || !content.version.title.length) {
|
|
293
|
+
console.warn(`${moduleName}: unable to find title for ${content.contentType.name} id: ${content.id}`);
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
return {
|
|
297
|
+
url: `/${content.routing[0].url}`,
|
|
298
|
+
title: content.version.title,
|
|
299
|
+
text: this.linkText,
|
|
300
|
+
target: this.linkTarget,
|
|
301
|
+
id: content.id
|
|
302
|
+
};
|
|
303
|
+
}
|
|
304
|
+
getSvg(url, options) {
|
|
305
|
+
const uid = this.addSvgIcon(url, options);
|
|
306
|
+
return new Observable((subscriber) => {
|
|
307
|
+
this.iconRegistry
|
|
308
|
+
.getNamedSvgIcon(uid)
|
|
309
|
+
.subscribe({
|
|
310
|
+
error(err) {
|
|
311
|
+
console.error(`getSvg(${url}): ${err}`);
|
|
312
|
+
},
|
|
313
|
+
complete() {
|
|
314
|
+
subscriber.next(uid);
|
|
382
315
|
}
|
|
383
|
-
};
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
316
|
+
});
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
addSvgIcon(url, options) {
|
|
320
|
+
if (url in this.svgIcons) {
|
|
321
|
+
return this.svgIcons[url];
|
|
322
|
+
}
|
|
323
|
+
if (!options) {
|
|
324
|
+
options = {};
|
|
325
|
+
}
|
|
326
|
+
const uid = this.svgIcons[url] = _.uniqueId('selector_svg');
|
|
327
|
+
this.iconRegistry.addSvgIcon(uid, this.sanitizer.bypassSecurityTrustResourceUrl(url), options);
|
|
328
|
+
return uid;
|
|
329
|
+
}
|
|
330
|
+
displayContentText(content) {
|
|
331
|
+
if (!content) {
|
|
332
|
+
return;
|
|
333
|
+
}
|
|
334
|
+
const routing = _.get(content, 'routing[0].url');
|
|
335
|
+
const routingText = !_.isUndefined(routing) ? ` (/${routing})` : ' (No route!)';
|
|
336
|
+
const contentId = _.get(content, 'id');
|
|
337
|
+
const contentIdText = !_.isUndefined(contentId) ? `Content: ${contentId}` : null;
|
|
338
|
+
return (_.get(content, 'version.title') || contentIdText) + routingText;
|
|
339
|
+
}
|
|
340
|
+
goToUrl(content) {
|
|
341
|
+
if (!content || !content.contentType) {
|
|
342
|
+
console.error('unable to execute goToUrl() because a valid model content was not provided.');
|
|
343
|
+
return;
|
|
398
344
|
}
|
|
399
|
-
|
|
400
|
-
}
|
|
345
|
+
window.open(content.contentType.editUrl + '?id=' + content.id, '_blank');
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
LinkDialogComponent = __decorate([
|
|
349
|
+
Component({
|
|
350
|
+
selector: `sa-${moduleName}`,
|
|
351
|
+
templateUrl: `${localDir}/${parentModuleName}/${moduleName}.component${min}.html`,
|
|
352
|
+
}),
|
|
353
|
+
__param(1, Inject(MAT_DIALOG_DATA)),
|
|
354
|
+
__metadata("design:paramtypes", [MatDialogRef, Object, FormBuilder,
|
|
355
|
+
BackendService,
|
|
356
|
+
MatSnackBar,
|
|
357
|
+
MatIconRegistry,
|
|
358
|
+
DomSanitizer,
|
|
359
|
+
ChangeDetectorRef])
|
|
360
|
+
], LinkDialogComponent);
|
|
361
|
+
export { LinkDialogComponent };
|
|
401
362
|
|
|
402
363
|
//# sourceMappingURL=link-dialog.component.js.map
|