Initial implementation of virtual panel

This commit is contained in:
Henry
2015-10-27 17:38:31 -07:00
parent 19bdf743fc
commit 3e7264d6b8
6 changed files with 150 additions and 38 deletions

View File

@@ -70,6 +70,25 @@ define(
this.$q = $q;
}
// Assemble the results from the model service and the
// capability service into one value, suitable to return
// from this service. Note that ids are matched to capabilities
// by index.
function assembleResult(ids, models, capabilities) {
var result = {};
ids.forEach(function (id, index) {
if (models[id]) {
// Create the domain object
result[id] = new DomainObjectImpl(
id,
models[id],
capabilities[index]
);
}
});
return result;
}
DomainObjectProvider.prototype.getObjects = function getObjects(ids) {
var modelService = this.modelService,
capabilityService = this.capabilityService,
@@ -87,25 +106,6 @@ define(
};
}
// Assemble the results from the model service and the
// capability service into one value, suitable to return
// from this service. Note that ids are matched to capabilities
// by index.
function assembleResult(ids, models, capabilities) {
var result = {};
ids.forEach(function (id, index) {
if (models[id]) {
// Create the domain object
result[id] = new DomainObjectImpl(
id,
models[id],
capabilities[index]
);
}
});
return result;
}
return modelService.getModels(ids).then(function (models) {
return $q.all(
ids.map(capabilityResolver(models))
@@ -115,6 +115,16 @@ define(
});
};
/**
* Given a model, return a fully constituted domain object that has
* not been persisted
* @param model
*/
DomainObjectProvider.prototype.newObject = function newObject(id, model){
var capabilities = this.capabilityService.getCapabilities(model);
return new DomainObjectImpl(id, model, capabilities);
}
return DomainObjectProvider;
}
);

View File

@@ -90,6 +90,15 @@ define(
expect(result.a.getModel()).toEqual(model);
});
it("provides a new, fully constituted domain object for a" +
" provided model", function () {
var model = { someKey: "some value"},
result;
result = provider.newObject("a", model);
expect(result.getId()).toEqual("a");
expect(result.getModel()).toEqual(model);
});
});
}
);