mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-21 15:13:50 +00:00
Squashed commit of the following:
commit 9e767fa3e0788d87437c235e51fcdc4f26f75d98 Author: Julien Fastré <julien.fastre@champs-libres.coop> Date: Mon Jan 17 15:28:02 2022 +0100 traductions commitdb65134743
Author: nobohan <juminet@gmail.com> Date: Mon Jan 17 12:17:22 2022 +0100 add person: increase z-index of toast and wait for validation before closing modal commit7af4c3434e
Merge:a09c8ee8a
46c6d0e29
Author: Julien Fastré <julien.fastre@champs-libres.coop> Date: Sun Jan 16 22:51:45 2022 +0100 Merge remote-tracking branch 'origin/master' into issue357_front_end_validation commita09c8ee8af
Author: nobohan <juminet@gmail.com> Date: Wed Jan 12 15:47:11 2022 +0100 upd CHANGELOG commita312a9463d
Author: nobohan <juminet@gmail.com> Date: Wed Jan 12 15:29:32 2022 +0100 address: display error message if some fields are empty (street & streetnumber) commit0035128138
Author: nobohan <juminet@gmail.com> Date: Wed Jan 12 14:47:43 2022 +0100 address: display error message if some fields are empty commit49cb154672
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 20:58:00 2022 +0100 address: add field validation (WIP) commit1a7ec9e396
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 17:16:43 2022 +0100 Activity: fix vuejs warning commitfa0b9271c2
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 16:13:23 2022 +0100 location: treat 422 error when POSTing new location commitc7b9a1a3fe
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 16:00:29 2022 +0100 location: fix error when creating a new location: a new location could not be added to the availableLocations due to refactoring commitf1c61a2387
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 15:20:33 2022 +0100 person: treat 422 error in AddPerson for thirdparty commit8f6a70b240
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 11:30:05 2022 +0100 person: add validation for required fields in on-the-fly person commit40e4bf953f
Author: nobohan <juminet@gmail.com> Date: Tue Jan 11 09:34:15 2022 +0100 vuejs: better violations message in 422 error handling commit378f3a16fc
Author: nobohan <juminet@gmail.com> Date: Mon Jan 10 18:11:02 2022 +0100 person: on-the-fly person: first implementation of makeFetch for posting person
This commit is contained in:
@@ -11,7 +11,7 @@ import Location from './components/Location.vue';
|
||||
|
||||
export default {
|
||||
name: "App",
|
||||
props: ['hasSocialIssues', 'hasLocation', 'hasPerson'],
|
||||
props: ['hasSocialIssues', 'hasLocation', 'hasPerson'],
|
||||
components: {
|
||||
ConcernedGroups,
|
||||
SocialIssuesAcc,
|
||||
|
@@ -24,7 +24,7 @@
|
||||
v-model="location"
|
||||
>
|
||||
</VueMultiselect>
|
||||
<new-location v-bind:locations="locations"></new-location>
|
||||
<new-location v-bind:availableLocations="availableLocations"></new-location>
|
||||
</div>
|
||||
</div>
|
||||
</teleport>
|
||||
|
@@ -18,15 +18,6 @@
|
||||
</template>
|
||||
<template v-slot:body>
|
||||
<form>
|
||||
<div class="form-floating mb-3">
|
||||
<p v-if="errors.length">
|
||||
<b>{{ $t('activity.errors') }}</b>
|
||||
<ul>
|
||||
<li v-for="error in errors" :key="error">{{ error }}</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="form-floating mb-3">
|
||||
<select class="form-select form-select-lg" id="type" required v-model="selectType">
|
||||
<option selected disabled value="">{{ $t('activity.choose_location_type') }}</option>
|
||||
@@ -62,6 +53,12 @@
|
||||
<input class="form-control form-control-lg" id="email" v-model="inputEmail" placeholder />
|
||||
<label for="email">{{ $t('activity.location_fields.email') }}</label>
|
||||
</div>
|
||||
|
||||
<div class="alert alert-warning" v-if="errors.length">
|
||||
<ul>
|
||||
<li v-for="(e, i) in errors" :key="i">{{ e }}</li>
|
||||
</ul>
|
||||
</div>
|
||||
</form>
|
||||
</template>
|
||||
<template v-slot:footer>
|
||||
@@ -81,7 +78,8 @@
|
||||
import Modal from 'ChillMainAssets/vuejs/_components/Modal.vue';
|
||||
import AddAddress from "ChillMainAssets/vuejs/Address/components/AddAddress.vue";
|
||||
import { mapState } from "vuex";
|
||||
import { getLocationTypes, postLocation } from "../../api";
|
||||
import { getLocationTypes } from "../../api";
|
||||
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||
|
||||
export default {
|
||||
name: "NewLocation",
|
||||
@@ -89,7 +87,7 @@ export default {
|
||||
Modal,
|
||||
AddAddress,
|
||||
},
|
||||
props: ['locations'],
|
||||
props: ['availableLocations'],
|
||||
data() {
|
||||
return {
|
||||
errors: [],
|
||||
@@ -223,7 +221,6 @@ export default {
|
||||
},
|
||||
saveNewLocation() {
|
||||
if (this.checkForm()) {
|
||||
console.log('saveNewLocation', this.selected);
|
||||
let body = {
|
||||
type: 'location',
|
||||
name: this.selected.name,
|
||||
@@ -242,23 +239,28 @@ export default {
|
||||
}
|
||||
});
|
||||
}
|
||||
postLocation(body)
|
||||
.then(
|
||||
location => new Promise(resolve => {
|
||||
this.locations.push(location);
|
||||
this.$store.dispatch('updateLocation', location);
|
||||
resolve();
|
||||
this.modal.showModal = false;
|
||||
})
|
||||
).catch(
|
||||
err => {
|
||||
this.errors.push(err.message);
|
||||
|
||||
makeFetch('POST', '/api/1.0/main/location.json', body)
|
||||
.then(response => {
|
||||
this.$store.dispatch('addAvailableLocationGroup', {
|
||||
locationGroup: 'Localisations nouvellement créées',
|
||||
locations: [response]
|
||||
});
|
||||
this.$store.dispatch('updateLocation', response);
|
||||
this.modal.showModal = false;
|
||||
})
|
||||
.catch((error) => {
|
||||
if (error.name === 'ValidationException') {
|
||||
for (let v of error.violations) {
|
||||
this.errors.push(v);
|
||||
}
|
||||
} else {
|
||||
this.errors.push('An error occurred');
|
||||
}
|
||||
);
|
||||
})
|
||||
};
|
||||
},
|
||||
submitNewAddress(payload) {
|
||||
console.log('submitNewAddress', payload);
|
||||
this.selected.addressId = payload.addressId;
|
||||
this.addAddress.context.addressId = payload.addressId;
|
||||
this.addAddress.context.edit = true;
|
||||
|
@@ -12,7 +12,11 @@ const hasLocation = document.querySelector('#location') !== null;
|
||||
const hasPerson = document.querySelector('#add-persons') !== null;
|
||||
|
||||
const app = createApp({
|
||||
template: `<app :hasSocialIssues="hasSocialIssues", :hasLocation="hasLocation", :hasPerson="hasPerson"></app>`,
|
||||
template: `<app
|
||||
:hasSocialIssues="hasSocialIssues"
|
||||
:hasLocation="hasLocation"
|
||||
:hasPerson="hasPerson"
|
||||
></app>`,
|
||||
data() {
|
||||
return {
|
||||
hasSocialIssues,
|
||||
|
@@ -240,6 +240,9 @@ const store = createStore({
|
||||
});
|
||||
commit("updateActionsSelected", payload);
|
||||
},
|
||||
addAvailableLocationGroup({ commit }, payload) {
|
||||
commit("addAvailableLocationGroup", payload);
|
||||
},
|
||||
addPersonsInvolved({ commit }, payload) {
|
||||
//console.log('### action addPersonsInvolved', payload.result.type);
|
||||
switch (payload.result.type) {
|
||||
|
Reference in New Issue
Block a user