Loading module/Oscar/src/Oscar/Controller/PersonController.php +23 Changes for module/Oscar/src/Oscar/Controller/PersonController.php: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -499,6 +499,29 @@ class PersonController extends AbstractOscarController $method = $this->getHttpXMethod(); if( $this->isAjax() ){ $action = $this->params()->fromQuery('a'); switch( $action ){ case 'schedule': /** @var TimesheetService $timesheetService */ $timesheetService = $this->getServiceLocator()->get('TimesheetService'); if( $method == "POST" ){ return $this->getResponseInternalError("Pas encore implémenté"); } $datas = $timesheetService->getDayLengthPerson($person); return $this->ajaxResponse($datas); break; default: return $this->getResponseInternalError("Action non-reconnue"); break; } } if( $method == "POST" ){ $action = $this->params()->fromPost('action', null); switch( $action ) { Loading module/Oscar/view/oscar/person/show.phtml +12 −16 Changes for module/Oscar/view/oscar/person/show.phtml: 12 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -221,27 +221,23 @@ <?php if($this->grant()->privilege(\Oscar\Provider\Privileges::PERSON_MANAGE_SCHEDULE)): ?> <h2><i class="icon-clock"></i> Horaires</h2> <div id="manage-schelude"></div> <div id="manage-schedule"></div> <script> require(['vue', 'vue-resource', 'mm', 'PersonSchelude'], function(Vue, VueResource, moment, PersonSchelude){ require(['vue', 'vue-resource', 'mm', 'PersonSchedule'], function(Vue, VueResource, moment, PersonSchedule){ Vue.use(VueResource); Vue.filter('heures', function(v){ var heure = Math.floor(v); var minutes = (v-heure)*60; return heure +':' +minutes; }); new Vue({ 'el': '#manage-schelude' 'el': '#manage-schedule', render: function(h){ return h(PersonSchedule.default, { props: {urlapi:'?a=schedule', edit: true}}) } }) }); </script> <p> Durée d'une journée normale : <strong><?= $schedule['value'] ?></strong><br> Maximum authorisé pour une journée : <strong><?= $schedule['max'] ?></strong><br> Minimum requis pour une journée : <strong><?= $schedule['min'] ?></strong><br> </p> <?php $days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"]; foreach ($days as $index=>$day): ?> <article class="card xs"> <strong><?= $day ?></strong> <em><?= $schedule['days'][$index+1] ?></em> </article> <?php endforeach; ?> <?php endif; ?> Loading public/js/oscar-config.js +1 −1 Changes for public/js/oscar-config.js: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ requirejs.config({ 'ImportIcalUI' : 'oscar/dist/ImportIcalUI', 'PeriodSelector' : 'oscar/dist/PeriodSelector', 'TimesheetDeclarationsList' : 'oscar/dist/TimesheetDeclarationsList', 'PersonSchelude' : 'oscar/dist/PersonSchelude', 'PersonSchedule' : 'oscar/dist/PersonSchedule', }, shim: { "bootstrap": { Loading public/js/oscar/src/PersonSchedule.vue +143 Changes for public/js/oscar/src/PersonSchedule.vue: 143 added lines, 0 removed lines. Original line number Diff line number Diff line <template> <section class="schedule"> <transition name="fade"> <div class="pending overlay" v-if="loading"> <div class="overlay-content"> <i class="icon-spinner animate-spin"></i> {{ loading }} </div> </div> </transition> <transition name="fade"> <div class="pending overlay" v-if="error"> <div class="overlay-content"> <i class="icon-attention-1"></i> {{ error }} </div> </div> </transition> <article class="card xs" v-for="total, day in days"> <h3 class="card-title"> <strong>{{daysLabels[day]}}</strong> <input type="text" v-model="days[day]" v-if="editDay"> <em class="total" @click="handlerEditDays()" v-else>{{ total | heures }}</em> </h3> </article> <article class="card"> <h3 class="card-title"> <strong>Total / semaine</strong> <em class="total">{{ totalWeek | heures }}</em> </h3> </article> <nav> <button @click="handlerEditDays()" class="btn btn-default" v-if="!editDay"><i class="icon-pencil"></i> modifier</button> <button @click="handlerSaveDays()" class="btn btn-primary" v-if="editDay"><i class="icon-floppy"></i> enregistrer</button> <button @click="fetch()" class="btn btn-primary" v-if="editDay"><i class="icon-cancel-circled"></i> annuler</button> </nav> <pre>{{ days }}</pre> </section> </template> <script> // poi watch --format umd --moduleName PersonSchedule --filename.css PersonSchedule.css --filename.js PersonSchedule.js --dist public/js/oscar/dist public/js/oscar/src/PersonSchedule.vue import AjaxResolve from "./AjaxResolve"; export default { name: 'PersonSchedule', props: { urlapi: {default: ''}, edit: { default: false } }, data() { return { daysLabels: { '1': 'Lundi', '2': 'Mardi', '3': 'Mercredi', '4': 'Jeudi', '5': 'Vendredi', '6': 'Samedi', '7': 'Dimanche' }, loading: null, error: null, dayLength: 0.0, days: {}, editDay: null, newValue: 0 } }, computed: { totalWeek(){ let total = 0.0; Object.keys(this.days).forEach(i => { total += parseFloat(this.days[i]); }); return total; } }, methods: { day(index){ if( this.days.hasOwnProperty(index) ){ return this.days[index]; } return this.dayLength; }, handlerEditDays(){ this.editDay = true; }, handlerSaveDays(){ this.loading = "Enregistrement des horaires"; let datas = new FormData(); datas.append('days', this.days); //datas.append('action', 'savedays'); this.$http.post(this.urlapi, datas).then( ok => { this.fetch(); }, ko => { this.error = AjaxResolve.resolve('Impossible de modifier les horaires', ko); } ).then(foo => { this.loading = false }); }, fetch(clear = true) { this.loading = "Chargement des données"; this.$http.get(this.urlapi).then( ok => { console.log(ok.body); this.days = ok.body.days; this.dayLength = ok.body.dayLength; }, ko => { this.error = AjaxResolve.resolve('Impossible de charger les données', ko); } ).then(foo => { this.loading = false; this.editDay = null; }); } }, mounted() { this.fetch(true) } } </script> No newline at end of file public/js/oscar/src/PersonSchelude.vue −67 File deleted. Show changes Loading
module/Oscar/src/Oscar/Controller/PersonController.php +23 Changes for module/Oscar/src/Oscar/Controller/PersonController.php: 23 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -499,6 +499,29 @@ class PersonController extends AbstractOscarController $method = $this->getHttpXMethod(); if( $this->isAjax() ){ $action = $this->params()->fromQuery('a'); switch( $action ){ case 'schedule': /** @var TimesheetService $timesheetService */ $timesheetService = $this->getServiceLocator()->get('TimesheetService'); if( $method == "POST" ){ return $this->getResponseInternalError("Pas encore implémenté"); } $datas = $timesheetService->getDayLengthPerson($person); return $this->ajaxResponse($datas); break; default: return $this->getResponseInternalError("Action non-reconnue"); break; } } if( $method == "POST" ){ $action = $this->params()->fromPost('action', null); switch( $action ) { Loading
module/Oscar/view/oscar/person/show.phtml +12 −16 Changes for module/Oscar/view/oscar/person/show.phtml: 12 added lines, 16 removed lines. Original line number Diff line number Diff line Loading @@ -221,27 +221,23 @@ <?php if($this->grant()->privilege(\Oscar\Provider\Privileges::PERSON_MANAGE_SCHEDULE)): ?> <h2><i class="icon-clock"></i> Horaires</h2> <div id="manage-schelude"></div> <div id="manage-schedule"></div> <script> require(['vue', 'vue-resource', 'mm', 'PersonSchelude'], function(Vue, VueResource, moment, PersonSchelude){ require(['vue', 'vue-resource', 'mm', 'PersonSchedule'], function(Vue, VueResource, moment, PersonSchedule){ Vue.use(VueResource); Vue.filter('heures', function(v){ var heure = Math.floor(v); var minutes = (v-heure)*60; return heure +':' +minutes; }); new Vue({ 'el': '#manage-schelude' 'el': '#manage-schedule', render: function(h){ return h(PersonSchedule.default, { props: {urlapi:'?a=schedule', edit: true}}) } }) }); </script> <p> Durée d'une journée normale : <strong><?= $schedule['value'] ?></strong><br> Maximum authorisé pour une journée : <strong><?= $schedule['max'] ?></strong><br> Minimum requis pour une journée : <strong><?= $schedule['min'] ?></strong><br> </p> <?php $days = ["Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi", "Dimanche"]; foreach ($days as $index=>$day): ?> <article class="card xs"> <strong><?= $day ?></strong> <em><?= $schedule['days'][$index+1] ?></em> </article> <?php endforeach; ?> <?php endif; ?> Loading
public/js/oscar-config.js +1 −1 Changes for public/js/oscar-config.js: 1 added line, 1 removed line. Original line number Diff line number Diff line Loading @@ -75,7 +75,7 @@ requirejs.config({ 'ImportIcalUI' : 'oscar/dist/ImportIcalUI', 'PeriodSelector' : 'oscar/dist/PeriodSelector', 'TimesheetDeclarationsList' : 'oscar/dist/TimesheetDeclarationsList', 'PersonSchelude' : 'oscar/dist/PersonSchelude', 'PersonSchedule' : 'oscar/dist/PersonSchedule', }, shim: { "bootstrap": { Loading
public/js/oscar/src/PersonSchedule.vue +143 Changes for public/js/oscar/src/PersonSchedule.vue: 143 added lines, 0 removed lines. Original line number Diff line number Diff line <template> <section class="schedule"> <transition name="fade"> <div class="pending overlay" v-if="loading"> <div class="overlay-content"> <i class="icon-spinner animate-spin"></i> {{ loading }} </div> </div> </transition> <transition name="fade"> <div class="pending overlay" v-if="error"> <div class="overlay-content"> <i class="icon-attention-1"></i> {{ error }} </div> </div> </transition> <article class="card xs" v-for="total, day in days"> <h3 class="card-title"> <strong>{{daysLabels[day]}}</strong> <input type="text" v-model="days[day]" v-if="editDay"> <em class="total" @click="handlerEditDays()" v-else>{{ total | heures }}</em> </h3> </article> <article class="card"> <h3 class="card-title"> <strong>Total / semaine</strong> <em class="total">{{ totalWeek | heures }}</em> </h3> </article> <nav> <button @click="handlerEditDays()" class="btn btn-default" v-if="!editDay"><i class="icon-pencil"></i> modifier</button> <button @click="handlerSaveDays()" class="btn btn-primary" v-if="editDay"><i class="icon-floppy"></i> enregistrer</button> <button @click="fetch()" class="btn btn-primary" v-if="editDay"><i class="icon-cancel-circled"></i> annuler</button> </nav> <pre>{{ days }}</pre> </section> </template> <script> // poi watch --format umd --moduleName PersonSchedule --filename.css PersonSchedule.css --filename.js PersonSchedule.js --dist public/js/oscar/dist public/js/oscar/src/PersonSchedule.vue import AjaxResolve from "./AjaxResolve"; export default { name: 'PersonSchedule', props: { urlapi: {default: ''}, edit: { default: false } }, data() { return { daysLabels: { '1': 'Lundi', '2': 'Mardi', '3': 'Mercredi', '4': 'Jeudi', '5': 'Vendredi', '6': 'Samedi', '7': 'Dimanche' }, loading: null, error: null, dayLength: 0.0, days: {}, editDay: null, newValue: 0 } }, computed: { totalWeek(){ let total = 0.0; Object.keys(this.days).forEach(i => { total += parseFloat(this.days[i]); }); return total; } }, methods: { day(index){ if( this.days.hasOwnProperty(index) ){ return this.days[index]; } return this.dayLength; }, handlerEditDays(){ this.editDay = true; }, handlerSaveDays(){ this.loading = "Enregistrement des horaires"; let datas = new FormData(); datas.append('days', this.days); //datas.append('action', 'savedays'); this.$http.post(this.urlapi, datas).then( ok => { this.fetch(); }, ko => { this.error = AjaxResolve.resolve('Impossible de modifier les horaires', ko); } ).then(foo => { this.loading = false }); }, fetch(clear = true) { this.loading = "Chargement des données"; this.$http.get(this.urlapi).then( ok => { console.log(ok.body); this.days = ok.body.days; this.dayLength = ok.body.dayLength; }, ko => { this.error = AjaxResolve.resolve('Impossible de charger les données', ko); } ).then(foo => { this.loading = false; this.editDay = null; }); } }, mounted() { this.fetch(true) } } </script> No newline at end of file