Ajout de la possibilité de modifier toute l'arborescence des dossiers
This commit is contained in:
parent
c8ef425e27
commit
05c31d2cf6
2 changed files with 43 additions and 35 deletions
|
|
@ -65,12 +65,13 @@ class FoldersController extends Controller
|
|||
$directory = Directories::where('id', $folder['id'])->first();
|
||||
$directory->order = $folder['order'];
|
||||
$directory->parent = null;
|
||||
$directory->needAuthorization = 0;
|
||||
$directory->save();
|
||||
if(isset($folder['children']) && count($folder['children']) > 0 ){
|
||||
$this->recordOrder($folder['children'], $folder['id']);
|
||||
}
|
||||
}
|
||||
return 'OK';
|
||||
return ['status' => 'OK', 'directories' => Directories::all()];
|
||||
}
|
||||
|
||||
private function recordOrder($folders, $parentId) {
|
||||
|
|
|
|||
|
|
@ -16,15 +16,15 @@
|
|||
<VueNestable v-model="nestableItems" @change="changeOrder" :hooks="{'beforeMove': beforeMove}">
|
||||
<VueNestableHandle slot-scope="{ item }" :item="item">
|
||||
<span>
|
||||
<i v-if="item.children.length" @click="hideChildren(item)" class="fas fa-minus-circle"></i>
|
||||
<i @click="showChildren(item)" class="fas fa-plus-circle" style="display:none;"></i>
|
||||
<i v-if="item.id !== 1" class="fas fa-arrows-alt"></i>
|
||||
{{ item.name.fr }}
|
||||
<i v-if="item.children.length" @click="hideChildren(item)" class="fas fa-minus-circle"></i>
|
||||
<i @click="showChildren(item)" class="fas fa-plus-circle" style="display:none;"></i>
|
||||
<i v-if="item.id !== 1" class="fas fa-arrows-alt"></i>
|
||||
{{ item.name.fr }}
|
||||
</span>
|
||||
<span>
|
||||
<span v-if="item.id !== 1">Autorisation : <input type="checkbox" v-model="item.needAuthorization" @change="toggleAuthorization(item)"></span>
|
||||
<i v-if="item.id !== 1" @click="modifyName(item)" class="fas fa-pencil-alt"></i>
|
||||
<i v-if="item.id !== 1" @click="AskDeleteFolder(item)" class="fas fa-trash-alt"></i>
|
||||
<span v-if="item.id !== 1 && item.parent !== null">Autorisation : <input type="checkbox" v-model="item.needAuthorization" @change="toggleAuthorization(item)"></span>
|
||||
<i v-if="item.id !== 1" @click="modifyName(item)" class="fas fa-pencil-alt"></i>
|
||||
<i v-if="item.id !== 1" @click="AskDeleteFolder(item)" class="fas fa-trash-alt"></i>
|
||||
</span>
|
||||
</VueNestableHandle>
|
||||
</VueNestable>
|
||||
|
|
@ -93,7 +93,11 @@
|
|||
get: function() {
|
||||
let allDirectories = this.directories.sort((a, b) =>(a.order > b.order) ? 1 : ((b.order > a.order) ? -1 : 0));
|
||||
allDirectories.forEach(child => {
|
||||
child.name = JSON.parse(child.name);
|
||||
|
||||
if (typeof child.name === 'string') {
|
||||
child.name = JSON.parse(child.name);
|
||||
}
|
||||
|
||||
if(child.children && child.children.length){
|
||||
child.children = this.orderChildren(child);
|
||||
} else {
|
||||
|
|
@ -137,15 +141,14 @@
|
|||
},
|
||||
methods: {
|
||||
toggleAuthorization(item) {
|
||||
let _this2 = this;
|
||||
axios.post('/folders/toggle-authorization', {id: item.id})
|
||||
.then(function (response) {
|
||||
.then(response => {
|
||||
let parseDirectories = response.data;
|
||||
_this2.directories = _this2.recursiveDir(parseDirectories);
|
||||
if(_this2.test){
|
||||
_this2.nestableItems = _this2.test
|
||||
this.directories = this.recursiveDir(parseDirectories);
|
||||
if(this.test){
|
||||
this.nestableItems = this.test
|
||||
}
|
||||
_this2.showAlert("Sauvegardé !");
|
||||
this.showAlert("Sauvegardé !");
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
|
|
@ -182,16 +185,15 @@
|
|||
},
|
||||
registerNewName() {
|
||||
this.done = false;
|
||||
let _this2 = this;
|
||||
axios.post('/save-folder-name', {id: this.folderId, name: JSON.stringify({fr: this.folderNameFR, en: this.folderNameEN, de: this.folderNameDE})})
|
||||
.then(function (response) {
|
||||
.then(response => {
|
||||
let parseDirectories = response.data;
|
||||
_this2.directories = _this2.recursiveDir(parseDirectories);
|
||||
if(_this2.test){
|
||||
_this2.nestableItems = _this2.test
|
||||
this.directories = this.recursiveDir(parseDirectories);
|
||||
if(this.test){
|
||||
this.nestableItems = this.test
|
||||
}
|
||||
$('#staticBackdrop').modal('hide');
|
||||
_this2.showAlert("Dossier renommé !");
|
||||
this.showAlert("Dossier renommé !");
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
|
|
@ -203,16 +205,15 @@
|
|||
return;
|
||||
}
|
||||
this.done = false;
|
||||
let _this2 = this;
|
||||
axios.post('/add-folder', {name: JSON.stringify({fr: this.newFolderFR}), order: this.nestableItems.length})
|
||||
.then(function (response) {
|
||||
.then(response => {
|
||||
let parseDirectories = response.data;
|
||||
_this2.directories = _this2.recursiveDir(parseDirectories);
|
||||
if(_this2.test){
|
||||
_this2.nestableItems = _this2.test
|
||||
this.directories = this.recursiveDir(parseDirectories);
|
||||
if(this.test){
|
||||
this.nestableItems = this.test
|
||||
}
|
||||
_this2.newFolderFR = '';
|
||||
_this2.showAlert("Dossier ajouté !");
|
||||
this.newFolderFR = '';
|
||||
this.showAlert("Dossier ajouté !");
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
|
|
@ -280,7 +281,9 @@
|
|||
if (folder.children && folder.children.length) {
|
||||
folder.children = folder.children.sort((a, b) => (a.order > b.order) ? 1 : ((b.order > a.order) ? -1 : 0))
|
||||
folder.children.forEach(child => {
|
||||
child.name = JSON.parse(child.name);
|
||||
if (typeof child.name === 'string') {
|
||||
child.name = JSON.parse(child.name);
|
||||
}
|
||||
if (child.children && child.children.length) {
|
||||
child.children = this.orderChildren(child);
|
||||
} else {
|
||||
|
|
@ -295,12 +298,16 @@
|
|||
axios.post('/save-folder-order', {
|
||||
folders: list,
|
||||
})
|
||||
.then(function (response) {
|
||||
console.log(response);
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
.then(response => {
|
||||
let parseDirectories = response.data.directories;
|
||||
this.directories = this.recursiveDir(parseDirectories);
|
||||
if(this.test){
|
||||
this.nestableItems = this.test
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.log(error);
|
||||
});
|
||||
},
|
||||
recursiveDir(list, parent = null) {
|
||||
let root = list.filter(e => e.parent == parent);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue