|
@@ -47,10 +47,23 @@ class EntityManager {
|
|
|
*
|
|
*
|
|
|
* @param entityName
|
|
* @param entityName
|
|
|
*/
|
|
*/
|
|
|
- public getModelFor(entityName: string): typeof ApiResource{
|
|
|
|
|
|
|
+ public getModelFor(entityName: string): typeof ApiResource {
|
|
|
return models[entityName]
|
|
return models[entityName]
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * Return the model class from an Opentalent Api IRI
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param iri An IRI of the form .../api/<entity>/...
|
|
|
|
|
+ */
|
|
|
|
|
+ public getModelFromIri(iri: string): typeof ApiResource {
|
|
|
|
|
+ const matches = iri.match(/^\/api\/(\w+)\/.*/)
|
|
|
|
|
+ if (!matches || !matches[1]) {
|
|
|
|
|
+ throw new Error('cannot parse the IRI')
|
|
|
|
|
+ }
|
|
|
|
|
+ return this.getModelFor(matches[1])
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* Create a new instance of the given model
|
|
* Create a new instance of the given model
|
|
|
*
|
|
*
|
|
@@ -266,6 +279,9 @@ class EntityManager {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * @Deprecated : a priori ce n'est pas le bon service pour mettre à jour le profil, on devrait voir ça
|
|
|
|
|
+ * depuis un service dédié, un composable, ou directement dans le store
|
|
|
|
|
+ *
|
|
|
* Re-fetch the user profile and update the store
|
|
* Re-fetch the user profile and update the store
|
|
|
*/
|
|
*/
|
|
|
public async refreshProfile() {
|
|
public async refreshProfile() {
|
|
@@ -282,7 +298,6 @@ class EntityManager {
|
|
|
const profile = this.newInstance(MyProfile, hydraResponse.data)
|
|
const profile = this.newInstance(MyProfile, hydraResponse.data)
|
|
|
|
|
|
|
|
// On met à jour le store accessProfile
|
|
// On met à jour le store accessProfile
|
|
|
- // TODO: sortir le use du service, ça devrait être dans un composable
|
|
|
|
|
const accessProfileStore = useAccessProfileStore()
|
|
const accessProfileStore = useAccessProfileStore()
|
|
|
accessProfileStore.setProfile(profile)
|
|
accessProfileStore.setProfile(profile)
|
|
|
}
|
|
}
|