Skip to content

Commit

Permalink
Merge pull request #50 from Sysvale/hotfix/break-line-on-checklist
Browse files Browse the repository at this point in the history
Hotfix/break line on checklist
  • Loading branch information
jedsonmelo authored Aug 24, 2021
2 parents 1d182c6 + 9231436 commit e1ed4e1
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions resources/js/modules/board/components/ChecklistForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,23 @@
>
Ainda não há nenhum item na sua checklist.
</div>

<v-list flat>
<v-list-item-group>
<v-list-item
v-for="(item, i) in value"
:key="i"
>
<template #default="{ active, toggle }">
<template #default="{ toggle }">
<v-list-item-action v-if="!editMode || selectedIndex !== i">
<v-checkbox v-model="item.done" @click="toggle"></v-checkbox>
<v-checkbox
v-model="item.done"
@click="toggle"
/>
</v-list-item-action>

<v-list-item-content>
<v-list-item-title
:class="{
'done': item.done
}"
>
<v-list-item-title :class="{ 'done': item.done }">
<span v-if="editMode && selectedIndex === i">
<v-text-field
v-model="editItem"
Expand All @@ -38,18 +38,21 @@
@blur="finishEdit(i)"
/>
</span>

<span v-else>
{{ item.description }}
</span>
</v-list-item-title>
</v-list-item-content>

<v-btn
v-if="!item.done && (!editMode || selectedIndex !== i)"
icon
@click="handleEdit(i)"
>
<v-icon>edit</v-icon>
</v-btn>

<v-btn
v-if="!editMode || selectedIndex !== i"
icon
Expand All @@ -61,6 +64,7 @@
</v-list-item>
</v-list-item-group>
</v-list>

<div class="d-flex mt-2">
<v-text-field
v-model="newItem"
Expand All @@ -70,6 +74,7 @@
class="mr-2"
@keydown.enter="handleAdd"
/>

<v-btn
@click="handleAdd"
>
Expand All @@ -78,6 +83,7 @@
</div>
</div>
</template>

<script>
export default {
props: {
Expand All @@ -93,18 +99,18 @@ export default {
editItem: null,
editMode: false,
selectedIndex: -1,
}
};
},
computed: {
addButtonText() {
return 'Adicionar';
}
},
},
methods: {
handleAdd() {
if(this.newItem === null || this.newItem.trim() === '' ) return;
if (this.newItem === null || this.newItem.trim() === '') return;
this.$emit('input', [...(this.value || []), {
description: this.newItem,
}]);
Expand All @@ -113,19 +119,20 @@ export default {
handleRemove(index) {
this.$emit('input', [
...this.value.filter((_, i) => index !== i)
...this.value.filter((_, i) => index !== i),
]);
},
handleToggle(index) {
this.$emit('input', [
...this.value.map((item, i) => {
if(index === i) {
item.done = !!!item.done;
if (index === i) {
item.done = !item.done;
}
return item;
})
])
}),
]);
},
handleEdit(index) {
Expand All @@ -137,7 +144,7 @@ export default {
finishEdit(index) {
this.$emit('input', [
...this.value.map((item, i) => {
if(index === i) {
if (index === i) {
item.description = this.editItem;
}
return item;
Expand All @@ -147,12 +154,18 @@ export default {
this.selectedIndex = -1;
this.editItem = null;
},
}
}
},
};
</script>

<style scoped>
.done {
text-decoration: line-through;
opacity: 0.3;
}
.v-list-item__subtitle, .v-list-item__title {
flex: 1 1 100%;
white-space: normal !important;
}
</style>

0 comments on commit e1ed4e1

Please sign in to comment.