@onehat/data 1.21.14 → 1.21.15
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.
|
@@ -147,6 +147,64 @@ describe('Repository Base', function() {
|
|
|
147
147
|
expect(this.repository.isAutoSave).to.be.false;
|
|
148
148
|
});
|
|
149
149
|
|
|
150
|
+
it('markLoaded', function() {
|
|
151
|
+
|
|
152
|
+
const repository = new this.Repository({
|
|
153
|
+
id: 'foo',
|
|
154
|
+
schema: this.schema,
|
|
155
|
+
isAutoLoad: false,
|
|
156
|
+
isAutoSave: true,
|
|
157
|
+
isPaginated: true,
|
|
158
|
+
data: [
|
|
159
|
+
{ key: 1, value: 'one', },
|
|
160
|
+
{ key: 2, value: 'two', },
|
|
161
|
+
{ key: 3, value: 'three', },
|
|
162
|
+
{ key: 4, value: 'four', },
|
|
163
|
+
{ key: 5, value: 'five', },
|
|
164
|
+
],
|
|
165
|
+
});
|
|
166
|
+
repository.initialize();
|
|
167
|
+
|
|
168
|
+
expect(repository.isLoading).to.be.false;
|
|
169
|
+
expect(repository.isLoaded).to.be.false;
|
|
170
|
+
expect(repository.lastLoaded).to.be.null;
|
|
171
|
+
|
|
172
|
+
repository.markLoaded();
|
|
173
|
+
|
|
174
|
+
expect(repository.isLoading).to.be.false;
|
|
175
|
+
expect(repository.isLoaded).to.be.true;
|
|
176
|
+
expect(repository.lastLoaded).to.be.not.null;
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it('markUnloaded', function() {
|
|
180
|
+
|
|
181
|
+
const repository = new this.Repository({
|
|
182
|
+
id: 'foo',
|
|
183
|
+
schema: this.schema,
|
|
184
|
+
isAutoLoad: false,
|
|
185
|
+
isAutoSave: true,
|
|
186
|
+
isPaginated: true,
|
|
187
|
+
data: [
|
|
188
|
+
{ key: 1, value: 'one', },
|
|
189
|
+
{ key: 2, value: 'two', },
|
|
190
|
+
{ key: 3, value: 'three', },
|
|
191
|
+
{ key: 4, value: 'four', },
|
|
192
|
+
{ key: 5, value: 'five', },
|
|
193
|
+
],
|
|
194
|
+
});
|
|
195
|
+
repository.initialize();
|
|
196
|
+
|
|
197
|
+
repository.isLoading = true;
|
|
198
|
+
repository.isLoaded = true;
|
|
199
|
+
repository.lastLoaded = true;
|
|
200
|
+
|
|
201
|
+
repository.markUnloaded();
|
|
202
|
+
|
|
203
|
+
expect(repository.isLoading).to.be.false;
|
|
204
|
+
expect(repository.isLoaded).to.be.false;
|
|
205
|
+
expect(repository.lastLoaded).to.be.null;
|
|
206
|
+
});
|
|
207
|
+
|
|
150
208
|
});
|
|
151
209
|
|
|
152
210
|
describe('sorting', function() {
|
|
@@ -325,7 +383,7 @@ describe('Repository Base', function() {
|
|
|
325
383
|
expect(filter.value).to.be.eq('1');
|
|
326
384
|
});
|
|
327
385
|
|
|
328
|
-
it
|
|
386
|
+
it('filter - object', function() {
|
|
329
387
|
// two possible ways to call filter with an object
|
|
330
388
|
// 1. filter({ name: 'key', value: '1' });
|
|
331
389
|
this.repository.filter({
|
package/package.json
CHANGED
package/src/Repository/Ajax.js
CHANGED
|
@@ -1097,6 +1097,18 @@ class AjaxRepository extends Repository {
|
|
|
1097
1097
|
}));
|
|
1098
1098
|
}
|
|
1099
1099
|
|
|
1100
|
+
/**
|
|
1101
|
+
* Clears all state and storage of entities, as though nothing was ever loaded.
|
|
1102
|
+
*/
|
|
1103
|
+
clearAll() {
|
|
1104
|
+
this._destroyEntities();
|
|
1105
|
+
this.entities = [];
|
|
1106
|
+
this.total = 0;
|
|
1107
|
+
this._setPaginationVars();
|
|
1108
|
+
this.markUnloaded();
|
|
1109
|
+
this.emit('changeData', this.entities);
|
|
1110
|
+
}
|
|
1111
|
+
|
|
1100
1112
|
setIsOnline(isOnline) {
|
|
1101
1113
|
this.isOnline = !!isOnline; // force convert type to boolean
|
|
1102
1114
|
}
|
|
@@ -431,6 +431,15 @@ export default class Repository extends EventEmitter {
|
|
|
431
431
|
await waitUntil(() => !this.isLoading, { timeout });
|
|
432
432
|
}
|
|
433
433
|
|
|
434
|
+
/**
|
|
435
|
+
* Marks this repository as unloaded
|
|
436
|
+
*/
|
|
437
|
+
markUnloaded() {
|
|
438
|
+
this.markLoading(false);
|
|
439
|
+
this.isLoaded = false;
|
|
440
|
+
this.lastLoaded = null;
|
|
441
|
+
}
|
|
442
|
+
|
|
434
443
|
/**
|
|
435
444
|
* Marks this repository as loaded
|
|
436
445
|
*/
|