mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 06:37:27 +02:00
Fix deep iteration.
This commit is contained in:
parent
14689bea87
commit
35fe561ceb
2 changed files with 18 additions and 37 deletions
|
@ -25,7 +25,7 @@
|
||||||
|
|
||||||
<v-spacer></v-spacer>
|
<v-spacer></v-spacer>
|
||||||
|
|
||||||
<v-btn medium color="primary" fab @click="sortInventory('top')">
|
<v-btn medium color="primary" fab @click="sortTopInventory('top')">
|
||||||
<v-icon>
|
<v-icon>
|
||||||
mdi-ab-testing
|
mdi-ab-testing
|
||||||
</v-icon>
|
</v-icon>
|
||||||
|
@ -968,17 +968,11 @@ export default {
|
||||||
findItem.parentArray.splice(findItem.iteration, 1);
|
findItem.parentArray.splice(findItem.iteration, 1);
|
||||||
},
|
},
|
||||||
removeFolder: function(uuid) {
|
removeFolder: function(uuid) {
|
||||||
for (var i = 0; i < this.items.length; i++) {
|
var findFolder = this.searchForItem(uuid);
|
||||||
if (this.items[i].uuid == uuid) {
|
findFolder.parentArray.splice(findFolder.iteration, 1);
|
||||||
this.items.splice(i, 1);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
editItem: function(uuid) {
|
editItem: function(uuid) {
|
||||||
var findItem = this.searchForItem(uuid);
|
var findItem = this.searchForItem(uuid);
|
||||||
|
|
||||||
findItem.returnedItem.type = this.checkItemType(this.$store.state.editDialog.data.type);
|
findItem.returnedItem.type = this.checkItemType(this.$store.state.editDialog.data.type);
|
||||||
findItem.returnedItem.name = this.$store.state.editDialog.data.name;
|
findItem.returnedItem.name = this.$store.state.editDialog.data.name;
|
||||||
findItem.returnedItem.folder = this.$store.state.editDialog.data.folder;
|
findItem.returnedItem.folder = this.$store.state.editDialog.data.folder;
|
||||||
|
@ -1072,7 +1066,7 @@ export default {
|
||||||
onDragChange: function(ev) {
|
onDragChange: function(ev) {
|
||||||
console.info("Drag Update.", ev);
|
console.info("Drag Update.", ev);
|
||||||
},
|
},
|
||||||
sortInventory: function(level) {
|
sortTopInventory: function(level) {
|
||||||
if (level == "top") {
|
if (level == "top") {
|
||||||
this.items.sort(function(a, b) {
|
this.items.sort(function(a, b) {
|
||||||
var nameA = a.name.toUpperCase(); // ignore upper and lowercase
|
var nameA = a.name.toUpperCase(); // ignore upper and lowercase
|
||||||
|
@ -1129,6 +1123,7 @@ export default {
|
||||||
};
|
};
|
||||||
|
|
||||||
var findItem = this.searchForItem(uuid);
|
var findItem = this.searchForItem(uuid);
|
||||||
|
|
||||||
itemToPush.type = findItem.returnedItem.type;
|
itemToPush.type = findItem.returnedItem.type;
|
||||||
itemToPush.name = findItem.returnedItem.name;
|
itemToPush.name = findItem.returnedItem.name;
|
||||||
itemToPush.url = findItem.returnedItem.url;
|
itemToPush.url = findItem.returnedItem.url;
|
||||||
|
@ -1144,10 +1139,10 @@ export default {
|
||||||
this.removeItem(uuid);
|
this.removeItem(uuid);
|
||||||
|
|
||||||
// Find that folder in our main items array.
|
// Find that folder in our main items array.
|
||||||
for (var folder = 0; folder < this.items.length; folder++) {
|
var findFolder = this.searchForItem(folderUUID);
|
||||||
if (this.items[folder].uuid === folderUUID && this.items[folder].hasChildren === true) {
|
|
||||||
this.items[folder].items.push(itemToPush);
|
if (findFolder) {
|
||||||
}
|
findFolder.returnedItem.items.push(itemToPush);
|
||||||
}
|
}
|
||||||
|
|
||||||
},
|
},
|
||||||
|
@ -1165,25 +1160,6 @@ export default {
|
||||||
uuid
|
uuid
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
sortFolder: function(uuid) {
|
|
||||||
var findFolder = this.searchForItem(uuid);
|
|
||||||
|
|
||||||
if (findFolder) {
|
|
||||||
findFolder.returnedItem.items.sort(function(a, b) {
|
|
||||||
var nameA = a.name.toUpperCase(); // ignore upper and lowercase
|
|
||||||
var nameB = b.name.toUpperCase(); // ignore upper and lowercase
|
|
||||||
if (nameA < nameB) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (nameA > nameB) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
// names must be equal
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
},
|
|
||||||
searchForItem: function(uuid) {
|
searchForItem: function(uuid) {
|
||||||
var foundItem = this.recursiveSingularSearch(uuid, this.items);
|
var foundItem = this.recursiveSingularSearch(uuid, this.items);
|
||||||
|
|
||||||
|
@ -1206,9 +1182,14 @@ export default {
|
||||||
}
|
}
|
||||||
return foundItem;
|
return foundItem;
|
||||||
} else if (Object.prototype.hasOwnProperty.call(indexToSearch[i], "items") && indexToSearch[i].items.length > 0) {
|
} else if (Object.prototype.hasOwnProperty.call(indexToSearch[i], "items") && indexToSearch[i].items.length > 0) {
|
||||||
this.recursiveSingularSearch(uuid, indexToSearch[i].items);
|
var deepSearch = this.recursiveSingularSearch(uuid, indexToSearch[i].items);
|
||||||
|
if (deepSearch !== null) {
|
||||||
|
return deepSearch;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
},
|
},
|
||||||
recursiveFolderPopulate: function(indexToSearch, firstIteration) {
|
recursiveFolderPopulate: function(indexToSearch, firstIteration) {
|
||||||
for (var i = 0; i < indexToSearch.length; i++) {
|
for (var i = 0; i < indexToSearch.length; i++) {
|
||||||
|
|
|
@ -353,11 +353,11 @@ export default {
|
||||||
"parentArray": indexToSearch,
|
"parentArray": indexToSearch,
|
||||||
}
|
}
|
||||||
return foundItem;
|
return foundItem;
|
||||||
} else if (Object.prototype.hasOwnProperty.call(indexToSearch[i], "items") && indexToSearch[i].length > 0) {
|
} else if (Object.prototype.hasOwnProperty.call(indexToSearch[i], "items") && indexToSearch[i].items.length > 0) {
|
||||||
this.recursiveSingularSearch(uuid, indexToSearch[i]);
|
return this.recursiveSingularSearch(uuid, indexToSearch[i].items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
Loading…
Reference in a new issue