sdc_client 0.58.6 → 0.158.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.js.yml +2 -2
- package/.idea/inspectionProfiles/Project_Default.xml +17 -0
- package/.idea/workspace.xml +122 -23
- package/.readthedocs.yaml +13 -0
- package/dist/index.js +70 -51
- package/dist/ugly.index.js +1 -1
- package/docs/api-reference.rst +225 -0
- package/docs/conf.py +11 -0
- package/docs/controllers.rst +228 -0
- package/docs/events-and-dom.rst +120 -0
- package/docs/getting-started.rst +143 -0
- package/docs/index.rst +22 -0
- package/docs/models.rst +351 -0
- package/docs/overview.rst +66 -0
- package/docs/requirements.txt +1 -0
- package/eslint.config.js +60 -0
- package/gulp/gulp.jsx +15 -13
- package/package.json +13 -3
- package/src/index.js +44 -11
- package/src/simpleDomControl/AbstractSDC.js +287 -286
- package/src/simpleDomControl/sdc_controller.js +157 -132
- package/src/simpleDomControl/sdc_dom_events.js +99 -88
- package/src/simpleDomControl/sdc_events.js +39 -40
- package/src/simpleDomControl/sdc_main.js +88 -67
- package/src/simpleDomControl/sdc_model.js +1513 -0
- package/src/simpleDomControl/sdc_params.js +44 -29
- package/src/simpleDomControl/sdc_server_call.js +153 -154
- package/src/simpleDomControl/sdc_socket.js +8 -829
- package/src/simpleDomControl/sdc_test_utils.js +77 -80
- package/src/simpleDomControl/sdc_utils.js +295 -176
- package/src/simpleDomControl/sdc_view.js +245 -177
- package/test/model.test.js +332 -0
- package/test/models/Author.js +145 -0
- package/test/models/Book.js +112 -0
- package/test/models/BookContent.js +114 -0
- package/test/models/SdcUser.js +75 -0
- package/test/models/src.js +8 -0
- package/test/sdc_model_dates.ai.test.js +57 -0
- package/test/sdc_server_call.ai.test.js +267 -0
|
@@ -1,337 +1,338 @@
|
|
|
1
1
|
import {allOff} from "./sdc_events.js";
|
|
2
2
|
import {app} from "./sdc_main.js";
|
|
3
|
-
import {
|
|
3
|
+
import {SdcQuerySet} from "./sdc_model.js";
|
|
4
4
|
import {callServer} from "./sdc_server_call.js";
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
uuidv4,
|
|
7
|
+
clearErrorsInForm,
|
|
8
|
+
tagNameToCamelCase,
|
|
9
|
+
tagNameToReadableName,
|
|
10
|
+
} from "./sdc_utils.js";
|
|
6
11
|
|
|
7
12
|
export class AbstractSDC {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
*
|
|
31
|
-
* @type {{string: AbstractSDC}}
|
|
32
|
-
*/
|
|
33
|
-
this._mixins = {};
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* @type {string}
|
|
37
|
-
*/
|
|
38
|
-
this._tagName = Object.getPrototypeOf(this)._tagName ?? '';
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* @type {{string:AbstractSDC}}
|
|
42
|
-
*/
|
|
43
|
-
this._childController = {};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* @type {AbstractSDC}
|
|
47
|
-
*/
|
|
48
|
-
this._parentController = null;
|
|
49
|
-
|
|
50
|
-
/**
|
|
51
|
-
* @type {boolean}
|
|
52
|
-
*/
|
|
53
|
-
this._onLoadDone = false;
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @type {jquery}
|
|
57
|
-
*/
|
|
58
|
-
this.$container = null;
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
*
|
|
62
|
-
* @type {boolean}
|
|
63
|
-
*/
|
|
64
|
-
this._isMixin = false;
|
|
65
|
-
}
|
|
13
|
+
constructor() {
|
|
14
|
+
this._uuid = uuidv4();
|
|
15
|
+
this.contentUrl = "";
|
|
16
|
+
this.contentReload = false;
|
|
17
|
+
this.parsedContentUrl = null;
|
|
18
|
+
this.events = [];
|
|
19
|
+
this.load_async = false;
|
|
20
|
+
this._isEventsSet = false;
|
|
21
|
+
this._allEvents = null;
|
|
22
|
+
|
|
23
|
+
this._urlParams = [];
|
|
24
|
+
this._models = [];
|
|
25
|
+
|
|
26
|
+
// ------------------ Old deprecated properties ----------------------
|
|
27
|
+
this._cssUrls = [];
|
|
28
|
+
this.afterShow = () => {
|
|
29
|
+
console.warn("afterShow is deprecated!!");
|
|
30
|
+
};
|
|
31
|
+
// -------------- End old deprecated properties ----------------------
|
|
66
32
|
|
|
67
33
|
/**
|
|
68
34
|
*
|
|
69
|
-
* @
|
|
70
|
-
* @param {Array} args in arguments of
|
|
71
|
-
*
|
|
35
|
+
* @type {{string: AbstractSDC}}
|
|
72
36
|
*/
|
|
73
|
-
|
|
74
|
-
if (app.DEBUG && !this._isMixin) {
|
|
75
|
-
console.debug(method, this._tagName);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
let returnPromisses = [];
|
|
79
|
-
if (this._isMixin) {
|
|
80
|
-
return;
|
|
81
|
-
}
|
|
82
|
-
this._isMixin = true;
|
|
83
|
-
for (let mixinKey in this._mixins) {
|
|
84
|
-
let mixin = this._mixins[mixinKey];
|
|
85
|
-
if (typeof mixin[method] === 'function') {
|
|
37
|
+
this._mixins = {};
|
|
86
38
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
return Promise.all(returnPromisses).then(() => {
|
|
92
|
-
this._isMixin = false;
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
onInit() {
|
|
97
|
-
if (app.DEBUG && !this._isMixin) {
|
|
98
|
-
console.DEBUG(Array.apply(null, arguments), this._tagName);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
39
|
+
/**
|
|
40
|
+
* @type {string}
|
|
41
|
+
*/
|
|
42
|
+
this._tagName = Object.getPrototypeOf(this)._tagName ?? "";
|
|
101
43
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
44
|
+
/**
|
|
45
|
+
* @type {{string:AbstractSDC}}
|
|
46
|
+
*/
|
|
47
|
+
this._childController = {};
|
|
105
48
|
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
49
|
+
/**
|
|
50
|
+
* @type {AbstractSDC}
|
|
51
|
+
*/
|
|
52
|
+
this._parentController = null;
|
|
109
53
|
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
54
|
+
/**
|
|
55
|
+
* @type {boolean}
|
|
56
|
+
*/
|
|
57
|
+
this._onLoadDone = false;
|
|
113
58
|
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
59
|
+
/**
|
|
60
|
+
* @type {jquery}
|
|
61
|
+
*/
|
|
62
|
+
this.$container = null;
|
|
117
63
|
|
|
118
|
-
|
|
119
|
-
|
|
64
|
+
/**
|
|
65
|
+
*
|
|
66
|
+
* @type {boolean}
|
|
67
|
+
*/
|
|
68
|
+
this._isMixin = false;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {string} method must be in {}
|
|
74
|
+
* @param {Array} args in arguments of
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
_runLifecycle(method, args) {
|
|
78
|
+
if (app.DEBUG && !this._isMixin) {
|
|
79
|
+
console.debug(method, this._tagName);
|
|
120
80
|
}
|
|
121
81
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
82
|
+
let returnPromisses = [];
|
|
83
|
+
if (this._isMixin) {
|
|
84
|
+
return;
|
|
125
85
|
}
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
86
|
+
this._isMixin = true;
|
|
87
|
+
for (let mixinKey in this._mixins) {
|
|
88
|
+
let mixin = this._mixins[mixinKey];
|
|
89
|
+
if (typeof mixin[method] === "function") {
|
|
90
|
+
returnPromisses.push(mixin[method].apply(this, args));
|
|
91
|
+
}
|
|
129
92
|
}
|
|
130
93
|
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
if (!this.onRemove || this.onRemove()) {
|
|
147
|
-
allOff(this);
|
|
148
|
-
const c_name = tagNameToCamelCase(this._tagName);
|
|
149
|
-
if (this._parentController._childController[c_name]) {
|
|
150
|
-
let arr = this._parentController._childController[c_name];
|
|
151
|
-
for (let i = 0; i < arr.length; i++) {
|
|
152
|
-
if (arr[i] === this) {
|
|
153
|
-
arr.splice(i, 1);
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
this.$container.remove();
|
|
159
|
-
delete this;
|
|
160
|
-
return true;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
return false;
|
|
94
|
+
return Promise.all(returnPromisses).then(() => {
|
|
95
|
+
this._isMixin = false;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
*
|
|
101
|
+
* @return {Promise<*>|*}
|
|
102
|
+
*/
|
|
103
|
+
onInit() {
|
|
104
|
+
if (app.DEBUG && !this._isMixin) {
|
|
105
|
+
console.debug(Array.apply(null, arguments), this._tagName);
|
|
164
106
|
}
|
|
107
|
+
}
|
|
165
108
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
109
|
+
get parentController() {
|
|
110
|
+
return this._parentController;
|
|
111
|
+
}
|
|
169
112
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this._allEvents[event][selector] = handler;
|
|
174
|
-
}
|
|
113
|
+
get childController() {
|
|
114
|
+
return this._childController;
|
|
115
|
+
}
|
|
175
116
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
allEvents = allEvents.concat(this.events);
|
|
180
|
-
for (let mixinKey in this._mixins) {
|
|
181
|
-
let mixin = this._mixins[mixinKey];
|
|
182
|
-
if (Array.isArray(mixin.events)) {
|
|
183
|
-
allEvents = allEvents.concat(mixin.events)
|
|
184
|
-
}
|
|
185
|
-
}
|
|
117
|
+
onLoad() {
|
|
118
|
+
return this._runLifecycle("onLoad", arguments);
|
|
119
|
+
}
|
|
186
120
|
|
|
121
|
+
willShow() {
|
|
122
|
+
return this._runLifecycle("willShow", arguments);
|
|
123
|
+
}
|
|
187
124
|
|
|
188
|
-
|
|
189
|
-
|
|
125
|
+
onRefresh() {
|
|
126
|
+
return this._runLifecycle("onRefresh", arguments);
|
|
127
|
+
}
|
|
190
128
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
129
|
+
onRemove() {
|
|
130
|
+
this._runLifecycle("onRemove", arguments);
|
|
131
|
+
return true;
|
|
132
|
+
}
|
|
194
133
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
134
|
+
noOpenModelRequests() {
|
|
135
|
+
return Promise.all(this._models.map((x) => x.noOpenRequests()));
|
|
136
|
+
}
|
|
198
137
|
|
|
199
|
-
|
|
200
|
-
|
|
138
|
+
remove() {
|
|
139
|
+
for (const model of this._models) {
|
|
140
|
+
model.close();
|
|
201
141
|
}
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
let
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
142
|
+
let _childController = this._childController;
|
|
143
|
+
for (let i in _childController) {
|
|
144
|
+
if (_childController.hasOwnProperty(i)) {
|
|
145
|
+
for (let cc of _childController[i]) {
|
|
146
|
+
if (!cc.remove()) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
209
149
|
}
|
|
210
|
-
|
|
211
|
-
return callServer(app[1], this._tagName, this.parsedContentUrl ?? this.contentUrl, methode, args);
|
|
150
|
+
}
|
|
212
151
|
}
|
|
213
152
|
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
if (model_name instanceof Model) {
|
|
225
|
-
return model_name;
|
|
153
|
+
if (!this.onRemove || this.onRemove()) {
|
|
154
|
+
allOff(this);
|
|
155
|
+
const c_name = tagNameToCamelCase(this._tagName);
|
|
156
|
+
if (this._parentController._childController[c_name]) {
|
|
157
|
+
let arr = this._parentController._childController[c_name];
|
|
158
|
+
for (let i = 0; i < arr.length; i++) {
|
|
159
|
+
if (arr[i] === this) {
|
|
160
|
+
arr.splice(i, 1);
|
|
161
|
+
}
|
|
226
162
|
}
|
|
163
|
+
}
|
|
227
164
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
165
|
+
this.$container.remove();
|
|
166
|
+
delete this;
|
|
167
|
+
return true;
|
|
231
168
|
}
|
|
232
169
|
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
170
|
+
return false;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
controller_name() {
|
|
174
|
+
return tagNameToReadableName(this._tagName);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
addEvent(event, selector, handler) {
|
|
178
|
+
this.getEvents();
|
|
179
|
+
this._allEvents[event] = this._allEvents[event] || {};
|
|
180
|
+
this._allEvents[event][selector] = handler;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
getEvents() {
|
|
184
|
+
if (this._allEvents) return this._allEvents;
|
|
185
|
+
let allEvents = [];
|
|
186
|
+
allEvents = allEvents.concat(this.events);
|
|
187
|
+
for (let mixinKey in this._mixins) {
|
|
188
|
+
let mixin = this._mixins[mixinKey];
|
|
189
|
+
if (Array.isArray(mixin.events)) {
|
|
190
|
+
allEvents = allEvents.concat(mixin.events);
|
|
191
|
+
}
|
|
249
192
|
}
|
|
250
193
|
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
194
|
+
return (this._allEvents = _.merge(...allEvents));
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
post(url, args) {
|
|
198
|
+
return app.post(this, url, args);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
get(url, args) {
|
|
202
|
+
return app.get(this, url, args);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
submitForm(form, url, method) {
|
|
206
|
+
return app.submitFormAndUpdateView(this, form, url, method);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
serverCall(methode, args) {
|
|
210
|
+
let re = /sdc_view\/([^/]+)/i;
|
|
211
|
+
let app = this.contentUrl.match(re);
|
|
212
|
+
if (!app || app.length < 2) {
|
|
213
|
+
console.error(
|
|
214
|
+
"To use the serverCall function the contentUrl must be set: " +
|
|
215
|
+
this.name,
|
|
216
|
+
);
|
|
217
|
+
return;
|
|
257
218
|
}
|
|
258
219
|
|
|
259
|
-
|
|
260
|
-
|
|
220
|
+
return callServer(
|
|
221
|
+
app[1],
|
|
222
|
+
this._tagName,
|
|
223
|
+
this.parsedContentUrl ?? this.contentUrl,
|
|
224
|
+
methode,
|
|
225
|
+
args,
|
|
226
|
+
);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
/**
|
|
230
|
+
*
|
|
231
|
+
* @param {string} modelName
|
|
232
|
+
* @param {object?} modelQuery
|
|
233
|
+
* @returns {SdcQuerySet}
|
|
234
|
+
*/
|
|
235
|
+
querySet(modelName, modelQuery = {}) {
|
|
236
|
+
const newQuerySet = new SdcQuerySet(modelName, modelQuery);
|
|
237
|
+
this._models.push(newQuerySet);
|
|
238
|
+
return newQuerySet;
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
newModel(modelName, modelQuery = {}) {
|
|
242
|
+
console.warn("newModel is deprecated and will soon be removed");
|
|
243
|
+
return this.querySet(modelName, modelQuery);
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* Adapter to this.$container.find
|
|
248
|
+
* @param {string} domSelector
|
|
249
|
+
*/
|
|
250
|
+
find(domSelector) {
|
|
251
|
+
return this.$container.find(domSelector);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
refresh() {
|
|
255
|
+
return app.refresh(this.$container, this);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
reload() {
|
|
259
|
+
return app.reloadController(this);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
reconcile($virtualNode, $realNode = null) {
|
|
263
|
+
return app.reconcile(this, $virtualNode, $realNode);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
submitModelFormDistributor($form, e) {
|
|
267
|
+
if (typeof this._submitModelForm === "function") {
|
|
268
|
+
return this._submitModelForm($form, e);
|
|
261
269
|
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
return app.reloadController(this);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
reconcile($virtualNode, $realNode = null) {
|
|
268
|
-
return app.reconcile(this, $virtualNode, $realNode);
|
|
270
|
+
if (typeof this.submitModelForm === "function") {
|
|
271
|
+
return this.submitModelForm($form, e);
|
|
269
272
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
273
|
+
return this.defaultSubmitModelForm($form, e);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
iterateAllChildren() {
|
|
277
|
+
let _childController = this._childController;
|
|
278
|
+
let res = [];
|
|
279
|
+
for (let i in _childController) {
|
|
280
|
+
if (_childController.hasOwnProperty(i)) {
|
|
281
|
+
for (let cc of _childController[i]) {
|
|
282
|
+
res.push(cc);
|
|
283
|
+
res.push(...cc.iterateAllChildren());
|
|
274
284
|
}
|
|
275
|
-
|
|
276
|
-
return this.submitModelForm($form, e);
|
|
277
|
-
}
|
|
278
|
-
return this.defaultSubmitModelForm($form, e);
|
|
285
|
+
}
|
|
279
286
|
}
|
|
287
|
+
return res;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* Model Form Events
|
|
292
|
+
*/
|
|
293
|
+
defaultSubmitModelForm($form, e) {
|
|
294
|
+
if (!this._isMixin) {
|
|
295
|
+
e.stopPropagation();
|
|
296
|
+
e.preventDefault();
|
|
297
|
+
let {model, form_name} = $form.data();
|
|
298
|
+
let data = model.syncForm($form);
|
|
299
|
+
return new Promise((resolve, reject) => {
|
|
300
|
+
let prom;
|
|
301
|
+
if (model.id !== null && model.id >= 0) {
|
|
302
|
+
prom = model.save({formName: form_name, data});
|
|
303
|
+
} else {
|
|
304
|
+
prom = model.create({data});
|
|
305
|
+
}
|
|
280
306
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
}
|
|
307
|
+
prom
|
|
308
|
+
.then((res) => {
|
|
309
|
+
clearErrorsInForm($form);
|
|
310
|
+
this.submit_model_form_success &&
|
|
311
|
+
this.submit_model_form_success(res[0]);
|
|
312
|
+
for (const controller of this.iterateAllChildren()) {
|
|
313
|
+
controller.submit_model_form_success &&
|
|
314
|
+
controller.submit_model_form_success(res[0]);
|
|
290
315
|
}
|
|
291
|
-
}
|
|
292
|
-
return res;
|
|
293
|
-
}
|
|
294
316
|
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
const
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
let prom;
|
|
308
|
-
if (instance_value.pk !== null && instance_value.pk >= 0) {
|
|
309
|
-
prom = model.save(instance_value.pk, form_name);
|
|
310
|
-
} else {
|
|
311
|
-
prom = model.create(instance_value);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
prom.then((res) => {
|
|
315
|
-
clearErrorsInForm($form);
|
|
316
|
-
this.submit_model_form_success && this.submit_model_form_success(res[0]);
|
|
317
|
-
for(const controller of this.iterateAllChildren()) {
|
|
318
|
-
controller.submit_model_form_success && controller.submit_model_form_success(res[0]);
|
|
319
|
-
}
|
|
320
|
-
resolve(res);
|
|
321
|
-
}).catch((data) => {
|
|
322
|
-
this.reconcile($(`<div class="container-fluid">${data.html}</div>`), $form.find('.container-fluid').first());
|
|
323
|
-
this.submit_model_form_error && this.submit_model_form_error(data);
|
|
324
|
-
for(const controller of this.iterateAllChildren()) {
|
|
325
|
-
controller.submit_model_form_error && controller.submit_model_form_error(data);
|
|
326
|
-
}
|
|
327
|
-
reject(data);
|
|
328
|
-
});
|
|
329
|
-
}));
|
|
317
|
+
resolve(res);
|
|
318
|
+
})
|
|
319
|
+
.catch((data) => {
|
|
320
|
+
this.reconcile(
|
|
321
|
+
$(`<div class="container-fluid">${data.html}</div>`),
|
|
322
|
+
$form.find(".container-fluid").first(),
|
|
323
|
+
);
|
|
324
|
+
this.submit_model_form_error &&
|
|
325
|
+
this.submit_model_form_error(data);
|
|
326
|
+
for (const controller of this.iterateAllChildren()) {
|
|
327
|
+
controller.submit_model_form_error &&
|
|
328
|
+
controller.submit_model_form_error(data);
|
|
330
329
|
}
|
|
331
|
-
}
|
|
332
330
|
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
331
|
+
reject(data);
|
|
332
|
+
});
|
|
333
|
+
});
|
|
336
334
|
}
|
|
337
|
-
|
|
335
|
+
|
|
336
|
+
return Promise.resolve();
|
|
337
|
+
}
|
|
338
|
+
}
|