Initial implementation of virtual panel
This commit is contained in:
@@ -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;
|
||||
}
|
||||
);
|
||||
|
||||
@@ -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);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
);
|
||||
Reference in New Issue
Block a user