mirror of
https://github.com/nasa/openmct.git
synced 2025-06-01 23:20:50 +00:00
Merge pull request #727 from nasa/open377
[Search] Index directly on mutation
This commit is contained in:
commit
abd5913f02
@ -121,9 +121,13 @@ define([
|
|||||||
provider = this;
|
provider = this;
|
||||||
|
|
||||||
mutationTopic.listen(function (mutatedObject) {
|
mutationTopic.listen(function (mutatedObject) {
|
||||||
var id = mutatedObject.getId();
|
var status = mutatedObject.getCapability('status');
|
||||||
provider.indexedIds[id] = false;
|
if (!status || !status.get('editing')) {
|
||||||
provider.scheduleForIndexing(id);
|
provider.index(
|
||||||
|
mutatedObject.getId(),
|
||||||
|
mutatedObject.getModel()
|
||||||
|
);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -99,12 +99,19 @@ define([
|
|||||||
.toHaveBeenCalledWith(jasmine.any(Function));
|
.toHaveBeenCalledWith(jasmine.any(Function));
|
||||||
});
|
});
|
||||||
|
|
||||||
it('reschedules indexing when mutation occurs', function () {
|
it('re-indexes when mutation occurs', function () {
|
||||||
var mockDomainObject =
|
var mockDomainObject =
|
||||||
jasmine.createSpyObj('domainObj', ['getId']);
|
jasmine.createSpyObj('domainObj', [
|
||||||
|
'getId',
|
||||||
|
'getModel',
|
||||||
|
'getCapability'
|
||||||
|
]),
|
||||||
|
testModel = { some: 'model' };
|
||||||
mockDomainObject.getId.andReturn("some-id");
|
mockDomainObject.getId.andReturn("some-id");
|
||||||
|
mockDomainObject.getModel.andReturn(testModel);
|
||||||
|
spyOn(provider, 'index').andCallThrough();
|
||||||
mutationTopic.listen.mostRecentCall.args[0](mockDomainObject);
|
mutationTopic.listen.mostRecentCall.args[0](mockDomainObject);
|
||||||
expect(provider.scheduleForIndexing).toHaveBeenCalledWith('some-id');
|
expect(provider.index).toHaveBeenCalledWith('some-id', testModel);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('starts indexing roots', function () {
|
it('starts indexing roots', function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user