mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 13:54:23 +00:00
accompanying course work: fix on-the-fly update of thirdParty
This commit is contained in:
parent
1f0ef6e187
commit
f139af8b6f
@ -211,7 +211,7 @@
|
|||||||
<template v-slot:record-actions>
|
<template v-slot:record-actions>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li><on-the-fly :type="thirdparty.type" :id="thirdparty.id" action="show"></on-the-fly></li>
|
<li><on-the-fly :type="thirdparty.type" :id="thirdparty.id" action="show"></on-the-fly></li>
|
||||||
<li><on-the-fly :type="thirdparty.type" :id="thirdparty.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly"></on-the-fly></li>
|
<li><on-the-fly :type="thirdparty.type" :id="thirdparty.id" action="edit" @saveFormOnTheFly="saveFormOnTheFly" ref="onTheFly"></on-the-fly></li>
|
||||||
<li>
|
<li>
|
||||||
<button :title="$t('remove_thirdparty')" class="btn btn-sm btn-remove" @click="removeThirdParty(thirdparty)" />
|
<button :title="$t('remove_thirdparty')" class="btn btn-sm btn-remove" @click="removeThirdParty(thirdparty)" />
|
||||||
</li>
|
</li>
|
||||||
@ -286,6 +286,8 @@ import ListWorkflowModal from 'ChillMainAssets/vuejs/_components/EntityWorkflow/
|
|||||||
import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue';
|
import PickWorkflow from 'ChillMainAssets/vuejs/_components/EntityWorkflow/PickWorkflow.vue';
|
||||||
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
import PersonText from 'ChillPersonAssets/vuejs/_components/Entity/PersonText.vue';
|
||||||
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
import {buildLinkCreate} from 'ChillMainAssets/lib/entity-workflow/api.js';
|
||||||
|
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
|
||||||
|
|
||||||
|
|
||||||
const i18n = {
|
const i18n = {
|
||||||
messages: {
|
messages: {
|
||||||
@ -476,15 +478,27 @@ export default {
|
|||||||
},
|
},
|
||||||
saveFormOnTheFly(payload) {
|
saveFormOnTheFly(payload) {
|
||||||
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
|
console.log('saveFormOnTheFly: type', payload.type, ', data', payload.data);
|
||||||
payload.target = 'resource';
|
|
||||||
this.$store.dispatch('patchOnTheFly', payload)
|
let body = { type: payload.type };
|
||||||
.catch(({name, violations}) => {
|
body.name = payload.data.text;
|
||||||
if (name === 'ValidationException' || name === 'AccessException') {
|
body.email = payload.data.email;
|
||||||
violations.forEach((violation) => this.$toast.open({message: violation}));
|
body.telephone = payload.data.phonenumber;
|
||||||
|
body.address = { id: payload.data.address.address_id };
|
||||||
|
|
||||||
|
makeFetch('PATCH', `/api/1.0/thirdparty/thirdparty/${payload.data.id}.json`, body)
|
||||||
|
.then(response => {
|
||||||
|
this.$store.dispatch('updateThirdParty', response)
|
||||||
|
this.$refs.onTheFly.closeModal();
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
if (error.name === 'ValidationException') {
|
||||||
|
for (let v of error.violations) {
|
||||||
|
this.$toast.open({message: v });
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.$toast.open({message: 'An error occurred'})
|
this.$toast.open({message: 'An error occurred'});
|
||||||
}
|
}
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
import { createApp } from 'vue';
|
import { createApp } from 'vue';
|
||||||
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n';
|
||||||
import { store } from './store';
|
import { store } from './store';
|
||||||
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n'
|
import { personMessages } from 'ChillPersonAssets/vuejs/_js/i18n';
|
||||||
|
import VueToast from 'vue-toast-notification';
|
||||||
|
import 'vue-toast-notification/dist/theme-sugar.css';
|
||||||
import App from './App.vue';
|
import App from './App.vue';
|
||||||
|
|
||||||
const i18n = _createI18n(personMessages);
|
const i18n = _createI18n(personMessages);
|
||||||
@ -10,6 +12,12 @@ const app = createApp({
|
|||||||
template: `<app></app>`,
|
template: `<app></app>`,
|
||||||
})
|
})
|
||||||
.use(store)
|
.use(store)
|
||||||
|
.use(VueToast, {
|
||||||
|
position: "bottom-right",
|
||||||
|
type: "error",
|
||||||
|
duration: 5000,
|
||||||
|
dismissible: true
|
||||||
|
})
|
||||||
.use(i18n)
|
.use(i18n)
|
||||||
.component('app', App)
|
.component('app', App)
|
||||||
.mount('#accompanying_course_work_edit');
|
.mount('#accompanying_course_work_edit');
|
||||||
|
@ -266,6 +266,14 @@ const store = createStore({
|
|||||||
state.thirdParties.push(unexistings[i]);
|
state.thirdParties.push(unexistings[i]);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
updateThirdParty(state, thirdParty) {
|
||||||
|
for (let t of state.thirdParties) {
|
||||||
|
if (t.id === thirdParty.id){
|
||||||
|
state.thirdParties = state.thirdParties.filter(t => t.id !== thirdParty.id);
|
||||||
|
state.thirdParties.push(thirdParty);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
removeThirdParty(state, thirdParty) {
|
removeThirdParty(state, thirdParty) {
|
||||||
state.thirdParties = state.thirdParties
|
state.thirdParties = state.thirdParties
|
||||||
.filter(t => t.id !== thirdParty.id);
|
.filter(t => t.id !== thirdParty.id);
|
||||||
@ -278,6 +286,10 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
|
updateThirdParty({ commit }, payload) {
|
||||||
|
console.log(payload);
|
||||||
|
commit('updateThirdParty', payload);
|
||||||
|
},
|
||||||
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
||||||
let
|
let
|
||||||
socialActionId = getters.socialAction.id,
|
socialActionId = getters.socialAction.id,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user