Commit aec886c4 authored by Julien BOUYER's avatar Julien BOUYER
Browse files

UNOTOPLYS-166 feat(screen) : modification d'un écran

parent f21e1984
......@@ -69,11 +69,7 @@ out/
######################
# Visual Studio Code
######################
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.vscode/
*.code-workspace
######################
......
......@@ -9,7 +9,7 @@ export const formStore: Module<any, any> = {
state: {
idForm: 0,
form: null,
screenList: null,
screenList: [],
},
getters: {
idForm: state => state.idForm,
......
......@@ -2,15 +2,15 @@ import { Module } from 'vuex';
export const screenStore: Module<any, any> = {
state: {
screen: null,
idScreen: 0,
},
getters: {
screen: state => state.screen,
idScreen: state => state.idScreen,
},
actions: {},
mutations: {
setScreen(state, screen) {
state.screen = screen;
setIdScreen(state, idScreen) {
state.idScreen = idScreen;
},
},
};
import Vue from 'vue';
import { Component, Inject, VModel } from 'vue-property-decorator';
import { Component, Inject } from 'vue-property-decorator';
import OaButton from '@/components/button/oa-button.vue';
import OaInput from '@/components/forms/input/oa-input.vue';
......
import Vue from 'vue';
import Component from 'vue-class-component';
import { Component, Inject } from 'vue-property-decorator';
import ScreenItemEdit from '@/components/screen-item/screen-item-edit.vue';
import StepToolbar from '@/components/step-toolbar/step-toolbar.vue';
import OaButton from '@/components/button/oa-button.vue';
import OaInput from '@/components/forms/input/oa-input.vue';
import StepToolbar from '@/components/step-toolbar/step-toolbar.vue';
import OaTextarea from '@/components/forms/textarea/oa-textarea.vue';
import { IScreen, Screen, screenValidate } from '@/shared/model/screen.model';
import ScreenService from '@/entities/screen/screen.service';
@Component({
components: {
ScreenItemEdit,
OaButton,
OaInput,
OaTextarea,
StepToolbar,
},
})
export default class FormEdit extends Vue {
export default class ScreenEdit extends Vue {
@Inject('screenService') private screenService: () => ScreenService;
public items: any = [{}]; // TODO récupérer les items dans le store
public screen: IScreen = new Screen();
beforeRouteEnter(to, from, next) {
next(vm => {
vm.$store.commit('setIdWorkspace', to.params.idWorkspace);
vm.$store.commit('setIdForm', to.params.idForm);
vm.$store.commit('setIdScreen', to.params.idScreen);
vm.$store.dispatch('loadScreens', to.params.idForm);
vm.retrieveScreen(to.params.idScreen);
});
}
public get stepNum(): number {
const idScreen = this.$store.getters.idScreen;
const index = this.$store.getters.screenList.findIndex((s: IScreen) => s.id === idScreen);
return index + 1;
}
public retrieveScreen(idScreen: number) {
this.screenService()
.find(idScreen)
.then(res => {
this.screen = res;
})
.catch(console.error);
}
public save() {
if (screenValidate.validate(this.screen)) {
this.screenService()
.update(this.screen)
.then(res => {
this.screen = res;
})
.catch(console.error);
} else {
// TODO message d'erreur de validation
}
}
}
<template>
<main>
<section class="max-w-4xl mx-auto p-9">
<h1 class="mb-6 text-3xl">Étape 4</h1>
<oa-input id="0" label="Titre de l’étape" value="Votre profil scolaire" required="true" />
<h1 class="mb-6 text-3xl">{{ $t('screen.label.step', { num: stepNum }) }}</h1>
<oa-input id="0" :label="$t('screen.label.title')" :value="screen.name" required="true" @update="screen.name = $event" />
<oa-input
id="1"
:label="$t('screen.label.reference.label')"
:value="screen.reference"
required="true"
@update="screen.reference = $event"
:helpText="$t('screen.label.reference.helpText')"
/>
<oa-textarea id="2" :label="$t('screen.label.description')" :value="screen.description" @update="screen.description = $event" />
<ul class="flex justify-center border-b-2 mb-8">
<li>
<a class="block p-2 text-blue-500 border-b border-blue-600 py-2" href="#">Contenus</a>
......@@ -15,7 +24,7 @@
<step-toolbar />
<div class="flex items-center">
<div class="text-right flex-grow">
<oa-button type="submit" variant="primary" label="Enregistrer" />
<oa-button type="submit" variant="primary" :label="$t('button.save')" @click="save" />
</div>
</div>
</section>
......
Markdown is supported
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