mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 12:17:45 +02:00
Basic folder moving functionality, missing safeguards.
This commit is contained in:
parent
35fe561ceb
commit
3197ec12a5
3 changed files with 111 additions and 55 deletions
|
@ -255,6 +255,16 @@
|
||||||
:rules="[v => !!v || 'Name is required.']"
|
:rules="[v => !!v || 'Name is required.']"
|
||||||
required
|
required
|
||||||
></v-text-field>
|
></v-text-field>
|
||||||
|
|
||||||
|
<v-select
|
||||||
|
:items="folderList"
|
||||||
|
item-text="name"
|
||||||
|
item-value="uuid"
|
||||||
|
class="my-2"
|
||||||
|
v-model="editFolderDialogStore.data.folder"
|
||||||
|
label="Folder"
|
||||||
|
outlined
|
||||||
|
></v-select>
|
||||||
|
|
||||||
<v-card-actions>
|
<v-card-actions>
|
||||||
|
|
||||||
|
@ -272,7 +282,7 @@
|
||||||
color="blue"
|
color="blue"
|
||||||
class="px-3"
|
class="px-3"
|
||||||
:disabled="!$store.state.editFolderDialog.valid"
|
:disabled="!$store.state.editFolderDialog.valid"
|
||||||
@click="editFolderDialogStore.show = false; editFolder($store.state.editFolderDialog.uuid);"
|
@click="editFolderDialogStore.show = false; editFolder($store.state.editFolderDialog.data.uuid);"
|
||||||
>
|
>
|
||||||
Done
|
Done
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
@ -643,13 +653,14 @@ export default {
|
||||||
{
|
{
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"name": "Test Folder",
|
"name": "Test Folder",
|
||||||
|
"folder": "No Folder",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"hasChildren": false,
|
"hasChildren": false,
|
||||||
"type": "script",
|
"type": "script",
|
||||||
"name": "TESTFOLDERSCRIPT",
|
"name": "TESTFOLDERSCRIPT",
|
||||||
"url": "https://googfdafsgaergale.com/vr.js",
|
"url": "https://googfdafsgaergale.com/vr.js",
|
||||||
"folder": "No Folder",
|
"folder": "Test Folder",
|
||||||
"uuid": "54hgfhgf25fdfadf4354353",
|
"uuid": "54hgfhgf25fdfadf4354353",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -657,19 +668,20 @@ export default {
|
||||||
"type": "script",
|
"type": "script",
|
||||||
"name": "FOLDERSCRIPT2",
|
"name": "FOLDERSCRIPT2",
|
||||||
"url": "https://googfdafsgaergale.com/vr.js",
|
"url": "https://googfdafsgaergale.com/vr.js",
|
||||||
"folder": "No Folder",
|
"folder": "Test Folder",
|
||||||
"uuid": "54hgfhgf25ffdafddfadf4354353",
|
"uuid": "54hgfhgf25ffdafddfadf4354353",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"name": "FolderWithinAFolder",
|
"name": "FolderWithinAFolder",
|
||||||
|
"folder": "Test Folder",
|
||||||
"items": [
|
"items": [
|
||||||
{
|
{
|
||||||
"hasChildren": false,
|
"hasChildren": false,
|
||||||
"type": "script",
|
"type": "script",
|
||||||
"name": "inception1",
|
"name": "inception1",
|
||||||
"url": "https://googfdafsgaergale.com/vr.js",
|
"url": "https://googfdafsgaergale.com/vr.js",
|
||||||
"folder": "No Folder",
|
"folder": "FolderWithinAFolder",
|
||||||
"uuid": "54hgfhgf25fdfadeqwqeqf4354353",
|
"uuid": "54hgfhgf25fdfadeqwqeqf4354353",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -677,7 +689,7 @@ export default {
|
||||||
"type": "script",
|
"type": "script",
|
||||||
"name": "123what",
|
"name": "123what",
|
||||||
"url": "https://googfdafsgaergale.com/vr.js",
|
"url": "https://googfdafsgaergale.com/vr.js",
|
||||||
"folder": "No Folder",
|
"folder": "FolderWithinAFolder",
|
||||||
"uuid": "54hgfhgf25ffdafdWDQDdsadasQWWQdfadf4354353",
|
"uuid": "54hgfhgf25ffdafdWDQDdsadasQWWQdfadf4354353",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -685,7 +697,7 @@ export default {
|
||||||
"type": "script",
|
"type": "script",
|
||||||
"name": "inception432",
|
"name": "inception432",
|
||||||
"url": "https://googfdafsgaergale.com/vr.js",
|
"url": "https://googfdafsgaergale.com/vr.js",
|
||||||
"folder": "No Folder",
|
"folder": "FolderWithinAFolder",
|
||||||
"uuid": "54hgfhgf25ffdafdWDQDQWWQdfadf4354353",
|
"uuid": "54hgfhgf25ffdafdWDQDQWWQdfadf4354353",
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
@ -842,7 +854,7 @@ export default {
|
||||||
this.items.push(itemToPush);
|
this.items.push(itemToPush);
|
||||||
|
|
||||||
if (folder !== null && folder !== "No Folder") {
|
if (folder !== null && folder !== "No Folder") {
|
||||||
this.moveItemToFolder(uuidToUse, folder);
|
this.moveItem(uuidToUse, folder);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
pushFolderToItems: function(name) {
|
pushFolderToItems: function(name) {
|
||||||
|
@ -909,11 +921,19 @@ export default {
|
||||||
this.pushFolderToItems(name);
|
this.pushFolderToItems(name);
|
||||||
},
|
},
|
||||||
editFolder: function(uuid) {
|
editFolder: function(uuid) {
|
||||||
for (var i = 0; i < this.items.length; i++) {
|
var findFolder = this.searchForItem(uuid);
|
||||||
if (this.items[i].uuid == uuid) {
|
|
||||||
this.items[i].name = this.editFolderDialog.data.name;
|
if (findFolder) {
|
||||||
|
findFolder.returnedItem.name = this.$store.state.editFolderDialog.data.name;
|
||||||
return;
|
|
||||||
|
if (this.$store.state.editFolderDialog.data.folder !== null && this.$store.state.editFolderDialog.data.folder !== "No Change") {
|
||||||
|
if (findFolder.returnedItem.folder !== this.$store.state.editFolderDialog.data.folder && this.$store.state.editFolderDialog.data.folder !== "No Folder") {
|
||||||
|
console.info("This folder?", this.$store.state.editFolderDialog.data.folder);
|
||||||
|
this.moveFolder(uuid, this.$store.state.editFolderDialog.data.folder);
|
||||||
|
} else if (this.$store.state.editFolderDialog.data.folder === "No Folder") {
|
||||||
|
console.info("This folder TOP?", this.$store.state.editFolderDialog.data.folder);
|
||||||
|
this.moveFolder(uuid, "top");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -988,9 +1008,9 @@ export default {
|
||||||
|
|
||||||
if (this.$store.state.editDialog.data.folder !== null) {
|
if (this.$store.state.editDialog.data.folder !== null) {
|
||||||
if (folderName !== this.$store.state.editDialog.data.folder && this.$store.state.editDialog.data.folder !== "No Folder") {
|
if (folderName !== this.$store.state.editDialog.data.folder && this.$store.state.editDialog.data.folder !== "No Folder") {
|
||||||
this.moveItemToFolder(uuid, this.$store.state.editDialog.data.folder);
|
this.moveItem(uuid, this.$store.state.editDialog.data.folder);
|
||||||
} else if (folderName === "No Folder") {
|
} else if (folderName === "No Folder") {
|
||||||
this.moveItemToTop(uuid);
|
this.moveItem(uuid, "top");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1111,54 +1131,79 @@ export default {
|
||||||
this.folderList = combinedArray;
|
this.folderList = combinedArray;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
moveItemToFolder: function(uuid, folderUUID) {
|
moveItem: function(uuid, folderUUID) {
|
||||||
// This function is used to take an item one level deep, do not use it for any other purposes and check beforehand if you need to do this.
|
|
||||||
var itemToPush = {
|
|
||||||
"hasChildren": false,
|
|
||||||
'type': null,
|
|
||||||
'name': null,
|
|
||||||
'folder': null,
|
|
||||||
'url': null,
|
|
||||||
'uuid': uuid,
|
|
||||||
};
|
|
||||||
|
|
||||||
var findItem = this.searchForItem(uuid);
|
var findItem = this.searchForItem(uuid);
|
||||||
|
|
||||||
itemToPush.type = findItem.returnedItem.type;
|
if (folderUUID === "top") {
|
||||||
itemToPush.name = findItem.returnedItem.name;
|
// Remove the old item before placing down the copy, we already got the attributes that we had wanted.
|
||||||
itemToPush.url = findItem.returnedItem.url;
|
this.removeItem(uuid);
|
||||||
|
|
||||||
|
this.pushToItems(
|
||||||
|
findItem.returnedItem.type,
|
||||||
|
findItem.returnedItem.name,
|
||||||
|
"No Folder",
|
||||||
|
findItem.returnedItem.url,
|
||||||
|
uuid
|
||||||
|
);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
var itemToPush = {
|
||||||
|
"hasChildren": false,
|
||||||
|
'type': null,
|
||||||
|
'name': null,
|
||||||
|
'folder': null,
|
||||||
|
'url': null,
|
||||||
|
'uuid': uuid,
|
||||||
|
};
|
||||||
|
|
||||||
// Get the folder UUID.
|
itemToPush.type = findItem.returnedItem.type;
|
||||||
for (var i = 0; i < this.folderList.length; i++) {
|
itemToPush.name = findItem.returnedItem.name;
|
||||||
if (this.folderList[i].uuid === folderUUID) {
|
itemToPush.url = findItem.returnedItem.url;
|
||||||
itemToPush.folder = this.folderList[i].name;
|
|
||||||
|
// Get the folder UUID.
|
||||||
|
for (var i = 0; i < this.folderList.length; i++) {
|
||||||
|
if (this.folderList[i].uuid === folderUUID) {
|
||||||
|
itemToPush.folder = this.folderList[i].name;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the old item before placing down the copy, we already got the attributes that we had wanted.
|
||||||
|
this.removeItem(uuid);
|
||||||
|
|
||||||
|
// Find that folder in our main items array.
|
||||||
|
var findFolder = this.searchForItem(folderUUID);
|
||||||
|
|
||||||
|
if (findFolder) {
|
||||||
|
findFolder.returnedItem.items.push(itemToPush);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove the old item before placing down the copy, we already got the attributes that we had wanted.
|
|
||||||
this.removeItem(uuid);
|
|
||||||
|
|
||||||
// Find that folder in our main items array.
|
|
||||||
var findFolder = this.searchForItem(folderUUID);
|
|
||||||
|
|
||||||
if (findFolder) {
|
|
||||||
findFolder.returnedItem.items.push(itemToPush);
|
|
||||||
}
|
|
||||||
|
|
||||||
},
|
},
|
||||||
moveItemToTop: function(uuid) {
|
moveFolder: function(uuid, parentFolderUUID) {
|
||||||
var findItem = this.searchForItem(uuid);
|
var findFolder = this.searchForItem(uuid);
|
||||||
|
console.info("WHAT", parentFolderUUID);
|
||||||
// Remove the old item before placing down the copy, we already got the attributes that we had wanted.
|
if (parentFolderUUID === "top") {
|
||||||
this.removeItem(uuid);
|
// Remove the old item before placing down the copy, we already got the attributes that we had wanted.
|
||||||
|
this.removeItem(uuid);
|
||||||
|
|
||||||
|
findFolder.returnedItem.folder = "No Folder";
|
||||||
|
|
||||||
this.pushToItems(
|
this.items.push(findFolder.returnedItem);
|
||||||
findItem.returnedItem.type,
|
|
||||||
findItem.returnedItem.name,
|
} else {
|
||||||
"No Folder",
|
// Find the parent folder.
|
||||||
findItem.returnedItem.url,
|
var findParentFolder = this.searchForItem(parentFolderUUID);
|
||||||
uuid
|
console.info("Going to push...", findFolder.returnedItem);
|
||||||
);
|
console.info("Into...", findParentFolder.returnedItem);
|
||||||
|
if (findParentFolder) {
|
||||||
|
// Remove the old item before placing down the copy, we already got the attributes that we had wanted.
|
||||||
|
this.removeItem(uuid);
|
||||||
|
|
||||||
|
findFolder.returnedItem.folder = findParentFolder.name;
|
||||||
|
findParentFolder.returnedItem.items.push(findFolder.returnedItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
},
|
},
|
||||||
searchForItem: function(uuid) {
|
searchForItem: function(uuid) {
|
||||||
var foundItem = this.recursiveSingularSearch(uuid, this.items);
|
var foundItem = this.recursiveSingularSearch(uuid, this.items);
|
||||||
|
@ -1286,6 +1331,9 @@ export default {
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
editFolderDialogShow: function() {
|
||||||
|
return this.$store.state.editFolderDialog.show;
|
||||||
|
},
|
||||||
createFolderDialogStore: {
|
createFolderDialogStore: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.state.createFolderDialog;
|
return this.$store.state.createFolderDialog;
|
||||||
|
@ -1369,6 +1417,13 @@ export default {
|
||||||
this.getFolderList('edit');
|
this.getFolderList('edit');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
editFolderDialogShow: {
|
||||||
|
handler: function(newVal) {
|
||||||
|
if (newVal === true) {
|
||||||
|
this.getFolderList('edit');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -133,7 +133,7 @@
|
||||||
<v-btn medium tile color="purple" class="mx-1 folder-button"
|
<v-btn medium tile color="purple" class="mx-1 folder-button"
|
||||||
@click="
|
@click="
|
||||||
editFolderDialogStore.show = true;
|
editFolderDialogStore.show = true;
|
||||||
editFolderDialogStore.uuid = item.uuid;
|
editFolderDialogStore.data.uuid = item.uuid;
|
||||||
editFolderDialogStore.data.name = item.name;
|
editFolderDialogStore.data.name = item.name;
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
|
|
|
@ -101,6 +101,7 @@ export const store = new Vuex.Store({
|
||||||
uuid: null, //
|
uuid: null, //
|
||||||
data: {
|
data: {
|
||||||
"name": null,
|
"name": null,
|
||||||
|
"folder": null,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
receiveDialog: {
|
receiveDialog: {
|
||||||
|
|
Loading…
Reference in a new issue