remove related from list related

This commit is contained in:
Yuri Kuznetsov
2025-02-21 12:04:13 +02:00
parent a0a801a7c7
commit b465faf936
+32
View File
@@ -272,6 +272,7 @@ class ListRelatedView extends MainView {
);
this.addActionHandler('fullRefresh', () => this.actionFullRefresh());
this.addActionHandler('removeRelated', () => this.actionRemoveRelated());
}
/**
@@ -833,6 +834,37 @@ class ListRelatedView extends MainView {
Espo.Ui.notify();
}
/**
* @protected
* @param {{id: string}} data
* @return {Promise<void>}
*/
async actionRemoveRelated(data) {
const id = data.id;
await this.confirm({
message: this.translate('removeRecordConfirmation', 'messages'),
confirmText: this.translate('Remove'),
});
const model = this.collection.get(id);
if (!model) {
return;
}
Espo.Ui.notifyWait();
await model.destroy();
Espo.Ui.success(this.translate('Removed'));
this.collection.fetch().then(() => {});
this.model.trigger('after:unrelate');
this.model.trigger(`after:unrelate:${this.link}`);
}
}
export default ListRelatedView;