Skip to content

Commit

Permalink
fix delete
Browse files Browse the repository at this point in the history
  • Loading branch information
Xziy committed Oct 28, 2024
1 parent b8faf7f commit 330f2f6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions libs/adminpanel/ProductMediaManager/ProductMediaManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class ProductMediaManager extends AbstractMediaManager_1.AbstractMediaManager {
sails.log.silly(`Starting setRelations for model: ${model}, modelId: ${modelId}, widgetName: ${widgetName}`);
// Debugging initial destruction query
let destroy = {};
destroy[`mediafile_${model}`] = modelId;
destroy[model] = modelId;
sails.log.silly(`Destroying selected media files with criteria:`, destroy);
await SelectedMediaFile.destroy(destroy).fetch();
// Debugging loop over data.list
Expand All @@ -25,8 +25,10 @@ class ProductMediaManager extends AbstractMediaManager_1.AbstractMediaManager {
init[`mediafile_${model}`] = widgetItem.id;
init[model] = modelId;
init["sortOrder"] = key + 1;
sails.log.silly(`Creating selected media file with data:`, init);
await SelectedMediaFile.create(init).fetch();
if (model && modelId) {
sails.log.silly(`Creating selected media file with data:`, init);
await SelectedMediaFile.create(init).fetch();
}
}
sails.log.debug(`Completed setRelations for model: ${model}, modelId: ${modelId}, widgetName: ${widgetName}`);
}
Expand Down
9 changes: 5 additions & 4 deletions libs/adminpanel/ProductMediaManager/ProductMediaManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class ProductMediaManager extends AbstractMediaManager {

// Debugging initial destruction query
let destroy: Record<string, string | number> = {};
destroy[`mediafile_${model}`] = modelId;
destroy[model] = modelId;
sails.log.silly(`Destroying selected media files with criteria:`, destroy);
await SelectedMediaFile.destroy(destroy).fetch();

Expand All @@ -32,9 +32,10 @@ export class ProductMediaManager extends AbstractMediaManager {
init[`mediafile_${model}`] = widgetItem.id;
init[model] = modelId;
init["sortOrder"] = key + 1;

sails.log.silly(`Creating selected media file with data:`, init);
await SelectedMediaFile.create(init).fetch();
if(model && modelId){
sails.log.silly(`Creating selected media file with data:`, init);
await SelectedMediaFile.create(init).fetch();
}
}

sails.log.debug(`Completed setRelations for model: ${model}, modelId: ${modelId}, widgetName: ${widgetName}`);
Expand Down

0 comments on commit 330f2f6

Please sign in to comment.