Commit 87d51836 authored by Django Janny's avatar Django Janny
Browse files

Merge branch 'develop' into...

Merge branch 'develop' into feature/UNOTOPLYS-79_Gestion_de_la_remontee_des_erreurs_dans_le_front_du_back
parents 3524c153 b255b74f
......@@ -10,6 +10,7 @@ export default class HeaderService {
public static readonly TAB_KEY_VIEW = 'view';
public static readonly TAB_KEY_VARIABLE = 'variable';
public static readonly TAB_KEY_WORKSPACES = 'workspaces';
public static readonly TAB_KEY_FORMS = 'forms';
public static readonly TAB_KEY_USERS = 'users';
constructor(private store: Store<any>, private translationService: TranslationService, private i18n: VueI18n) {
......@@ -90,4 +91,25 @@ export default class HeaderService {
this.store.commit('filArianeElements', res.data);
});
}
public updateTabsForHome(currentKey: string): void {
let tabs = [
{
title: this.i18n.t('onglets.forms'),
link: `/admin/forms`,
isCurrent: currentKey === HeaderService.TAB_KEY_FORMS,
},
{
title: this.i18n.t('onglets.workspaces'),
link: `/admin/workspaces`,
isCurrent: currentKey === HeaderService.TAB_KEY_WORKSPACES,
},
{
title: this.i18n.t('onglets.utilisateurs'),
link: '/admin/user',
isCurrent: currentKey === HeaderService.TAB_KEY_USERS,
},
];
this.store.commit('tabs', tabs);
}
}
......@@ -28,7 +28,9 @@ export default class Login extends mixins(AdminMixin) {
}
}
this.authenticationError = false;
sessionStorage.setItem('requested-url', '/admin');
this.getAccountService()
.retrieveUsersHome()
.then(pathHome => sessionStorage.setItem('requested-url', pathHome));
this.getAccountService().retrieveAccount();
})
.catch(() => {
......
......@@ -26,7 +26,7 @@ export default class UserList extends Vue {
beforeRouteEnter(to, from, next) {
next(vm => {
vm.headerService().filArianeForHome();
vm.headerService().updateTabsForAdmin(TABS.KEY_USERS);
vm.headerService().updateTabsForHome(TABS.KEY_USERS);
});
}
......
import Vue from 'vue';
import Component from 'vue-class-component';
import { Inject } from 'vue-property-decorator';
import FormService from '@/services/form.service';
import WorkspaceService from '@/services/workspace.service';
import HeaderService from '@/shared/service/header-service';
import Card from '@/components/card/card.vue';
import Toolbar from '@/components/toolbar/toolbar.vue';
@Component({
components: {
Card,
Toolbar,
},
})
export default class HomeView extends Vue {
/**
* Service des formulaires.
*/
@Inject('formService')
private formService: () => FormService;
/**
* Service des workspaces.
*/
@Inject('headerService')
private headerService: () => HeaderService;
/**
* Service des workspaces.
*/
@Inject('workspaceService')
private workspaceService: () => WorkspaceService;
/**
* Liste des forms.
*/
public elements = [];
public showForms = false;
public showWorkspaces = false;
/**
* Récupération des workspaces avant de faire l'affichage.
*/
beforeRouteEnter(to, from, next) {
next(vm => {
vm.showForms = to.meta.showForms;
vm.showWorkspaces = to.meta.showWorkspaces;
if (to.meta.showForms) {
vm.retrieveForms();
vm.headerService().updateTabsForHome('forms');
} else if (to.meta.showWorkspaces) {
vm.retrieveWorkspaces();
vm.headerService().updateTabsForHome('workspaces');
}
vm.headerService().filArianeForHome();
});
}
/**
* Récupération des formulaires du contributeur.
*/
public retrieveForms(): void {
const idUser = this.$store.getters.account.id;
this.formService()
.retrieveWithPermissionForContributeur(idUser)
.then(res => {
this.elements = res.data;
})
.catch(() => (this.elements = []));
}
public retrieveWorkspaces(): void {
const login = this.$store.getters.account.login;
this.workspaceService()
.retrieveWithPermission(login)
.then(res => {
this.elements = res.data;
})
.catch(() => (this.elements = []));
}
public getLink(element): string {
if (this.showForms) {
return `/admin/workspace/${element.workspaceId}/form/${element.id}/view`;
} else if (this.showWorkspaces) {
return `/admin/workspace/${element.id}/view`;
}
}
}
<template>
<section class="max-w-6xl px-4 mx-auto py-9 xl:px-0">
<div class="grid grid-cols-1 gap-4 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4">
<card
v-for="(element, index) in elements"
type="form"
:key="index"
:title="element.name"
:number="element.number_element"
:link="getLink(element)"
></card>
</div>
</section>
</template>
<script lang="ts" src="./home-view.component.ts" />
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment