remove related from list related
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user