Skip to content

Commit

Permalink
Merge pull request #62 from uasoft-indonesia/develop
Browse files Browse the repository at this point in the history
Merge develop to main
  • Loading branch information
rizkiheryandi authored Jun 23, 2021
2 parents 7f49141 + b46f3df commit 94caa28
Showing 1 changed file with 55 additions and 2 deletions.
57 changes: 55 additions & 2 deletions src/resources/js/components/BadasoContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,28 @@
<vs-button
color="danger"
type="relief"
@click="dropItem(items, key)"
@click="dropItem(item, key)"
>
<vs-icon icon="delete"></vs-icon>
</vs-button>
<vs-button
color="warning"
type="relief"
@click="moveUp(index)"
v-if="Object.values(items.data).length > 1"
:disabled="index === 0"
>
<vs-icon icon="expand_less"></vs-icon>
</vs-button>
<vs-button
color="warning"
type="relief"
@click="moveDown(index)"
v-if="Object.values(items.data).length > 1"
:disabled="index === Object.values(items.data).length - 1"
>
<vs-icon icon="expand_more"></vs-icon>
</vs-button>
</td>
</tr>
<tr :key="items.name + '-' + key + '-opened'" v-if="opened.includes(index)">
Expand Down Expand Up @@ -164,7 +182,7 @@ export default {
color: "danger",
title: this.$t("action.delete.title"),
text: this.$t("action.delete.text"),
accept: () => this.$delete(items.data, key),
accept: () => this.$delete(this.items.data, key),
acceptText: this.$t("action.delete.accept"),
cancelText: this.$t("action.delete.cancel"),
cancel: () => {},
Expand All @@ -182,6 +200,41 @@ export default {
openCopyItemDialog(item) {
this.willCopyItem = item
this.copyItemDialog = true
},
moveDown(index) {
const temp = []
var tempObject = {}
for (const item in this.items.data) {
if (Object.hasOwnProperty.call(this.items.data, item)) {
temp.push(this.items.data[item])
}
}
[temp[index], temp[index + 1]] = [temp[index + 1], temp[index]]
tempObject = this.convertArrayToObject(temp, 'name')
this.items.data = tempObject
},
moveUp(index) {
const temp = []
var tempObject = {}
for (const item in this.items.data) {
if (Object.hasOwnProperty.call(this.items.data, item)) {
temp.push(this.items.data[item])
}
}
[temp[index], temp[index - 1]] = [temp[index - 1], temp[index]]
tempObject = this.convertArrayToObject(temp, 'name')
this.items.data = tempObject
},
convertArrayToObject(array, key) {
const initialValue = {};
return array.reduce((obj, item) => {
return {
...obj,
[item[key]]: item,
};
}, initialValue);
}
},
};
Expand Down

0 comments on commit 94caa28

Please sign in to comment.