Commit 4fbd6a5e authored by Laurent Lecluse's avatar Laurent Lecluse
Browse files

Mise en place d'un système de onfirmations compatible vue + refactoring

parent b7ec3432
Loading
Loading
Loading
Loading
+1 −1
Changes for front/Application/UI/UIcon.vue: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@

<script>
export default {
    name: "icon",
    name: "UIcon",
    props: {
        name: {required: true, type: String}
    },
+46 −17
Changes for front/Mission/Mission.vue: 46 added lines, 17 removed lines.
Original line number Diff line number Diff line
@@ -40,13 +40,33 @@
                            <div class="col-md-12">&nbsp;</div>
                        </div>
                        <div class="row">
                            <!-- Boutons d'actions -->
                            <div class="col-md-12">
                                <a v-if="mission.canEdit" :href="saisieUrl" class="btn btn-primary" @click.prevent="saisie">Modifier la mission</a>
                                <a v-if="!mission.validation" class="btn btn-secondary" @click.prevent="valider">Validation de la mission</a>
                                <a v-if="mission.validation" class="btn btn-danger" @click.prevent="devalider">Dévalidation de la mission</a>
                                <a class="btn btn-danger" :href="supprimerUrl" data-title="Suppression de la mission"
                                <a v-if="mission.canSaisie"
                                   :href="saisieUrl"
                                   class="btn btn-primary"
                                   @click.prevent="saisie">Modifier</a>

                                <a v-if="mission.canValider"
                                   :href="validerUrl"
                                   class="btn btn-secondary"
                                   data-title="Validation de la mission"
                                   data-content="Êtes-vous sur de vouloir valider la mission ?"
                                   @click.prevent="valider">Valider</a>

                                <a v-if="mission.canDevalider"
                                   :href="devaliderUrl"
                                   class="btn btn-danger"
                                   data-title="Dévalidation de la mission"
                                   data-content="Êtes-vous sur de vouloir dévalider la mission ?"
                                   @click.prevent="devalider">Dévalider</a>

                                <a v-if="mission.canSupprimer"
                                   :href="supprimerUrl"
                                   class="btn btn-danger"
                                   data-title="Suppression de la mission"
                                   data-content="Êtes-vous sur de vouloir supprimer la mission ?"
                                   data-confirm="true" @click.prevent="supprimer">Suppression de la mission</a>
                                   @click.prevent="supprimer">Supprimer</a>
                            </div>
                        </div>
                    </div>
@@ -56,18 +76,18 @@
                            <label class=" form-label">Suivi</label>
                        </div>
                        <div>
                            <icon name="thumbs-up"/>
                            <u-icon name="thumbs-up"/>
                            Créé le {{ mission.histoCreation }} par
                            <utilisateur :nom="mission.histoCreateur.displayName" :mail="mission.histoCreateur.email"/>
                        </div>
                        <div>
                            <icon :name="mission.valide ? 'thumbs-up' : 'thumbs-down'"/>
                            <u-icon :name="mission.valide ? 'thumbs-up' : 'thumbs-down'"/>
                            {{ validationText }}
                            <utilisateur v-if="mission.validation && mission.validation.histoCreateur" :nom="mission.validation.histoCreateur.libelle"
                                         :mail="mission.validation.histoCreateur.email"/>
                        </div>
                        <div>
                            <icon :name="mission.contrat ? 'thumbs-up' : 'thumbs-down'"/>
                            <u-icon :name="mission.contrat ? 'thumbs-up' : 'thumbs-down'"/>
                            {{ mission.contrat ? 'Contrat établi' : 'Pas de contrat' }}
                        </div>
                        <div>
@@ -77,6 +97,7 @@
                </div>
            </div>
        </form>

    </div>
</template>

@@ -91,7 +112,10 @@ export default {
    {
        return {
            validationText: this.calcValidation(this.mission.validation),

            saisieUrl: Util.url('mission/saisie/:mission', {mission: this.mission.id}),
            validerUrl: Util.url('mission/valider/:mission', {mission: this.mission.id}),
            devaliderUrl: Util.url('mission/devalider/:mission', {mission: this.mission.id}),
            supprimerUrl: Util.url("mission/supprimer/:mission", {mission: this.mission.id}),
        };
    },
@@ -133,23 +157,19 @@ export default {
        },
        supprimer(event)
        {
            popAjax(event.target, (widget) => {
            popConfirm(event.target, (response) => {
                this.$emit('supprimer', this.mission);
            });
        },
        valider()
        valider(event)
        {
            axios.get(
                Util.url("mission/valider/:mission", {mission: this.mission.id})
            ).then(response => {
            popConfirm(event.target, (response) => {
                this.$emit('refresh', response.data);
            });
        },
        devalider()
        devalider(event)
        {
            axios.get(
                Util.url("mission/devalider/:mission", {mission: this.mission.id})
            ).then(response => {
            popConfirm(event.target, (response) => {
                this.$emit('refresh', response.data);
            });
        },
@@ -161,6 +181,10 @@ export default {
                this.$emit('refresh', response.data);
            });
        },
        test()
        {
            console.log('Go go go!!!');
        },
    }
}
</script>
@@ -169,4 +193,9 @@ export default {
.card-header h5 {
    font-weight: 500;
}

.btn {
    margin-left: 2px;
    margin-right: 2px;
}
</style>
 No newline at end of file
+3 −1
Changes for front/autoload.js: 3 added lines, 1 removed line.
Original line number Diff line number Diff line
export default {
    /* UI components */
    uIcon: 'Application/UI/UIcon',

    /* App common components */
    utilisateur: 'Application/Utilisateur',
    icon: 'Application/Icon',

};
 No newline at end of file
+4 −1
Changes for module/Mission/src/Service/MissionService.php: 4 added lines, 1 removed line.
Original line number Diff line number Diff line
@@ -97,7 +97,10 @@ class MissionService extends AbstractEntityService
            ['validation', ['histoCreation', 'histoCreateur']],
        ]);

        $json['canEdit'] = true;
        $json['canSaisie']    = !$mission->isValide();
        $json['canValider']   = !$mission->isValide();
        $json['canDevalider'] = $mission->isValide();
        $json['canSupprimer'] = !$mission->isValide();

        return $json;
    }
+70 −0
Changes for public/js/pop-ajax.js: 70 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -308,3 +308,73 @@ function popAjax(element, onSubmit)

    return widget;
}



function popConfirm(element, options)
{
    var popConfirm = bootstrap.Popover.getInstance(element);
    if (!popConfirm) {
        if (typeof options == 'function') {
            options = {
                onConfirm: options
            };
        }

        if (!options) {
            options = {};
        }
        if (!options.title) {
            options.title = $(element).data('title');
        }
        if (!options.title) {
            options.title = "Demande de confirmation";
        }

        if (!options.content) {
            options.content = $(element).data('content');
        }
        if (!options.content) {
            options.content = "Confirmez-vous cette action ?";
        }

        if (!options.onConfirm) {
            options.onConfirm = function () {};
        }

        if (element.nodeName == 'A') {
            goFunc = function () {
                axios.get(element.href).then(response => {
                    console.log('co');
                    options.onConfirm(response, element);
                });
            };
        } else {
            goFunc = function () {
                options.onConfirm(element);
            }
        }

        let popoptions = {
            html: true,
            sanitize: false,
            trigger: "focus",
            title: options.title,
            content: options.content + '<div class="btn-goup" style="text-align:right;padding-top: 10px" role="group"><button class="btn btn-secondary" id="nogo">Non</button><button class="btn btn-primary" id="go">Oui</button></div>',
        };
        popConfirm = new bootstrap.Popover(element, popoptions);
        element.addEventListener('shown.bs.popover', (eventShown) => {
            let popDivId = $(eventShown.target).attr('aria-describedby');
            $("#" + popDivId).find("button#go").click(() => {
                popConfirm.hide();
                goFunc();
            });

            $("#" + popDivId).find("button#nogo").click(() => {
                popConfirm.hide();
            });
        });
    }

    popConfirm.show();
}
 No newline at end of file
Loading