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

Ajout de l'arrivé sur la page d'édition d'un écran sans l'identifiant de...

Ajout de l'arrivé sur la page d'édition d'un écran sans l'identifiant de l'écran (pour la liste des formulaire).
parent 2ed1ba6e
......@@ -31,7 +31,7 @@ public interface ScreenRepository extends JpaRepository<Screen, Long> {
* @return Le premier écran du formulaire s'il existe.
*/
@Query(
value = "select * from screen join form on form.id = screen.form_id where screen.previous_id is null and form.id = :formId",
value = "select * from screen join form on form.id = screen.form_id where screen.index = 1 and form.id = :formId",
nativeQuery = true
)
Optional<Screen> findFirstScreenOfForm(final @Param("formId") Long formId);
......
......@@ -80,6 +80,12 @@ public class ScreenResource {
return screenService.findScreenByFormId(formId, user);
}
@GetMapping("/forms/{formId}/firstscreen")
public ScreenDTO getFirstScreenForForm(@PathVariable Long formId) {
// TODO : Mettre un vraie exception.
return screenService.findFirstScreenOfForm(formId).orElseThrow(() -> new RuntimeException());
}
/**
* {@code PUT /screens} : Updates an existing screen.
*
......
......@@ -44,6 +44,19 @@ export default class ScreenService {
});
}
public retrieveFirstScreenOfForm(formId): Promise<any> {
return new Promise<any>((resolve, reject) => {
axios
.get(`api/forms/${formId}/firstscreen`)
.then(res => {
resolve(res);
})
.catch(err => {
reject(err);
});
});
}
public delete(id: number): Promise<any> {
return new Promise<any>((resolve, reject) => {
axios
......
......@@ -22,4 +22,13 @@ export default [
panel: 'panel/panel-screen/panel-screen',
},
},
{
path: '/admin/workspace/:idWorkspace/form/:idForm/view',
name: 'FirstScreenEditComponent',
component: ScreenEditComponent,
meta: {
authorities: [Authority.ADMIN],
panel: 'panel/panel-screen/panel-screen',
},
},
];
......@@ -45,7 +45,11 @@ export default class ScreenEdit extends Vue {
this.$store.commit('setIdForm', to.params.idForm);
this.$store.commit('setIdScreen', to.params.idScreen);
this.$store.dispatch('loadScreens', to.params.idForm);
this.retrieveScreen(to.params.idScreen);
if (to.params.idScreen) {
this.retrieveScreen(to.params.idScreen);
} else {
this.retrieveFirstScreenOfForm(to.params.idForm);
}
}
public get stepNum(): number {
......@@ -63,6 +67,16 @@ export default class ScreenEdit extends Vue {
.catch(console.error);
}
public retrieveFirstScreenOfForm(idForm) {
this.screenService()
.retrieveFirstScreenOfForm(idForm)
.then(res => {
this.screen = res.data;
this.$store.commit('setIdScreen', res.data.id);
})
.catch(console.error);
}
public save() {
if (screenValidate.validate(this.screen)) {
this.screenService()
......
......@@ -13,7 +13,7 @@
:title="form.name"
:number="form.number_element"
type="Formulaire"
:link="'/admin/form/' + form.id + '/view'"
:link="'/admin/workspace/' + idWorkspace + '/form/' + form.id + '/view'"
></card>
</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