@onehat/data 1.21.0 → 1.21.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/package.json +1 -1
- package/src/Repository/OneBuild.js +23 -14
package/package.json
CHANGED
|
@@ -30,19 +30,20 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
30
30
|
constructor(config = {}) {
|
|
31
31
|
super(...arguments);
|
|
32
32
|
|
|
33
|
+
const model = this._getModel();
|
|
33
34
|
const defaults = {
|
|
34
35
|
|
|
35
36
|
isAutoLoad: false,
|
|
36
37
|
isAutoSave: false,
|
|
37
38
|
|
|
38
39
|
api: {
|
|
39
|
-
get:
|
|
40
|
-
add:
|
|
41
|
-
edit:
|
|
42
|
-
delete:
|
|
43
|
-
batchAdd:
|
|
44
|
-
batchEdit:
|
|
45
|
-
batchDelete:
|
|
40
|
+
get: model + '/get',
|
|
41
|
+
add: model + '/add',
|
|
42
|
+
edit: model + '/edit',
|
|
43
|
+
delete: model + '/delete',
|
|
44
|
+
batchAdd: model + '/batchAdd',
|
|
45
|
+
batchEdit: model + '/batchEdit',
|
|
46
|
+
batchDelete: model + '/batchDelete',
|
|
46
47
|
},
|
|
47
48
|
|
|
48
49
|
methods: {
|
|
@@ -81,6 +82,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
81
82
|
|
|
82
83
|
this.registerEvents([
|
|
83
84
|
'logout',
|
|
85
|
+
'loadRootNodes',
|
|
84
86
|
]);
|
|
85
87
|
|
|
86
88
|
await super.initialize();
|
|
@@ -146,6 +148,13 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
146
148
|
});
|
|
147
149
|
}
|
|
148
150
|
|
|
151
|
+
_getModel() {
|
|
152
|
+
if (!this.isUnique) {
|
|
153
|
+
return this.name;
|
|
154
|
+
}
|
|
155
|
+
return this.name.match(/^([^-]*)-(.*)/)[1]; // converts 'ModelName-22f9915c-79f5-4e86-a25b-9446c7b85b63' to 'ModelName'
|
|
156
|
+
}
|
|
157
|
+
|
|
149
158
|
/**
|
|
150
159
|
* Helper for reloadEntity.
|
|
151
160
|
* @private
|
|
@@ -285,7 +294,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
285
294
|
}
|
|
286
295
|
|
|
287
296
|
const data = {
|
|
288
|
-
url: this.
|
|
297
|
+
url: this._getModel() + '/reorder',
|
|
289
298
|
data: qs.stringify({
|
|
290
299
|
ids,
|
|
291
300
|
dropPosition,
|
|
@@ -581,7 +590,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
581
590
|
console.log('loadRootNodes', data);
|
|
582
591
|
}
|
|
583
592
|
|
|
584
|
-
return this._send('POST', this.
|
|
593
|
+
return this._send('POST', this._getModel() + '/getNodes', data)
|
|
585
594
|
.then((result) => {
|
|
586
595
|
if (this.debugMode) {
|
|
587
596
|
console.log('Response for loadRootNodes', result);
|
|
@@ -626,7 +635,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
626
635
|
|
|
627
636
|
// Don't emit events for root nodes...
|
|
628
637
|
this.rehash();
|
|
629
|
-
this.emit('
|
|
638
|
+
this.emit('loadRootNodes', this);
|
|
630
639
|
// this.emit('changeData', this.entities);
|
|
631
640
|
|
|
632
641
|
return this.getBy((entity) => {
|
|
@@ -672,7 +681,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
672
681
|
console.log('loadNode', data);
|
|
673
682
|
}
|
|
674
683
|
|
|
675
|
-
return this._send('POST', this.
|
|
684
|
+
return this._send('POST', this._getModel() + '/getNodes', data)
|
|
676
685
|
.then((result) => {
|
|
677
686
|
if (this.debugMode) {
|
|
678
687
|
console.log('Response for loadNode', result);
|
|
@@ -755,7 +764,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
755
764
|
console.log('loadChildNodes', data);
|
|
756
765
|
}
|
|
757
766
|
|
|
758
|
-
return this._send('POST', this.
|
|
767
|
+
return this._send('POST', this._getModel() + '/getNodes', data)
|
|
759
768
|
.then((result) => {
|
|
760
769
|
if (this.debugMode) {
|
|
761
770
|
console.log('Response for loadChildNodes', result);
|
|
@@ -836,7 +845,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
836
845
|
console.log('searchNodes', data);
|
|
837
846
|
}
|
|
838
847
|
|
|
839
|
-
return this._send('POST', this.
|
|
848
|
+
return this._send('POST', this._getModel() + '/searchNodes', data)
|
|
840
849
|
.then((result) => {
|
|
841
850
|
if (this.debugMode) {
|
|
842
851
|
console.log('Response for searchNodes', result);
|
|
@@ -897,7 +906,7 @@ class OneBuildRepository extends AjaxRepository {
|
|
|
897
906
|
console.log('moveTreeNode', data);
|
|
898
907
|
}
|
|
899
908
|
|
|
900
|
-
return this._send('POST', this.
|
|
909
|
+
return this._send('POST', this._getModel() + '/moveNode', data)
|
|
901
910
|
.then((result) => {
|
|
902
911
|
if (this.debugMode) {
|
|
903
912
|
console.log('Response for searchNodes', result);
|