| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- import {AnyJson, organizationState, OrganizationStore} from "~/types/interfaces";
- /**
- * @category Services/profiles
- * @class OrganizationProfile
- * Classe répondant aux différentes questions que l'on peut se poser sur l'organization de l'access connecté
- */
- class OrganizationProfile{
- private organizationProfile:organizationState
- /**
- * @constructor
- * @param {OrganizationStore} store State organization du store contenant les informations de l'organisation
- */
- constructor(store:OrganizationStore) {
- this.organizationProfile = store.state.profile.organization
- }
- /**
- * Est-ce que l'organisation possède le module
- * @param {Array<string>} modules Modules à tester
- * @return {boolean}
- */
- hasModule(modules:Array<string>):boolean {
- let hasModule = false;
- modules.map((module) => {
- if (this.organizationProfile.modules && this.organizationProfile.modules.indexOf(module) > -1)
- hasModule = true
- });
- return hasModule
- }
- /**
- * L'organization fait-elle partie d'un réseau ?
- * @return {boolean}
- */
- isInsideNetwork(): boolean{
- return this.isCmf() || this.isFfec()
- }
- /**
- * L'organization fait-elle partie du réseau CMF ?
- * @return {boolean}
- */
- isCmf():boolean {
- const networks = this.organizationProfile.networks.filter( (network:string) => {
- return network == process.env.cmf_network
- });
- return networks.length > 0;
- }
- /**
- * L'organization fait-elle partie du réseau FFEC ?
- * @return {boolean}
- */
- isFfec():boolean {
- const networks = this.organizationProfile.networks.filter( (network:string) => {
- return network == process.env.ffec_network
- });
- return networks.length > 0;
- }
- /**
- * L'organization possède t'elle un produit school ou school premium
- * @return {boolean}
- */
- isSchool():boolean {
- return this.isSchoolProduct() || this.isSchoolPremiumProduct()
- }
- /**
- * L'organization possède t'elle un produit artiste ou artiste premium
- * @return {boolean}
- */
- isArtist():boolean {
- return this.isArtistProduct() || this.isArtistPremiumProduct()
- }
- /**
- * L'organization possède t'elle un produit school
- * @return {boolean}
- */
- isSchoolProduct():boolean {
- return this.organizationProfile.product === process.env.school_product
- }
- /**
- * L'organization possède t'elle un produit school premium
- * @return {boolean}
- */
- isSchoolPremiumProduct():boolean {
- return this.organizationProfile.product === process.env.school_premium_product
- }
- /**
- * L'organization possède t'elle un produit premium
- * @return {boolean}
- */
- isArtistProduct():boolean {
- return this.organizationProfile.product === process.env.artist_product
- }
- /**
- * L'organization possède t'elle un produit artiste premium
- * @return {boolean}
- */
- isArtistPremiumProduct():boolean {
- return this.organizationProfile.product === process.env.artist_premium_product
- }
- /**
- * L'organization possède t'elle un produit manager
- * @return {boolean}
- */
- isManagerProduct():boolean {
- return this.organizationProfile.product === process.env.manager_product
- }
- /**
- * L'organization possède t'elledes enfants
- * @return {boolean|null}
- */
- isOrganizationWithChildren():any{
- return this.organizationProfile.hasChildren;
- }
- /**
- * Factory
- * @return {AnyJson} retourne les fonction rendues publiques
- */
- handler():AnyJson{
- return {
- hasModule: this.hasModule.bind(this),
- isSchool: this.isSchool.bind(this),
- isArtist: this.isArtist.bind(this),
- isManagerProduct: this.isManagerProduct.bind(this),
- isOrganizationWithChildren: this.isOrganizationWithChildren.bind(this),
- isCmf: this.isCmf.bind(this)
- }
- }
- }
- export const $organizationProfile = (store:OrganizationStore) => new OrganizationProfile(store);
|