Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 544x 544x 389x 293x 293x | 'use strict';
define([
'jquery',
'oro/mediator',
'routing'
], function (
$,
mediator,
Routing
) {
return {
/**
* Save an entity
*
* @param {String} code
* @param {Object} data
* @param {String} method
*
* @return {Promise}
*/
save: function (code, data, method) {
return $.ajax({
/* todo: remove ternary when all instances using this module will provide method parameter */
type: 'undefined' === typeof method ? 'POST' : method,
url: this.getUrl(code),
data: JSON.stringify(data)
}).then(function (entity) {
mediator.trigger('pim_enrich:form:entity:post_save', entity);
return entity;
}.bind(this));
},
/**
* Get the entity url
* @param {String} code
*
* @return {String}
*/
getUrl: function (code) {
return Routing.generate(__moduleConfig.url, {code: code});
}
};
}
);
|