Merge branch 'fix'

This commit is contained in:
Yuri Kuznetsov
2025-06-16 16:43:47 +03:00
5 changed files with 74 additions and 45 deletions
+2 -1
View File
@@ -599,7 +599,8 @@ class Model {
/**
* Delete the record in the backend.
*
* @param {{wait?: boolean} & Object.<string, *>} [options] Options.
* @param {{wait?: boolean} & Object.<string, *>} [options] Options. If `wait`, unsubscribing and
* removal from the collection will wait for a successful response.
* @returns {Promise}
* @fires Model#sync
* @copyright Credits to Backbone.js.
+4 -1
View File
@@ -300,7 +300,10 @@ class ComposeEmailModalView extends EditModalView {
beforeCollapse() {
if (this.wasModified) {
this.actionSaveDraft({skipNotModifiedWarning: true})
.then(() => this.getRecordView().setConfirmLeaveOut(false));
.then(() => {
this.getRecordView().setConfirmLeaveOut(false);
this.getRouter().removeWindowLeaveOutObject(this);
});
}
return super.beforeCollapse();
+32 -19
View File
@@ -3523,7 +3523,12 @@ class ListRecordView extends View {
}
// noinspection JSUnusedGlobalSymbols
actionQuickRemove(data) {
/**
* @protected
* @param {{id?: string}} [data]
* @return {Promise<void>}
*/
async actionQuickRemove(data) {
data = data || {};
const id = data.id;
@@ -3533,6 +3538,11 @@ class ListRecordView extends View {
}
const model = this.collection.get(id);
const index = this.collection.indexOf(model);
if (!model) {
throw new Error("No model.");
}
if (!this.getAcl().checkModel(model, 'delete')) {
Espo.Ui.error(this.translate('Access denied'));
@@ -3540,27 +3550,30 @@ class ListRecordView extends View {
return;
}
this.confirm({
await this.confirm({
message: this.translate('removeRecordConfirmation', 'messages', this.scope),
confirmText: this.translate('Remove'),
}, () => {
this.collection.trigger('model-removing', id);
this.collection.remove(model);
Espo.Ui.notifyWait();
model.destroy({wait: true, fromList: true})
.then(() => {
Espo.Ui.success(this.translate('Removed'));
this.trigger('after:delete', model);
this.removeRecordFromList(id);
})
.catch(() => {
// @todo Revert to the same position.
this.collection.push(model);
});
});
this.collection.trigger('model-removing', id);
this.collection.remove(model);
Espo.Ui.notifyWait();
try {
await model.destroy({wait: true, fromList: true});
} catch (e) {
if (!this.collection.models.includes(model)) {
this.collection.add(model, {at: index});
}
return;
}
Espo.Ui.success(this.translate('Removed'));
this.trigger('after:delete', model);
this.removeRecordFromList(id);
}
/**
+33 -19
View File
@@ -821,31 +821,45 @@ class RelationshipPanelView extends BottomPanelView {
* A `remove-related` action.
*
* @protected
* @param {{id?: string}} [data]
* @return {Promise<void>}
*/
actionRemoveRelated(data) {
async actionRemoveRelated(data) {
const id = data.id;
this.confirm({
const model = this.collection.get(id);
const index = this.collection.indexOf(model);
if (!model) {
throw new Error("No model.");
}
await this.confirm({
message: this.translate('removeRecordConfirmation', 'messages'),
confirmText: this.translate('Remove'),
}, () => {
const model = this.collection.get(id);
Espo.Ui.notifyWait();
model
.destroy()
.then(() => {
Espo.Ui.success(this.translate('Removed'));
this.collection.fetch();
this.model.trigger('after:unrelate');
this.model.trigger('after:unrelate:' + this.link);
this.processSyncBack();
});
});
Espo.Ui.notifyWait();
try {
await model.destroy({wait: true});
} catch (e) {
if (!this.collection.models.includes(model)) {
this.collection.add(model, {at: index});
}
return;
}
Espo.Ui.success(this.translate('Removed'));
this.collection.fetch().then(() => {});
this.model.trigger('after:unrelate');
this.model.trigger(`after:unrelate:${this.link}`);
this.processSyncBack();
}
// noinspection JSUnusedGlobalSymbols
+3 -5
View File
@@ -4107,17 +4107,15 @@ body > .autocomplete-suggestions.text-search-suggestions {
width: var(--220px);
}
&:has(.popover-content > .list > table) {
padding-left: 0;
padding-right: 0;
}
.popover-content {
&:has(> .list > table) {
padding: 0;
}
> .list > table {
margin-left: var(--minus-1px);
margin-right: var(--minus-1px);
> tbody {
> tr {
> td:first-child {