mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +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\Table(schema="chill_asideactivity")
|
||||
*/
|
||||
final class AsideActivity implements TrackUpdateInterface, TrackCreationInterface
|
||||
class AsideActivity implements TrackUpdateInterface, TrackCreationInterface
|
||||
{
|
||||
/**
|
||||
* @ORM\Id
|
||||
|
@ -13,15 +13,15 @@
|
||||
*
|
||||
*/
|
||||
const dateToISO = (date) => {
|
||||
if (null === date) {
|
||||
return null;
|
||||
}
|
||||
if (null === date) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return [
|
||||
date.getFullYear(),
|
||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||
date.getDate().toString().padStart(2, '0')
|
||||
].join('-');
|
||||
return [
|
||||
date.getFullYear(),
|
||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||
date.getDate().toString().padStart(2, '0')
|
||||
].join('-');
|
||||
};
|
||||
|
||||
/**
|
||||
@ -30,10 +30,17 @@ const dateToISO = (date) => {
|
||||
* **Experimental**
|
||||
*/
|
||||
const ISOToDate = (str) => {
|
||||
let
|
||||
[year, month, day] = str.split('-');
|
||||
|
||||
return new Date(year, month-1, day);
|
||||
if (null === str) {
|
||||
return null;
|
||||
}
|
||||
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) => {
|
||||
if (null === str) {
|
||||
return null;
|
||||
}
|
||||
if (null === str) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let
|
||||
[cal, times] = str.split('T'),
|
||||
[year, month, date] = cal.split('-'),
|
||||
[time, timezone] = times.split(times.charAt(8)),
|
||||
[hours, minutes, seconds] = time.split(':')
|
||||
;
|
||||
let
|
||||
[cal, times] = str.split('T'),
|
||||
[year, month, date] = cal.split('-'),
|
||||
[time, timezone] = times.split(times.charAt(8)),
|
||||
[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
|
||||
*
|
||||
*
|
||||
*/
|
||||
const datetimeToISO = (date) => {
|
||||
let cal, time, offset;
|
||||
cal = [
|
||||
date.getFullYear(),
|
||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||
date.getDate().toString().padStart(2, '0')
|
||||
].join('-');
|
||||
|
||||
time = [
|
||||
date.getHours().toString().padStart(2, '0'),
|
||||
date.getMinutes().toString().padStart(2, '0'),
|
||||
date.getSeconds().toString().padStart(2, '0')
|
||||
].join(':');
|
||||
let cal, time, offset;
|
||||
cal = [
|
||||
date.getFullYear(),
|
||||
(date.getMonth() + 1).toString().padStart(2, '0'),
|
||||
date.getDate().toString().padStart(2, '0')
|
||||
].join('-');
|
||||
|
||||
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;
|
||||
time = [
|
||||
date.getHours().toString().padStart(2, '0'),
|
||||
date.getMinutes().toString().padStart(2, '0'),
|
||||
date.getSeconds().toString().padStart(2, '0')
|
||||
].join(':');
|
||||
|
||||
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 {
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
ISOToDatetime,
|
||||
datetimeToISO
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
ISOToDatetime,
|
||||
datetimeToISO,
|
||||
intervalISOToDays,
|
||||
intervalDaysToISO,
|
||||
};
|
||||
|
@ -74,6 +74,7 @@ class AccompanyingPeriodWorkEvaluation implements TrackUpdateInterface, TrackCre
|
||||
/**
|
||||
* @ORM\Column(type="dateinterval", nullable=true, options={"default": null})
|
||||
* @Serializer\Groups({"read"})
|
||||
* @Serializer\Groups({"write"})
|
||||
* @Serializer\Groups({"accompanying_period_work_evaluation:create"})
|
||||
*/
|
||||
private ?DateInterval $warningInterval = null;
|
||||
|
@ -8,7 +8,7 @@
|
||||
|
||||
<div id="startDate" class="action-row">
|
||||
<label>{{ $t('startDate') }}</label>
|
||||
<input v-model="startDate" type="date"/>
|
||||
<input v-model="startDate" type="date" required="true"/>
|
||||
</div>
|
||||
|
||||
<div id="endDate" class="action-row">
|
||||
@ -87,7 +87,7 @@
|
||||
<!-- list evaluations -->
|
||||
<add-evaluation
|
||||
v-for="e in pickedEvaluations"
|
||||
v-bind:key="e.id"
|
||||
v-bind:key="e.key"
|
||||
v-bind:evaluation="e">
|
||||
</add-evaluation>
|
||||
|
||||
@ -96,7 +96,7 @@
|
||||
<div v-if="showAddEvaluation">
|
||||
<p>{{ $t('available_evaluations_text') }}</p>
|
||||
<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>
|
||||
{{ e.title.fr }}
|
||||
</li>
|
||||
@ -349,12 +349,6 @@ export default {
|
||||
|
||||
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() {
|
||||
return this.$store.state.evaluationsPicked;
|
||||
},
|
||||
|
@ -1,20 +1,20 @@
|
||||
<template>
|
||||
<div>
|
||||
<div class="item-title" @click="removeEvaluation(e)">
|
||||
<div class="item-title" @click="removeEvaluation(evaluation)">
|
||||
<i class="fa fa-fw fa-times"></i>
|
||||
{{ evaluation.evaluation.title.fr }}
|
||||
</div>
|
||||
<div v-if="!editEvaluation">
|
||||
<div v-if="!evaluation.editEvaluation">
|
||||
<dl class="item-details definition-inline">
|
||||
|
||||
<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>
|
||||
<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>
|
||||
<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>
|
||||
<dd v-if="evaluation.warningInterval">{{ evaluation.warningInterval }}</dd>
|
||||
@ -26,7 +26,11 @@
|
||||
<dl class="item-details">
|
||||
|
||||
<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>
|
||||
<ul class="record_actions">
|
||||
@ -35,8 +39,8 @@
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div v-if="editEvaluation">
|
||||
<form-evaluation ref="FormEvaluation" :key="evaluation.id" :evaluation="evaluation"></form-evaluation>
|
||||
<div v-if="evaluation.editEvaluation">
|
||||
<form-evaluation ref="FormEvaluation" :key="evaluation.key" :evaluation="evaluation"></form-evaluation>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<button class="btn btn-sm btn-update" @click="submitForm">{{ $t('action.save') }}</button>
|
||||
@ -73,9 +77,7 @@ export default {
|
||||
props: ['evaluation'],
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
editEvaluation: false,
|
||||
};
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
pickedEvaluations() {
|
||||
@ -84,14 +86,14 @@ export default {
|
||||
},
|
||||
methods: {
|
||||
removeEvaluation(e) {
|
||||
console.log(e);
|
||||
this.$store.commit('removeEvaluation', e);
|
||||
return;
|
||||
},
|
||||
toggleEditEvaluation(e) {
|
||||
this.editEvaluation = !this.editEvaluation;
|
||||
this.$store.commit('toggleEvaluationEdit', { key: this.evaluation.key });
|
||||
},
|
||||
submitForm() {
|
||||
this.$refs.FormEvaluation.saveEvaluation();
|
||||
this.toggleEditEvaluation();
|
||||
}
|
||||
}
|
||||
|
@ -139,56 +139,42 @@ export default {
|
||||
},
|
||||
*/
|
||||
startDate: {
|
||||
get() {
|
||||
if (this.evaluation.startDate) {
|
||||
return this.evaluation.startDate.datetime.split('T')[0];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
set(v) {
|
||||
this.evaluation.startDate.datetime = `${v}T00:00:00+0100`;
|
||||
}
|
||||
get() {
|
||||
return dateToISO(this.evaluation.startDate);
|
||||
},
|
||||
set(v) {
|
||||
console.log(v);
|
||||
this.$store.commit('setEvaluationStartDate', { key: this.evaluation.key, date: ISOToDate(v) });
|
||||
}
|
||||
},
|
||||
endDate: {
|
||||
get() {
|
||||
if (this.evaluation.endDate) {
|
||||
return this.evaluation.endDate.datetime.split('T')[0];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
set(v) {
|
||||
this.evaluation.endDate.datetime = `${v}T00:00:00+0100`;
|
||||
}
|
||||
get() {
|
||||
return dateToISO(this.evaluation.endDate);
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit('setEvaluationEndDate', { key: this.evaluation.key, date: ISOToDate(v) });
|
||||
}
|
||||
},
|
||||
maxDate: {
|
||||
get() {
|
||||
if (this.evaluation.maxDate) {
|
||||
return this.evaluation.maxDate.datetime.split('T')[0];
|
||||
}
|
||||
return null;
|
||||
},
|
||||
set(v) {
|
||||
this.evaluation.maxDate.datetime = `${v}T00:00:00+0100`;
|
||||
}
|
||||
get() {
|
||||
return dateToISO(this.evaluation.maxDate);
|
||||
},
|
||||
set(v) {
|
||||
this.$store.commit('setEvaluationMaxDate', { key: this.evaluation.key, date: ISOToDate(v) });
|
||||
}
|
||||
},
|
||||
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: {
|
||||
get() { return this.evaluation.comment; },
|
||||
set(v) { this.evaluation.comment = v; }
|
||||
set(v) { this.$store.commit('setEvaluationComment', { key: this.evaluation.key, comment: v }); }
|
||||
},
|
||||
template: {
|
||||
get() { return this.evaluation.template; },
|
||||
set(v) { this.evaluation.template = v; }
|
||||
},
|
||||
/*
|
||||
documents: {
|
||||
get() { return this.evaluation.documents; },
|
||||
set(v) { this.evaluation.documents = v; }
|
||||
}
|
||||
*/
|
||||
},
|
||||
methods: {
|
||||
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() {
|
||||
//this.listAllStatus();
|
||||
|
@ -1,26 +1,36 @@
|
||||
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 { create } from 'ChillPersonAssets/vuejs/_api/AccompanyingCourseWork.js';
|
||||
|
||||
const debug = process.env.NODE_ENV !== 'production';
|
||||
|
||||
console.log('acw', window.accompanyingCourseWork);
|
||||
|
||||
const store = createStore({
|
||||
strict: debug,
|
||||
state: {
|
||||
work: window.accompanyingCourseWork,
|
||||
startDate: ISOToDatetime(window.accompanyingCourseWork.startDate.datetime),
|
||||
endDate: (window.accompanyingCourseWork.endDate !== null ?
|
||||
ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null),
|
||||
startDate: window.accompanyingCourseWork.startDate !== null ?
|
||||
ISOToDatetime(window.accompanyingCourseWork.startDate.datetime) : null,
|
||||
endDate: window.accompanyingCourseWork.endDate !== null ?
|
||||
ISOToDatetime(window.accompanyingCourseWork.endDate.datetime) : null,
|
||||
note: window.accompanyingCourseWork.note,
|
||||
goalsPicked: window.accompanyingCourseWork.goals,
|
||||
goalsForAction: [],
|
||||
resultsPicked: window.accompanyingCourseWork.results,
|
||||
resultsForAction: [],
|
||||
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: [],
|
||||
personsPicked: window.accompanyingCourseWork.persons,
|
||||
personsReachables: window.accompanyingCourseWork.accompanyingPeriod.participations.filter(p => p.endDate == null)
|
||||
@ -57,7 +67,7 @@ const store = createStore({
|
||||
return {
|
||||
type: 'accompanying_period_work',
|
||||
id: state.work.id,
|
||||
startDate: {
|
||||
startDate: state.startDate === null ? null : {
|
||||
datetime: datetimeToISO(state.startDate)
|
||||
},
|
||||
endDate: state.endDate === null ? null : {
|
||||
@ -93,16 +103,16 @@ const store = createStore({
|
||||
id: e.evaluation.id,
|
||||
type: e.evaluation.type
|
||||
},
|
||||
startDate: e.startDate,
|
||||
endDate: e.endDate,
|
||||
maxDate: e.maxDate,
|
||||
warningInterval: e.warningInterval,
|
||||
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,
|
||||
warningInterval: intervalDaysToISO(e.warningInterval),
|
||||
comment: e.comment,
|
||||
documents: e.documents
|
||||
};
|
||||
if (e.id !== undefined) {
|
||||
o.id = e.id;
|
||||
}
|
||||
|
||||
return o;
|
||||
})
|
||||
};
|
||||
@ -116,23 +126,18 @@ const store = createStore({
|
||||
state.endDate = date;
|
||||
},
|
||||
setResultsForAction(state, results) {
|
||||
//console.log('set results for action', results);
|
||||
state.resultsForAction = results;
|
||||
},
|
||||
setResultsForGoal(state, { goal, results }) {
|
||||
//console.log('set results for goal', results);
|
||||
state.goalsForAction.push(goal);
|
||||
for (let i in results) {
|
||||
let r = results[i];
|
||||
r.goalId = goal.id;
|
||||
//console.log('adding result', r);
|
||||
state.resultsForGoal.push(r);
|
||||
}
|
||||
},
|
||||
setEvaluationsForAction(state, results) {
|
||||
//console.log('set evaluations for action', results);
|
||||
state.evaluationsForAction = results;
|
||||
console.log('e4a', state.evaluationsForAction);
|
||||
},
|
||||
addResultPicked(state, result) {
|
||||
state.resultsPicked.push(result);
|
||||
@ -154,10 +159,6 @@ const store = createStore({
|
||||
},
|
||||
addResultForGoalPicked(state, { goal, result}) {
|
||||
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) {
|
||||
return;
|
||||
@ -165,7 +166,7 @@ const store = createStore({
|
||||
|
||||
found.results.push(result);
|
||||
},
|
||||
removeResultForGoalPicked(state, { goal, result}) {
|
||||
removeResultForGoalPicked(state, { goal, result }) {
|
||||
let found = state.goalsPicked.find(g => g.goal.id === goal.id);
|
||||
|
||||
if (found === undefined) {
|
||||
@ -177,23 +178,45 @@ const store = createStore({
|
||||
addEvaluation(state, evaluation) {
|
||||
let e = {
|
||||
type: "accompanying_period_work_evaluation",
|
||||
key: state.evaluationsPicked.length + 1,
|
||||
evaluation: evaluation,
|
||||
//startDate,
|
||||
//endDate,
|
||||
//maxDate,
|
||||
//warningInterval
|
||||
//comment,
|
||||
//documents,
|
||||
}
|
||||
startDate: null,
|
||||
endDate: null,
|
||||
maxDate: null,
|
||||
warningInterval: null,
|
||||
comment: "",
|
||||
editEvaluation: true,
|
||||
};
|
||||
state.evaluationsPicked.push(e);
|
||||
console.log('ep', state.evaluationsPicked);
|
||||
},
|
||||
removeEvaluation(state, evaluation) {
|
||||
state.evaluationsPicked = state.evaluationsPicked.filter(e => e.id !== evaluation.id);
|
||||
console.log('ep', state.evaluationsPicked);
|
||||
state.evaluationsPicked = state.evaluationsPicked.filter(e => e.key !== evaluation.key);
|
||||
},
|
||||
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) {
|
||||
//console.log('persons ids', ids);
|
||||
state.personsPicked = state.personsReachables
|
||||
.filter(p => ids.includes(p.id))
|
||||
},
|
||||
@ -204,11 +227,10 @@ const store = createStore({
|
||||
state.handlingThirdParty = thirdParty;
|
||||
},
|
||||
addThirdParties(state, thirdParties) {
|
||||
//console.log('addThirdParties', thirdParties);
|
||||
// filter to remove existing thirdparties
|
||||
let ids = state.thirdParties.map(t => t.id);
|
||||
let unexistings = thirdParties.filter(t => !ids.includes(t.id));
|
||||
//console.log('unexisting third parties', unexistings);
|
||||
|
||||
for (let i in unexistings) {
|
||||
state.thirdParties.push(unexistings[i]);
|
||||
}
|
||||
@ -218,7 +240,6 @@ const store = createStore({
|
||||
.filter(t => t.id !== thirdParty.id);
|
||||
},
|
||||
setErrors(state, errors) {
|
||||
//console.log('handling errors', errors);
|
||||
state.errors = errors;
|
||||
},
|
||||
setIsPosting(state, st) {
|
||||
@ -227,12 +248,10 @@ const store = createStore({
|
||||
},
|
||||
actions: {
|
||||
getReachablesGoalsForAction({ getters, commit, dispatch }) {
|
||||
//console.log('getReachablesGoalsForAction');
|
||||
let
|
||||
socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/goal/by-social-action/${socialActionId}.json`
|
||||
;
|
||||
//console.log(url);
|
||||
window
|
||||
.fetch(
|
||||
url
|
||||
@ -250,11 +269,9 @@ const store = createStore({
|
||||
});
|
||||
},
|
||||
getReachablesResultsForGoal({ commit }, goal) {
|
||||
//console.log('getReachablesResultsForGoal');
|
||||
let
|
||||
url = `/api/1.0/person/social-work/result/by-goal/${goal.id}.json`
|
||||
;
|
||||
//console.log(url);
|
||||
window.fetch(url)
|
||||
.then(response => {
|
||||
if (response.ok) {
|
||||
@ -264,17 +281,14 @@ const store = createStore({
|
||||
throw { m: 'Error while retriving results for goal', s: response.status, b: response.body };
|
||||
})
|
||||
.then(data => {
|
||||
//console.log('data');
|
||||
commit('setResultsForGoal', { goal, results: data.results });
|
||||
});
|
||||
},
|
||||
getReachablesResultsForAction({ getters, commit }) {
|
||||
//console.log('getReachablesResultsForAction');
|
||||
let
|
||||
socialActionId = getters.socialAction.id,
|
||||
url = `/api/1.0/person/social-work/result/by-social-action/${socialActionId}.json`
|
||||
;
|
||||
//console.log(url);
|
||||
window.fetch(url)
|
||||
.then(response => {
|
||||
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 };
|
||||
})
|
||||
.then(data => {
|
||||
//console.log('data retrived', data);
|
||||
commit('setResultsForAction', data.results);
|
||||
});
|
||||
},
|
||||
getReachablesEvaluationsForAction({ getters, commit }) {
|
||||
//console.log('getReachablesEvaluationsForAction');
|
||||
let
|
||||
socialActionId = getters.socialAction.id,
|
||||
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`,
|
||||
errors = []
|
||||
;
|
||||
//console.log('action submitting', payload, url);
|
||||
|
||||
commit('setIsPosting', true);
|
||||
|
||||
window.fetch(url, {
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
@ -347,8 +360,6 @@ const store = createStore({
|
||||
dispatch('getReachablesResultsForAction');
|
||||
dispatch('getReachablesGoalsForAction');
|
||||
dispatch('getReachablesEvaluationsForAction');
|
||||
|
||||
console.log('ep', this.state.evaluationsPicked);
|
||||
},
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user