Commit 1123f313 authored by Stéphane Bouvry's avatar Stéphane Bouvry
Browse files

Fix : bug dans l'interface de maintenance des lots de travail

parent e7646a70
Loading
Loading
Loading
Loading
+17 −3
Changes for module/Oscar/src/Oscar/Controller/WorkPackageController.php: 17 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -8,6 +8,7 @@
namespace Oscar\Controller;


use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\ORM\Query;
use Oscar\Entity\Activity;
use Oscar\Entity\Person;
@@ -77,6 +78,9 @@ class WorkPackageController extends AbstractOscarController

            $datas = $this->getRequest()->getPost();


            if( array_key_exists('workpackageid', $datas) ){
                // Enregistrement du lot de travail
                $code = trim($datas['code']);

                // On contrôle les code vide
@@ -84,8 +88,6 @@ class WorkPackageController extends AbstractOscarController
                    return $this->getResponseBadRequest("Vous devez renseigner un code");
                }

            if( array_key_exists('workpackageid', $datas) ){
                // Enregistrement du lot de travail
                /** @var WorkPackage $workpackage */
                $workpackage = $this->getEntityManager()->getRepository(WorkPackage::class)->find($datas['workpackageid']);
                if( !$workpackage ){
@@ -126,6 +128,10 @@ class WorkPackageController extends AbstractOscarController
        if( $method == 'PUT' ){
            $data = $this->getRequest()->getPost();

//            parse_str(file_get_contents('php://input'), $_PUT);
//
//            $this->getLogger()->info(print_r($_PUT, true));

            if( $data['workpackageid'] == -1) {
                $code = trim($data['code']);
                try {
@@ -144,6 +150,9 @@ class WorkPackageController extends AbstractOscarController
                } catch( \Exception $e ){
                    return $this->getResponseInternalError('Impossible de créer le lot de travail.');
                }
            } else {
                $this->getLogger()->info(print_r($data['workpackageid'], true));

            }

            try {
@@ -217,7 +226,12 @@ class WorkPackageController extends AbstractOscarController
                    $this->getEntityManager()->remove($workpackage);
                    $this->getEntityManager()->flush();
                    return $this->getResponseOk();
                } catch( \Exception $e ){
                }
                catch (ForeignKeyConstraintViolationException $ex) {
                    return $this->getResponseInternalError('Ce lot de travail est déjà utilisé pour des déclarations');
                }
                catch( \Exception $e ){
                    $this->getLogger()->error(get_class($e));
                    return $this->getResponseInternalError('Impossible de supprimer le lot de travail. ' . $e->getMessage());
                }
            }
+29 −2
Changes for module/Oscar/view/oscar/project-grant/show.phtml: 29 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -550,7 +550,34 @@ if( $this->grant()->privilege(\Oscar\Provider\Privileges::ACTIVITY_WORKPACKAGE_S

    <?php if( $this->grant()->privilege(\Oscar\Provider\Privileges::ACTIVITY_WORKPACKAGE_SHOW, $entity) ): ?>
    <script>
        require(['workpackageperson'], function(Workpackageperson){
        require(['vue', 'vue-resource', 'bootbox', 'Workpackage'], function(Vue, VueResource, Bootbox, Workpackage){
            Vue.use(VueResource);

            Vue.http.options.emulateJSON = true;
            Vue.http.options.emulateHTTP = true;

            // Transmission du jeton
            Vue.http.interceptors.push((request, next) => {
                request.headers.set('X-CSRF-TOKEN', '<?= $tokenValue ?>');
                request.headers.set('Authorization', 'OSCAR TOKEN');
                next();
            });

            new Vue({
                render: function(h){
                    return h(Workpackage.default,{ props: {
                        url: '<?= $this->url('workpackage/rest', ['idactivity' => $entity->getId()]) ?>',
                        token: '<?= $tokenValue ?>',
                        isValidateur: true,
                        editable: true,
                        Bootbox: Bootbox,
                    }})
                },
                el: '#workpackages'
            })
        });
        /*
        require(['workpackageperson', 'mm'], function(Workpackageperson, moment){
            var wp = new Workpackageperson.default({
                http: {
                    root: '<?= $this->url('workpackage/rest', ['idactivity' => $entity->getId()]) ?>'
@@ -571,7 +598,7 @@ if( $this->grant()->privilege(\Oscar\Provider\Privileges::ACTIVITY_WORKPACKAGE_S
            wp.$on('declarer', function(){
                window.location = '<?= $this->url('timesheet/declaration2', ['idactivity' => $entity->getId()]) ?>';
            });
        })
        })*/
    </script>
    <?php endif; ?>
    <?php endif; ?>
+3 −2
Changes for public/js/oscar-config.js: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -22,7 +22,7 @@ requirejs.config({
        'jquery-serialize': 'vendor/jquery-serialize-object/dist/jquery.serialize-object.min',
        'moment': 'vendor/momentjs/min/moment-with-locales.min',
        'moment-tz': 'vendor/moment-timezone/builds/moment-timezone-with-data.min',
        'moment-timezone': 'vendorworkpackageperson/moment-timezone/builds/moment-timezone-with-data',
        'moment-timezone': 'vendor/moment-timezone/builds/moment-timezone-with-data',
        'underscore': 'vendor/underscore/underscore-min',
        'bt-datepicker': 'vendor/bootstrap-datepicker/dist/js/bootstrap-datepicker.min',
        'timepicker': 'vendor/bootstrap-timepicker/js/bootstrap-timepicker',
@@ -78,7 +78,8 @@ requirejs.config({
        'PersonSchedule' : 'oscar/dist/PersonSchedule',
        'TimesheetPersonResume' : 'oscar/dist/TimesheetPersonResume',
        'ResumeActivity' : 'oscar/dist/ResumeActivity',
        'PersonsList' : 'oscar/dist/PersonsList'
        'PersonsList' : 'oscar/dist/PersonsList',
        'Workpackage': 'oscar/dist/WorkpackageUI'
    },
    shim: {
        "bootstrap": {
+2 −0
Changes for public/js/oscar/dist/WorkpackageUI.js: 2 added lines, 0 removed lines.
Original line number Diff line number Diff line
(function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.WorkpackageUI=t():e.WorkpackageUI=t()})("undefined"!=typeof self?self:this,function(){return function(e){function t(r){if(a[r])return a[r].exports;var n=a[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var a={};return t.m=e,t.c=a,t.d=function(e,a,r){t.o(e,a)||Object.defineProperty(e,a,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var a=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(a,"a",a),a},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="/",t(t.s=4)}([function(e,t){e.exports=function(e,t,a,r,n,o){var s,i=e=e||{},c=typeof e.default;"object"!==c&&"function"!==c||(s=e,i=e.default);var l="function"==typeof i?i.options:i;t&&(l.render=t.render,l.staticRenderFns=t.staticRenderFns,l._compiled=!0),a&&(l.functional=!0),n&&(l._scopeId=n);var d;if(o?(d=function(e){e=e||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext,e||"undefined"==typeof __VUE_SSR_CONTEXT__||(e=__VUE_SSR_CONTEXT__),r&&r.call(this,e),e&&e._registeredComponents&&e._registeredComponents.add(o)},l._ssrRegister=d):r&&(d=r),d){var u=l.functional,p=u?l.render:l.beforeCreate;u?(l._injectStyles=d,l.render=function(e,t){return d.call(t),p(e,t)}):l.beforeCreate=p?[].concat(p,d):[d]}return{esModule:s,exports:i,options:l}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={components:{workpackage:a(6).default},data:function(){return{loading:!1,errors:[],workpackages:[],persons:[],editable:!1,isDeclarant:!1,isValidateur:!1,token:"DEFAULT_TKN"}},props:{url:{required:!0},token:{required:!0},isValidateur:{required:!0},editable:{required:!0},Bootbox:{required:!0}},watch:{},computed:{},created:function(){this.fetch()},methods:{handlerWorkPackageCancelNew:function(e){this.workpackages.splice(this.workpackages.indexOf(e),1)},handlerWorkPackageNew:function(){this.workpackages.push({id:-1,code:"Nouveau Lot",label:"",persons:[],description:""})},handlerWorkPackagePersonDelete:function(e){var t=this;this.Bootbox.confirm("Supprimer le déclarant ? ",function(a){a&&t.$http.delete(t.url+"?workpackagepersonid="+e.id).then(function(e){t.fetch()},function(e){t.errors.push("Impossible de supprimer le déclarant : "+e.body)})})},handlerWorkPackageDelete:function(e){var t=this;this.Bootbox.confirm("Souhaitez-vous supprimer ce lot ?",function(a){a&&t.$http.delete(t.url+"?workpackageid="+e.id).then(function(e){t.fetch()},function(e){t.errors.push("Impossible de supprimer le lot : "+e.body)})})},handlerWorkPackageUpdate:function(e){var t=this,a=new FormData;for(var r in e)a.append(r,e[r]);e.id>0?(console.log("MAJ du LOT"),a.append("workpackageid",e.id),this.$http.post(this.url,a).then(function(e){t.fetch()},function(e){t.errors.push("Impossible de mettre à jour le lot de travail : "+e.body)})):(console.log("NOUVEAU du LOT"),a.append("workpackageid",-1),this.$http.put(this.url,a).then(function(e){t.fetch()},function(e){t.errors.push("Impossible de créer le lot de travail : "+e.body)}).then(function(e){return t.fetch()}))},handlerUpdateWorkPackagePerson:function(e,t){var a=this,r=new FormData;r.append("workpackagepersonid",e.id),r.append("duration",t),this.$http.post(this.url,r).then(function(a){e.duration=t},function(e){a.errors.push("Impossible de mettre à jour les heures prévues : "+e.body)})},addperson:function(e,t){var a=this;console.log(arguments);var r=new FormData;r.append("idworkpackage",t),r.append("idperson",e),this.$http.put(this.url,r).then(function(e){a.fetch()},function(e){a.errors.push("Impossible d'ajouter le déclarant : "+e.body)}).then(function(){return a.loading=!1})},fetch:function(){var e=this;this.loading=!0,console.log(this.url),this.$http.get(this.url).then(function(t){e.workpackages=t.body.workpackages,e.persons=t.body.persons,e.editable=t.body.editable,e.isDeclarant=t.body.isDeclarant,e.isValidateur=t.body.isValidateur},function(t){e.errors.push("Impossible de charger les lots de travail : "+t.body)}).then(function(){return e.loading=!1})}}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={components:{workpackageperson:a(7).default},data:function(){return{mode:"read",canSave:!1,formData:{id:-1,code:"",label:"",description:""}}},created:function(){console.log("created",this.workpackage.id),this.workpackage.id<0&&(this.mode="edit")},props:{workpackage:null,persons:{default:function(){return[]}},editable:!1,isValidateur:!1},watch:{"person.duration":function(){console.log("Modification de la durée")}},methods:{handlerEditWorkPackage:function(){this.formData=JSON.parse(JSON.stringify(this.workpackage)),this.mode="edit"},handlerCancelEdit:function(){this.workpackage.id<0?this.$emit("workpackagecancelnew",this.workpackage):this.mode="read"},handlerDeleteWorkPackage:function(){this.$emit("workpackagedelete",this.workpackage)},handlerUpdateWorkPackage:function(){this.$emit("workpackageupdate",this.formData),this.mode="read"},handlerUpdate:function(e,t){this.$emit("workpackagepersonupdate",e,t)},handlerDelete:function(e){this.$emit("workpackagepersondelete",e)},roles:function(e){return e.roles.join(",")},tempsPrevu:function(e){return 0},tempsDeclare:function(e){return 0}}}},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={props:{person:{default:function(){return{}}},editable:!1},computed:{duration:function(){return this.person.duration}},data:function(){return{canSave:!1,mode:"read",durationForm:666}},methods:{handlerKeyUp:function(){console.log(arguments)},handlerUpdate:function(){this.$emit("workpackagepersonupdate",this.person,this.durationForm),this.mode="read"},handlerEdit:function(){this.mode="edit",this.durationForm=this.person.duration},handlerCancel:function(){this.mode="read",this.durationForm=this.person.duration},handlerRemove:function(){this.$emit("workpackagepersondelete",this.person)}}}},function(e,t,a){e.exports=a(5)},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=a(1),n=a.n(r);for(var o in r)"default"!==o&&function(e){a.d(t,e,function(){return r[e]})}(o);var s=a(10),i=a(0),c=i(n.a,s.a,!1,null,null,null);t.default=c.exports},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=a(2),n=a.n(r);for(var o in r)"default"!==o&&function(e){a.d(t,e,function(){return r[e]})}(o);var s=a(9),i=a(0),c=i(n.a,s.a,!1,null,null,null);t.default=c.exports},function(e,t,a){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=a(3),n=a.n(r);for(var o in r)"default"!==o&&function(e){a.d(t,e,function(){return r[e]})}(o);var s=a(8),i=a(0),c=i(n.a,s.a,!1,null,null,null);t.default=c.exports},function(e,t,a){"use strict";var r=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("article",{staticClass:"workpackage-person"},[a("div",{staticClass:"displayname"},[a("strong",[e._v(e._s(e.person.person.displayname))]),e._v(" "),e.editable&&"read"==e.mode?a("a",{staticClass:"link",attrs:{href:"#",title:"Supprimer ce déclarant"},on:{click:function(t){t.preventDefault(),e.handlerRemove(e.person)}}},[a("i",{staticClass:"icon-trash"})]):e._e()]),e._v(" "),a("div",{staticClass:"tempsdeclare temps"},[e.editable&&"edit"==e.mode?a("div",[e._v("\n            Heures prévues :\n            "),a("input",{directives:[{name:"model",rawName:"v-model",value:e.durationForm,expression:"durationForm"}],staticStyle:{width:"5em"},attrs:{type:"integer"},domProps:{value:e.durationForm},on:{keyup:function(t){return"button"in t||13===t.keyCode?e.handlerUpdate(t):null},input:function(t){t.target.composing||(e.durationForm=t.target.value)}}}),e._v(" "),a("a",{attrs:{href:"#",title:"Appliquer la modification des heures prévues"},on:{click:function(t){return t.preventDefault(),e.handlerUpdate(t)}}},[a("i",{staticClass:"icon-floppy"})]),e._v(" "),a("a",{attrs:{href:"#",title:"Annuler la modification des heures prévues"},on:{click:function(t){return t.preventDefault(),e.handlerCancel(t)}}},[a("i",{staticClass:"icon-cancel-outline"})])]):a("span",[a("strong",{staticClass:"wp-hours"},[a("span",{staticClass:"wp-hour unsend",attrs:{title:"Heure(s) saisie(s)"}},[e._v(e._s(e._f("heures")(e.person.unsend)))]),e._v(" "),a("span",{staticClass:"wp-hour validate",attrs:{title:"Heure(s) validée(s)"}},[e._v(e._s(e._f("heures")(e.person.validate)))]),e._v(" "),e.person.validating>0?a("span",{staticClass:"wp-hour validating",attrs:{title:"Heure(s) en cours de validation"}},[e._v(e._s(e._f("heures")(e.person.validating)))]):e._e(),e._v(" "),e.person.conflicts>0?a("span",{staticClass:"wp-hour conflicts",attrs:{title:"Heure(s) en conflit"}},[e._v(e._s(e._f("heures")(e.person.conflicts)))]):e._e(),e._v(" "),a("span",{staticClass:"wp-hour duration",attrs:{title:"Heure(s) à valider"}},[e._v("\n                            / "+e._s(e.person.duration)+"\n                            "),e.editable&&"read"==e.mode?a("a",{attrs:{href:"#",title:"Modifier les heures prévues"},on:{click:function(t){return t.preventDefault(),e.handlerEdit(t)}}},[a("i",{staticClass:"icon-pencil"})]):e._e()])])])])])},n=[],o={render:r,staticRenderFns:n};t.a=o},function(e,t,a){"use strict";var r=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("article",{staticClass:"workpackage"},["edit"==e.mode?a("form",{attrs:{action:""},on:{submit:function(t){return t.preventDefault(),e.handlerUpdateWorkPackage(t)}}},[a("h4",[e.workpackage.id>0?a("span",[e._v("Modification du lot")]):a("span",[e._v("Nouveau lot")]),e._v(" "+e._s(e.formData.label))]),e._v(" "),a("div",{staticClass:"form-group"},[a("label",{attrs:{for:""}},[e._v("Code")]),e._v(" "),e._m(0),e._v(" "),a("input",{directives:[{name:"model",rawName:"v-model",value:e.formData.code,expression:"formData.code"}],staticClass:"form-control",attrs:{type:"text",placeholder:"CODE"},domProps:{value:e.formData.code},on:{input:function(t){t.target.composing||e.$set(e.formData,"code",t.target.value)}}})]),e._v(" "),a("div",{staticClass:"form-group"},[a("label",{attrs:{for:""}},[e._v("Intitulé")]),e._v(" "),a("input",{directives:[{name:"model",rawName:"v-model",value:e.formData.label,expression:"formData.label"}],staticClass:"form-control",attrs:{type:"text",placeholder:"Intitulé"},domProps:{value:e.formData.label},on:{input:function(t){t.target.composing||e.$set(e.formData,"label",t.target.value)}}})]),e._v(" "),a("div",{staticClass:"form-group"},[a("label",{attrs:{for:""}},[e._v("Description")]),e._v(" "),a("textarea",{directives:[{name:"model",rawName:"v-model",value:e.formData.description,expression:"formData.description"}],staticClass:"form-control",attrs:{type:"text",placeholder:"Description"},domProps:{value:e.formData.description},on:{input:function(t){t.target.composing||e.$set(e.formData,"description",t.target.value)}}})]),e._v(" "),a("div",{staticClass:"buttons"},[a("button",{staticClass:"btn btn-default",class:{disabled:!e.formData.code},attrs:{type:"submit"}},[e._v("Enregistrer")]),e._v(" "),a("button",{staticClass:"btn btn-default",attrs:{type:"button"},on:{click:e.handlerCancelEdit}},[e._v("Annuler")])])]):e._e(),e._v(" "),"read"==e.mode?a("div",[a("h3",[e._v("["+e._s(e.workpackage.code)+"] "+e._s(e.workpackage.label))]),e._v(" "),a("p",[e._v(e._s(e.workpackage.description))]),e._v(" "),a("section",{staticClass:"workpackage-persons"},[e._m(1),e._v(" "),e._l(e.workpackage.persons,function(t){return a("workpackageperson",{key:t.id,attrs:{person:t,editable:e.editable},on:{workpackagepersondelete:e.handlerDelete,workpackagepersonupdate:e.handlerUpdate}})})],2),e._v(" "),e.editable&&e.persons.length?a("div",{staticClass:"buttons"},[a("div",{staticClass:"btn-group"},[e._m(2),e._v(" "),a("ul",{staticClass:"dropdown-menu"},e._l(e.persons,function(t){return a("li",[a("a",{attrs:{href:"#"},on:{click:function(a){a.preventDefault(),e.$emit("addperson",t.id,e.workpackage.id)}}},[e._v(e._s(t.displayname))])])}))]),e._v(" "),a("a",{staticClass:"btn btn-default btn-xs",attrs:{href:"#"},on:{click:function(t){return t.preventDefault(),e.handlerEditWorkPackage(t)}}},[a("i",{staticClass:"icon-pencil"}),e._v("Modifier")]),e._v(" "),a("a",{staticClass:"btn btn-default btn-xs",attrs:{href:"#"},on:{click:function(t){return t.preventDefault(),e.handlerDeleteWorkPackage(t)}}},[a("i",{staticClass:"icon-trash"}),e._v("Supprimer")])]):e._e(),e._v(" "),e.persons.length<=0?a("div",{staticClass:"text-danger"},[e._v("\n            Vous n'avez pas encore ajouté de membre à cette activité. "),a("strong",[e._v("Seul les membres d'une activité peuvent être identifiés comme déclarant")]),e._v(".\n        ")]):e._e()]):e._e()])},n=[function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("p",{staticClass:"text-danger"},[e._v("Le code est "),a("strong",[e._v("utilisé pour l'affichage des créneaux")]),e._v(" simplifiés, utilisez un code de préférence entre 3 et 5 caractères.")])},function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("h4",[a("i",{staticClass:"icon-calendar"}),e._v("Déclarants ")])},function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("button",{staticClass:"btn btn-default  btn-xs dropdown-toggle",attrs:{type:"button","data-toggle":"dropdown","aria-haspopup":"true","aria-expanded":"false"}},[e._v("\n                    Ajouter un déclarant "),a("span",{staticClass:"caret"})])}],o={render:r,staticRenderFns:n};t.a=o},function(e,t,a){"use strict";var r=function(){var e=this,t=e.$createElement,a=e._self._c||t;return a("section",[a("transition",{attrs:{name:"fade"}},[e.errors.length?a("div",{staticClass:"vue-loader"},e._l(e.errors,function(t,r){return a("div",{staticClass:"alert alert-danger"},[e._v("\n                "+e._s(t)+"\n                "),a("a",{attrs:{href:""},on:{click:function(t){t.preventDefault(),e.errors.splice(r,1)}}},[a("i",{staticClass:"icon-cancel-outline"})])])})):e._e()]),e._v(" "),e.loading?a("div",{staticClass:"vue-loader-component"},[a("span",[e._v("Chargement")])]):e._e(),e._v(" "),a("nav",{staticClass:"buttons"},[e.editable?a("a",{staticClass:"btn btn-primary",attrs:{href:""},on:{click:function(t){return t.preventDefault(),e.handlerWorkPackageNew(t)}}},[e._v("Nouveau lot")]):e._e()]),e._v(" "),a("section",{staticClass:"workpackages"},e._l(e.workpackages,function(t){return a("workpackage",{key:t.id,attrs:{workpackage:t,persons:e.persons,editable:e.editable,"is-validateur":e.isValidateur},on:{addperson:e.addperson,workpackageupdate:e.handlerWorkPackageUpdate,workpackagepersonupdate:e.handlerUpdateWorkPackagePerson,workpackagepersondelete:e.handlerWorkPackagePersonDelete,workpackagedelete:e.handlerWorkPackageDelete,workpackagecancelnew:e.handlerWorkPackageCancelNew}})}))],1)},n=[],o={render:r,staticRenderFns:n};t.a=o}])});
//# sourceMappingURL=WorkpackageUI.js.map
 No newline at end of file
+1 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading