Commit c9f71635 authored by Kevin Robert's avatar Kevin Robert
Browse files

[UNOTOPLYS-189] Listing des variables.

[UNOTOPLYS-191] Ajout d'une variable.
[UNOTOPLYS-192] Modification d'une variable.

Contient les correctifs des requêtes de modification des entités suite à la mise à jour JHipster.
parent 1d3a0b8f
......@@ -125,4 +125,8 @@ public class VariableService {
}
return variableMapper.toDto(variableRepository.findByFormId(formId));
}
public List<VariableDTO> findVariableByFormId(Long formId) {
return variableRepository.findByFormId(formId).stream().map(variableMapper::toDto).collect(Collectors.toList());
}
}
......@@ -144,6 +144,11 @@ public class VariableResource {
return variableService.findAll();
}
@GetMapping("/forms/{formId}/variables")
public List<VariableDTO> getVariableByFormId(@PathVariable Long formId) {
return variableService.findVariableByFormId(formId);
}
/**
* {@code GET /variables/:id} : get the "id" variable.
*
......
......@@ -86,7 +86,7 @@ export default class FormService {
public update(entity: IForm): Promise<IForm> {
return new Promise<IForm>((resolve, reject) => {
axios
.put(`${baseApiUrl}`, entity)
.put(`${baseApiUrl}/${entity.id}`, entity)
.then(res => {
resolve(res.data);
})
......
......@@ -36,7 +36,6 @@ export default class VariableUpdate extends mixins(JhiDataUtils) {
public variables: IVariable[] = [];
@Inject('formService') private formService: () => FormService;
public forms: IForm[] = [];
public isSaving = false;
public currentLanguage = '';
......
......@@ -31,6 +31,19 @@ export default class VariableService {
});
}
public retrieveByFormId(idForm: string): Promise<any> {
return new Promise<any>((resolve, reject) => {
axios
.get(`api/forms/${idForm}/variables`)
.then(res => {
resolve(res);
})
.catch(err => {
reject(err);
});
});
}
public delete(id: number): Promise<any> {
return new Promise<any>((resolve, reject) => {
axios
......@@ -60,7 +73,7 @@ export default class VariableService {
public update(entity: IVariable): Promise<IVariable> {
return new Promise<IVariable>((resolve, reject) => {
axios
.put(`${baseApiUrl}`, entity)
.put(`${baseApiUrl}/${entity.id}`, entity)
.then(res => {
resolve(res.data);
})
......
......@@ -86,7 +86,7 @@ export default class WorkspaceService {
public update(entity: IWorkspace): Promise<IWorkspace> {
return new Promise<IWorkspace>((resolve, reject) => {
axios
.put(`${baseApiUrl}`, entity)
.put(`${baseApiUrl}/${entity.id}`, entity)
.then(res => {
resolve(res.data);
})
......
import { Authority } from '@/shared/security/authority';
const VariableEditComponent = () => import('@/views/variable/variable-edit.vue');
const VariableListComponent = () => import('@/views/variable/variable-list.vue');
export default [
{
path: '/admin/variable/:idVariable/edit',
path: '/admin/workspace/:idWorkspace/form/:idForm/variable/:idVariable/edit',
name: 'VariableEditComponent',
component: VariableEditComponent,
meta: { authorities: [Authority.ADMIN] },
},
{
path: '/admin/workspace/:idWorkspace/form/:idForm/variable/list',
name: 'VariableListComponent',
component: VariableListComponent,
meta: { authorities: [Authority.ADMIN] },
},
{
path: '/admin/workspace/:idWorkspace/form/:idForm/variable/creation',
name: 'VariableEditComponent',
component: VariableEditComponent,
meta: { authorities: [Authority.ADMIN] },
......
......@@ -6,6 +6,13 @@ import TranslationService from '@/locale/translation.service';
const filArianeBaseApiUrl = 'filariane';
export default class HeaderService {
static readonly TAB_KEY_SETTINGS = 'settings';
static readonly TAB_KEY_VIEW = 'view';
static readonly TAB_KEY_VARIABLE = 'variable';
static readonly TAB_KEY_WORKSPACES = 'workspaces';
static readonly TAB_KEY_USERS= 'users';
constructor(private store: Store<any>, private translationService: TranslationService, private i18n: VueI18n) {
this.translationService.refreshTranslation(this.store.getters.currentLanguage);
}
......@@ -15,12 +22,12 @@ export default class HeaderService {
{
title: this.i18n.t('onglets.parametrages'),
link: `/admin/workspace/${workspaceId}/settings`,
isCurrent: currentKey === 'settings',
isCurrent: currentKey === HeaderService.TAB_KEY_SETTINGS,
},
{
title: this.i18n.t('onglets.forms'),
link: `/admin/workspace/${workspaceId}/view`,
isCurrent: currentKey === 'view',
isCurrent: currentKey === HeaderService.TAB_KEY_VIEW,
},
];
this.store.commit('tabs', tabs);
......@@ -31,12 +38,17 @@ export default class HeaderService {
{
title: this.i18n.t('onglets.parametrages'),
link: `/admin/workspace/${workspaceId}/form/${formId}/settings`,
isCurrent: currentKey === 'settings',
isCurrent: currentKey === HeaderService.TAB_KEY_SETTINGS,
},
{
title: this.i18n.t('onglets.edition'),
link: `/admin/workspace/${workspaceId}/form/${formId}/view`,
isCurrent: currentKey === 'view',
isCurrent: currentKey === HeaderService.TAB_KEY_VIEW,
},
{
'title': this.i18n.t('variable.onglets.list'),
'link': `/admin/workspace/${workspaceId}/form/${formId}/variable/list`,
'isCurrent': currentKey === HeaderService.TAB_KEY_VARIABLE
},
];
this.store.commit('tabs', tabs);
......@@ -47,12 +59,12 @@ export default class HeaderService {
{
title: this.i18n.t('onglets.workspaces'),
link: '/admin/workspace/list',
isCurrent: currentTab === 'workspaces',
isCurrent: currentTab === HeaderService.TAB_KEY_WORKSPACES,
},
{
title: this.i18n.t('onglets.utilisateurs'),
link: '/admin/user/list',
isCurrent: currentTab === 'users',
isCurrent: currentTab === HeaderService.TAB_KEY_USERS,
},
];
this.store.commit('tabs', tabs);
......
......@@ -34,7 +34,7 @@ export default class FormSettings extends Vue {
next(vm => {
vm.headerService().filArianeForForm(to.params.idForm);
if (to.params.idForm) {
vm.headerService().updateTabsForFormId(to.params.idWorkspace, to.params.idForm, 'settings');
vm.headerService().updateTabsForFormId(to.params.idWorkspace, to.params.idForm, vm.headerService().TAB_KEY_SETTINGS);
vm.retrieveForm(to.params.idForm);
vm.retrieveAuthorizedUsers(to.params.idForm);
}
......
......@@ -25,7 +25,7 @@ export default class UserList extends Vue {
beforeRouteEnter(to, from, next) {
next(vm => {
vm.headerService().filArianeForHome();
vm.headerService().updateTabsForAdmin('users');
vm.headerService().updateTabsForAdmin(vm.headerService().TAB_KEY_USERS);
});
}
......
import Vue from 'vue';
import Component from 'vue-class-component';
import {Inject} from 'vue-property-decorator';
import VariableService from '@/entities/variable/variable.service';
import {IVariable, Variable} from '@/shared/model/variable.model';
import HeaderService from '@/shared/service/header-service';
import OaInput from '@/components/forms/input/oa-input.vue';
import OaTextarea from '@/components/forms/textarea/oa-textarea.vue';
import OaButton from '@/components/button/oa-button.vue';
@Component
export default class VariableEdit extends Vue {}
@Component({
components: {
OaInput,
OaTextarea,
OaButton,
},
})
export default class VariableEdit extends Vue {
@Inject('variableService')
private variableService: () => VariableService;
@Inject('headerService')
private headerService: () => HeaderService;
public idVariable: String = '';
public variable: IVariable;
public constructor() {
super();
this.variable = new Variable();
}
beforeRouteEnter(to, from, next) {
next(vm => {
vm.headerService().updateTabsForFormId(to.params.idWorkspace, to.params.idForm, vm.headerService().TAB_KEY_VARIABLE);
let idVariable = to.params.idVariable;
vm.variable.formId = to.params.idForm;
if (idVariable) {
vm.idVariable = idVariable;
vm.variableService()
.find(idVariable)
.then(res => {
vm.variable = res;
});
}
});
}
public save() {
if (this.idVariable) {
this.variableService()
.update(this.variable)
.then(() => {
this.$router.go(-1);
});
} else {
this.variableService()
.create(this.variable)
.then(() => {
this.$router.go(-1);
});
}
}
public setName(name: string) {
this.variable.name = name;
}
public setReference(reference: string) {
this.variable.reference = reference;
}
public setDescription(description: string) {
this.variable.description = description;
}
public setExpression(expression: string) {
this.variable.expression = expression;
}
}
<template></template>
<template>
<main>
<section class="max-w-4xl mx-auto p-9">
<div class="flex items-center mb-8">
<h1 class="flex-auto text-4xl">{{ $t('variable.settings.title') }}</h1>
</div>
<form v-on:submit.prevent="save()">
<oa-input v-if="idVariable" id="id" label="ID" type="text" :value="variable.id" required="true" disabled="true"></oa-input>
<oa-input id="name" :label="$t('variable.name')" type="text" :value="variable.name" required="true" @update="setName"></oa-input>
<oa-input id="reference" :label="$t('variable.reference')" type="text" :value="variable.reference" required="true" @update="setReference"></oa-input>
<oa-textarea id="description" :label="$t('variable.description')" :value="variable.description" @update="setDescription"></oa-textarea>
<oa-input id="expression" :label="$t('variable.expression')" type="text" :value="variable.expression" required="true" @update="setExpression"></oa-input>
<oa-button type="submit" variant="primary" :label="$t('button.save')"></oa-button>
</form>
</section>
</main>
</template>
<script lang="ts" src="./variable-edit.component.ts" />
import {Inject, Vue} from 'vue-property-decorator';
import Component from 'vue-class-component';
import HeaderService from '@/shared/service/header-service';
import VariableService from '@/entities/variable/variable.service';
import Toolbar from '@/components/toolbar/toolbar.vue';
@Component({
components: {
Toolbar,
},
})
export default class VariableList extends Vue {
@Inject('variableService')
private variableService: () => VariableService;
/**
* Service du header.
*/
@Inject('headerService')
private headerService: () => HeaderService;
public variables: any[] = [];
public idForm: string = '';
public idWorkspace: string = '';
beforeRouteEnter(to, from, next) {
next(vm => {
vm.idForm = to.params.idForm;
vm.idWorkspace = to.params.idWorkspace;
vm.headerService().updateTabsForFormId(vm.idWorkspace, vm.idForm, vm.headerService().TAB_KEY_VARIABLE);
vm.loadAll(to.params.idForm)
});
}
public loadAll(idForm: string): void {
this.variableService()
.retrieveByFormId(idForm)
.then(res => {
this.variables = res.data;
});
}
public getVariableEditLink(idVariable: String) {
return `/admin/workspace/${this.idWorkspace}/form/${this.idForm}/variable/${idVariable}/edit`;
}
public createVariablePath(): string {
return `/admin/workspace/${this.idWorkspace}/form/${this.idForm}/variable/creation`;
}
}
<template>
<main>
<section class="max-w-6xl px-4 mx-auto py-9 xl:px-0">
<toolbar title="Utilisateurs" :addActionName="$t('variable.actions.add')" :actionLink="createVariablePath()"></toolbar>
<table class="w-full bg-white border-t-2">
<thead class="font-bold">
<tr class="border-b-2">
<th class="p-2 text-left" v-text="$t('variable.id')">ID</th>
<th class="p-2 text-left" v-text="$t('variable.name')">Nom</th>
<th class="p-2 text-left" v-text="$t('variable.reference')">Réference</th>
</tr>
</thead>
<tbody>
<tr v-for="(variable, index) in variables" :key="index" class="text-left align-top border-b">
<td class="p-2">
<a :href="getVariableEditLink(variable.id)">{{ variable.id }}</a>
</td>
<td class="p-2">
<a :href="getVariableEditLink(variable.id)">{{ variable.name }}</a>
</td>
<td class="p-2">
<a :href="getVariableEditLink(variable.id)">{{ variable.reference }}</a>
</td>
</tr>
</tbody>
</table>
</section>
</main>
</template>
<script lang="ts" src="./variable-list.component.ts" />
......@@ -35,7 +35,7 @@ export default class WorkspaceList extends Vue {
beforeRouteEnter(to, from, next) {
next(vm => {
vm.retrieveWorkspace();
vm.headerService().updateTabsForAdmin('workspaces');
vm.headerService().updateTabsForAdmin(vm.headerService().TAB_KEY_WORKSPACES);
vm.headerService().filArianeForHome();
});
}
......
......@@ -35,7 +35,7 @@ export default class WorkspaceSettings extends Vue {
if (to.params.idWorkspace) {
vm.retrieveWorkspace(to.params.idWorkspace);
vm.retrieveAuthorizedUsers(to.params.idWorkspace);
vm.headerService().updateTabsForWorkspaceId(to.params.idWorkspace, 'settings');
vm.headerService().updateTabsForWorkspaceId(to.params.idWorkspace, vm.headerService().TAB_KEY_SETTINGS);
vm.headerService().filArianeForWorkspace(to.params.idWorkspace);
}
});
......
......@@ -38,7 +38,7 @@ export default class WorkspaceView extends Vue {
beforeRouteEnter(to, from, next) {
next(vm => {
vm.retrieveWorkspace(to.params.idWorkspace);
vm.headerService().updateTabsForWorkspaceId(to.params.idWorkspace, 'view');
vm.headerService().updateTabsForWorkspaceId(to.params.idWorkspace, vm.headerService().TAB_KEY_VIEW);
vm.headerService().filArianeForWorkspace(to.params.idWorkspace);
});
}
......
......@@ -30,5 +30,21 @@
"reference": "reference de la variable pour l&#39;utiliser dans les formules"
}
}
},
"variable": {
"actions": {
"add": "Ajouter une variable"
},
"settings": {
"title": "Édition d'une variable"
},
"onglets": {
"list": "Variables"
},
"id": "ID",
"name": "Nom",
"reference": "Référence",
"description": "Description",
"expression": "Expression"
}
}
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