mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-13 05:44:24 +00:00
Merge branch 'features/work-evaluation-save' into 'master'
[Social Work] Save evaluations See merge request Chill-Projet/chill-bundles!126
This commit is contained in:
commit
8c0d8692b0
@ -13,7 +13,7 @@ use Symfony\Component\Validator\Constraints as Assert;
|
|||||||
* @ORM\Entity
|
* @ORM\Entity
|
||||||
* @ORM\Table(schema="chill_asideactivity")
|
* @ORM\Table(schema="chill_asideactivity")
|
||||||
*/
|
*/
|
||||||
final class AsideActivity implements TrackUpdateInterface, TrackCreationInterface
|
class AsideActivity implements TrackUpdateInterface, TrackCreationInterface
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* @ORM\Id
|
* @ORM\Id
|
||||||
|
@ -13,15 +13,15 @@
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const dateToISO = (date) => {
|
const dateToISO = (date) => {
|
||||||
if (null === date) {
|
if (null === date) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
return [
|
return [
|
||||||
date.getFullYear(),
|
date.getFullYear(),
|
||||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||||
date.getDate().toString().padStart(2, '0')
|
date.getDate().toString().padStart(2, '0')
|
||||||
].join('-');
|
].join('-');
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -30,10 +30,17 @@ const dateToISO = (date) => {
|
|||||||
* **Experimental**
|
* **Experimental**
|
||||||
*/
|
*/
|
||||||
const ISOToDate = (str) => {
|
const ISOToDate = (str) => {
|
||||||
let
|
if (null === str) {
|
||||||
[year, month, day] = str.split('-');
|
return null;
|
||||||
|
}
|
||||||
return new Date(year, month-1, day);
|
if ("" === str.trim()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let
|
||||||
|
[year, month, day] = str.split('-');
|
||||||
|
|
||||||
|
return new Date(year, month-1, day);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -41,53 +48,119 @@ const ISOToDate = (str) => {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const ISOToDatetime = (str) => {
|
const ISOToDatetime = (str) => {
|
||||||
if (null === str) {
|
if (null === str) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
let
|
let
|
||||||
[cal, times] = str.split('T'),
|
[cal, times] = str.split('T'),
|
||||||
[year, month, date] = cal.split('-'),
|
[year, month, date] = cal.split('-'),
|
||||||
[time, timezone] = times.split(times.charAt(8)),
|
[time, timezone] = times.split(times.charAt(8)),
|
||||||
[hours, minutes, seconds] = time.split(':')
|
[hours, minutes, seconds] = time.split(':')
|
||||||
;
|
;
|
||||||
|
|
||||||
return new Date(year, month-1, date, hours, minutes, seconds);
|
return new Date(year, month-1, date, hours, minutes, seconds);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert a date to ISO8601, valid for usage in api
|
* Convert a date to ISO8601, valid for usage in api
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
const datetimeToISO = (date) => {
|
const datetimeToISO = (date) => {
|
||||||
let cal, time, offset;
|
let cal, time, offset;
|
||||||
cal = [
|
cal = [
|
||||||
date.getFullYear(),
|
date.getFullYear(),
|
||||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||||
date.getDate().toString().padStart(2, '0')
|
date.getDate().toString().padStart(2, '0')
|
||||||
].join('-');
|
].join('-');
|
||||||
|
|
||||||
time = [
|
|
||||||
date.getHours().toString().padStart(2, '0'),
|
|
||||||
date.getMinutes().toString().padStart(2, '0'),
|
|
||||||
date.getSeconds().toString().padStart(2, '0')
|
|
||||||
].join(':');
|
|
||||||
|
|
||||||
offset = [
|
time = [
|
||||||
date.getTimezoneOffset() <= 0 ? '+' : '-',
|
date.getHours().toString().padStart(2, '0'),
|
||||||
Math.abs(Math.floor(date.getTimezoneOffset() / 60)).toString().padStart(2, '0'),
|
date.getMinutes().toString().padStart(2, '0'),
|
||||||
':',
|
date.getSeconds().toString().padStart(2, '0')
|
||||||
Math.abs(date.getTimezoneOffset() % 60).toString().padStart(2, '0'),
|
].join(':');
|
||||||
].join('');
|
|
||||||
|
|
||||||
let x = cal + 'T' + time + offset;
|
|
||||||
|
|
||||||
return x;
|
offset = [
|
||||||
|
date.getTimezoneOffset() <= 0 ? '+' : '-',
|
||||||
|
Math.abs(Math.floor(date.getTimezoneOffset() / 60)).toString().padStart(2, '0'),
|
||||||
|
':',
|
||||||
|
Math.abs(date.getTimezoneOffset() % 60).toString().padStart(2, '0'),
|
||||||
|
].join('');
|
||||||
|
|
||||||
|
let x = cal + 'T' + time + offset;
|
||||||
|
|
||||||
|
return x;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const intervalDaysToISO = (days) => {
|
||||||
|
console.log(days);
|
||||||
|
if (null === days) {
|
||||||
|
return 'PD0';
|
||||||
|
}
|
||||||
|
|
||||||
|
return `P${days}D`;
|
||||||
|
}
|
||||||
|
|
||||||
|
const intervalISOToDays = (str) => {
|
||||||
|
if (null === str) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("" === str.trim()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
let days = 0;
|
||||||
|
let isDate = true;
|
||||||
|
let vstring = "";
|
||||||
|
for (let i = 0; i < str.length; i = i + 1) {
|
||||||
|
if (!isDate) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch (str.charAt(i)) {
|
||||||
|
case 'P':
|
||||||
|
isDate = true;
|
||||||
|
break;
|
||||||
|
case 'T':
|
||||||
|
isDate = false;
|
||||||
|
break;
|
||||||
|
case '0':
|
||||||
|
case '1':
|
||||||
|
case '2':
|
||||||
|
case '3':
|
||||||
|
case '4':
|
||||||
|
case '5':
|
||||||
|
case '6':
|
||||||
|
case '7':
|
||||||
|
case '8':
|
||||||
|
case '9':
|
||||||
|
vstring = vstring + str.charAt(i);
|
||||||
|
break;
|
||||||
|
case 'Y':
|
||||||
|
days = days + Number.parseInt(vstring) * 365;
|
||||||
|
vstring = "";
|
||||||
|
break;
|
||||||
|
case 'M':
|
||||||
|
days = days + Number.parseInt(vstring) * 30;
|
||||||
|
vstring = "";
|
||||||
|
break;
|
||||||
|
case 'D':
|
||||||
|
days = days + Number.parseInt(vstring);
|
||||||
|
vstring = "";
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw Error("this character should not appears: " + str.charAt(i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return days;
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
dateToISO,
|
dateToISO,
|
||||||
ISOToDate,
|
ISOToDate,
|
||||||
ISOToDatetime,
|
ISOToDatetime,
|
||||||
datetimeToISO
|
datetimeToISO,
|
||||||
|
intervalISOToDays,
|
||||||
|
intervalDaysToISO,
|
||||||
};
|
};
|
||||||
|
@ -74,6 +74,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
|||||||
/**
|
/**
|
||||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||||
* @Serializer\Groups({"read"})
|
* @Serializer\Groups({"read"})
|
||||||
|
* @Serializer\Groups({"write"})
|
||||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||||
*/
|
*/
|
||||||
private ?DateInterval $warningInterval = null;
|
private ?DateInterval $warningInterval = null;
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
<div id="startDate" class="action-row">
|
<div id="startDate" class="action-row">
|
||||||
<label>{{ $t('startDate') }}</label>
|
<label>{{ $t('startDate') }}</label>
|
||||||
<input v-model="startDate" type="date"/>
|
<input v-model="startDate" type="date" required="true"/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="endDate" class="action-row">
|
<div id="endDate" class="action-row">
|
||||||
@ -87,7 +87,7 @@
|
|||||||
<!-- list evaluations -->
|
<!-- list evaluations -->
|
||||||
<add-evaluation
|
<add-evaluation
|
||||||
v-for="e in pickedEvaluations"
|
v-for="e in pickedEvaluations"
|
||||||
v-bind:key="e.id"
|
v-bind:key="e.key"
|
||||||
v-bind:evaluation="e">
|
v-bind:evaluation="e">
|
||||||
</add-evaluation>
|
</add-evaluation>
|
||||||
|
|
||||||
@ -96,7 +96,7 @@
|
|||||||
<div v-if="showAddEvaluation">
|
<div v-if="showAddEvaluation">
|
||||||
<p>{{ $t('available_evaluations_text') }}</p>
|
<p>{{ $t('available_evaluations_text') }}</p>
|
||||||
<ul class="list-evaluations">
|
<ul class="list-evaluations">
|
||||||
<li v-for="e in availableForCheckEvaluation" class="badge bg-primary" @click="addEvaluation(e)">
|
<li v-for="e in evaluationsForAction" class="badge bg-primary" @click="addEvaluation(e)">
|
||||||
<i class="fa fa-plus"></i>
|
<i class="fa fa-plus"></i>
|
||||||
{{ e.title.fr }}
|
{{ e.title.fr }}
|
||||||
</li>
|
</li>
|
||||||
@ -349,12 +349,6 @@ export default {
|
|||||||
|
|
||||||
return this.$store.state.goalsForAction.filter(g => !pickedIds.includes(g.id));
|
return this.$store.state.goalsForAction.filter(g => !pickedIds.includes(g.id));
|
||||||
},
|
},
|
||||||
availableForCheckEvaluation() {
|
|
||||||
//console.log('evaluationsPicked', this.$store.state.evaluationsPicked);
|
|
||||||
//console.log('evaluationsForAction', this.$store.state.evaluationsForAction);
|
|
||||||
let pickedIds = this.$store.state.evaluationsPicked.map(e => e.evaluation.id);
|
|
||||||
return this.$store.state.evaluationsForAction.filter(e => !pickedIds.includes(e.id));
|
|
||||||
},
|
|
||||||
pickedEvaluations() {
|
pickedEvaluations() {
|
||||||
return this.$store.state.evaluationsPicked;
|
return this.$store.state.evaluationsPicked;
|
||||||
},
|
},
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div>
|
<div>
|
||||||
<div class="item-title" @click="removeEvaluation(e)">
|
<div class="item-title" @click="removeEvaluation(evaluation)">
|
||||||
<i class="fa fa-fw fa-times"></i>
|
<i class="fa fa-fw fa-times"></i>
|
||||||
{{ evaluation.evaluation.title.fr }}
|
{{ evaluation.evaluation.title.fr }}
|
||||||
</div>
|
</div>
|
||||||
<div v-if="!editEvaluation">
|
<div v-if="!evaluation.editEvaluation">
|
||||||
<dl class="item-details definition-inline">
|
<dl class="item-details definition-inline">
|
||||||
|
|
||||||
<dt v-if="evaluation.startDate">{{ $t('startDate') }} :</dt>
|
<dt v-if="evaluation.startDate">{{ $t('startDate') }} :</dt>
|
||||||
<dd v-if="evaluation.startDate">{{ $d(evaluation.startDate.datetime, 'short') }}</dd>
|
<dd v-if="evaluation.startDate">{{ $d(evaluation.startDate, 'short') }}</dd>
|
||||||
|
|
||||||
<dt v-if="evaluation.endDate">{{ $t('endDate') }} :</dt>
|
<dt v-if="evaluation.endDate">{{ $t('endDate') }} :</dt>
|
||||||
<dd v-if="evaluation.endDate">{{ $d(evaluation.endDate.datetime, 'short') }}</dd>
|
<dd v-if="evaluation.endDate">{{ $d(evaluation.endDate, 'short') }}</dd>
|
||||||
|
|
||||||
<dt v-if="evaluation.maxDate">{{ $t('maxDate') }} :</dt>
|
<dt v-if="evaluation.maxDate">{{ $t('maxDate') }} :</dt>
|
||||||
<dd v-if="evaluation.maxDate">{{ $d(evaluation.maxDate.datetime, 'short') }}</dd>
|
<dd v-if="evaluation.maxDate">{{ $d(evaluation.maxDate, 'short') }}</dd>
|
||||||
|
|
||||||
<dt v-if="evaluation.warningInterval">{{ $t('warningInterval') }} :</dt>
|
<dt v-if="evaluation.warningInterval">{{ $t('warningInterval') }} :</dt>
|
||||||
<dd v-if="evaluation.warningInterval">{{ evaluation.warningInterval }}</dd>
|
<dd v-if="evaluation.warningInterval">{{ evaluation.warningInterval }}</dd>
|
||||||
@ -26,7 +26,11 @@
|
|||||||
<dl class="item-details">
|
<dl class="item-details">
|
||||||
|
|
||||||
<dt v-if="evaluation.comment">{{ $t('comment') }} :</dt>
|
<dt v-if="evaluation.comment">{{ $t('comment') }} :</dt>
|
||||||
<dd v-if="evaluation.comment">{{ evaluation.comment }}</dd>
|
<dd v-if="evaluation.comment">
|
||||||
|
<blockquote class="chill-user-quote">
|
||||||
|
{{ evaluation.comment }}
|
||||||
|
</blockquote>
|
||||||
|
</dd>
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
@ -35,8 +39,8 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="editEvaluation">
|
<div v-if="evaluation.editEvaluation">
|
||||||
<form-evaluation ref="FormEvaluation" :key="evaluation.id" :evaluation="evaluation"></form-evaluation>
|
<form-evaluation ref="FormEvaluation" :key="evaluation.key" :evaluation="evaluation"></form-evaluation>
|
||||||
<ul class="record_actions">
|
<ul class="record_actions">
|
||||||
<li>
|
<li>
|
||||||
<button class="btn btn-sm btn-update" @click="submitForm">{{ $t('action.save') }}</button>
|
<button class="btn btn-sm btn-update" @click="submitForm">{{ $t('action.save') }}</button>
|
||||||
@ -73,9 +77,7 @@ export default {
|
|||||||
props: ['evaluation'],
|
props: ['evaluation'],
|
||||||
i18n,
|
i18n,
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {};
|
||||||
editEvaluation: false,
|
|
||||||
};
|
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
pickedEvaluations() {
|
pickedEvaluations() {
|
||||||
@ -84,14 +86,14 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
removeEvaluation(e) {
|
removeEvaluation(e) {
|
||||||
|
console.log(e);
|
||||||
this.$store.commit('removeEvaluation', e);
|
this.$store.commit('removeEvaluation', e);
|
||||||
return;
|
return;
|
||||||
},
|
},
|
||||||
toggleEditEvaluation(e) {
|
toggleEditEvaluation(e) {
|
||||||
this.editEvaluation = !this.editEvaluation;
|
this.$store.commit('toggleEvaluationEdit', { key: this.evaluation.key });
|
||||||
},
|
},
|
||||||
submitForm() {
|
submitForm() {
|
||||||
this.$refs.FormEvaluation.saveEvaluation();
|
|
||||||
this.toggleEditEvaluation();
|
this.toggleEditEvaluation();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -139,56 +139,42 @@ export default {
|
|||||||
},
|
},
|
||||||
*/
|
*/
|
||||||
startDate: {
|
startDate: {
|
||||||
get() {
|
get() {
|
||||||
if (this.evaluation.startDate) {
|
return dateToISO(this.evaluation.startDate);
|
||||||
return this.evaluation.startDate.datetime.split('T')[0];
|
},
|
||||||
}
|
set(v) {
|
||||||
return null;
|
console.log(v);
|
||||||
},
|
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) });
|
||||||
set(v) {
|
}
|
||||||
this.evaluation.startDate.datetime = `${v}T00:00:00+0100`;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
endDate: {
|
endDate: {
|
||||||
get() {
|
get() {
|
||||||
if (this.evaluation.endDate) {
|
return dateToISO(this.evaluation.endDate);
|
||||||
return this.evaluation.endDate.datetime.split('T')[0];
|
},
|
||||||
}
|
set(v) {
|
||||||
return null;
|
this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) });
|
||||||
},
|
}
|
||||||
set(v) {
|
|
||||||
this.evaluation.endDate.datetime = `${v}T00:00:00+0100`;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
maxDate: {
|
maxDate: {
|
||||||
get() {
|
get() {
|
||||||
if (this.evaluation.maxDate) {
|
return dateToISO(this.evaluation.maxDate);
|
||||||
return this.evaluation.maxDate.datetime.split('T')[0];
|
},
|
||||||
}
|
set(v) {
|
||||||
return null;
|
this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) });
|
||||||
},
|
}
|
||||||
set(v) {
|
|
||||||
this.evaluation.maxDate.datetime = `${v}T00:00:00+0100`;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
warningInterval: {
|
warningInterval: {
|
||||||
get() { return this.evaluation.warningInterval; },
|
get() { return this.evaluation.warningInterval; },
|
||||||
set(v) { this.evaluation.warningInterval = v; }
|
set(v) { this.$store.commit('setEvaluationWarningInterval', { key: this.evaluation.key, days: v }); }
|
||||||
},
|
},
|
||||||
comment: {
|
comment: {
|
||||||
get() { return this.evaluation.comment; },
|
get() { return this.evaluation.comment; },
|
||||||
set(v) { this.evaluation.comment = v; }
|
set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); }
|
||||||
},
|
},
|
||||||
template: {
|
template: {
|
||||||
get() { return this.evaluation.template; },
|
get() { return this.evaluation.template; },
|
||||||
set(v) { this.evaluation.template = v; }
|
set(v) { this.evaluation.template = v; }
|
||||||
},
|
},
|
||||||
/*
|
|
||||||
documents: {
|
|
||||||
get() { return this.evaluation.documents; },
|
|
||||||
set(v) { this.evaluation.documents = v; }
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
listAllStatus() {
|
listAllStatus() {
|
||||||
@ -203,12 +189,6 @@ export default {
|
|||||||
})
|
})
|
||||||
;
|
;
|
||||||
},
|
},
|
||||||
saveEvaluation() {
|
|
||||||
console.log('save evaluation');
|
|
||||||
|
|
||||||
console.log('dispatch action: post/patch/put evaluation');
|
|
||||||
console.log('commit mutation: update state.mutation');
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
//this.listAllStatus();
|
//this.listAllStatus();
|
||||||
|
@ -1,26 +1,36 @@
|
|||||||
import { createStore } from 'vuex';
|
import { createStore } from 'vuex';
|
||||||
import { datetimeToISO, ISOToDatetime } from 'ChillMainAssets/chill/js/date.js';
|
import { datetimeToISO, ISOToDatetime, intervalDaysToISO, intervalISOToDays } from 'ChillMainAssets/chill/js/date.js';
|
||||||
import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js';
|
import { findSocialActionsBySocialIssue } from 'ChillPersonAssets/vuejs/_api/SocialWorkSocialAction.js';
|
||||||
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
import { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
||||||
|
|
||||||
const debug = process.env.NODE_ENV !== 'production';
|
const debug = process.env.NODE_ENV !== 'production';
|
||||||
|
|
||||||
console.log('acw', window.accompanyingCourseWork);
|
|
||||||
|
|
||||||
const store = createStore({
|
const store = createStore({
|
||||||
strict: debug,
|
strict: debug,
|
||||||
state: {
|
state: {
|
||||||
work: window.accompanyingCourseWork,
|
work: window.accompanyingCourseWork,
|
||||||
startDate: ISOToDatetime(window.accompanyingCourseWork.startDate.datetime),
|
startDate: window.accompanyingCourseWork.startDate !== null ?
|
||||||
endDate: (window.accompanyingCourseWork.endDate !== null ?
|
ISOToDatetime(window.accompanyingCourseWork.startDate.datetime) : null,
|
||||||
ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null),
|
endDate: window.accompanyingCourseWork.endDate !== null ?
|
||||||
|
ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null,
|
||||||
note: window.accompanyingCourseWork.note,
|
note: window.accompanyingCourseWork.note,
|
||||||
goalsPicked: window.accompanyingCourseWork.goals,
|
goalsPicked: window.accompanyingCourseWork.goals,
|
||||||
goalsForAction: [],
|
goalsForAction: [],
|
||||||
resultsPicked: window.accompanyingCourseWork.results,
|
resultsPicked: window.accompanyingCourseWork.results,
|
||||||
resultsForAction: [],
|
resultsForAction: [],
|
||||||
resultsForGoal: [],
|
resultsForGoal: [],
|
||||||
evaluationsPicked: window.accompanyingCourseWork.accompanyingPeriodWorkEvaluations,
|
evaluationsPicked: window.accompanyingCourseWork.accompanyingPeriodWorkEvaluations.map((e, index) => {
|
||||||
|
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,
|
||||||
|
warningInterval: e.warningInterval !== null ? intervalISOToDays(e.warningInterval) : null,
|
||||||
|
});
|
||||||
|
|
||||||
|
return k;
|
||||||
|
}),
|
||||||
evaluationsForAction: [],
|
evaluationsForAction: [],
|
||||||
personsPicked: window.accompanyingCourseWork.persons,
|
personsPicked: window.accompanyingCourseWork.persons,
|
||||||
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
|
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
|
||||||
@ -57,7 +67,7 @@ const store = createStore({
|
|||||||
return {
|
return {
|
||||||
type: 'accompanying_period_work',
|
type: 'accompanying_period_work',
|
||||||
id: state.work.id,
|
id: state.work.id,
|
||||||
startDate: {
|
startDate: state.startDate === null ? null : {
|
||||||
datetime: datetimeToISO(state.startDate)
|
datetime: datetimeToISO(state.startDate)
|
||||||
},
|
},
|
||||||
endDate: state.endDate === null ? null : {
|
endDate: state.endDate === null ? null : {
|
||||||
@ -93,16 +103,16 @@ const store = createStore({
|
|||||||
id: e.evaluation.id,
|
id: e.evaluation.id,
|
||||||
type: e.evaluation.type
|
type: e.evaluation.type
|
||||||
},
|
},
|
||||||
startDate: e.startDate,
|
startDate: e.startDate !== null ? { datetime: datetimeToISO(e.startDate) } : null,
|
||||||
endDate: e.endDate,
|
endDate: e.endDate !== null ? { datetime: datetimeToISO(e.endDate) } : null,
|
||||||
maxDate: e.maxDate,
|
maxDate: e.maxDate !== null ? { datetime: datetimeToISO(e.maxDate) } : null,
|
||||||
warningInterval: e.warningInterval,
|
warningInterval: intervalDaysToISO(e.warningInterval),
|
||||||
comment: e.comment,
|
comment: e.comment,
|
||||||
documents: e.documents
|
|
||||||
};
|
};
|
||||||
if (e.id !== undefined) {
|
if (e.id !== undefined) {
|
||||||
o.id = e.id;
|
o.id = e.id;
|
||||||
}
|
}
|
||||||
|
|
||||||
return o;
|
return o;
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
@ -116,23 +126,18 @@ const store = createStore({
|
|||||||
state.endDate = date;
|
state.endDate = date;
|
||||||
},
|
},
|
||||||
setResultsForAction(state, results) {
|
setResultsForAction(state, results) {
|
||||||
//console.log('set results for action', results);
|
|
||||||
state.resultsForAction = results;
|
state.resultsForAction = results;
|
||||||
},
|
},
|
||||||
setResultsForGoal(state, { goal, results }) {
|
setResultsForGoal(state, { goal, results }) {
|
||||||
//console.log('set results for goal', results);
|
|
||||||
state.goalsForAction.push(goal);
|
state.goalsForAction.push(goal);
|
||||||
for (let i in results) {
|
for (let i in results) {
|
||||||
let r = results[i];
|
let r = results[i];
|
||||||
r.goalId = goal.id;
|
r.goalId = goal.id;
|
||||||
//console.log('adding result', r);
|
|
||||||
state.resultsForGoal.push(r);
|
state.resultsForGoal.push(r);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setEvaluationsForAction(state, results) {
|
setEvaluationsForAction(state, results) {
|
||||||
//console.log('set evaluations for action', results);
|
|
||||||
state.evaluationsForAction = results;
|
state.evaluationsForAction = results;
|
||||||
console.log('e4a', state.evaluationsForAction);
|
|
||||||
},
|
},
|
||||||
addResultPicked(state, result) {
|
addResultPicked(state, result) {
|
||||||
state.resultsPicked.push(result);
|
state.resultsPicked.push(result);
|
||||||
@ -154,10 +159,6 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
addResultForGoalPicked(state, { goal, result}) {
|
addResultForGoalPicked(state, { goal, result}) {
|
||||||
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
||||||
//console.log('adResultForGoalPicked');
|
|
||||||
//console.log('found', found);
|
|
||||||
//console.log('goal', goal);
|
|
||||||
//console.log('result', result);
|
|
||||||
|
|
||||||
if (found === undefined) {
|
if (found === undefined) {
|
||||||
return;
|
return;
|
||||||
@ -165,7 +166,7 @@ const store = createStore({
|
|||||||
|
|
||||||
found.results.push(result);
|
found.results.push(result);
|
||||||
},
|
},
|
||||||
removeResultForGoalPicked(state, { goal, result}) {
|
removeResultForGoalPicked(state, { goal, result }) {
|
||||||
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
||||||
|
|
||||||
if (found === undefined) {
|
if (found === undefined) {
|
||||||
@ -177,23 +178,45 @@ const store = createStore({
|
|||||||
addEvaluation(state, evaluation) {
|
addEvaluation(state, evaluation) {
|
||||||
let e = {
|
let e = {
|
||||||
type: "accompanying_period_work_evaluation",
|
type: "accompanying_period_work_evaluation",
|
||||||
|
key: state.evaluationsPicked.length + 1,
|
||||||
evaluation: evaluation,
|
evaluation: evaluation,
|
||||||
//startDate,
|
startDate: null,
|
||||||
//endDate,
|
endDate: null,
|
||||||
//maxDate,
|
maxDate: null,
|
||||||
//warningInterval
|
warningInterval: null,
|
||||||
//comment,
|
comment: "",
|
||||||
//documents,
|
editEvaluation: true,
|
||||||
}
|
};
|
||||||
state.evaluationsPicked.push(e);
|
state.evaluationsPicked.push(e);
|
||||||
console.log('ep', state.evaluationsPicked);
|
|
||||||
},
|
},
|
||||||
removeEvaluation(state, evaluation) {
|
removeEvaluation(state, evaluation) {
|
||||||
state.evaluationsPicked = state.evaluationsPicked.filter(e => e.id !== evaluation.id);
|
state.evaluationsPicked = state.evaluationsPicked.filter(e => e.key !== evaluation.key);
|
||||||
console.log('ep', state.evaluationsPicked);
|
},
|
||||||
|
setEvaluationStartDate(state, {key, date}) {
|
||||||
|
state.evaluationsPicked.find(e => e.key === key)
|
||||||
|
.startDate = date;
|
||||||
|
},
|
||||||
|
setEvaluationEndDate(state, {key, date}) {
|
||||||
|
state.evaluationsPicked.find(e => e.key === key)
|
||||||
|
.endDate = date;
|
||||||
|
},
|
||||||
|
setEvaluationMaxDate(state, {key, date}) {
|
||||||
|
state.evaluationsPicked.find(e => e.key === key)
|
||||||
|
.maxDate = date;
|
||||||
|
},
|
||||||
|
setEvaluationWarningInterval(state, {key, days}) {
|
||||||
|
state.evaluationsPicked.find(e => e.key === key)
|
||||||
|
.warningInterval = days;
|
||||||
|
},
|
||||||
|
setEvaluationComment(state, {key, comment}) {
|
||||||
|
state.evaluationsPicked.find(e => e.key === key)
|
||||||
|
.comment = comment;
|
||||||
|
},
|
||||||
|
toggleEvaluationEdit(state, {key}) {
|
||||||
|
let evaluation = state.evaluationsPicked.find(e => e.key === key);
|
||||||
|
evaluation.editEvaluation = !evaluation.editEvaluation;
|
||||||
},
|
},
|
||||||
setPersonsPickedIds(state, ids) {
|
setPersonsPickedIds(state, ids) {
|
||||||
//console.log('persons ids', ids);
|
|
||||||
state.personsPicked = state.personsReachables
|
state.personsPicked = state.personsReachables
|
||||||
.filter(p => ids.includes(p.id))
|
.filter(p => ids.includes(p.id))
|
||||||
},
|
},
|
||||||
@ -204,11 +227,10 @@ const store = createStore({
|
|||||||
state.handlingThirdParty = thirdParty;
|
state.handlingThirdParty = thirdParty;
|
||||||
},
|
},
|
||||||
addThirdParties(state, thirdParties) {
|
addThirdParties(state, thirdParties) {
|
||||||
//console.log('addThirdParties', thirdParties);
|
|
||||||
// filter to remove existing thirdparties
|
// filter to remove existing thirdparties
|
||||||
let ids = state.thirdParties.map(t => t.id);
|
let ids = state.thirdParties.map(t => t.id);
|
||||||
let unexistings = thirdParties.filter(t => !ids.includes(t.id));
|
let unexistings = thirdParties.filter(t => !ids.includes(t.id));
|
||||||
//console.log('unexisting third parties', unexistings);
|
|
||||||
for (let i in unexistings) {
|
for (let i in unexistings) {
|
||||||
state.thirdParties.push(unexistings[i]);
|
state.thirdParties.push(unexistings[i]);
|
||||||
}
|
}
|
||||||
@ -218,7 +240,6 @@ const store = createStore({
|
|||||||
.filter(t => t.id !== thirdParty.id);
|
.filter(t => t.id !== thirdParty.id);
|
||||||
},
|
},
|
||||||
setErrors(state, errors) {
|
setErrors(state, errors) {
|
||||||
//console.log('handling errors', errors);
|
|
||||||
state.errors = errors;
|
state.errors = errors;
|
||||||
},
|
},
|
||||||
setIsPosting(state, st) {
|
setIsPosting(state, st) {
|
||||||
@ -227,12 +248,10 @@ const store = createStore({
|
|||||||
},
|
},
|
||||||
actions: {
|
actions: {
|
||||||
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
||||||
//console.log('getReachablesGoalsForAction');
|
|
||||||
let
|
let
|
||||||
socialActionId = getters.socialAction.id,
|
socialActionId = getters.socialAction.id,
|
||||||
url = `/api/1.0/person/social-work/goal/by-social-action/${socialActionId}.json`
|
url = `/api/1.0/person/social-work/goal/by-social-action/${socialActionId}.json`
|
||||||
;
|
;
|
||||||
//console.log(url);
|
|
||||||
window
|
window
|
||||||
.fetch(
|
.fetch(
|
||||||
url
|
url
|
||||||
@ -250,11 +269,9 @@ const store = createStore({
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
getReachablesResultsForGoal({ commit }, goal) {
|
getReachablesResultsForGoal({ commit }, goal) {
|
||||||
//console.log('getReachablesResultsForGoal');
|
|
||||||
let
|
let
|
||||||
url = `/api/1.0/person/social-work/result/by-goal/${goal.id}.json`
|
url = `/api/1.0/person/social-work/result/by-goal/${goal.id}.json`
|
||||||
;
|
;
|
||||||
//console.log(url);
|
|
||||||
window.fetch(url)
|
window.fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@ -264,17 +281,14 @@ const store = createStore({
|
|||||||
throw { m: 'Error while retriving results for goal', s: response.status, b: response.body };
|
throw { m: 'Error while retriving results for goal', s: response.status, b: response.body };
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
//console.log('data');
|
|
||||||
commit('setResultsForGoal', { goal, results: data.results });
|
commit('setResultsForGoal', { goal, results: data.results });
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getReachablesResultsForAction({ getters, commit }) {
|
getReachablesResultsForAction({ getters, commit }) {
|
||||||
//console.log('getReachablesResultsForAction');
|
|
||||||
let
|
let
|
||||||
socialActionId = getters.socialAction.id,
|
socialActionId = getters.socialAction.id,
|
||||||
url = `/api/1.0/person/social-work/result/by-social-action/${socialActionId}.json`
|
url = `/api/1.0/person/social-work/result/by-social-action/${socialActionId}.json`
|
||||||
;
|
;
|
||||||
//console.log(url);
|
|
||||||
window.fetch(url)
|
window.fetch(url)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
@ -284,12 +298,10 @@ const store = createStore({
|
|||||||
throw { m: 'Error while retriving results for social action', s: response.status, b: response.body };
|
throw { m: 'Error while retriving results for social action', s: response.status, b: response.body };
|
||||||
})
|
})
|
||||||
.then(data => {
|
.then(data => {
|
||||||
//console.log('data retrived', data);
|
|
||||||
commit('setResultsForAction', data.results);
|
commit('setResultsForAction', data.results);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
getReachablesEvaluationsForAction({ getters, commit }) {
|
getReachablesEvaluationsForAction({ getters, commit }) {
|
||||||
//console.log('getReachablesEvaluationsForAction');
|
|
||||||
let
|
let
|
||||||
socialActionId = getters.socialAction.id,
|
socialActionId = getters.socialAction.id,
|
||||||
url = `/api/1.0/person/social-work/evaluation/by-social-action/${socialActionId}.json`
|
url = `/api/1.0/person/social-work/evaluation/by-social-action/${socialActionId}.json`
|
||||||
@ -311,8 +323,9 @@ const store = createStore({
|
|||||||
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
|
url = `/api/1.0/person/accompanying-course/work/${state.work.id}.json`,
|
||||||
errors = []
|
errors = []
|
||||||
;
|
;
|
||||||
//console.log('action submitting', payload, url);
|
|
||||||
commit('setIsPosting', true);
|
commit('setIsPosting', true);
|
||||||
|
|
||||||
window.fetch(url, {
|
window.fetch(url, {
|
||||||
method: 'PUT',
|
method: 'PUT',
|
||||||
headers: {
|
headers: {
|
||||||
@ -347,8 +360,6 @@ const store = createStore({
|
|||||||
dispatch('getReachablesResultsForAction');
|
dispatch('getReachablesResultsForAction');
|
||||||
dispatch('getReachablesGoalsForAction');
|
dispatch('getReachablesGoalsForAction');
|
||||||
dispatch('getReachablesEvaluationsForAction');
|
dispatch('getReachablesEvaluationsForAction');
|
||||||
|
|
||||||
console.log('ep', this.state.evaluationsPicked);
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user