Merge remote-tracking branch 'origin/master' into issue557_address_civility_in_form_person

This commit is contained in:
2022-05-06 10:21:13 +02:00
403 changed files with 2662 additions and 41292 deletions

View File

@@ -5,9 +5,8 @@
</h2>
<div>
<div class="mb-3 row">
<label class="col-form-label col-sm-4">{{ $t('startdate.date') }}</label>
<div class="col-sm-8">
<input class="form-control" type="date" v-model="startDate" @change="updateStartDate" />
<div class="col-sm-12 date-update">
<input class="form-control" type="date" id="startDate" v-model="startDateInput">
</div>
</div>
</div>
@@ -17,30 +16,54 @@
<script>
import { datetimeToISO, dateToISO, ISOToDate, ISOToDatetime} from 'ChillMainAssets/chill/js/date.js';
import { mapState, mapGetters } from 'vuex';
import { dateToISO, ISOToDatetime} from 'ChillMainAssets/chill/js/date.js';
import { mapState } from 'vuex';
export default {
name: 'startDate',
methods: {
updateStartDate(event) {
const date = event.target.value;
// console.log(date)
this.$store.dispatch('updateStartDate', date)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
});
},
data() {
return {
lastRecordedDate: null
}
},
computed: {
...mapState({
startDate: state => dateToISO(ISOToDatetime(state.accompanyingCourse.openingDate.datetime))
})
}),
startDateInput: {
get() {
return this.startDate;
},
set(value) {
this.lastRecordedDate = value;
setTimeout(() => {
console.log('timeout finished')
if (this.lastRecordedDate === value) {
console.log('last recorded', this.lastRecordedDate, 'value', value)
this.$store.dispatch('updateStartDate', value)
.catch(({name, violations}) => {
if (name === 'ValidationException' || name === 'AccessException') {
violations.forEach((violation) => this.$toast.open({message: violation}));
} else {
this.$toast.open({message: 'An error occurred'})
}
})
}
}, 3000)
}
}
}
}
</script>
</script>
<style lang="scss" scoped>
.date-update {
display: flex;
justify-content: space-between;
&-btn {
margin-left: 1rem;
}
}
</style>

View File

@@ -59,8 +59,8 @@ const appMessages = {
ok: "Oui, l'usager quitte le parcours",
show_household_number: "Voir le ménage (n° {id})",
show_household: "Voir le ménage",
person_without_household_warning: "Certaines usagers n'appartiennent actuellement à aucun ménage. Renseignez leur appartenance dès que possible.",
update_household: "Renseigner l'appartenance",
person_without_household_warning: "Certaines usagers n'appartiennent actuellement à aucun ménage. Veuillez les associer à un ménage dès que possible.",
update_household: "Associer à un ménage",
participation_not_valid: "Sélectionnez ou créez au minimum 1 usager",
},
requestor: {
@@ -153,7 +153,7 @@ const appMessages = {
},
startdate: {
change: "Date d'ouverture",
date: "Date d'ouverture",
// update: "La nouvelle date d'ouverture a été enregistrée"
},
// catch errors
'Error while updating AccompanyingPeriod Course.': "Erreur du serveur lors de la mise à jour du parcours d'accompagnement.",

View File

@@ -322,7 +322,6 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
}
},
updateStartDate(state, date) {
console.log('new state date', date)
state.accompanyingCourse.openingDate = date;
}
},
@@ -814,11 +813,9 @@ let initPromise = (root) => Promise.all([getScopesPromise(root), accompanyingCou
})
},
updateStartDate({commit}, payload) {
console.log('payload', payload)
const date = ISOToDate(payload);
const url = `/api/1.0/person/accompanying-course/${id}.json`;
const body = { type: "accompanying_period", openingDate: { datetime: datetimeToISO(date) }};
console.log('body', body)
const date = payload === null || payload === '' ? null : { datetime: datetimeToISO(ISOToDate(payload)) }
const body = { type: "accompanying_period", openingDate: date};
return makeFetch('PATCH', url, body)
.then((response) => {
commit('updateStartDate', response.openingDate);

View File

@@ -227,19 +227,18 @@ export default {
},
startDate: {
get() {
let d = this.$store.state.startDate;
return dateToISO(d);
return this.$store.state.startDate;
},
set(value) {
this.$store.commit('setStartDate', ISOToDate(value));
this.$store.commit('setStartDate', value);
}
},
endDate: {
get() {
return dateToISO(this.$store.state.endDate);
return this.$store.state.endDate;
},
set(value) {
this.$store.commit('setEndDate', ISOToDate(value));
this.$store.commit('setEndDate', value);
}
},
setSocialIssue: {

View File

@@ -1,6 +1,6 @@
import { createStore } from 'vuex';
import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js';
import { datetimeToISO, dateToISO, ISOToDate, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js';
// import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
import { makeFetch } from 'ChillMainAssets/lib/api/apiMethods';
@@ -20,7 +20,7 @@ const store = createStore({
.map(p => p.person),
personsReachables: window.accompanyingCourse.participations.filter(p => p.endDate == null)
.map(p => p.person),
startDate: new Date(),
startDate: dateToISO(new Date()),
endDate: null,
isLoadingSocialActions: false,
isPostingWork: false,
@@ -47,7 +47,7 @@ const store = createStore({
id: state.socialActionPicked.id
},
startDate: {
datetime: datetimeToISO(state.startDate)
datetime: datetimeToISO(ISOToDate(state.startDate))
},
persons: []
};
@@ -61,7 +61,7 @@ const store = createStore({
if (null !== state.endDate) {
payload.endDate = {
datetime: datetimeToISO(state.endDate)
datetime: datetimeToISO(ISOToDate(state.endDate))
};
}
@@ -111,6 +111,7 @@ const store = createStore({
state.startDate = date;
},
setEndDate(state, date) {
console.log(date)
state.endDate = date;
},
setPersonsPickedIds(state, ids) {

View File

@@ -439,18 +439,18 @@ export default {
]),
startDate: {
get() {
return dateToISO(this.$store.state.startDate);
return this.$store.state.startDate;
},
set(v) {
this.$store.commit('setStartDate', ISOToDate(v));
this.$store.commit('setStartDate', v);
}
},
endDate: {
get() {
return dateToISO(this.$store.state.endDate);
return this.$store.state.endDate;
},
set(v) {
this.$store.commit('setEndDate', ISOToDate(v));
this.$store.commit('setEndDate', v);
}
},
note: {
@@ -521,12 +521,12 @@ export default {
this.$store.commit('removeReferrer', u);
},
goToGenerateWorkflow({link}) {
console.log('save before leave to generate workflow')
const callback = (data) => {
window.location.assign(link);
};
// console.log('save before leave to generate workflow')
const callback = (data) => {
window.location.assign(link);
};
return this.$store.dispatch('submit', callback)
return this.$store.dispatch('submit', callback)
.catch(e => { console.log(e); throw e; });
},
submit() {

View File

@@ -298,38 +298,39 @@ export default {
}
},
computed: {
...mapState([
'isPosting'
]),
...mapState([
'isPosting'
]),
getTemplatesAvailables() {
return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation);
return this.$store.getters.getTemplatesAvailablesForEvaluation(this.evaluation.evaluation);
},
canGenerate() {
return !this.$store.state.isPosting && this.template !== null;
return !this.$store.state.isPosting && this.template !== null;
},
startDate: {
get() {
return dateToISO(this.evaluation.startDate);
},
set(v) {
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
get() {
console.log('evaluation', this.evaluation);
return this.evaluation.startDate;
},
set(v) {
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: v });
}
},
endDate: {
get() {
return dateToISO(this.evaluation.endDate);
},
set(v) {
this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
get() {
return this.evaluation.endDate;
},
set(v) {
this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: v });
}
},
maxDate: {
get() {
return dateToISO(this.evaluation.maxDate);
},
set(v) {
this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) });
}
get() {
return this.evaluation.maxDate;
},
set(v) {
this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: v });
}
},
warningInterval: {
get() { return this.evaluation.warningInterval; },
@@ -344,7 +345,7 @@ export default {
ISOToDatetime,
canEditDocument(document) {
return 'storedObject' in document ?
this.mime.includes(document.storedObject.type) && document.storedObject.keyInfos.length === 0 : false;
this.mime.includes(document.storedObject.type) : false;
},
listAllStatus() {
console.log('load all status');
@@ -360,16 +361,16 @@ export default {
},
buildEditLink(storedObject) {
return `/wopi/edit/${storedObject.uuid}?returnPath=` + encodeURIComponent(
window.location.pathname + window.location.search + window.location.hash);
window.location.pathname + window.location.search + window.location.hash);
},
submitBeforeGenerate({template}) {
const callback = (data) => {
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
const callback = (data) => {
let evaluationId = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key).id;
window.location.assign(buildLink(template, evaluationId, 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation'));
};
window.location.assign(buildLink(template, evaluationId, 'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluation'));
};
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
return this.$store.dispatch('submit', callback).catch(e => { console.log(e); throw e; });
},
onInputDocumentTitle(event) {
const id = Number(event.target.id);
@@ -395,20 +396,20 @@ export default {
},
removeDocument(document) {
if (window.confirm("Êtes-vous sûr·e de vouloir supprimer le document qui a pour titre \"" + document.title +"\" ?")) {
this.$store.commit('removeDocument', {key: this.evaluation.key, document: document});
this.$store.commit('removeDocument', {key: this.evaluation.key, document: document});
}
},
goToGenerateWorkflowEvaluationDocument({event, link, workflowName, payload}) {
const callback = (data) => {
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
let updatedDocument = evaluation.documents.find(d => d.key === payload.doc.key);
window.location.assign(buildLinkCreate(workflowName,
'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', updatedDocument.id));
};
const callback = (data) => {
let evaluation = data.accompanyingPeriodWorkEvaluations.find(e => e.key === this.evaluation.key);
let updatedDocument = evaluation.documents.find(d => d.key === payload.doc.key);
window.location.assign(buildLinkCreate(workflowName,
'Chill\\PersonBundle\\Entity\\AccompanyingPeriod\\AccompanyingPeriodWorkEvaluationDocument', updatedDocument.id));
};
return this.$store.dispatch('submit', callback)
.catch(e => { console.log(e); throw e; });
},
return this.$store.dispatch('submit', callback)
.catch(e => { console.log(e); throw e; });
},
},
}
</script>

View File

@@ -1,5 +1,5 @@
import { createStore } from 'vuex';
import { datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js';
import { dateToISO, ISOToDate, datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js';
import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js';
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
import { fetchResults, makeFetch } from 'ChillMainAssets/lib/api/apiMethods.js';
@@ -13,9 +13,9 @@ const store = createStore({
state: {
work: window.accompanyingCourseWork,
startDate: window.accompanyingCourseWork.startDate !== null ?
ISOToDatetime(window.accompanyingCourseWork.startDate.datetime) : null,
dateToISO(new Date(window.accompanyingCourseWork.startDate.datetime)) : null,
endDate: window.accompanyingCourseWork.endDate !== null ?
ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null,
dateToISO(new Date(window.accompanyingCourseWork.endDate.datetime)) : null,
note: window.accompanyingCourseWork.note,
goalsPicked: window.accompanyingCourseWork.goals,
goalsForAction: [],
@@ -72,11 +72,11 @@ const store = createStore({
return {
type: 'accompanying_period_work',
id: state.work.id,
startDate: state.startDate === null ? null : {
datetime: datetimeToISO(state.startDate)
startDate: state.startDate === null || state.startDate === '' ? null : {
datetime: datetimeToISO(ISOToDate(state.startDate))
},
endDate: state.endDate === null ? null : {
datetime: datetimeToISO(state.endDate)
endDate: state.endDate === null || state.endDate === '' ? null : {
datetime: datetimeToISO(ISOToDate(state.endDate))
},
note: state.note,
persons: state.personsPicked.map(p => ({id: p.id, type: p.type})),
@@ -110,9 +110,9 @@ const store = createStore({
id: e.evaluation.id,
type: e.evaluation.type
},
startDate: e.startDate !== null ? { datetime: datetimeToISO(e.startDate) } : null,
endDate: e.endDate !== null ? { datetime: datetimeToISO(e.endDate) } : null,
maxDate: e.maxDate !== null ? { datetime: datetimeToISO(e.maxDate) } : null,
startDate: e.startDate === null || e.startDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.startDate)) },
endDate: e.endDate === null || e.endDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.endDate)) },
maxDate: e.maxDate === null || e.maxDate === '' ? null : { datetime: datetimeToISO(ISOToDate(e.maxDate)) },
warningInterval: intervalDaysToISO(e.warningInterval),
comment: e.comment,
documents: e.documents
@@ -132,9 +132,9 @@ const store = createStore({
var k = Object.assign(e, {
key: index,
editEvaluation: false,
startDate: e.startDate !== null ? ISOToDatetime(e.startDate.datetime) : null,
endDate: e.endDate !== null ? ISOToDatetime(e.endDate.datetime) : null,
maxDate: e.maxDate !== null ? ISOToDatetime(e.maxDate.datetime) : null,
startDate: e.startDate !== null ? dateToISO(new Date(e.startDate.datetime)) : null,
endDate: e.endDate !== null ? dateToISO(new Date(e.endDate.datetime)) : null,
maxDate: e.maxDate !== null ? dateToISO(new Date(e.maxDate.datetime)) : null,
warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null,
documents: e.documents.map((d, docIndex) => {
return Object.assign(d, {
@@ -244,7 +244,7 @@ const store = createStore({
type: "accompanying_period_work_evaluation",
key: state.evaluationsPicked.length + 1,
evaluation: evaluation,
startDate: new Date(),
startDate: dateToISO(new Date()),
endDate: null,
maxDate: null,
warningInterval: null,
@@ -264,6 +264,7 @@ const store = createStore({
.startDate = date;
},
setEvaluationEndDate(state, {key, date}) {
console.log('commit date', date)
state.evaluationsPicked.find(e => e.key === key)
.endDate = date;
},

View File

@@ -66,18 +66,19 @@ export default {
},
startDate: {
get() {
return [
this.$store.state.startDate.getFullYear(),
(this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'),
this.$store.state.startDate.getDate().toString().padStart(2, '0')
].join('-');
return this.$store.state.startDate;
// return [
// this.$store.state.startDate.getFullYear(),
// (this.$store.state.startDate.getMonth() + 1).toString().padStart(2, '0'),
// this.$store.state.startDate.getDate().toString().padStart(2, '0')
// ].join('-');
},
set(value) {
let
[year, month, day] = value.split('-'),
dValue = new Date(year, month-1, day);
// let
// [year, month, day] = value.split('-'),
// dValue = new Date(year, month-1, day);
this.$store.dispatch('setStartDate', dValue);
this.$store.dispatch('setStartDate', value);
}
}
}

View File

@@ -2,7 +2,7 @@ import { createStore } from 'vuex';
import { householdMove, fetchHouseholdSuggestionByAccompanyingPeriod, fetchAddressSuggestionByPerson} from './../api.js';
import { fetchResults } from 'ChillMainAssets/lib/api/apiMethods.js'
import { fetchHouseholdByAddressReference } from 'ChillPersonAssets/lib/household.js';
import { datetimeToISO } from 'ChillMainAssets/chill/js/date.js';
import { datetimeToISO, dateToISO, ISOToDate } from 'ChillMainAssets/chill/js/date.js';
const debug = process.env.NODE_ENV !== 'production';
@@ -30,7 +30,7 @@ const store = createStore({
}
return 0;
}),
startDate: new Date(),
startDate: dateToISO(new Date()),
/**
* Indicates if the destination is:
*
@@ -278,7 +278,7 @@ const store = createStore({
type: conc.person.type
},
start_date: {
datetime: datetimeToISO(state.startDate)
datetime: state.startDate === null || state.startDate === '' ? null : datetimeToISO(ISOToDate(state.startDate))
}
};
@@ -302,7 +302,7 @@ const store = createStore({
},
number_of_children: state.numberOfChildren,
start_date: {
datetime: datetimeToISO(state.startDate),
datetime: datetimeToISO(ISOToDate(state.startDate)),
},
};
}

View File

@@ -472,15 +472,25 @@ export default {
case 'create':
return postRelationship(this.modal.data)
.then(relationship => new Promise(resolve => {
//console.log('post relationship response', relationship)
this.$store.dispatch('addLinkFromRelationship', relationship)
this.modal.showModal = false
this.resetForm()
this.forceUpdateComponent()
resolve()
}))
.catch()
.then(relationship => new Promise(resolve => {
//console.log('post relationship response', relationship)
this.$store.dispatch('addLinkFromRelationship', relationship)
this.modal.showModal = false
this.resetForm()
this.forceUpdateComponent()
resolve()
}))
.catch( error => {
if (error.name === 'ValidationException') {
for (let v of error.violations) {
this.$toast.open({message: v });
console.log(v)
}
} else {
this.$toast.open({message: 'An error occurred'});
}
}
)
case 'edit':
return patchRelationship(this.modal.data)

View File

@@ -1,50 +1,5 @@
import { splitId } from './vis-network'
/**
* @function makeFetch
* @param method
* @param url
* @param body
* @returns {Promise<Response>}
*/
const makeFetch = (method, url, body) => {
return fetch(url, {
method: method,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
body: (body !== null) ? JSON.stringify(body) : null
})
.then(response => {
if (response.ok) {
return response.json();
}
if (response.status === 422) {
return response.json().then(violations => {
throw ValidationException(violations)
});
}
throw {
msg: 'Error while updating AccompanyingPeriod Course.',
sta: response.status,
txt: response.statusText,
err: new Error(),
body: response.body
};
});
}
/**
* @param violations
* @constructor
*/
const ValidationException = (violations) => {
this.violations = violations
this.name = 'ValidationException'
}
import { splitId } from './vis-network';
import {makeFetch} from 'ChillMainAssets/lib/api/apiMethods.js';
/**
* @function getFetch
@@ -136,7 +91,7 @@ const getRelationsList = () => {
* @returns {Promise<Response>}
*/
const postRelationship = (relationship) => {
//console.log(relationship)
//console.log(relationship);
return postFetch(
`/api/1.0/relations/relationship.json`,
{

View File

@@ -3,8 +3,10 @@ import { store } from "./store.js"
import { _createI18n } from 'ChillMainAssets/vuejs/_js/i18n'
import { visMessages } from './i18n'
import App from './App.vue'
import VueToast from 'vue-toast-notification';
import 'vue-toast-notification/dist/theme-sugar.css';
import './vis-network'
import './vis-network';
const i18n = _createI18n(visMessages)
const container = document.getElementById('relationship-graph')
@@ -25,5 +27,11 @@ const app = createApp({
})
.use(store)
.use(i18n)
.use(VueToast, {
position: "bottom-right",
type: "error",
duration: 5000,
dismissible: true
})
.component('app', App)
.mount('#relationship-graph')