mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 08:49:05 +02:00
Fix items in folders deletion, editing, optimize process. Add folder sort.
This commit is contained in:
parent
32c06299bb
commit
5440508254
4 changed files with 79 additions and 6 deletions
2
scripts/system/inventory/package-lock.json
generated
2
scripts/system/inventory/package-lock.json
generated
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "inventory",
|
"name": "Inventory",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"name": "inventory",
|
"name": "Inventory",
|
||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
@ -43,6 +43,8 @@
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"> 1%",
|
"> 1%",
|
||||||
"last 2 versions",
|
"last 2 versions",
|
||||||
"not dead"
|
"not dead",
|
||||||
|
"ChromeAndroid > 55",
|
||||||
|
"Chrome > 55"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -218,7 +218,7 @@ function startup() {
|
||||||
|
|
||||||
ui = new AppUi({
|
ui = new AppUi({
|
||||||
buttonName: "INVENTORY",
|
buttonName: "INVENTORY",
|
||||||
home: Script.resolvePath("inventory.html"),
|
home: Script.resolvePath("index.html"),
|
||||||
graphicsDirectory: Script.resolvePath("./"), // Where your button icons are located
|
graphicsDirectory: Script.resolvePath("./"), // Where your button icons are located
|
||||||
onOpened: onOpened,
|
onOpened: onOpened,
|
||||||
onClosed: onClosed
|
onClosed: onClosed
|
||||||
|
|
|
@ -22,6 +22,14 @@
|
||||||
<v-app-bar-nav-icon @click="drawer = true"></v-app-bar-nav-icon>
|
<v-app-bar-nav-icon @click="drawer = true"></v-app-bar-nav-icon>
|
||||||
|
|
||||||
<v-toolbar-title>Inventory</v-toolbar-title>
|
<v-toolbar-title>Inventory</v-toolbar-title>
|
||||||
|
|
||||||
|
<v-spacer></v-spacer>
|
||||||
|
|
||||||
|
<v-btn color="primary" fab @click="sortInventory('top')">
|
||||||
|
<v-icon>
|
||||||
|
mdi-ab-testing
|
||||||
|
</v-icon>
|
||||||
|
</v-btn>
|
||||||
|
|
||||||
</v-app-bar>
|
</v-app-bar>
|
||||||
|
|
||||||
|
@ -189,7 +197,7 @@
|
||||||
{{item.name}}
|
{{item.name}}
|
||||||
</v-list-item>
|
</v-list-item>
|
||||||
</template>
|
</template>
|
||||||
<v-btn block medium color="primary"
|
<v-btn medium color="primary" class="mx-1"
|
||||||
@click="
|
@click="
|
||||||
editFolderDialog.show = true;
|
editFolderDialog.show = true;
|
||||||
editFolderDialog.uuid = item.uuid;
|
editFolderDialog.uuid = item.uuid;
|
||||||
|
@ -198,11 +206,16 @@
|
||||||
>
|
>
|
||||||
Edit Folder
|
Edit Folder
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-btn block medium color="red"
|
<v-btn medium color="red" class="mx-1"
|
||||||
@click="removeFolderDialog.show = true; removeFolderDialog.uuid = item.uuid;"
|
@click="removeFolderDialog.show = true; removeFolderDialog.uuid = item.uuid;"
|
||||||
>
|
>
|
||||||
Delete Folder
|
Delete Folder
|
||||||
</v-btn>
|
</v-btn>
|
||||||
|
<v-btn medium color="purple" class="mx-1"
|
||||||
|
@click="sortFolder(item.uuid);"
|
||||||
|
>
|
||||||
|
Sort Folder
|
||||||
|
</v-btn>
|
||||||
<v-col
|
<v-col
|
||||||
cols="12"
|
cols="12"
|
||||||
sm="6"
|
sm="6"
|
||||||
|
@ -1118,6 +1131,16 @@ export default {
|
||||||
for (var i = 0; i < this.items.length; i++) {
|
for (var i = 0; i < this.items.length; i++) {
|
||||||
if (this.items[i].uuid == uuid) {
|
if (this.items[i].uuid == uuid) {
|
||||||
this.items.splice(i, 1);
|
this.items.splice(i, 1);
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else if (Object.prototype.hasOwnProperty.call(this.items[i], "items")) {
|
||||||
|
for (var di = 0; di < this.items[i].items.length; di++) { // DI means deep iteration
|
||||||
|
if (this.items[i].items[di].uuid == uuid) {
|
||||||
|
this.items[i].items.splice(di, 1);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1134,6 +1157,18 @@ export default {
|
||||||
this.items[i].type = this.checkItemType(this.editDialog.data.type);
|
this.items[i].type = this.checkItemType(this.editDialog.data.type);
|
||||||
this.items[i].name = this.editDialog.data.name;
|
this.items[i].name = this.editDialog.data.name;
|
||||||
this.items[i].url = this.editDialog.data.url;
|
this.items[i].url = this.editDialog.data.url;
|
||||||
|
|
||||||
|
return;
|
||||||
|
} else if (Object.prototype.hasOwnProperty.call(this.items[i], "items")) {
|
||||||
|
for (var di = 0; di < this.items[i].items.length; di++) { // DI means deep iteration
|
||||||
|
if (this.items[i].items[di].uuid == uuid) {
|
||||||
|
this.items[i].items[di].type = this.checkItemType(this.editDialog.data.type);
|
||||||
|
this.items[i].items[di].name = this.editDialog.data.name;
|
||||||
|
this.items[i].items[di].url = this.editDialog.data.url;
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1176,6 +1211,42 @@ export default {
|
||||||
"url": url
|
"url": url
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
sortInventory: function(level) {
|
||||||
|
if (level == "top") {
|
||||||
|
this.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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
},
|
||||||
|
sortFolder: function(uuid) {
|
||||||
|
for (var i = 0; i < this.items.length; i++) {
|
||||||
|
if (this.items[i].uuid == uuid) {
|
||||||
|
this.items[i].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;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
sendInventory: function() {
|
sendInventory: function() {
|
||||||
this.sendAppMessage("web-to-script-inventory", this.items );
|
this.sendAppMessage("web-to-script-inventory", this.items );
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue