Skip to content

EspoCRM – Open Source CRM Application

syckBackWithModel param

Yuri Kuznetsovbd3e06d40367
diff --git a/client/src/views/record/panels/relationship.js b/client/src/views/record/panels/relationship.js
index aa58a7326f..93014d2d1c 100644
--- a/client/src/views/record/panels/relationship.js
+++ b/client/src/views/record/panels/relationship.js
@@ -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;
diff --git a/schema/metadata/clientDefs.json b/schema/metadata/clientDefs.json
index 7293d541dd..d69124d5f5 100644
--- a/schema/metadata/clientDefs.json
+++ b/schema/metadata/clientDefs.json
@@ -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."