@reldens/cms 0.68.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>
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
{{&extraContentTop}}
|
|
16
16
|
</div>
|
|
17
17
|
{{#fields}}
|
|
18
|
-
<div class="view-field">
|
|
18
|
+
<div class="view-field" data-property="{{&propertyKey}}">
|
|
19
19
|
<span class="field-name">{{&name}}</span>
|
|
20
20
|
<span class="field-value">{{&value}}</span>
|
|
21
21
|
</div>
|
|
@@ -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,
|
|
@@ -138,6 +140,7 @@ class ContentsBuilder
|
|
|
138
140
|
});
|
|
139
141
|
let fields = driverResource.options.showProperties.map((property) => {
|
|
140
142
|
return {
|
|
143
|
+
propertyKey: property,
|
|
141
144
|
name: this.fetchTranslation(property, entityId),
|
|
142
145
|
value: '{{&'+property+'}}'
|
|
143
146
|
};
|
|
@@ -173,6 +176,7 @@ class ContentsBuilder
|
|
|
173
176
|
list: '{{&list}}',
|
|
174
177
|
pagination: '{{&pagination}}',
|
|
175
178
|
extraContent: '{{&extraContentForList}}'+extraContentForList,
|
|
179
|
+
deleteRelationsWarning,
|
|
176
180
|
}
|
|
177
181
|
),
|
|
178
182
|
view: await this.render(
|
|
@@ -188,7 +192,8 @@ class ContentsBuilder
|
|
|
188
192
|
entityNewRoute: '{{&entityNewRoute}}',
|
|
189
193
|
extraContentTop: '{{&extraContentForViewTop}}',
|
|
190
194
|
extraContentBottom: '{{&extraContentForViewBottom}}'+extraContentForView,
|
|
191
|
-
extraFormContent: '{{&extraFormContentForView}}'+extraFormContentForView
|
|
195
|
+
extraFormContent: '{{&extraFormContentForView}}'+extraFormContentForView,
|
|
196
|
+
deleteRelationsWarning,
|
|
192
197
|
}
|
|
193
198
|
),
|
|
194
199
|
edit: await this.render(
|
|
@@ -211,6 +216,41 @@ class ContentsBuilder
|
|
|
211
216
|
return entitiesContents;
|
|
212
217
|
}
|
|
213
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
|
+
|
|
214
254
|
async render(content, params)
|
|
215
255
|
{
|
|
216
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',
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reldens/cms",
|
|
3
3
|
"scope": "@reldens",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.70.0",
|
|
5
5
|
"description": "Reldens - CMS",
|
|
6
6
|
"author": "Damian A. Pastorini",
|
|
7
7
|
"license": "MIT",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@reldens/server-utils": "^0.52.0",
|
|
38
|
-
"@reldens/storage": "^0.
|
|
38
|
+
"@reldens/storage": "^0.100.0",
|
|
39
39
|
"@reldens/utils": "^0.56.0",
|
|
40
40
|
"dotenv": "17.4.2",
|
|
41
41
|
"mustache": "4.2.0"
|