mirror of
https://github.com/nasa/openmct.git
synced 2024-12-19 05:07:52 +00:00
[Search] Index directly on mutation
Pass model directly when indexing is triggered via object mutation, to avoid issuing an extra, unnecessary request to the server. Additionally supports indexing of objects which have been created but not yet persisted. Addresses #377.
This commit is contained in:
parent
ff5f37dfbe
commit
2d305415b3
@ -121,9 +121,9 @@ define([
|
||||
provider = this;
|
||||
|
||||
mutationTopic.listen(function (mutatedObject) {
|
||||
var id = mutatedObject.getId();
|
||||
provider.indexedIds[id] = false;
|
||||
provider.scheduleForIndexing(id);
|
||||
var id = mutatedObject.getId(),
|
||||
model = mutatedObject.getModel();
|
||||
provider.index(id, model);
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -99,12 +99,15 @@ define([
|
||||
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||
});
|
||||
|
||||
it('reschedules indexing when mutation occurs', function () {
|
||||
it('re-indexes when mutation occurs', function () {
|
||||
var mockDomainObject =
|
||||
jasmine.createSpyObj('domainObj', ['getId']);
|
||||
jasmine.createSpyObj('domainObj', ['getId', 'getModel']),
|
||||
testModel = { some: 'model' };
|
||||
mockDomainObject.getId.andReturn("some-id");
|
||||
mockDomainObject.getModel.andReturn(testModel);
|
||||
spyOn(provider, 'index').andCallThrough();
|
||||
mutationTopic.listen.mostRecentCall.args[0](mockDomainObject);
|
||||
expect(provider.scheduleForIndexing).toHaveBeenCalledWith('some-id');
|
||||
expect(provider.index).toHaveBeenCalledWith('some-id', testModel);
|
||||
});
|
||||
|
||||
it('starts indexing roots', function () {
|
||||
|
Loading…
Reference in New Issue
Block a user