Skip to content

EspoCRM – Open Source CRM Application

model-sync set

Yuri Kuznetsovdf6b5ae0434d
diff --git a/client/src/model.js b/client/src/model.js
index 96b0feecac..320d42efe7 100644
--- a/client/src/model.js
+++ b/client/src/model.js
@@ -276,7 +276,9 @@ class Model {
* @param {{
* silent?: boolean,
* unset?: boolean,
+ * sync?: boolean,
* } & Object.<string, *>} [options] Options. `silent` won't trigger a `change` event.
+ * `sync` can be used to emulate syncing.
* @return {this}
* @fires Model#change Unless `{silent: true}`.
* @copyright Credits to Backbone.js.
@@ -330,6 +332,14 @@ class Model {
}
}
+ if (options.sync) {
+ if (this.collection) {
+ const modelSyncOptions = {...options, action: 'set'};
+
+ this.collection.trigger('model-sync', this, modelSyncOptions);
+ }
+ }
+
if (changing) {
return this;
}
diff --git a/client/src/views/record/list.js b/client/src/views/record/list.js
index 07be46eeab..063a90dfc7 100644
--- a/client/src/views/record/list.js
+++ b/client/src/views/record/list.js
@@ -2165,7 +2165,7 @@ class ListRecordView extends View {
return;
}
- if (o.action === 'fetch' || o.action === 'save') {
+ if (o.action === 'set' || o.action === 'fetch' || o.action === 'save') {
model.setMultiple(m.getClonedAttributes(), o);
}
});