wacom 20.2.4 → 20.2.6
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/fesm2022/wacom.mjs +65 -54
- package/fesm2022/wacom.mjs.map +1 -1
- package/index.d.ts +6 -10
- package/package.json +1 -1
package/fesm2022/wacom.mjs
CHANGED
|
@@ -2396,7 +2396,8 @@ class CrudService extends BaseService {
|
|
|
2396
2396
|
}
|
|
2397
2397
|
else if (localStorage.getItem('waw_user')) {
|
|
2398
2398
|
const user = JSON.parse(localStorage.getItem('waw_user'));
|
|
2399
|
-
if (user._id ===
|
|
2399
|
+
if (user._id ===
|
|
2400
|
+
localStorage.getItem(this._config.name + 'waw_user_id')) {
|
|
2400
2401
|
this.restoreDocs();
|
|
2401
2402
|
}
|
|
2402
2403
|
}
|
|
@@ -2493,7 +2494,8 @@ class CrudService extends BaseService {
|
|
|
2493
2494
|
this.new({
|
|
2494
2495
|
_id,
|
|
2495
2496
|
});
|
|
2496
|
-
if (!this._docs.find((d) => this._id(d) === _id) &&
|
|
2497
|
+
if (!this._docs.find((d) => this._id(d) === _id) &&
|
|
2498
|
+
!this._fetchingId[_id]) {
|
|
2497
2499
|
this._fetchingId[_id] = true;
|
|
2498
2500
|
setTimeout(() => {
|
|
2499
2501
|
this.fetch({ _id }).subscribe((_doc) => {
|
|
@@ -2529,7 +2531,9 @@ class CrudService extends BaseService {
|
|
|
2529
2531
|
const url = `${this._url}/get${options.name || ''}`;
|
|
2530
2532
|
const params = (typeof config.page === 'number' || config.query ? '?' : '') +
|
|
2531
2533
|
(config.query || '') +
|
|
2532
|
-
(typeof config.page === 'number'
|
|
2534
|
+
(typeof config.page === 'number'
|
|
2535
|
+
? `&skip=${this._perPage * (config.page - 1)}&limit=${this._perPage}`
|
|
2536
|
+
: '');
|
|
2533
2537
|
const obs = this.__http.get(`${url}${params}`);
|
|
2534
2538
|
obs.subscribe({
|
|
2535
2539
|
next: (resp) => {
|
|
@@ -2797,67 +2801,74 @@ class CrudService extends BaseService {
|
|
|
2797
2801
|
});
|
|
2798
2802
|
return obs;
|
|
2799
2803
|
}
|
|
2800
|
-
|
|
2801
|
-
* Filters documents based on specific conditions and stores the result in a provided object.
|
|
2802
|
-
*
|
|
2803
|
-
* @param storeObject - Object to store filtered documents.
|
|
2804
|
-
* @param field - The field to filter by or a function to extract the field.
|
|
2805
|
-
* @param valid - Optional function to check the validity of a document.
|
|
2806
|
-
* @param sort - Function to sort the filtered documents.
|
|
2807
|
-
* @returns A callback function that triggers the filtering process.
|
|
2808
|
-
*/
|
|
2809
|
-
filteredDocuments(storeObject, field = 'author', valid, sort = (a, b) => {
|
|
2810
|
-
if (a[this._id(a)] < b[this._id(b)])
|
|
2811
|
-
return -1;
|
|
2812
|
-
if (a[this._id(a)] > b[this._id(b)])
|
|
2813
|
-
return 1;
|
|
2814
|
-
return 0;
|
|
2815
|
-
}) {
|
|
2804
|
+
filteredDocuments(storeObjectOrArray, config = {}) {
|
|
2816
2805
|
const callback = () => {
|
|
2817
|
-
|
|
2818
|
-
|
|
2819
|
-
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
|
|
2823
|
-
storeObject[parentId].splice(i, 1);
|
|
2824
|
-
}
|
|
2806
|
+
if (Array.isArray(storeObjectOrArray)) {
|
|
2807
|
+
const result = this._docs.filter(config.valid ?? (() => true));
|
|
2808
|
+
storeObjectOrArray.length = 0;
|
|
2809
|
+
storeObjectOrArray.push(...result);
|
|
2810
|
+
if (typeof config.sort === 'function') {
|
|
2811
|
+
storeObjectOrArray.sort(config.sort);
|
|
2825
2812
|
}
|
|
2826
2813
|
}
|
|
2827
|
-
|
|
2828
|
-
|
|
2829
|
-
|
|
2830
|
-
|
|
2831
|
-
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
2835
|
-
|
|
2836
|
-
|
|
2837
|
-
|
|
2838
|
-
|
|
2839
|
-
|
|
2814
|
+
else {
|
|
2815
|
+
const storeObject = storeObjectOrArray;
|
|
2816
|
+
/* remove docs if they were removed */
|
|
2817
|
+
for (const parentId in storeObject) {
|
|
2818
|
+
for (let i = storeObject[parentId].length - 1; i >= 0; i--) {
|
|
2819
|
+
const _field = typeof config.field === 'function'
|
|
2820
|
+
? config.field(storeObject[parentId][i])
|
|
2821
|
+
: config.field || 'author';
|
|
2822
|
+
const _doc = storeObject[parentId][i];
|
|
2823
|
+
if (!this._docs.find((doc) => Array.isArray(doc[_field])
|
|
2824
|
+
? doc[_field].includes(_doc[this._id(doc)])
|
|
2825
|
+
: doc[_field] === _doc[this._id(doc)])) {
|
|
2826
|
+
storeObject[parentId].splice(i, 1);
|
|
2827
|
+
}
|
|
2840
2828
|
}
|
|
2841
2829
|
}
|
|
2842
|
-
|
|
2843
|
-
|
|
2844
|
-
|
|
2845
|
-
|
|
2846
|
-
|
|
2830
|
+
/* add docs if they are not added */
|
|
2831
|
+
for (const doc of this._docs) {
|
|
2832
|
+
const _field = typeof config.field === 'function'
|
|
2833
|
+
? config.field(doc)
|
|
2834
|
+
: config.field || 'author';
|
|
2835
|
+
if (typeof config.valid === 'function'
|
|
2836
|
+
? !config.valid(doc)
|
|
2837
|
+
: Array.isArray(doc[_field])
|
|
2838
|
+
? !doc[_field]?.length
|
|
2839
|
+
: !doc[_field]) {
|
|
2840
|
+
continue;
|
|
2841
|
+
}
|
|
2842
|
+
if (typeof config.field === 'function') {
|
|
2843
|
+
if (config.field(doc) &&
|
|
2844
|
+
!storeObject[doc[_field]].find((c) => c._id === doc._id)) {
|
|
2845
|
+
storeObject[doc[_field]].push(doc);
|
|
2847
2846
|
}
|
|
2848
|
-
}
|
|
2847
|
+
}
|
|
2848
|
+
else if (Array.isArray(doc[_field])) {
|
|
2849
|
+
doc[_field].forEach((_field) => {
|
|
2850
|
+
storeObject[_field] = storeObject[_field] || [];
|
|
2851
|
+
if (!storeObject[_field].find((c) => c._id === doc._id)) {
|
|
2852
|
+
storeObject[_field].push(doc);
|
|
2853
|
+
}
|
|
2854
|
+
});
|
|
2855
|
+
}
|
|
2856
|
+
else {
|
|
2857
|
+
storeObject[doc[_field]] =
|
|
2858
|
+
storeObject[doc[_field]] || [];
|
|
2859
|
+
if (!storeObject[doc[_field]].find((c) => c._id === doc._id)) {
|
|
2860
|
+
storeObject[doc[_field]].push(doc);
|
|
2861
|
+
}
|
|
2862
|
+
}
|
|
2849
2863
|
}
|
|
2850
|
-
|
|
2851
|
-
|
|
2852
|
-
|
|
2853
|
-
storeObject[
|
|
2864
|
+
/* sort the array's */
|
|
2865
|
+
if (typeof config.sort === 'function') {
|
|
2866
|
+
for (const parentId in storeObject) {
|
|
2867
|
+
storeObject[parentId].sort(config.sort);
|
|
2854
2868
|
}
|
|
2855
2869
|
}
|
|
2856
2870
|
}
|
|
2857
|
-
|
|
2858
|
-
for (const parentId in storeObject) {
|
|
2859
|
-
storeObject[parentId].sort(sort);
|
|
2860
|
-
}
|
|
2871
|
+
config.filtered?.(storeObjectOrArray);
|
|
2861
2872
|
};
|
|
2862
2873
|
this._filteredDocumentsCallbacks.push(callback);
|
|
2863
2874
|
return callback;
|