|
@@ -27,6 +27,8 @@ class EntityManager {
|
|
|
this.apiRequestService = apiRequestService
|
|
this.apiRequestService = apiRequestService
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ // TODO: renommer les variables entity en 'instance'
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Return the repository for the model
|
|
* Return the repository for the model
|
|
|
*
|
|
*
|
|
@@ -84,7 +86,8 @@ class EntityManager {
|
|
|
let entity = repository.make(properties)
|
|
let entity = repository.make(properties)
|
|
|
|
|
|
|
|
// Keep track of the entity's model
|
|
// Keep track of the entity's model
|
|
|
- entity.setModel(model)
|
|
|
|
|
|
|
+ // TODO : attendre de voir si utile ou non
|
|
|
|
|
+ // entity.setModel(model)
|
|
|
|
|
|
|
|
// @ts-ignore
|
|
// @ts-ignore
|
|
|
if (!properties.hasOwnProperty('id') || !properties.id) {
|
|
if (!properties.hasOwnProperty('id') || !properties.id) {
|
|
@@ -105,6 +108,7 @@ class EntityManager {
|
|
|
* @param entity
|
|
* @param entity
|
|
|
*/
|
|
*/
|
|
|
public save(model: typeof ApiResource, entity: ApiResource): ApiResource {
|
|
public save(model: typeof ApiResource, entity: ApiResource): ApiResource {
|
|
|
|
|
+ this.saveInitialState(model, entity)
|
|
|
return this.getRepository(model).save(entity)
|
|
return this.getRepository(model).save(entity)
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -216,7 +220,8 @@ class EntityManager {
|
|
|
*/
|
|
*/
|
|
|
public async persist(model: typeof ApiModel, entity: ApiModel) {
|
|
public async persist(model: typeof ApiModel, entity: ApiModel) {
|
|
|
// Recast in case class definition has been "lost"
|
|
// Recast in case class definition has been "lost"
|
|
|
- entity = this.cast(model, entity)
|
|
|
|
|
|
|
+ // TODO: attendre de voir si cette ligne est nécessaire
|
|
|
|
|
+ // entity = this.cast(model, entity)
|
|
|
|
|
|
|
|
let url = UrlUtils.join('api', model.entity)
|
|
let url = UrlUtils.join('api', model.entity)
|
|
|
let response
|
|
let response
|