sdc_client 0.158.6 → 0.158.7

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.
@@ -6,6 +6,13 @@ import { trigger } from "./sdc_events.js";
6
6
  const MAX_FILE_UPLOAD = 25000;
7
7
  const CONNECTING_REQUEST_ID = "_connecting_process";
8
8
 
9
+ const cloneObject = (original) => {
10
+ return Object.assign(
11
+ Object.create(Object.getPrototypeOf(original)),
12
+ structuredClone(original)
13
+ );
14
+ }
15
+
9
16
  class SdcModelError extends Error {
10
17
  constructor(props) {
11
18
  if (typeof props === 'string') {
@@ -149,16 +156,31 @@ export class SdcQuerySet {
149
156
  * @param {Array<integr|string>|integer|SdcModel|SdcQuerySet|string} ids
150
157
  */
151
158
  setIds(ids) {
159
+ const vl = this._setIds(ids);
160
+ const filter = {
161
+ id__in: vl.map((x) => x.id)
162
+ }
163
+
164
+ this.setFilter(filter);
165
+ return vl;
166
+ }
167
+
168
+ /**
169
+ *
170
+ *
171
+ * @param {Array<integr|string>|integer|SdcModel|SdcQuerySet|string} ids
172
+ */cloneObject
173
+ _setIds(ids) {
152
174
 
153
175
  if (ids === null || ids === "" || Array.isArray(ids) && ids.length === 0) {
154
176
  this.valuesList = [];
155
177
  return this.valuesList;
156
178
  } else if (ids instanceof SdcQuerySet) {
157
- this.valuesList = structuredClone(ids.valuesList);
179
+ this.valuesList = ids.valuesList.map(cloneObject);
158
180
  this.valuesList.forEach(value => value._setQuerySet(this, true));
159
181
  return this.valuesList;
160
182
  } else if (ids instanceof SdcModel) {
161
- this.valuesList = [structuredClone(ids)];
183
+ this.valuesList = [cloneObject(ids)];
162
184
  this.valuesList.forEach(value => value._setQuerySet(this, true));
163
185
  return this.valuesList;
164
186
  }
@@ -181,8 +203,11 @@ export class SdcQuerySet {
181
203
  }
182
204
 
183
205
  if (!Number.isNaN(numId)) {
184
- const newModel = this.new();
185
- newModel.id = numId;
206
+ this.valuesList = this.valuesList.filter((item) => numId === item.id);
207
+ if (this.valuesList.length === 0) {
208
+ const newModel = this.new();
209
+ newModel.id = numId;
210
+ }
186
211
  } else if (numList) {
187
212
  this.valuesList = this.valuesList.filter((item) => numList.includes(item.id));
188
213
  const valueIds = this.getIds();
@@ -269,7 +294,7 @@ export class SdcQuerySet {
269
294
  */
270
295
  update({ modelQuery = null, item = null }) {
271
296
  this.modelQuery = modelQuery ?? this.modelQuery;
272
- let loadQuery = item ? { pk: item.id } : this.modelQuery;
297
+ let loadQuery = item ? { id: item.id } : this.modelQuery;
273
298
  return this._sendLoad(loadQuery);
274
299
  }
275
300
 
@@ -279,28 +304,30 @@ export class SdcQuerySet {
279
304
  * @param elem {SdcModel}
280
305
  * @returns {Promise<unknown>}
281
306
  */
282
- delete({ pk = null, elem = null }) {
307
+ delete({ pk = null, id = null, elem = null }) {
308
+ pk ??= id;
283
309
  pk = !elem ? pk : elem.id;
284
310
  if (pk === null) {
285
311
  throw new Error("pk or elem must be set");
286
312
  }
287
- const id = uuidv4();
313
+ const event_id = uuidv4();
288
314
  return this.isConnected().then(() => {
289
315
  return new Promise((resolve, reject) => {
290
316
  this.socket.send(
291
317
  JSON.stringify({
292
318
  event: "model",
293
319
  event_type: "delete",
294
- event_id: id,
320
+ event_id,
295
321
  args: {
296
322
  model_name: this.modelName,
297
323
  model_query: this.modelQuery,
298
- pk,
324
+ id: pk,
325
+ pk
299
326
  },
300
327
  }),
301
328
  );
302
329
 
303
- this.openRequest[id] = [resolve, reject];
330
+ this.openRequest[event_id] = [resolve, reject];
304
331
  });
305
332
  });
306
333
  }
@@ -312,13 +339,13 @@ export class SdcQuerySet {
312
339
  */
313
340
  _sendLoad(loadQuery = null) {
314
341
  return this.isConnected().then(() => {
315
- const id = uuidv4();
342
+ const event_id = uuidv4();
316
343
  return new Promise((resolve, reject) => {
317
344
  this.socket.send(
318
345
  JSON.stringify({
319
346
  event: "model",
320
347
  event_type: "load",
321
- event_id: id,
348
+ event_id,
322
349
  args: {
323
350
  model_name: this.modelName,
324
351
  model_query: loadQuery ?? this.modelQuery,
@@ -326,7 +353,7 @@ export class SdcQuerySet {
326
353
  }),
327
354
  );
328
355
 
329
- this.openRequest[id] = [(data) => {
356
+ this.openRequest[event_id] = [(data) => {
330
357
  this.loaded = true;
331
358
  resolve(data);
332
359
  }, reject];
@@ -371,12 +398,12 @@ export class SdcQuerySet {
371
398
  }) {
372
399
  let $divList = $('<div class="container-fluid">');
373
400
  this.isConnected().then(() => {
374
- const id = uuidv4();
401
+ const event_id = uuidv4();
375
402
  this.socket.send(
376
403
  JSON.stringify({
377
404
  event: "model",
378
405
  event_type: eventType,
379
- event_id: id,
406
+ event_id,
380
407
  args: {
381
408
  view_name: viewName,
382
409
  model_name: this.modelName,
@@ -386,7 +413,7 @@ export class SdcQuerySet {
386
413
  }),
387
414
  );
388
415
 
389
- this.openRequest[id] = [
416
+ this.openRequest[event_id] = [
390
417
  (data) => {
391
418
  $divList.append(data.html);
392
419
  app.refresh($divList);
@@ -409,30 +436,33 @@ export class SdcQuerySet {
409
436
  */
410
437
  _sendDetailView({
411
438
  pk = null,
439
+ id = null,
412
440
  cbResolve = null,
413
441
  cbReject = null,
414
442
  templateContext = {},
415
443
  }) {
444
+ pk ??= id;
416
445
  pk = normalizePk(pk);
417
446
  let $divList = $('<div class="container-fluid">');
418
447
 
419
448
  this.isConnected().then(() => {
420
- const id = uuidv4();
449
+ const event_id = uuidv4();
421
450
  this.socket.send(
422
451
  JSON.stringify({
423
452
  event: "model",
424
453
  event_type: "detail_view",
425
- event_id: id,
454
+ event_id,
426
455
  args: {
427
456
  model_name: this.modelName,
428
457
  model_query: this.modelQuery,
458
+ id: pk,
429
459
  pk,
430
460
  template_context: templateContext,
431
461
  },
432
462
  }),
433
463
  );
434
464
 
435
- this.openRequest[id] = [
465
+ this.openRequest[event_id] = [
436
466
  (data) => {
437
467
  $divList.append(data.html);
438
468
  app.refresh($divList);
@@ -453,18 +483,24 @@ export class SdcQuerySet {
453
483
  *
454
484
  * @param {string} eventType
455
485
  * @param {SdcModel} modelObj
486
+ * @param formName
487
+ * @param $divForm
488
+ * @param cbResolve
489
+ * @param cbReject
490
+ * @param formId
456
491
  */
457
492
  getForm({ modelObj, eventType, formName, $divForm, cbResolve, cbReject, formId }) {
458
- const id = uuidv4();
493
+ const event_id = uuidv4();
459
494
  const pk = modelObj.id ?? -1;
460
495
  this.isConnected().then(() => {
461
496
  this.socket.send(
462
497
  JSON.stringify({
463
498
  event: "model",
464
499
  event_type: eventType,
465
- event_id: id,
500
+ event_id,
466
501
  args: {
467
502
  model_name: this.modelName,
503
+ id: pk,
468
504
  pk,
469
505
  form_name: formName,
470
506
  },
@@ -474,7 +510,7 @@ export class SdcQuerySet {
474
510
 
475
511
  const className = pk === null || pk === -1 ? "create" : "edit";
476
512
 
477
- this.openRequest[id] = [
513
+ this.openRequest[event_id] = [
478
514
  (data) => {
479
515
  $divForm.append(data.html);
480
516
  let $form = $divForm
@@ -508,7 +544,10 @@ export class SdcQuerySet {
508
544
  */
509
545
  async get(modelQuery = null, doNotLoad = false) {
510
546
  if (doNotLoad) {
511
- const id = modelQuery?.id ?? modelQuery?.pk;
547
+ const id = modelQuery?.id ?? this.modelQuery?.id;
548
+ if(modelQuery) {
549
+ this.setFilter(modelQuery);
550
+ }
512
551
  return this.byId(id) ?? this.new(modelQuery || this.modelQuery);
513
552
  }
514
553
  await this.load(modelQuery);
@@ -516,12 +555,14 @@ export class SdcQuerySet {
516
555
  throw new Error(`model query returns ${this.length} but only 1 expected.`);
517
556
  }
518
557
 
558
+ this.addFilter({ id: this.valuesList[0].id });
559
+
519
560
  return this.valuesList[0];
520
561
  }
521
562
 
522
563
  detailView({ pk, cbResolve = null, cbReject = null, templateContext = {} }) {
523
564
  return this._sendDetailView({
524
- pk,
565
+ id: pk,
525
566
  cbResolve,
526
567
  cbReject,
527
568
  templateContext,
@@ -537,7 +578,8 @@ export class SdcQuerySet {
537
578
  });
538
579
  }
539
580
 
540
- save({ pk = null, formName = "edit_form", data = null } = {}) {
581
+ save({ pk = null, id = null, formName = "edit_form", data = null } = {}) {
582
+ pk ??= id;
541
583
  const normPk = normalizePk(pk);
542
584
  return this.isConnected().then(() => {
543
585
  let elemList;
@@ -552,29 +594,30 @@ export class SdcQuerySet {
552
594
  }
553
595
  let pList = [];
554
596
  elemList.forEach((elem) => {
555
- const id = uuidv4();
597
+ const event_id = uuidv4();
556
598
  pList.push(
557
599
  new Promise((resolve, reject) => {
558
600
  this._readFiles(elem).then((files) => {
559
601
  const sendData = data ? { ...data } : elem.serialize();
560
- sendData.pk = elem.id;
602
+ sendData.id = elem.id;
561
603
  this.socket.send(
562
604
  JSON.stringify({
563
605
  event: "model",
564
606
  event_type: "save",
565
- event_id: id,
607
+ event_id,
566
608
  args: {
567
609
  form_name: formName,
568
610
  model_name: this.modelName,
569
611
  model_query: this.modelQuery,
570
612
  data: sendData,
571
- pk: sendData.pk,
613
+ id: sendData.id,
614
+ pk: sendData.id,
572
615
  files: files,
573
616
  },
574
617
  }),
575
618
  );
576
619
 
577
- this.openRequest[id] = [
620
+ this.openRequest[event_id] = [
578
621
  (res) => {
579
622
  let data =
580
623
  typeof res.data.instance === "string"
@@ -601,7 +644,7 @@ export class SdcQuerySet {
601
644
  * @returns {Promise<unknown>}
602
645
  */
603
646
  create({ elem = null, data = null } = {}) {
604
- const id = uuidv4();
647
+ const event_id = uuidv4();
605
648
  if (!elem) {
606
649
  elem = this.new(data);
607
650
  }
@@ -612,7 +655,7 @@ export class SdcQuerySet {
612
655
  JSON.stringify({
613
656
  event: "model",
614
657
  event_type: "create",
615
- event_id: id,
658
+ event_id,
616
659
  args: {
617
660
  model_name: this.modelName,
618
661
  model_query: this.modelQuery,
@@ -622,14 +665,14 @@ export class SdcQuerySet {
622
665
  }),
623
666
  );
624
667
 
625
- this.openRequest[id] = [
668
+ this.openRequest[event_id] = [
626
669
  (res) => {
627
670
  let data =
628
671
  typeof res.data.instance === "string"
629
672
  ? JSON.parse(res.data.instance)
630
673
  : res.data.instance;
631
674
  if (elem) {
632
- elem.id = data[0]?.pk || data[0]?.id;
675
+ elem.id = data[0]?.id || data[0]?.pk;
633
676
  }
634
677
  res.data.instance = this._parseServerRes(data)[0];
635
678
  resolve(res);
@@ -716,14 +759,14 @@ export class SdcQuerySet {
716
759
  if (value instanceof File) {
717
760
  toSolve.push(
718
761
  new Promise(async (resolve, reject) => {
719
- const id = uuidv4();
720
- this.openRequest[id] = [resolve, reject];
762
+ const event_id = uuidv4();
763
+ this.openRequest[event_id] = [resolve, reject];
721
764
 
722
765
  const buffer = await value.arrayBuffer();
723
766
  let result = new Uint8Array(buffer);
724
767
  let numberOfChunks = Math.ceil(result.length / MAX_FILE_UPLOAD);
725
768
  files[key] = {
726
- id: id,
769
+ id: event_id,
727
770
  file_name: value.name,
728
771
  field_name: key,
729
772
  content_length: value.size,
@@ -737,7 +780,7 @@ export class SdcQuerySet {
737
780
  JSON.stringify({
738
781
  event: "model",
739
782
  event_type: "upload",
740
- event_id: id,
783
+ event_id,
741
784
  args: {
742
785
  chunk,
743
786
  idx: i,
@@ -916,13 +959,13 @@ export class SdcQuerySet {
916
959
  * @returns {Promise<*>}
917
960
  */
918
961
  _checkConnection() {
919
- const id = uuidv4();
962
+ const event_id = uuidv4();
920
963
  return new Promise((resolve, reject) => {
921
964
  this.socket.send(
922
965
  JSON.stringify({
923
966
  event: "model",
924
967
  event_type: "connect",
925
- event_id: id,
968
+ event_id,
926
969
  args: {
927
970
  model_name: this.modelName,
928
971
  model_query: this.modelQuery,
@@ -930,7 +973,7 @@ export class SdcQuerySet {
930
973
  }),
931
974
  );
932
975
 
933
- this.openRequest[id] = [resolve, reject];
976
+ this.openRequest[event_id] = [resolve, reject];
934
977
  });
935
978
  }
936
979
 
@@ -946,7 +989,7 @@ export class SdcQuerySet {
946
989
  if (!ModelClass) {
947
990
  throw new Error(`${this.modelName} is no SdcModel. mybe the models ar not importad.`);
948
991
  }
949
- const newModel = new ModelClass({ 'id': x.pk ?? x.id, ...x.fields });
992
+ const newModel = new ModelClass({ 'id': x.id ?? x.pk, ...x.fields });
950
993
  const currentModel = this.byId(newModel.id);
951
994
  if (currentModel) {
952
995
  currentModel.setValues(newModel);
@@ -1039,6 +1082,10 @@ export default class SdcModel {
1039
1082
  this.loaded = isLoaded;
1040
1083
  }
1041
1084
 
1085
+ get querySet() {
1086
+ return this._querySet.deref();
1087
+ }
1088
+
1042
1089
  save({ formName = "edit_form", data = null } = {}) {
1043
1090
  return this._querySet.deref().save({ pk: this.id, formName, data });
1044
1091
  }
@@ -1055,14 +1102,22 @@ export default class SdcModel {
1055
1102
  return this._querySet.deref().update({ item: this });
1056
1103
  }
1057
1104
 
1105
+ update() {
1106
+ return this.load();
1107
+ }
1108
+
1058
1109
  get id() {
1059
1110
  return this._id;
1060
1111
  }
1061
1112
 
1062
- set pk(data) {
1113
+ set id(data) {
1063
1114
  this._id = data;
1064
1115
  }
1065
1116
 
1117
+ set pk(data) {
1118
+ this.id = data;
1119
+ }
1120
+
1066
1121
  get pk() {
1067
1122
  return this._id;
1068
1123
  }
@@ -1316,12 +1371,20 @@ export default class SdcModel {
1316
1371
  */
1317
1372
  parseValue(value, config) {
1318
1373
  const {
1319
- type
1374
+ type,
1375
+ many_to_many: manyToMany,
1376
+ one_to_many: oneToMany,
1377
+ many_to_one: manyToOne,
1378
+ one_to_one: oneToOne,
1320
1379
  } = config;
1321
1380
  if (value === null) {
1322
1381
  return null;
1323
1382
  }
1324
1383
 
1384
+ if ((manyToMany || oneToMany || manyToOne || oneToOne) && value && typeof value === 'string') {
1385
+ return JSON.parse(value);
1386
+ }
1387
+
1325
1388
  switch (type) {
1326
1389
  case "CharField":
1327
1390
  case "TeextField":
@@ -1336,10 +1399,7 @@ export default class SdcModel {
1336
1399
 
1337
1400
  case "FloatField":
1338
1401
  case "DecimalField":
1339
- if (typeof value !== "number") {
1340
- return "Must be a number";
1341
- }
1342
- break;
1402
+ return parseFloat(value);
1343
1403
 
1344
1404
  case "BooleanField":
1345
1405
  return !!value;
@@ -1432,6 +1492,13 @@ function validateField(value, config) {
1432
1492
 
1433
1493
  if (manyToMany || oneToMany || manyToOne || oneToOne) {
1434
1494
  if (!(value instanceof SdcQuerySet) || value.modelName !== relatedModel) {
1495
+ if(typeof value === 'string') {
1496
+ value = JSON.parse(value);
1497
+ }
1498
+
1499
+ if ((manyToMany || manyToOne) && Array.isArray(value) && value.some((x) => !Number.isNaN(parseInt(x)))) {
1500
+ return null;
1501
+ }
1435
1502
  if (typeof value !== "object" && Number.isNaN(parseInt(value))) {
1436
1503
  return "Must be object or ID";
1437
1504
  }
@@ -1453,14 +1520,14 @@ function validateField(value, config) {
1453
1520
  case "IntegerField":
1454
1521
  case "AutoField":
1455
1522
  case "BigIntegerField":
1456
- if (!Number.isInteger(value)) {
1523
+ if (!isFinite(parseInt(value))) {
1457
1524
  return "Must be an integer";
1458
1525
  }
1459
1526
  break;
1460
1527
 
1461
1528
  case "FloatField":
1462
1529
  case "DecimalField":
1463
- if (typeof value !== "number") {
1530
+ if (!isFinite(parseFloat(value))) {
1464
1531
  return "Must be a number";
1465
1532
  }
1466
1533
  break;
@@ -1,15 +1,14 @@
1
1
  import {
2
- getParamsNameOfFunction,
3
2
  checkIfParamNumberBoolOrString,
4
3
  } from "./sdc_utils.js";
5
4
  import { DATA_CONTROLLER_KEY } from "./sdc_view.js";
6
5
 
7
- export function prepareData(data, paramNameList = []) {
6
+ export function prepareData(data, controller = null) {
8
7
  const data_json_key = "SDC_JSON_MODEL=[";
9
8
  return Object.fromEntries(
10
9
  Object.entries(data)
11
10
  .filter(([key, element]) => {
12
- return key !== DATA_CONTROLLER_KEY && !paramNameList.includes(key);
11
+ return key !== DATA_CONTROLLER_KEY;
13
12
  })
14
13
  .map(([key, element]) => {
15
14
  if (typeof element === "string" && element.startsWith(data_json_key)) {
@@ -22,54 +21,20 @@ export function prepareData(data, paramNameList = []) {
22
21
  {
23
22
  ...fields,
24
23
  id: pk,
25
- pk,
24
+ id: pk,
26
25
  },
27
26
  ];
28
- } catch {}
27
+ } catch {
28
+ }
29
29
  }
30
- return [key, element];
30
+ return [key, checkIfParamNumberBoolOrString(element, controller)];
31
31
  }),
32
32
  );
33
33
  }
34
34
 
35
- function getParamList(paramNameList, $element) {
36
- let returnList;
37
- if (!paramNameList) {
38
- paramNameList = [];
39
- }
40
-
41
- let data = $element.data();
42
- let restData = prepareData(data, paramNameList);
43
35
 
44
- returnList = [];
45
- for (let i = 0; i < paramNameList.length; i++) {
46
- let data_name = paramNameList[i];
47
-
48
- if (data.hasOwnProperty(data_name)) {
49
- returnList.push(data[data_name]);
50
- } else {
51
- returnList.push("undefined");
52
- }
53
- }
54
-
55
- returnList.push(restData);
56
- return returnList;
57
- }
58
-
59
- function parseParamNameList(list, controller = null) {
60
- let values = [];
61
-
62
- for (let i = 0; i < list.length; i++) {
63
- let tempValue = checkIfParamNumberBoolOrString(list[i], controller);
64
- values.push(tempValue);
65
- }
66
-
67
- return values;
68
- }
69
-
70
- function getDomTagParamsWithList(paramNameList, $element, controller = null) {
71
- let paramList = getParamList(paramNameList, $element);
72
- return parseParamNameList(paramList, controller);
36
+ function getDomTagParamsWithList($element, controller = null) {
37
+ return prepareData($element.data(), controller);
73
38
  }
74
39
 
75
40
  /**
@@ -85,28 +50,11 @@ function reg_runOnInitWithParameter(controller, $element, applyController) {
85
50
  } else if (typeof controller.onInit !== "function") {
86
51
  return false;
87
52
  }
88
- let paramNameList;
89
- if (typeof controller._on_init_params === "function") {
90
- paramNameList = controller._on_init_params();
91
- } else {
92
- paramNameList = getParamsNameOfFunction(controller.onInit);
93
- }
94
53
 
95
- let initParams = getDomTagParamsWithList(
96
- paramNameList,
54
+ controller.params = getDomTagParamsWithList(
97
55
  $element,
98
56
  applyController._parentController,
99
57
  );
100
- controller.onInit.apply(applyController, initParams);
101
- if (applyController === controller) {
102
- for (let mixinKey in controller._mixins) {
103
- reg_runOnInitWithParameter(
104
- controller._mixins[mixinKey],
105
- $element,
106
- applyController,
107
- );
108
- }
109
- }
110
58
  }
111
59
 
112
60
  export function runOnInitWithParameter($element, controller) {
@@ -114,5 +62,15 @@ export function runOnInitWithParameter($element, controller) {
114
62
  }
115
63
 
116
64
  export function getUrlParam(controller, $element) {
117
- return getDomTagParamsWithList(controller._urlParams, $element);
65
+ const values = getDomTagParamsWithList($element, controller);
66
+ const [params, args] = Object.entries(values).reduce(([params, args], [k, v]) => {
67
+ if (controller._urlParams.includes(k)) {
68
+ params[k] = v;
69
+ } else {
70
+ args[k] = v;
71
+ }
72
+ return [params, args]
73
+ }, [{}, {}]);
74
+
75
+ return { params, args };
118
76
  }
@@ -50,7 +50,7 @@ function postCallServer(parsedContentUrl, funcName, args) {
50
50
  return data;
51
51
  })
52
52
  .catch((res) => {
53
- const data = res.responseJSON;
53
+ const data = res.responseJSON || {};
54
54
  data.is_error = true;
55
55
  _handle_response(data);
56
56
  throw res;
@@ -104,11 +104,13 @@ export async function get_controller(
104
104
  for (const [key, value] of Object.entries(init_arguments)) {
105
105
  $controller.data(key, value);
106
106
  }
107
- const $divContainer = $("<div></div>").append($controller);
107
+ const $divContainer = $("<div></div>").append($controller)
108
108
 
109
109
  $body.append($divContainer);
110
110
  app._isInit = false;
111
111
  app.cleanCache();
112
112
  await app.init_sdc();
113
- return app.getController($controller);
113
+ const controller = app.getController($controller);
114
+ controller.navControllerPath = [tag_name]
115
+ return controller;
114
116
  }
@@ -75,7 +75,11 @@ function replacePlaceholderController(controller, url, urlValues) {
75
75
  if (controller._urlParams.hasOwnProperty(key_idx)) {
76
76
  let key = controller._urlParams[key_idx];
77
77
  let re = RegExp("%\\(" + key + "\\)\\w", "gm");
78
- url = url.replace(re, "" + urlValues.shift());
78
+ const val = urlValues[key];
79
+ if(!val) {
80
+ console.warn(`${key} is not set for controller ${ controller._tagName }`);
81
+ }
82
+ url = url.replace(re, val);
79
83
  }
80
84
  }
81
85
 
@@ -164,14 +168,14 @@ function parseContentUrl(controller) {
164
168
  }
165
169
  }
166
170
 
167
- let params = getUrlParam(controller, controller.$container);
171
+ let { args, params } = getUrlParam(controller, controller.$container);
168
172
  if (controller._urlParams.length) {
169
173
  url = replacePlaceholderController(controller, url, params);
170
174
  }
171
175
 
172
176
  controller.parsedContentUrl = url;
173
177
 
174
- return { url: url, args: params[params.length - 1] };
178
+ return { url: url, args };
175
179
  }
176
180
 
177
181
  /**
@@ -263,6 +267,7 @@ function runReplaceTagElementsInContainer(
263
267
  return replaceAllTagElementsInContainer($element, controller, process);
264
268
  }
265
269
 
270
+
266
271
  controller = controllerFactory(
267
272
  parentController,
268
273
  $element,
@@ -378,7 +383,7 @@ function _reloadMethodHTML(controller, $dom, process) {
378
383
  }
379
384
 
380
385
  if (typeof result === "function") {
381
- const newData = prepareData($this.data());
386
+ const newData = prepareData($this.data(), controller);
382
387
  result = result.bind(controller)(newData);
383
388
  }
384
389
  if (result) {