Commit 21a71d91 authored by Jerome Chauveau's avatar Jerome Chauveau
Browse files

Corbeille : appel API rpc + debug du déplacement d'une sélection(JamaActionsToolbar)

parent 41f54a24
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
{
  "name": "@chauveau/vue-jama",
  "version": "0.3.31",
  "version": "0.3.32",
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
+10 −5
Original line number Diff line number Diff line
@@ -63,6 +63,7 @@
        <v-card-title>{{ $t('move_dialog_title') }}</v-card-title>
        <v-card-text>
          <collection-tree-select ref="treeViewSelect"
                                  @dest-selected="moveDestSelected"
                                  :root="isTreeWithRoot"
                                  :ancestors="unavailableDests"
          />
@@ -71,7 +72,7 @@
          <v-btn color="secondary" @click.stop="moveDialog=false">
            Annuler
          </v-btn>
          <v-btn color="primary" @click.stop="moveSelection">
          <v-btn color="primary" :disabled="!moveDestId" @click.stop="moveSelection">
            Confirmer
          </v-btn>
        </v-card-actions>
@@ -98,6 +99,7 @@ export default {
    return {
      moveDialog: false,
      allSelected : false,
      moveDestId : null,
      actions: [
        {
          title : this.$t('move'),
@@ -179,6 +181,11 @@ export default {
  },

  methods: {

    moveDestSelected(dest){
      this.moveDestId = dest;
    },

    deleteSelection(){
      this.$jamaConfirm(this.$t('delete_confirm'), (res) => {
        if(res){
@@ -196,23 +203,21 @@ export default {
    },

    moveSelection(){
      const targetCollectionId = this.$refs.treeViewSelect.selection[0];
      //const targetCollectionId = this.$refs.treeViewSelect.selection[0];

       this.$jamaConfirm(this.$t('move_confirm'), (res) => {
        if(res){
          let collectionsIds = []
          let resourcesIds = [];
          this.selectedCollections.map((c) => {
            if(c.selected)
              collectionsIds.push(c.id)
          });
          this.selectedResources.map((r) => {
            if(r.selected)
              resourcesIds.push(r.id)
          });
          this.$jamaClient.moveItems(
              this.currentCollection ? this.currentCollection.id : null,
              targetCollectionId,
              this.moveDestId,
              collectionsIds,
              resourcesIds);
          this.$emit('items-moved');//need to fetch &reload current collection
+0 −1
Original line number Diff line number Diff line
@@ -214,7 +214,6 @@ export default {

    remove(rec = false) {
      this.$store.dispatch('deleteCollection',{collectionId: this.collection.id, recursive :rec}).then(res => {
        console.log(res, rec);
          if ((!rec && res) || (res && res.success)) {
            this.$emit('collection-removed', this.collection, true);
          } else {
+43 −6
Original line number Diff line number Diff line
<i18n>
{
  "en": {
    "size": "Media"
  },
  "fr": {
    "restore_fail" : "Restauration impossible. Une erreur est survenue.",
    "restore_success" : "Restauration effectuée.",
    "size": "Taille de la corbeille"
  }
}
</i18n>
<template>
  <v-container>
    <h3>
      Taille de la corbeille : {{items.length}}
      {{ $t('size') }} : {{items.length}}
    </h3>
    <v-data-table
        :headers="headers"
@@ -27,11 +39,11 @@
      <v-card v-if="restoringItem" class="text-wrap">
        <v-card-title>{{restoreTitle}}</v-card-title>
        <v-card-text style="height: 350px;">
          <collection-tree-select :root="restoringItem.object_type==='collection'" :ancestors="[]"/>
          <collection-tree-select ref="treeViewSelect" @dest-selected="destSelection" :root="restoringItem.object_type==='collection'" :ancestors="[]"/>
        </v-card-text>
        <v-card-actions>
          <v-btn color="secondary" @click="restoringItem=null">Annuler</v-btn>
          <v-btn color="primary" @click="restore">Restaurer</v-btn>
          <v-btn color="primary" @click="restore"  :disabled="restoringDest===null">Restaurer</v-btn>
        </v-card-actions>
      </v-card>
    </v-dialog>
@@ -43,6 +55,7 @@


import CollectionTreeSelect from "./widgets/CollectionTreeSelect";
import EventBus from "../events/event-bus";
export default {
  name: "JamaTrash",

@@ -67,6 +80,7 @@ export default {
          + (this.restoringItem.object_type === 'collection' ? 'collection ' : 'ressource ')
          + this.restoringItem.label +' dans : '
    },

  },

  data(){
@@ -90,14 +104,37 @@ export default {
        }
      ],
      items: [],
      restoringItem : null
      restoringItem : null,
      restoringDest : null
    }
  },

  methods:{
    restore(){

     this.$jamaAlert("Fonctionnalité à venir. L'élément " + this.restoringItem.label +" ne sera pas restauré.")
    destSelection(selection){
      this.restoringDest = selection;
    },

    async restore(){
      let res;
      if(this.restoringItem.object_type === 'collection'){
        res = await this.$jamaClient.restoreCollection(this.restoringItem.id, this.restoringDest);
      }
      else {
        res = await this.$jamaClient.restoreResource(this.restoringItem.id, this.restoringDest);
      }
      if(res){
        this.items.splice(this.items.indexOf(this.restoringItem),1);
        EventBus.$emit('reload-current-collection');
      }
      EventBus.$emit('JAMA_NOTIFICATION', {
        type: res ? 'success' : 'error',
        timeout: 2000,
        message: res ? this.$t('restore_success') : this.$t('restore_fail') ,
        visible: true
      })
      this.restoringItem = null;
      this.restoringDest = null;
    }
  }
}
+2 −19
Original line number Diff line number Diff line
@@ -473,9 +473,11 @@ export default {

    async loadCollection(collection) {
      this.loading = true;
      if(!this.trashMode){
        EventBus.$emit('set-mode', RESOURCES_MODE);
        if (this.viewMode === FULLSCREEN)
          this.viewMode = MOSAIC;
      }
      this.$store.commit('setCurrentResource', null);
      this.$store.commit('setCurrentCollection', collection);
      this.$store.commit('setSelectedCollections', []);
@@ -538,7 +540,6 @@ export default {
    },

    async manageFilesUpload(files) {
      console.log("- prise en charge des fichiers : " + files.length)
      this.loading = true;
      await this.$store.dispatch('manageFilesUpload', {
        files: files,
@@ -664,24 +665,6 @@ export default {
            limitTo : end
          }
      ).then(() => {this.loading = false});
      // let collectionId = this.currentCollection ? this.currentCollection.id : null;
      // await this.fetchCollections({
      //   parentId: collectionId,
      //   recursive: false,
      //   limitFrom: start,
      //   limitTo: end,
      // })
      // let nbItems = this.collections.length;
      // if (this.currentCollection && nbItems < this.pageLength) {//do not fetch ressources in root collection context
      //   start = start - nbItems < 0 ? 0 : start - nbItems;
      //   await this.fetchResources({
      //     collectionId: this.currentCollection.id,
      //     includeMetas: false,
      //     limitFrom: start,
      //     limitTo: start + this.pageLength - nbItems
      //   });
      //   this.loading = false;
      // } else this.loading = false;

    },

Loading