|
|
@@ -134,23 +134,18 @@ class EntityManager {
|
|
|
instance.id = 'tmp' + uuid4()
|
|
|
}
|
|
|
|
|
|
- return this.save(model, instance, true)
|
|
|
+ return this.save(instance, true)
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Save the model instance into the store
|
|
|
*
|
|
|
- * @param model
|
|
|
* @param instance
|
|
|
* @param permanent Is the change already persisted in the datasource? If this is the case, the initial state of this
|
|
|
* record is also updated.
|
|
|
*/
|
|
|
- public save(
|
|
|
- model: typeof ApiResource,
|
|
|
- instance: ApiResource,
|
|
|
- permanent: boolean = false,
|
|
|
- ): ApiResource {
|
|
|
- instance = this.cast(model, instance)
|
|
|
+ public save(instance: ApiResource, permanent: boolean = false): ApiResource {
|
|
|
+ const model = instance.constructor as typeof ApiResource
|
|
|
|
|
|
if (permanent) {
|
|
|
this.saveInitialState(model, instance)
|
|
|
@@ -270,13 +265,10 @@ class EntityManager {
|
|
|
/**
|
|
|
* Persist the model instance as it is in the store into the data source via the API
|
|
|
*
|
|
|
- * @param model
|
|
|
* @param instance
|
|
|
*/
|
|
|
- public async persist(model: typeof ApiModel, instance: ApiModel) {
|
|
|
- // Recast in case class definition has been "lost"
|
|
|
- // TODO: attendre de voir si cette ligne est nécessaire
|
|
|
- instance = this.cast(model, instance)
|
|
|
+ public async persist(instance: ApiModel) {
|
|
|
+ const model = instance.constructor as typeof ApiModel
|
|
|
|
|
|
let url = UrlUtils.join('api', model.entity)
|
|
|
let response
|