Commit 47893c30 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Finalisation refonte piece jointe en vue js

parent 7d4e5740
Loading
Loading
Loading
Loading
Loading
+103 −106
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
    "php": ">=8.2",
    "laminas/laminas-cli": "1.11.0",
    "symfony/process": "7.2.0",

    "twbs/bootstrap": "5.0.2",
    "components/jquery": "3.7.1",
    "components/font-awesome": "6.5.2",
@@ -20,7 +19,6 @@
    "snapappointments/bootstrap-select": "1.14.0-beta3",
    "datatables.net/datatables.net-bs5": "2.1.8",
    "vakata/jstree": "3.3.17",

    "unicaen/app": "7.1.0",
    "unicaen/authentification": "6.4.3",
    "unicaen/privilege": "6.2.1",
@@ -31,7 +29,7 @@
    "unicaen/open-document": "6.0.10",
    "unicaen/siham": "6.2.0",
    "unicaen/mail": "7.1.2",
        "unicaen/vue"                      : "6.3.3",
    "unicaen/vue": "6.4.0",
    "unicaen/bddadmin": "1.4.0",
    "unicaen/signature": "1.0.6",
    "connecteur-ose/actul": "dev-master",
@@ -87,7 +85,6 @@
    "update-public-vendor": [
      "rm -rf public/vendor",
      "mkdir public/vendor",

      "cp -R vendor/twbs/bootstrap/dist public/vendor/bootstrap",
      "cp -R vendor/components/jquery public/vendor/jquery",
      "cp -R vendor/components/font-awesome public/vendor/font-awesome",
+335 −260

File changed.

Preview size limit exceeded, changes collapsed.

+53 −42
Original line number Diff line number Diff line
<template>

    <pieceJointe v-for="(pieceJointe, key) in datasPiecesJointes"
    <!-- Affichage des messages -->
    <div
        v-for="(message, key) in datasPiecesJointes?.messagesPiecesJointes || []"
        :key="'msg-' + key"
        :class="'messenger alert alert-dismissible alert-' + message.type">
        <span class="fas fa-info-circle"></span>
        {{ message.text }}
        <button
            type="button"
            class="btn-close alert-dismissible"
            title="Fermer cette alerte"
            data-bs-dismiss="alert">
        </button>
    </div>

    <!-- Affichage des pièces jointes -->
    <pieceJointe
        v-if="datasPiecesJointes?.privileges"
        v-for="(pieceJointe, key) in datasPiecesJointes?.piecesJointes || []"
        :datas="pieceJointe"
        :privileges="datasPiecesJointes.privileges"
        :intervenant="intervenant"
                 @refresh="getPiecesJointes"></pieceJointe>
        @refresh="getPiecesJointes"
    />
</template>

<script setup>

</template>
import {ref, onMounted, computed} from 'vue'
import pieceJointe from './PieceJointe.vue'

<script>
const props = defineProps(['intervenant']);

import pieceJointe from './PieceJointe.vue';
// Refs
const datasPiecesJointes = ref(null)

const urlGetPiecesJointes = computed(() =>
    unicaenVue.url('piece-jointe/intervenant/:intervenant/get-pieces-jointes', {
        intervenant: props.intervenant,
        test: 'test'
    })
)

export default {
    components: {
        pieceJointe
    },
    props: {
        intervenant: {required: true},
    },
    data()
function getPiecesJointes()
{
        return {
            datasPiecesJointes: null,
            urlGetPiecesJointes: unicaenVue.url('piece-jointe/intervenant/:intervenant/get-pieces-jointes', {intervenant: this.intervenant}),

    unicaenVue.axios.get(urlGetPiecesJointes.value).then(response => {
        datasPiecesJointes.value = response.data
    }).catch(error => {
        console.error(error)
    })
}

    },
    mounted()
    {
        this.getPiecesJointes();
    },
    methods: {
// Initialisation
onMounted(() => {
    getPiecesJointes()
        {
            unicaenVue.axios.get(this.urlGetPiecesJointes).then(response => {
                this.datasPiecesJointes = response.data;
            }).catch(error => {
                console.error(error);
})

        },
    }
}
</script>

<style scoped>
+56 −27
Original line number Diff line number Diff line
@@ -11,7 +11,8 @@
                <div class="validation-bar float-end" data-url="">
                    <div v-if="datas.pieceJointe">
                        <!-- actions de validation de la pièce jointe entière -->
                        <button v-if="!datas.pieceJointe.validation" :id="'valider-' + datas.pieceJointe.id"
                        <button v-if="!datas.pieceJointe.validation && privileges.canValider"
                                :id="'valider-' + datas.pieceJointe?.id"
                                class="btn btn-success me-2"
                                type="button"
                                :title="'Valider la pièce justificative \'' +  datas.typePieceJointe.libelle + '\''"
@@ -20,9 +21,10 @@

                            <u-icon id="action" name="thumbs-up"
                                    style="color:black;"/>
                            Valider
                            VALIDER
                        </button>
                        <button v-if="!datas.pieceJointe.validation" :id="'refuser-' + datas.pieceJointe.id"
                        <button v-if="!datas.pieceJointe.validation && privileges.canRefuser"
                                :id="'refuser-' + datas.pieceJointe?.id"
                                class="btn btn-danger"
                                type="button"
                                :title="'Refuser la pièce justificative \'' +  datas.typePieceJointe.libelle + '\''"
@@ -30,9 +32,13 @@
                                :data-url="urlRefuserPiecesJointes">
                            <u-icon id="action" name="trash"
                                    style="color:black;"/>
                            Refuser
                            REFUSER
                        </button>
                        <button v-if="this.datas.pieceJointe.validation" :id="'devalider-' + datas.pieceJointe.id"
                        <button
                            v-if="this.datas.pieceJointe.validation &&
                                  (datas.annee == datas.pieceJointe?.anneeOrigine??false) &&
                                  privileges.canValider"
                            :id="'devalider-' + datas.pieceJointe?.id"
                            class="btn btn-danger"
                            type="button"
                            :title="'Dévalider la pièce justificative \'' +  datas.typePieceJointe.libelle + '\''"
@@ -40,12 +46,14 @@
                            :data-url="urlDevaliderPiecesJointes">
                            <u-icon id="action" name="thumbs-up"
                                    style="color:black;"/>
                            Dévalider
                            DÉVALIDER
                        </button>
                    </div>

                </div>
                {{ datas.typePieceJointe.libelle }}
                <span v-if="datas.annee != (datas.pieceJointe?.anneeOrigine??datas.annee)"
                      style="font-size:0.6em;">Fourni(e) en {{ datas.pieceJointe?.anneeOrigine }}</span>
                <br>
            </h5>
        </div>
@@ -60,11 +68,19 @@
                            <li v-for="(fichier, key) in datas.pieceJointe?.fichier" class="fichier-pj">
                                <div class="d-flex">
                                    <div>
                                        <a class="download-file"
                                        <a v-if="privileges.canTelecharger" class="download-file"
                                           :href="'/piece-jointe/intervenant/' + intervenant + '/fichier/telecharger/' + fichier.id + '/' + fichier.nom"
                                           :title="'Télécharger le fichier déposé \'' + fichier.nom + '\''">
                                            <span class="icon icon-file"></span> {{ truncate(fichier.nom, 15) }} (<abbr
                                            :title="fichier.poids">{{ fichier.poids }}</abbr>)</a>
                                        <a v-if="!privileges.canTelecharger"
                                           class="disabled download-file"
                                           tabindex="-1"
                                           aria-disabled="true"
                                           onclick="return false;"
                                           :title="'Vous n\'avez pas les droits pour télécharge le fichier déposé \'' + fichier.nom + '\''">
                                            <span class="icon icon-file"></span> {{ truncate(fichier.nom, 15) }} (<abbr
                                            :title="fichier.poids">{{ fichier.poids }}</abbr>)</a>


                                        <!-- date de dépôt éventuelle du fichier -->
@@ -78,7 +94,7 @@
                                    </div>
                                    <div>
                                        <!-- lien de suppression du fichier -->
                                        <button v-if="!fichier.validation"
                                        <button v-if="!fichier.validation && privileges.canEditer"
                                                :id="'supprimer-fichier-' + fichier.id"
                                                class="delete-file btn btn-sm btn-danger ms-2 p-1 py-0"
                                                type="button"
@@ -90,7 +106,10 @@
                                                    style="color:black;"/>
                                        </button>
                                        <!-- lien de validation du fichier -->
                                        <button v-if="!fichier.validation"
                                        <button
                                            v-if="!fichier.validation &&
                                                  datas.pieceJointe?.validation &&
                                                  privileges.canValider"
                                            :id="'valider-fichier-' + fichier.id"
                                            class="validate-file btn btn-sm btn-success ms-2 p-1 py-0"
                                            type="button"
@@ -108,14 +127,14 @@
                        </ul>
                    </div>
                </div>
                <div class="col-md-6">
                <div v-if="privileges.canEditer" class="col-md-6">
                    <div class="row">
                        <!-- Formulaire sur 4 colonnes -->
                        <div class="col-md-8">
                            <form :id="formId" action=""
                                  enctype="multipart/form-data" method="post">
                                <div>
                                    <label class="form-label" for="importFile">Choisissez le fichier à déposer :</label>
                                    <label class="form-label small" for="importFile">{{ labelUpload }}</label>
                                    <input class="form-control form-control-sm" name="importFile" type="file"
                                           @change="handleFileUpload" multiple>
                                </div>
@@ -143,7 +162,7 @@

import {ref, computed} from 'vue'

const props = defineProps(['intervenant', 'datas']);
const props = defineProps(['intervenant', 'datas', 'privileges']);

// Emits
const emit = defineEmits(['refresh'])
@@ -155,31 +174,32 @@ const selectedFiles = ref(null)
const urlValiderPiecesJointes = computed(() =>
    unicaenVue.url('piece-jointe/intervenant/:intervenant/valider/:pieceJointe', {
        intervenant: props.intervenant,
        pieceJointe: props.datas.pieceJointe ? props.datas.pieceJointe.id : 0
        pieceJointe: props.datas.pieceJointe?.id ?? 0,
    })
)

const urlDevaliderPiecesJointes = computed(() =>
    unicaenVue.url('piece-jointe/intervenant/:intervenant/devalider/:pieceJointe', {
        intervenant: props.intervenant,
        pieceJointe: props.datas.pieceJointe ? props.datas.pieceJointe.id : 0
        pieceJointe: props.datas.pieceJointe?.id ?? 0,
    })
)

const urlRefuserPiecesJointes = computed(() =>
    unicaenVue.url('piece-jointe/intervenant/:intervenant/refuser/:pieceJointe', {
        intervenant: props.intervenant,
        pieceJointe: props.datas.pieceJointe ? props.datas.pieceJointe.id : 0
        pieceJointe: props.datas.pieceJointe?.id ?? 0,
    })
)

const urlDeposerFichier = computed(() =>
    unicaenVue.url('piece-jointe/intervenant/:intervenant/fichier/televerser/:typePieceJointe', {
        intervenant: props.intervenant,
        typePieceJointe: props.datas.typePieceJointe ? props.datas.typePieceJointe.id : 0
        typePieceJointe: props.datas.typePieceJointe?.id ?? 0,
    })
)


// Computed pour les IDs dynamiques
const formId = computed(() => {
    const id = props.datas.typePieceJointe?.id ?? 'unknown';
@@ -190,6 +210,15 @@ const buttonId = computed(() => {
    return `btn-import-${id}`;
});

const labelUpload = computed(() => {
    if (props.datas.pieceJointe?.validation && (props.datas.annee != props.datas.pieceJointe?.anneeOrigine ?? false)) {
        return 'Déposez un document pour le mettre à jour :'
    } else {
        return 'Déposez un document : '
    }

});

// Méthodes
function handleFileUpload(event)
{
+1 −8
Original line number Diff line number Diff line
@@ -32,7 +32,7 @@ return [
            'child_routes'  => [
                'intervenant' => [
                    'route'         => '/intervenant/:intervenant',
                    'action'        => 'indexNew',
                    'action'        => 'index',
                    'may_terminate' => true,
                    'child_routes'  => [
                        'infos'              => [
@@ -71,13 +71,6 @@ return [
                            ],
                            'action'      => 'refuser',
                        ],
                        'archiver'           => [
                            'route'       => '/archiver/:pieceJointe',
                            'constraints' => [
                                'pieceJointe' => '[0-9]*',
                            ],
                            'action'      => 'archiver',
                        ],
                        'get-pieces-jointes' => [
                            'route'      => '/get-pieces-jointes',
                            'action'     => 'getPiecesJointes',
Loading