This commit is contained in:
2018-11-27 23:45:20 +00:00
parent cc7322380a
commit 79384cde07
2 changed files with 16 additions and 31 deletions

View File

@@ -20,7 +20,7 @@
<v-icon>fa-ellipsis-v</v-icon>
</v-btn>
</v-toolbar>
<WidgetEdit :dialog="dialog" v-on:dialogclose="dialog=false"/>
<WidgetEdit :dialogdata="dialogdata" v-on:dialogclose="dialogdata.dialog=false"/>
<v-data-table
v-model="selected"
:headers="headers"
@@ -59,7 +59,10 @@ export default {
},
data() {
return {
dialog: false,
dialogdata: {
dialog: false,
recordId: 2
},
editedIndex: -1,
editedItem: {
name: "",
@@ -130,7 +133,8 @@ export default {
},
newItem() {
this.dialog = true;
this.dialogdata.recordId = -1;
this.dialogdata.dialog = true;
},
getDataFromApi() {
var listOptions = {
@@ -153,29 +157,8 @@ export default {
});
},
editItem(item) {
this.editedIndex = this.Items.indexOf(item);
this.editedItem = Object.assign({}, item);
this.dialog = true;
},
deleteItem(item) {
const index = this.Items.indexOf(item);
confirm("Are you sure you want to delete this item?") &&
this.Items.splice(index, 1);
},
close() {
this.dialog = false;
setTimeout(() => {
this.editedItem = Object.assign({}, this.defaultItem);
this.editedIndex = -1;
}, 300);
},
save() {
if (this.editedIndex > -1) {
Object.assign(this.Items[this.editedIndex], this.editedItem);
} else {
this.Items.push(this.editedItem);
}
this.close();
this.dialogdata.recordId = this.Items.indexOf(item);
this.dialogdata.dialog = true;
}
}
};