This commit is contained in:
Yuri Kuznetsov
2022-06-10 20:29:29 +03:00
parent cd953b47fe
commit 69ef1bf275
7 changed files with 370 additions and 67 deletions
+15 -2
View File
@@ -37,16 +37,29 @@
this.config = config;
};
_.extend(CollectionFactory.prototype, /** @lends Espo.CollectionFactory */ {
_.extend(CollectionFactory.prototype, /** @lends Espo.CollectionFactory.prototype */ {
/**
* @private
*/
loader: null,
/**
* @private
*/
modelFactory: null,
/**
* @private
*/
recordListMaxSizeLimit: 200,
/**
* @param {string} name Entity Type.
* Create a collection.
*
* @param {string} name An entity Type.
* @param {Function} [callback] Deprecated.
* @param {Object} [context] Deprecated.
* @returns {Promise<Espo.Collection>}
*/
create: function (name, callback, context) {
+6 -6
View File
@@ -32,7 +32,7 @@ define('collection', [], function () {
* Add a model or models. Firing an `add` event for each model, and an `update` event afterwards.
*
* @function add
* @memberof Backbone.Collection
* @memberof Backbone.Collection.prototype
* @param {Backbone.Model|Backbone.Model[]} models A model or models.
* @param {Object} [options] Options.
*/
@@ -42,7 +42,7 @@ define('collection', [], function () {
* unless `{silent: true}`.
*
* @function remove
* @memberof Backbone.Collection
* @memberof Backbone.Collection.prototype
* @param {Backbone.Model|Backbone.Model[]|string|string[]} models A model, models, ID or IDs.
* @param {Object} [options] Options.
*/
@@ -51,7 +51,7 @@ define('collection', [], function () {
* Append a model.
*
* @function push
* @memberof Backbone.Collection
* @memberof Backbone.Collection.prototype
* @param {Backbone.Model} model A model.
* @param {Object} [options] Options.
*/
@@ -60,19 +60,19 @@ define('collection', [], function () {
* Remove and return the last model from the collection.
*
* @function pop
* @memberof Backbone.Collection
* @memberof Backbone.Collection.prototype
* @param {Object} [options] Options.
*/
/**
* @class Espo.Collection
* @extends Backbone.Collection
* @extends Backbone.Collection.prototype
* @mixes Backbone.Events
*
* @property {number} length - A number of records.
* @property {Espo.Model[]} models - Models.
*/
var Collection = Backbone.Collection.extend(/** @lends Espo.Collection */ {
var Collection = Backbone.Collection.extend(/** @lends Espo.Collection.prototype */ {
/**
* An entity type.
+68 -18
View File
@@ -28,6 +28,11 @@
define('controller', [], function () {
/**
* @callback Espo.Controller.viewCallback
* @param {Espo.View} view A view.
*/
/**
* Controller. Views, Models and Collections are created here.
*
@@ -65,50 +70,63 @@ define('controller', [], function () {
this.set('masterRendered', false);
};
_.extend(Controller.prototype, /** @lends Espo.Controller */ {
_.extend(Controller.prototype, /** @lends Espo.Controller.prototype */ {
/**
* A default action.
*
* @param {string}
*/
defaultAction: 'index',
/**
* A name.
*
* @param {(string|false)}
*/
name: false,
/**
* Params.
*
* @param {Object}
*/
params: null,
/**
* A view factory.
*
* @param {Bull.ViewFactory}
*/
viewFactory: null,
/**
* A model factory.
*
* @param {Espo.ModelFactory}
* @protected
*/
modelFactory: null,
/**
* A controller factory.
*
* @param {Espo.ControllerFactory}
* @protected
*/
controllerFactory: null,
/**
* Initialize.
*
* @protected
*/
initialize: function () {},
/**
* Set the router.
*
* @internal
* @param {Espo.Router} router
*/
setRouter: function (router) {
@@ -116,6 +134,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Models.Settings}
*/
getConfig: function () {
@@ -123,6 +142,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Models.User}
*/
getUser: function () {
@@ -130,6 +150,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Models.Preferences}
*/
getPreferences: function () {
@@ -137,6 +158,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Acl}
*/
getAcl: function () {
@@ -144,6 +166,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Cache}
*/
getCache: function () {
@@ -151,6 +174,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Router}
*/
getRouter: function () {
@@ -158,6 +182,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Storage}
*/
getStorage: function () {
@@ -165,6 +190,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.Metadata}
*/
getMetadata: function () {
@@ -172,6 +198,7 @@ define('controller', [], function () {
},
/**
* @protected
* @returns {Espo.DateTime}
*/
getDateTime: function () {
@@ -180,7 +207,8 @@ define('controller', [], function () {
/**
* Get a parameter of all controllers.
* @param {string} key
*
* @param {string} key A key.
* @return {*} Null if doesn't exist.
*/
get: function (key) {
@@ -192,8 +220,9 @@ define('controller', [], function () {
},
/**
* Set a paramer for all controllers.
* @param {key} Name of view.
* Set a parameter for all controllers.
*
* @param {string} key A name of a view.
* @param {*} value
*/
set: function (key, value) {
@@ -202,7 +231,8 @@ define('controller', [], function () {
/**
* Unset a parameter.
* @param {string} key
*
* @param {string} key A key.
*/
unset: function (key) {
delete this.params[key];
@@ -210,7 +240,8 @@ define('controller', [], function () {
/**
* Has a parameter.
* @param {string} key
*
* @param {string} key A key.
* @returns {boolean}
*/
has: function (key) {
@@ -219,8 +250,9 @@ define('controller', [], function () {
/**
* Get a stored main view.
* @param {string} key
* @returns {Espo.View|null}
*
* @param {string} key A key.
* @returns {?Espo.View}
*/
getStoredMainView: function (key) {
return this.get('storedMainView-' + key);
@@ -251,8 +283,9 @@ define('controller', [], function () {
/**
* Store a main view.
* @param {string} key
* @param {Espo.View} view
*
* @param {string} key A key.
* @param {Espo.View} view A view.
*/
storeMainView: function (key, view) {
this.set('storedMainView-' + key, view);
@@ -287,13 +320,17 @@ define('controller', [], function () {
/**
* Check access to an action.
* @param {string} action
*
* @param {string} action An action.
* @returns {boolean}
*/
checkAccess: function (action) {
return true;
},
/**
* Process access check to the controller.
*/
handleAccessGlobal: function () {
if (!this.checkAccessGlobal()) {
throw new Espo.Exceptions.AccessDenied("Denied access to '" + this.name + "'");
@@ -302,6 +339,7 @@ define('controller', [], function () {
/**
* Check access to the controller.
*
* @returns {boolean}
*/
checkAccessGlobal: function () {
@@ -309,7 +347,9 @@ define('controller', [], function () {
},
/**
* @param {string} action
* Check access to an action. Throwing an exception.
*
* @param {string} action An action.
*/
handleCheckAccess: function (action) {
if (!this.checkAccess(action)) {
@@ -327,6 +367,8 @@ define('controller', [], function () {
},
/**
* Process an action.
*
* @param {string} action
* @param {Object} options
*/
@@ -357,7 +399,8 @@ define('controller', [], function () {
/**
* Create a master view, render if not already rendered.
* @param {Function<Espo.View>} callback Master view will be argument for this.
*
* @param {Espo.Controller.viewCallback} callback A callback with a created master view.
*/
master: function (callback) {
let entire = this.get('entire');
@@ -397,9 +440,9 @@ define('controller', [], function () {
/**
* Create a main view in the master.
* @param {String} view Name of view.
* @param {String} view A view name.
* @param {Object} options Options for view.
* @param {Function<Espo.View>|null} [callback]
* @param {Espo.Controller.viewCallback} [callback] A callback with a created view.
* @param {boolean} [useStored] Use a stored view if available.
* @param {boolean} [storedKey] A stored view key.
*/
@@ -512,6 +555,9 @@ define('controller', [], function () {
});
},
/**
* Show a loading notify-message.
*/
showLoadingNotification: function () {
let master = this.get('master');
@@ -520,6 +566,9 @@ define('controller', [], function () {
}
},
/**
* Hide a loading notify-message.
*/
hideLoadingNotification: function () {
let master = this.get('master');
@@ -530,9 +579,10 @@ define('controller', [], function () {
/**
* Create a view in the <body> element.
* @param {String} view Name of view.
* @param {Object} options Options for view.
* @param {Function<Espo.View>}
*
* @param {String} view A view name.
* @param {Object} options Options for a view.
* @param {Espo.Controller.viewCallback} [callback] A callback with a created view.
*/
entire: function (view, options, callback) {
let master = this.get('master');
+24 -2
View File
@@ -39,20 +39,39 @@ define('model-factory', [], function () {
this.seeds = {};
};
_.extend(ModelFactory.prototype, /** @lends Espo.ModelFactory */ {
_.extend(ModelFactory.prototype, /** @lends Espo.ModelFactory.prototype */ {
/**
* @private
*/
loader: null,
/**
* @private
*/
metadata: null,
/**
* @private
*/
seeds: null,
/**
* @private
*/
dateTime: null,
/**
* @private
*/
user: null,
/**
* @param {string} name Entity Type.
* Create a model.
*
* @param {string} name An entity type.
* @param {Function} [callback] Deprecated.
* @param {Object} [context] Deprecated.
* @returns {Promise<Espo.Model>}
*/
create: function (name, callback, context) {
@@ -71,6 +90,9 @@ define('model-factory', [], function () {
});
},
/**
* @private
*/
getSeed: function (name, callback) {
if ('name' in this.seeds) {
callback(this.seeds[name]);
+35 -13
View File
@@ -34,7 +34,7 @@ define('model', [], function () {
* Save values to the backend.
*
* @function save
* @memberof Backbone.Model
* @memberof Backbone.Model.prototype
* @param {Object} [attributes] Attribute values.
* @param {Object} [options] Options.
* @returns {Promise}
@@ -44,7 +44,7 @@ define('model', [], function () {
* Whether an attribute is changed. To be used only within a callback of a 'change' event listener.
*
* @function changed
* @memberof Backbone.Model
* @memberof Backbone.Model.prototype
* @param {string} attribute An attribute name.
* @returns {boolean}
*/
@@ -54,7 +54,7 @@ define('model', [], function () {
* Fires a `change` event unless `silent` is passed as an option.
*
* @function clear
* @memberof Backbone.Model
* @memberof Backbone.Model.prototype
* @param {Object} [options] Options.
*/
@@ -67,7 +67,7 @@ define('model', [], function () {
* @property {Object} attributes - Attribute values.
* @property {string} cid - An ID unique among all models.
*/
let Model = Dep.extend(/** @lends Espo.Model */{
let Model = Dep.extend(/** @lends Espo.Model.prototype */{
/**
* A root URL.
@@ -81,8 +81,14 @@ define('model', [], function () {
*/
name: null,
/**
* @private
*/
dateTime: null,
/**
* @private
*/
_user: null,
/**
@@ -91,6 +97,9 @@ define('model', [], function () {
*/
defs: null,
/**
* @protected
*/
initialize: function () {
this.urlRoot = this.urlRoot || this.name;
@@ -164,7 +173,7 @@ define('model', [], function () {
},
/**
* Is new.
* Whether is new.
*
* @returns {boolean}
*/
@@ -173,6 +182,8 @@ define('model', [], function () {
},
/**
* Set defs.
*
* @param {Object} defs
*/
setDefs: function (defs) {
@@ -239,6 +250,8 @@ define('model', [], function () {
},
/**
* @protected
*
* @param {*} defaultValue
* @returns {*}
* @deprecated
@@ -369,8 +382,8 @@ define('model', [], function () {
/**
* Get a link param.
*
* @param {string} link
* @param {string} param
* @param {string} link A link.
* @param {string} param A param.
* @returns {*}
*/
getLinkParam: function (link, param) {
@@ -386,7 +399,7 @@ define('model', [], function () {
/**
* Is a field read-only.
*
* @param {string} field
* @param {string} field A field.
* @returns {bool}
*/
isFieldReadOnly: function (field) {
@@ -396,7 +409,7 @@ define('model', [], function () {
/**
* If a field required.
*
* @param {string} field
* @param {string} field A field.
* @returns {bool}
*/
isRequired: function (field) {
@@ -406,7 +419,7 @@ define('model', [], function () {
/**
* Get IDs of a link-multiple field.
*
* @param {type} field
* @param {type} field A link-multiple field name.
* @returns {string[]}
*/
getLinkMultipleIdList: function (field) {
@@ -416,17 +429,25 @@ define('model', [], function () {
/**
* Get team IDs.
*
* @param {type} field
* @returns {string[]}
*/
getTeamIdList: function () {
return this.get('teamsIds') || [];
},
/**
* @protected
* @returns {Espo.DateTime}
*/
getDateTime: function () {
return this.dateTime;
},
/**
* @protected
* @returns {Espo.Models.User}
*/
getUser: function () {
return this._user;
},
@@ -434,7 +455,7 @@ define('model', [], function () {
/**
* Whether has a field.
*
* @param {string} field
* @param {string} field A field.
* @returns {boolean}
*/
hasField: function (field) {
@@ -444,7 +465,7 @@ define('model', [], function () {
/**
* Whether has a link.
*
* @param {string} field
* @param {string} link A link.
* @returns {boolean}
*/
hasLink: function (link) {
@@ -476,6 +497,7 @@ define('model', [], function () {
/**
* Fetch values from the backend.
*
* @param {Object} options Options.
* @returns {Promise<Object>}
*/
+97 -16
View File
@@ -32,8 +32,11 @@ define('router', [], function () {
* @class Espo.Router
* @mixes Espo.Events
*/
let Router = Backbone.Router.extend(/** @lends Espo.Router */ {
let Router = Backbone.Router.extend(/** @lends Espo.Router.prototype */ {
/**
* @private
*/
routeList: [
{
route: "clearCache",
@@ -81,8 +84,14 @@ define('router', [], function () {
},
],
/**
* @private
*/
_bindRoutes: function() {},
/**
* @private
*/
setupRoutes: function () {
this.routeParams = {};
@@ -117,18 +126,48 @@ define('router', [], function () {
});
},
/**
* @private
*/
_last: null,
/**
* Whether a confirm-leave-out was set.
*
* @public
* @property {boolean}
*/
confirmLeaveOut: false,
/**
* Whether back has been processed.
*
* @public
* @property {boolean}
*/
backProcessed: false,
/**
* @property {string}
* @internal
*/
confirmLeaveOutMessage: 'Are you sure?',
/**
* @property {string}
* @internal
*/
confirmLeaveOutConfirmText: 'Yes',
/**
* @property {string}
* @internal
*/
confirmLeaveOutCancelText: 'No',
/**
* @private
*/
initialize: function (options) {
this.options = options || {};
this.setupRoutes();
@@ -136,33 +175,33 @@ define('router', [], function () {
this.history = [];
let detectBackOrForward = (onBack, onForward) => {
hashHistory = [window.location.hash];
historyLength = window.history.length;
let hashHistory = [window.location.hash];
let historyLength = window.history.length;
return function () {
let hash = window.location.hash, length = window.history.length;
if (hashHistory.length && historyLength === length) {
if (hashHistory[hashHistory.length - 2] === hash) {
hashHistory = hashHistory.slice(0, -1);
if (onBack) {
onBack();
}
}
else {
hashHistory.push(hash);
if (onForward) {
onForward();
}
return;
}
}
else {
hashHistory.push(hash);
historyLength = length;
if (onForward) {
onForward();
}
return;
}
hashHistory.push(hash);
};
};
@@ -203,10 +242,14 @@ define('router', [], function () {
return '#' + Backbone.history.fragment;
},
/**
* @callback Espo.Router.checkConfirmLeaveOutCallback
*/
/**
* Process confirm-leave-out.
*
* @param {Function} callback Proceed if confirmed.
* @param {Espo.Router.checkConfirmLeaveOutCallback} callback Proceed if confirmed.
* @param {?Object} [context] A context.
* @param {boolean} [navigateBack] To navigate back if not confirmed.
*/
@@ -255,6 +298,9 @@ define('router', [], function () {
callback.call(context);
},
/**
* @private
*/
route: function (route, name, callback) {
let routeOriginal = route;
@@ -304,6 +350,9 @@ define('router', [], function () {
return this;
},
/**
* @private
*/
execute: function (callback, args, name, routeOriginal, options) {
this.checkConfirmLeaveOut(function () {
if (name === 'defaultRoute') {
@@ -319,7 +368,7 @@ define('router', [], function () {
/**
* Navigate.
*
* @param {string} fragment
* @param {string} fragment An URL fragment.
* @param {Options} options Options: trigger, replace.
*/
navigate: function (fragment, options) {
@@ -346,6 +395,9 @@ define('router', [], function () {
this.navigate(url, options);
},
/**
* @private
*/
_parseOptionsParams: function (string) {
if (!string) {
return {};
@@ -372,6 +424,9 @@ define('router', [], function () {
return options;
},
/**
* @private
*/
defaultRoute: function (params, options) {
let controller = params.controller || options.controller;
let action = params.action || options.action;
@@ -379,6 +434,9 @@ define('router', [], function () {
this.dispatch(controller, action, options);
},
/**
* @private
*/
record: function (controller, action, id, options) {
options = this._parseOptionsParams(options);
@@ -387,36 +445,60 @@ define('router', [], function () {
this.dispatch(controller, action, options);
},
/**
* @private
*/
view: function (controller, id, options) {
this.record(controller, 'view', id, options);
},
/**
* @private
*/
edit: function (controller, id, options) {
this.record(controller, 'edit', id, options);
},
/**
* @private
*/
create: function (controller, options) {
this.record(controller, 'create', null, options);
},
/**
* @private
*/
action: function (controller, action, options) {
this.dispatch(controller, action, this._parseOptionsParams(options));
},
/**
* @private
*/
defaultAction: function (controller) {
this.dispatch(controller, null);
},
/**
* @private
*/
home: function () {
this.dispatch('Home', null);
},
/**
* Process `logout` route.
*/
logout: function () {
this.dispatch(null, 'logout');
this.navigate('', {trigger: false});
},
/**
* @private
*/
clearCache: function () {
this.dispatch(null, 'clearCache');
},
@@ -452,7 +534,6 @@ define('router', [], function () {
});
return Router;
});
function isIOS9UIWebView() {
+125 -10
View File
@@ -34,24 +34,34 @@ define('view', [], function () {
* @class Espo.View
* @extends Bull.View
*
* @property {(Espo.Model|undefined)} model - A model.
* @property {(Espo.Collection|undefined)} collection - A collection.
* @property {?Espo.Model} model - A model.
* @property {?Espo.Collection} collection - A collection.
* @property {Object} options - Passed options.
*/
return Bull.View.extend(/** @lends Espo.View */{
return Bull.View.extend(/** @lends Espo.View.prototype */{
/**
* @callback Espo.View.actionHandlerCallback
* @param {jQuery.Event} e
*/
/**
* Add a DOM action event handler.
*
* @param {string} action
* @param {function} handler
* @param {Espo.View.actionHandlerCallback} handler
*/
addActionHandler: function (action, handler) {
this.events = this.events || {};
var fullAction = 'click button[data-action=\"'+action+'\"]';
let fullAction = 'click button[data-action=\"'+action+'\"]';
this.events[fullAction] = handler;
},
/**
* Escape a string.
*
* @param {string} string
* @returns {string}
*/
@@ -59,6 +69,15 @@ define('view', [], function () {
return Handlebars.Utils.escapeExpression(string);
},
/**
* Show a notify-message.
*
* @deprecated Use `Espo.Ui.notify`.
* @param {string} label
* @param {string} [type]
* @param {number} [timeout]
* @param {string} [scope]
*/
notify: function (label, type, timeout, scope) {
if (label == false) {
Espo.Ui.notify(false);
@@ -79,6 +98,8 @@ define('view', [], function () {
},
/**
* Get the view-helper.
*
* @returns {Espo.ViewHelper}
*/
getHelper: function () {
@@ -86,6 +107,8 @@ define('view', [], function () {
},
/**
* Get the current user.
*
* @returns {Espo.Models.User}
*/
getUser: function () {
@@ -95,6 +118,8 @@ define('view', [], function () {
},
/**
* Get the preferences.
*
* @returns {Espo.Models.Preferences}
*/
getPreferences: function () {
@@ -104,6 +129,8 @@ define('view', [], function () {
},
/**
* Get the config.
*
* @returns {Espo.Models.Settings}
*/
getConfig: function () {
@@ -113,6 +140,8 @@ define('view', [], function () {
},
/**
* Get the ACL.
*
* @returns {Espo.Acl}
*/
getAcl: function () {
@@ -122,6 +151,8 @@ define('view', [], function () {
},
/**
* Get the model factory.
*
* @returns {Espo.ModelFactory}
*/
getModelFactory: function () {
@@ -131,6 +162,8 @@ define('view', [], function () {
},
/**
* Get the collection factory.
*
* @returns {Espo.CollectionFactory}
*/
getCollectionFactory: function () {
@@ -140,6 +173,8 @@ define('view', [], function () {
},
/**
* Get the router.
*
* @returns {Espo.Router}
*/
getRouter: function () {
@@ -149,6 +184,8 @@ define('view', [], function () {
},
/**
* Get the storage-util.
*
* @returns {Espo.Storage}
*/
getStorage: function () {
@@ -167,6 +204,8 @@ define('view', [], function () {
},
/**
* Get the language-util.
*
* @returns {Espo.Language}
*/
getLanguage: function () {
@@ -176,6 +215,8 @@ define('view', [], function () {
},
/**
* Get metadata.
*
* @returns {Espo.Metadata}
*/
getMetadata: function () {
@@ -185,6 +226,8 @@ define('view', [], function () {
},
/**
* Get the cache-util.
*
* @returns {Espo.Cache}
*/
getCache: function () {
@@ -194,6 +237,8 @@ define('view', [], function () {
},
/**
* Get the date-time util.
*
* @returns {Espo.DateTime}
*/
getDateTime: function () {
@@ -203,6 +248,8 @@ define('view', [], function () {
},
/**
* Get the number-util.
*
* @returns {Espo.Number}
*/
getNumberUtil: function () {
@@ -212,6 +259,8 @@ define('view', [], function () {
},
/**
* Get the field manager.
*
* @returns {Espo.FieldManager}
*/
getFieldManager: function () {
@@ -221,6 +270,8 @@ define('view', [], function () {
},
/**
* Get the base-controller.
*
* @returns {Espo.Controllers.Base}
*/
getBaseController: function () {
@@ -230,6 +281,8 @@ define('view', [], function () {
},
/**
* Get the theme manager.
*
* @returns {Espo.ThemeManager}
*/
getThemeManager: function () {
@@ -238,12 +291,18 @@ define('view', [], function () {
}
},
/**
* Update a page title. Supposed to be overridden if needed.
*/
updatePageTitle: function () {
var title = this.getConfig().get('applicationName') || 'EspoCRM';
this.setPageTitle(title);
},
/**
* Set a page title.
*
* @param {string} title
*/
setPageTitle: function (title) {
@@ -251,9 +310,11 @@ define('view', [], function () {
},
/**
* @param {string} label
* @param {string} category
* @param {string} scope
* Translate a label.
*
* @param {string} label Label.
* @param {string} category Category.
* @param {string} scope Scope.
* @returns {string}
*/
translate: function (label, category, scope) {
@@ -261,12 +322,22 @@ define('view', [], function () {
},
/**
* Get a base path.
* @returns {string}
*/
getBasePath: function () {
return this._helper.basePath || '';
},
/**
* Ajax request.
*
* @param {string} url An URL.
* @param {string} type A method.
* @param {any} [data] Data.
* @param {Object} [options] Options.
* @returns {Promise<any>}
*/
ajaxRequest: function (url, type, data, options) {
options = options || {};
@@ -283,6 +354,14 @@ define('view', [], function () {
return xhr;
},
/**
* POST request.
*
* @param {string} url An URL.
* @param {any} [data] Data.
* @param {Object} [options] Options.
* @returns {Promise<any>}
*/
ajaxPostRequest: function (url, data, options) {
if (data) {
data = JSON.stringify(data);
@@ -291,6 +370,14 @@ define('view', [], function () {
return this.ajaxRequest(url, 'POST', data, options);
},
/**
* PATCH request.
*
* @param {string} url An URL.
* @param {any} [data] Data.
* @param {Object} [options] Options.
* @returns {Promise<any>}
*/
ajaxPatchRequest: function (url, data, options) {
if (data) {
data = JSON.stringify(data);
@@ -299,6 +386,14 @@ define('view', [], function () {
return this.ajaxRequest(url, 'PATCH', data, options);
},
/**
* PUT request.
*
* @param {string} url An URL.
* @param {any} [data] Data.
* @param {Object} [options] Options.
* @returns {Promise<any>}
*/
ajaxPutRequest: function (url, data, options) {
if (data) {
data = JSON.stringify(data);
@@ -307,10 +402,26 @@ define('view', [], function () {
return this.ajaxRequest(url, 'PUT', data, options);
},
/**
* GET request.
*
* @param {string} url An URL.
* @param {any} [data] Data.
* @param {Object} [options] Options.
* @returns {Promise<any>}
*/
ajaxGetRequest: function (url, data, options) {
return this.ajaxRequest(url, 'GET', data, options);
},
/**
* DELETE request.
*
* @param {string} url An URL.
* @param {any} [data] Data.
* @param {Object} [options] Options.
* @returns {Promise<any>}
*/
ajaxDeleteRequest: function (url, data, options) {
if (data) {
data = JSON.stringify(data);
@@ -320,8 +431,12 @@ define('view', [], function () {
},
/**
* @param {(string|Object)} o
* @returns {Promise}
* Show a confirmation dialog.
*
* @param {(string|Object)} o A message or options.
* @param [callback]
* @param [context]
* @returns {Promise} To be resolved if confirmed.
*/
confirm: function (o, callback, context) {
let message;