diff --git a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php index 40d8aa6cd..92478d787 100644 --- a/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php +++ b/src/Bundle/ChillAsideActivityBundle/src/Entity/AsideActivity.php @@ -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 diff --git a/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js b/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js index ec66da770..22f935744 100644 --- a/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js +++ b/src/Bundle/ChillMainBundle/Resources/public/chill/js/date.js @@ -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, }; diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php index cd4bb3ac4..050be9f93 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod/AccompanyingPeriodWorkEvaluation.php @@ -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; diff --git a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue index cf18dd4f2..fb143789c 100644 --- a/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue +++ b/src/Bundle/ChillPersonBundle/Resources/public/vuejs/AccompanyingCourseWorkEdit/App.vue @@ -8,7 +8,7 @@
- +
@@ -87,7 +87,7 @@ @@ -96,7 +96,7 @@

{{ $t('available_evaluations_text') }}