fix: show active heart icon if list filter is applied & if doc is liked
This commit is contained in:
parent
2c2a49acd7
commit
72fa3e3eaa
@ -21,7 +21,8 @@
|
|||||||
<Button
|
<Button
|
||||||
v-if="column.key == '_liked_by'"
|
v-if="column.key == '_liked_by'"
|
||||||
variant="ghosted"
|
variant="ghosted"
|
||||||
class="!h-4 fill-white"
|
class="!h-4"
|
||||||
|
:class="isLikeFilterApplied ? 'fill-red-500' : 'fill-white'"
|
||||||
>
|
>
|
||||||
<HeartIcon class="h-4 w-4" />
|
<HeartIcon class="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@ -104,7 +105,7 @@
|
|||||||
<Button
|
<Button
|
||||||
v-if="column.key == '_liked_by'"
|
v-if="column.key == '_liked_by'"
|
||||||
variant="ghosted"
|
variant="ghosted"
|
||||||
class="fill-white"
|
:class="isLiked(item) ? 'fill-red-500' : 'fill-white'"
|
||||||
>
|
>
|
||||||
<HeartIcon class="h-4 w-4" />
|
<HeartIcon class="h-4 w-4" />
|
||||||
</Button>
|
</Button>
|
||||||
@ -187,7 +188,8 @@ import {
|
|||||||
Dropdown,
|
Dropdown,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref, watch } from 'vue'
|
import { sessionStore } from '@/stores/session'
|
||||||
|
import { ref, computed, watch } from 'vue'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
rows: {
|
rows: {
|
||||||
@ -220,6 +222,19 @@ const emit = defineEmits([
|
|||||||
const pageLengthCount = defineModel()
|
const pageLengthCount = defineModel()
|
||||||
const list = defineModel('list')
|
const list = defineModel('list')
|
||||||
|
|
||||||
|
const isLikeFilterApplied = computed(() => {
|
||||||
|
return list.value.params?.filters?._liked_by ? true : false
|
||||||
|
})
|
||||||
|
|
||||||
|
const { user } = sessionStore()
|
||||||
|
|
||||||
|
function isLiked(item) {
|
||||||
|
if (item) {
|
||||||
|
let likedByMe = JSON.parse(item)
|
||||||
|
return likedByMe.includes(user)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
watch(pageLengthCount, (val, old_value) => {
|
watch(pageLengthCount, (val, old_value) => {
|
||||||
if (val === old_value) return
|
if (val === old_value) return
|
||||||
emit('updatePageCount', val)
|
emit('updatePageCount', val)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user