@reldens/cms 0.81.0 → 0.82.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.
@@ -246,21 +246,28 @@ class ContentsBuilder
246
246
  continue;
247
247
  }
248
248
  if(!reverseRelations[property.reference]){
249
- reverseRelations[property.reference] = [];
249
+ reverseRelations[property.reference] = {deleted: [], unlinked: []};
250
250
  }
251
- if(-1 === reverseRelations[property.reference].indexOf(childLabel)){
252
- reverseRelations[property.reference].push(childLabel);
251
+ let relationGroup = true === property.unlinkOnDelete ? 'unlinked' : 'deleted';
252
+ if(-1 === reverseRelations[property.reference][relationGroup].indexOf(childLabel)){
253
+ reverseRelations[property.reference][relationGroup].push(childLabel);
253
254
  }
254
255
  }
255
256
  }
256
257
 
257
258
  fetchDeleteRelationsWarning(entityId, reverseRelations)
258
259
  {
259
- let childLabels = sc.get(reverseRelations, entityId, []);
260
+ return this.buildRelationsSentence(entityId, reverseRelations, 'deleted', 'confirmDeleteRelations')
261
+ +this.buildRelationsSentence(entityId, reverseRelations, 'unlinked', 'confirmUnlinkRelations');
262
+ }
263
+
264
+ buildRelationsSentence(entityId, reverseRelations, relationGroup, messageKey)
265
+ {
266
+ let childLabels = sc.get(sc.get(reverseRelations, entityId, {}), relationGroup, []);
260
267
  if(0 === childLabels.length){
261
268
  return '';
262
269
  }
263
- return ' '+this.translations.messages.confirmDeleteRelations+' '+[...childLabels].sort().join(', ')+'.';
270
+ return ' '+this.translations.messages[messageKey]+' '+[...childLabels].sort().join(', ')+'.';
264
271
  }
265
272
 
266
273
  async render(content, params)
@@ -18,7 +18,8 @@ module.exports.DefaultTranslations = {
18
18
  reldensLoading: 'Loading...',
19
19
  confirmClearCacheMessage: 'Are you sure you want to clear all cache? This action cannot be undone.',
20
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
+ confirmDeleteRelations: 'The following related records will also be deleted:',
22
+ confirmUnlinkRelations: 'The following related records will be kept but unlinked from it:'
22
23
  },
23
24
  labels: {
24
25
  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.81.0",
4
+ "version": "0.82.0",
5
5
  "description": "Reldens - CMS",
6
6
  "author": "Damian A. Pastorini",
7
7
  "license": "MIT",