syckBackWithModel param

This commit is contained in:
Yuri Kuznetsov
2025-06-04 10:16:25 +03:00
parent bf43ab05ff
commit bd3e06d403
2 changed files with 35 additions and 3 deletions
+31 -3
View File
@@ -390,6 +390,10 @@ class RelationshipPanelView extends BottomPanelView {
this.once('show', () => collection.fetch());
});
if (this.defs.syncBackWithModel) {
this.listenTo(view, 'after:save after:delete', () => this.processSyncBack());
}
});
});
@@ -750,8 +754,11 @@ class RelationshipPanelView extends BottomPanelView {
model: model,
})
.then(view => {
// @todo Move to afterSave?
this.listenTo(view, 'after:save', () => {
this.collection.fetch();
this.processSyncBack();
});
});
}
@@ -773,6 +780,8 @@ class RelationshipPanelView extends BottomPanelView {
id: id,
afterSave: () => {
this.collection.fetch();
this.processSyncBack();
},
});
}
@@ -801,6 +810,8 @@ class RelationshipPanelView extends BottomPanelView {
this.model.trigger('after:unrelate');
this.model.trigger('after:unrelate:' + this.link);
this.processSyncBack();
});
});
}
@@ -831,6 +842,8 @@ class RelationshipPanelView extends BottomPanelView {
this.model.trigger('after:unrelate');
this.model.trigger('after:unrelate:' + this.link);
this.processSyncBack();
});
});
}
@@ -857,6 +870,8 @@ class RelationshipPanelView extends BottomPanelView {
this.model.trigger('after:unrelate');
this.model.trigger('after:unrelate:' + this.link);
this.processSyncBack();
});
});
}
@@ -869,7 +884,22 @@ class RelationshipPanelView extends BottomPanelView {
actionCreateRelated() {
const helper = new CreateRelatedHelper(this);
helper.process(this.model, this.link);
helper.process(this.model, this.link, {
afterSave: () => {
this.processSyncBack();
},
});
}
/**
* @protected
*/
processSyncBack() {
if (!this.defs.syncBackWithModel || this.getHelper().webSocketManager) {
return;
}
this.model.fetch({highlight: true});
}
// noinspection JSUnusedGlobalSymbols
@@ -912,8 +942,6 @@ class RelationshipPanelView extends BottomPanelView {
this.defs.create = false;
}
}
export default RelationshipPanelView;
+4
View File
@@ -507,6 +507,10 @@
"type": "boolean",
"description": "Re-fetch records when the parent model is saved or refreshed by WebSocket."
},
"syncBackWithModel": {
"type": "boolean",
"description": "Re-fetch the parent model when the relationship is updated. Ignored if WebSocked is enabled."
},
"massSelect": {
"type": "boolean",
"description": "Allow mass select."