mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improve editing of evaluation
- an evaluation type can be repeated multiple times on the same action; - in vue, evaluation are listed by key, not id, - adding an evaluation make appears directly in "edit" mode; - ...
This commit is contained in:
parent
9447516694
commit
bab06796f1
@ -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,10 @@ const dateToISO = (date) => {
|
||||
* **Experimental**
|
||||
*/
|
||||
const ISOToDate = (str) => {
|
||||
let
|
||||
[year, month, day] = str.split('-');
|
||||
|
||||
return new Date(year, month-1, day);
|
||||
let
|
||||
[year, month, day] = str.split('-');
|
||||
|
||||
return new Date(year, month-1, day);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -41,53 +41,100 @@ 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) => {
|
||||
if (null === days) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return `PD${days}`;
|
||||
}
|
||||
|
||||
const intervalISOToDays = (str) => {
|
||||
if (null === str) {
|
||||
return null
|
||||
}
|
||||
|
||||
let days = 0;
|
||||
let isDate = true;
|
||||
for (let i = 0; i < str.length; i = i + 1) {
|
||||
// we do not take time into account
|
||||
if (!isDate) {
|
||||
continue;
|
||||
}
|
||||
switch (str.charAt(i)) {
|
||||
case 'P':
|
||||
isDate = true;
|
||||
break;
|
||||
case 'Y':
|
||||
i = i+1;
|
||||
days = days + Number.parseInt(str.charAt(i)) * 365;
|
||||
break;
|
||||
case 'M':
|
||||
i = i+1;
|
||||
days = days + Number.parseInt(str.charAt(i)) * 30;
|
||||
break;
|
||||
case 'D':
|
||||
i = i+1;
|
||||
days = days + Number.parseInt(str.charAt(i));
|
||||
break;
|
||||
case 'T':
|
||||
isDate = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return days;
|
||||
}
|
||||
|
||||
export {
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
ISOToDatetime,
|
||||
datetimeToISO
|
||||
dateToISO,
|
||||
ISOToDate,
|
||||
ISOToDatetime,
|
||||
datetimeToISO,
|
||||
intervalISOToDays,
|
||||
intervalDaysToISO,
|
||||
};
|
||||
|
@ -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,10 +1,10 @@
|
||||
<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>
|
||||
@ -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>
|
||||
@ -70,12 +74,10 @@ export default {
|
||||
components: {
|
||||
FormEvaluation
|
||||
},
|
||||
props: ['evaluation', 'editEvaluation'],
|
||||
props: ['evaluation'],
|
||||
i18n,
|
||||
data() {
|
||||
return {
|
||||
editEvaluation: false,
|
||||
};
|
||||
return {};
|
||||
},
|
||||
computed: {
|
||||
pickedEvaluations() {
|
||||
@ -84,11 +86,12 @@ 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.toggleEditEvaluation();
|
||||
|
@ -164,22 +164,16 @@ export default {
|
||||
},
|
||||
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() {
|
||||
|
@ -179,31 +179,44 @@ const store = createStore({
|
||||
type: "accompanying_period_work_evaluation",
|
||||
key: state.evaluationsPicked.length + 1,
|
||||
evaluation: evaluation,
|
||||
"startDate": null,
|
||||
"endDate": null,
|
||||
"maxDate": null,
|
||||
"warningInterval": null,
|
||||
"comment": "",
|
||||
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);
|
||||
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)
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.startDate = date;
|
||||
},
|
||||
setEvaluationEndDate(state, {key, date}) {
|
||||
state.evaluationsPicked.find(e => e.key == key)
|
||||
state.evaluationsPicked.find(e => e.key === key)
|
||||
.endDate = date;
|
||||
},
|
||||
setEvaluationMaxDate(state, {key, date}) {
|
||||
state.evaluationsPicked.find(e => e.key == key)
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user