/
provider.js
59 lines (51 loc) · 1.28 KB
/
provider.js
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
48
49
50
51
52
53
54
55
56
57
58
59
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
define([
'underscore',
'uiElement',
'./client'
], function (_, Element, Client) {
'use strict';
return Element.extend({
defaults: {
clientConfig: {
urls: {
save: '${ $.submit_url }',
beforeSave: '${ $.validate_url }'
}
}
},
/**
* Initializes provider component.
*
* @returns {Provider} Chainable.
*/
initialize: function () {
this._super()
.initClient();
return this;
},
/**
* Initializes client component.
*
* @returns {Provider} Chainable.
*/
initClient: function () {
this.client = new Client(this.clientConfig);
return this;
},
/**
* Saves currently available data.
*
* @param {Object} [options] - Addtitional request options.
* @returns {Provider} Chainable.
*/
save: function (options) {
var data = this.get('data');
this.client.save(data, options);
return this;
}
});
});