@reldens/cms 0.69.0 → 0.70.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.
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
<dialog class="confirm-dialog">
|
|
45
45
|
<div class="dialog-content">
|
|
46
46
|
<h5 class="dialog-title">Confirm Delete</h5>
|
|
47
|
-
<p class="dialog-message">Are you sure you want to delete the selected items? This action cannot be undone.</p>
|
|
47
|
+
<p class="dialog-message">Are you sure you want to delete the selected items?{{&deleteRelationsWarning}} This action cannot be undone.</p>
|
|
48
48
|
<div class="dialog-actions">
|
|
49
49
|
<button type="button" class="button button-secondary dialog-cancel">Cancel</button>
|
|
50
50
|
<button type="button" class="button button-danger dialog-confirm">Delete</button>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<dialog class="confirm-dialog">
|
|
40
40
|
<div class="dialog-content">
|
|
41
41
|
<h5 class="dialog-title">Confirm Delete</h5>
|
|
42
|
-
<p class="dialog-message">Are you sure you want to delete this item? This action cannot be undone.</p>
|
|
42
|
+
<p class="dialog-message">Are you sure you want to delete this item?{{&deleteRelationsWarning}} This action cannot be undone.</p>
|
|
43
43
|
<div class="dialog-actions">
|
|
44
44
|
<button type="button" class="button button-secondary dialog-cancel">Cancel</button>
|
|
45
45
|
<button type="button" class="button button-danger dialog-confirm">Delete</button>
|
|
@@ -116,6 +116,7 @@ class ContentsBuilder
|
|
|
116
116
|
async buildEntitiesContents()
|
|
117
117
|
{
|
|
118
118
|
let entitiesContents = {};
|
|
119
|
+
let reverseRelations = this.buildReverseRelationsMap();
|
|
119
120
|
for(let driverResource of this.resources()){
|
|
120
121
|
let templateTitle = this.translations.labels[driverResource.id()];
|
|
121
122
|
let entityName = (driverResource.id().replace(/_/g, '-'));
|
|
@@ -129,6 +130,7 @@ class ContentsBuilder
|
|
|
129
130
|
let editProperties = Object.keys(driverResource.options.properties);
|
|
130
131
|
editProperties.splice(editProperties.indexOf(idProperty), 1);
|
|
131
132
|
let entityId = driverResource.id();
|
|
133
|
+
let deleteRelationsWarning = this.fetchDeleteRelationsWarning(entityId, reverseRelations);
|
|
132
134
|
let filters = driverResource.options.filterProperties.map((property) => {
|
|
133
135
|
return {
|
|
134
136
|
propertyKey: property,
|
|
@@ -174,6 +176,7 @@ class ContentsBuilder
|
|
|
174
176
|
list: '{{&list}}',
|
|
175
177
|
pagination: '{{&pagination}}',
|
|
176
178
|
extraContent: '{{&extraContentForList}}'+extraContentForList,
|
|
179
|
+
deleteRelationsWarning,
|
|
177
180
|
}
|
|
178
181
|
),
|
|
179
182
|
view: await this.render(
|
|
@@ -189,7 +192,8 @@ class ContentsBuilder
|
|
|
189
192
|
entityNewRoute: '{{&entityNewRoute}}',
|
|
190
193
|
extraContentTop: '{{&extraContentForViewTop}}',
|
|
191
194
|
extraContentBottom: '{{&extraContentForViewBottom}}'+extraContentForView,
|
|
192
|
-
extraFormContent: '{{&extraFormContentForView}}'+extraFormContentForView
|
|
195
|
+
extraFormContent: '{{&extraFormContentForView}}'+extraFormContentForView,
|
|
196
|
+
deleteRelationsWarning,
|
|
193
197
|
}
|
|
194
198
|
),
|
|
195
199
|
edit: await this.render(
|
|
@@ -212,6 +216,41 @@ class ContentsBuilder
|
|
|
212
216
|
return entitiesContents;
|
|
213
217
|
}
|
|
214
218
|
|
|
219
|
+
buildReverseRelationsMap()
|
|
220
|
+
{
|
|
221
|
+
let reverseRelations = {};
|
|
222
|
+
for(let resource of this.resources()){
|
|
223
|
+
let childLabel = sc.get(this.translations.labels, resource.id(), resource.id());
|
|
224
|
+
this.addResourceReverseRelations(reverseRelations, resource.options.properties, childLabel);
|
|
225
|
+
}
|
|
226
|
+
return reverseRelations;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
addResourceReverseRelations(reverseRelations, properties, childLabel)
|
|
230
|
+
{
|
|
231
|
+
for(let propertyKey of Object.keys(properties)){
|
|
232
|
+
let property = properties[propertyKey];
|
|
233
|
+
if('reference' !== property.type){
|
|
234
|
+
continue;
|
|
235
|
+
}
|
|
236
|
+
if(!reverseRelations[property.reference]){
|
|
237
|
+
reverseRelations[property.reference] = [];
|
|
238
|
+
}
|
|
239
|
+
if(-1 === reverseRelations[property.reference].indexOf(childLabel)){
|
|
240
|
+
reverseRelations[property.reference].push(childLabel);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
fetchDeleteRelationsWarning(entityId, reverseRelations)
|
|
246
|
+
{
|
|
247
|
+
let childLabels = sc.get(reverseRelations, entityId, []);
|
|
248
|
+
if(0 === childLabels.length){
|
|
249
|
+
return '';
|
|
250
|
+
}
|
|
251
|
+
return ' '+this.translations.messages.confirmDeleteRelations+' '+[...childLabels].sort().join(', ')+'.';
|
|
252
|
+
}
|
|
253
|
+
|
|
215
254
|
async render(content, params)
|
|
216
255
|
{
|
|
217
256
|
return await this.renderCallback(content, params);
|
|
@@ -17,7 +17,8 @@ module.exports.DefaultTranslations = {
|
|
|
17
17
|
+' Find the source code or create an issue in GitHub',
|
|
18
18
|
reldensLoading: 'Loading...',
|
|
19
19
|
confirmClearCacheMessage: 'Are you sure you want to clear all cache? This action cannot be undone.',
|
|
20
|
-
clearCacheWarning: 'This will clear all cached routes and may impact site performance temporarily.'
|
|
20
|
+
clearCacheWarning: 'This will clear all cached routes and may impact site performance temporarily.',
|
|
21
|
+
confirmDeleteRelations: 'The following related records will also be deleted:'
|
|
21
22
|
},
|
|
22
23
|
labels: {
|
|
23
24
|
navigation: 'Reldens - CMS',
|