mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
change event action
This commit is contained in:
@@ -36,7 +36,7 @@ import _ from 'underscore';
|
||||
*
|
||||
* @event Model#change
|
||||
* @param {Model} model A model.
|
||||
* @param {Object.<string, *>} o Options.
|
||||
* @param {Record.<string, *> & {action?: string|'ui'|'save'|'fetch'|'cancel-edit'}} o Options.
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -290,6 +290,14 @@ class Model {
|
||||
|
||||
options = options || {};
|
||||
|
||||
if (options.ui && !options.action) {
|
||||
options.action = 'ui';
|
||||
}
|
||||
|
||||
if (!options.ui && options.action === 'ui') {
|
||||
options.ui = true;
|
||||
}
|
||||
|
||||
const changes = [];
|
||||
const changing = this._changing;
|
||||
|
||||
@@ -485,6 +493,9 @@ class Model {
|
||||
fetch(options) {
|
||||
options = {...options};
|
||||
|
||||
options.action = 'fetch';
|
||||
|
||||
// For bc.
|
||||
const success = options.success;
|
||||
|
||||
options.success = response => {
|
||||
@@ -496,8 +507,6 @@ class Model {
|
||||
success.call(options.context, this, response, options);
|
||||
}
|
||||
|
||||
options.action = 'fetch';
|
||||
|
||||
this.trigger('sync', this, response, options);
|
||||
|
||||
if (this.collection) {
|
||||
@@ -517,7 +526,8 @@ class Model {
|
||||
* @param {{
|
||||
* patch?: boolean,
|
||||
* wait?: boolean,
|
||||
* } & Object.<string, *>} [options] Options.
|
||||
* } & Object.<string, *>} [options] Options. Use `patch` to send a PATCH request. If `wait`, attributes will be
|
||||
* set only after the request is completed.
|
||||
* @returns {Promise<Object.<string, *>>}
|
||||
* @fires Model#sync
|
||||
* @copyright Credits to Backbone.js.
|
||||
@@ -542,6 +552,8 @@ class Model {
|
||||
responseAttributes = {...setAttributes, ...responseAttributes};
|
||||
}
|
||||
|
||||
options.action = 'save';
|
||||
|
||||
if (responseAttributes) {
|
||||
this.setMultiple(responseAttributes, options);
|
||||
}
|
||||
@@ -550,8 +562,6 @@ class Model {
|
||||
success.call(options.context, this, response, options);
|
||||
}
|
||||
|
||||
options.action = 'save';
|
||||
|
||||
this.trigger('sync', this, response, options);
|
||||
|
||||
if (this.collection) {
|
||||
|
||||
@@ -940,6 +940,7 @@ class BaseFieldView extends View {
|
||||
this.model.set(attributes, {
|
||||
ui: true,
|
||||
fromView: this,
|
||||
action: 'ui',
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -1375,7 +1376,7 @@ class BaseFieldView extends View {
|
||||
if (!noReset) {
|
||||
this.model.set(this.initialAttributes, {
|
||||
skipReRenderInEditMode: true,
|
||||
editCancel: true,
|
||||
action: 'cancel-edit',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1601,7 +1601,7 @@ class DetailRecordView extends BaseRecordView {
|
||||
|
||||
this.model.set(this.attributes, {
|
||||
skipReRenderInEditMode: skipReRender,
|
||||
editCancel: true,
|
||||
action: 'cancel-edit',
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user