Merge pull request #75 from shariquerik/apply-listview-resize-column

fix: update column width on column resize by dragging and remove tooltip from listviews
This commit is contained in:
Shariq Ansari 2024-02-19 14:28:53 +05:30 committed by GitHub
commit 01b7aad776
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 119 additions and 45 deletions

View File

@ -0,0 +1,51 @@
<template>
<div
class="flex cursor-grab items-center justify-between gap-6 rounded px-2 py-1.5 text-base text-gray-800 hover:bg-gray-100"
>
<div class="flex items-center gap-2">
<DragIcon class="h-3.5" />
<div>{{ column.label }}</div>
</div>
<div class="flex cursor-pointer items-center gap-1">
<Button
variant="ghost"
class="!h-5 w-5 !p-1"
@click="emit('edit', column)"
>
<EditIcon class="h-3.5" />
</Button>
<Button
variant="ghost"
class="!h-5 w-5 !p-1"
@click="emit('remove', column)"
>
<FeatherIcon name="x" class="h-3.5" />
</Button>
</div>
</div>
</template>
<script setup>
import EditIcon from '@/components/Icons/EditIcon.vue'
import DragIcon from '@/components/Icons/DragIcon.vue'
import { watchDebounced } from '@vueuse/core'
const props = defineProps({
column: {
type: Object,
required: true,
},
})
const emit = defineEmits(['edit', 'remove', 'update'])
watchDebounced(
() => props.column.width,
(val, old_val) => {
val = val.replace(/[^\d.]/g, '')
old_val = old_val.replace(/[^\d.]/g, '')
if (Math.abs(val - old_val) > 1) return
emit('update')
},
{ debounce: 1000 }
)
</script>

View File

@ -19,30 +19,12 @@
class="list-group" class="list-group"
> >
<template #item="{ element }"> <template #item="{ element }">
<div <ColumnItem
class="flex cursor-grab items-center justify-between gap-6 rounded px-2 py-1.5 text-base text-gray-800 hover:bg-gray-100" :column="element"
> @edit="editColumn"
<div class="flex items-center gap-2"> @remove="removeColumn"
<DragIcon class="h-3.5" /> @update="apply"
<div>{{ element.label }}</div> />
</div>
<div class="flex cursor-pointer items-center gap-1">
<Button
variant="ghost"
class="!h-5 w-5 !p-1"
@click="editColumn(element)"
>
<EditIcon class="h-3.5" />
</Button>
<Button
variant="ghost"
class="!h-5 w-5 !p-1"
@click="removeColumn(element)"
>
<FeatherIcon name="x" class="h-3.5" />
</Button>
</div>
</div>
</template> </template>
</Draggable> </Draggable>
<div class="mt-1.5 flex flex-col gap-1 border-t pt-1.5"> <div class="mt-1.5 flex flex-col gap-1 border-t pt-1.5">
@ -135,8 +117,7 @@
<script setup> <script setup>
import ColumnsIcon from '@/components/Icons/ColumnsIcon.vue' import ColumnsIcon from '@/components/Icons/ColumnsIcon.vue'
import EditIcon from '@/components/Icons/EditIcon.vue' import ColumnItem from '@/components/ColumnItem.vue'
import DragIcon from '@/components/Icons/DragIcon.vue'
import ReloadIcon from '@/components/Icons/ReloadIcon.vue' import ReloadIcon from '@/components/Icons/ReloadIcon.vue'
import NestedPopover from '@/components/NestedPopover.vue' import NestedPopover from '@/components/NestedPopover.vue'
import Autocomplete from '@/components/frappe-ui/Autocomplete.vue' import Autocomplete from '@/components/frappe-ui/Autocomplete.vue'

View File

@ -8,6 +8,7 @@
params: { callLogId: row.name }, params: { callLogId: row.name },
}), }),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -35,12 +36,13 @@
<FeatherIcon :name="item.icon" class="h-3 w-3" /> <FeatherIcon :name="item.icon" class="h-3 w-3" />
</div> </div>
</template> </template>
<div <Tooltip
:text="item.label"
v-if="['modified', 'creation'].includes(column.key)" v-if="['modified', 'creation'].includes(column.key)"
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div v-else-if="column.key === 'status'" class="truncate text-base"> <div v-else-if="column.key === 'status'" class="truncate text-base">
<Badge <Badge
:variant="'subtle'" :variant="'subtle'"
@ -82,6 +84,7 @@ import {
ListSelectBanner, ListSelectBanner,
ListRowItem, ListRowItem,
ListFooter, ListFooter,
Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { watch } from 'vue' import { watch } from 'vue'
@ -98,6 +101,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -9,6 +9,7 @@
params: { contactId: row.name }, params: { contactId: row.name },
}), }),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -45,12 +46,13 @@
<PhoneIcon class="h-4 w-4" /> <PhoneIcon class="h-4 w-4" />
</div> </div>
</template> </template>
<div <Tooltip
:text="item.label"
v-if="['modified', 'creation'].includes(column.key)" v-if="['modified', 'creation'].includes(column.key)"
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div v-else-if="column.type === 'Check'"> <div v-else-if="column.type === 'Check'">
<FormControl <FormControl
type="checkbox" type="checkbox"
@ -64,7 +66,11 @@
</ListRows> </ListRows>
<ListSelectBanner> <ListSelectBanner>
<template #actions="{ selections, unselectAll }"> <template #actions="{ selections, unselectAll }">
<Button variant="subtle" label="Edit" @click="editValues(selections, unselectAll)"> <Button
variant="subtle"
label="Edit"
@click="editValues(selections, unselectAll)"
>
<template #prefix> <template #prefix>
<EditIcon class="h-3 w-3" /> <EditIcon class="h-3 w-3" />
</template> </template>
@ -103,6 +109,7 @@ import {
ListSelectBanner, ListSelectBanner,
ListRowItem, ListRowItem,
ListFooter, ListFooter,
Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
@ -119,6 +126,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -6,6 +6,7 @@
:options="{ :options="{
getRowRoute: (row) => ({ name: 'Deal', params: { dealId: row.name } }), getRowRoute: (row) => ({ name: 'Deal', params: { dealId: row.name } }),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -48,7 +49,8 @@
<PhoneIcon class="h-4 w-4" /> <PhoneIcon class="h-4 w-4" />
</div> </div>
</template> </template>
<div <Tooltip
:text="item.label"
v-if=" v-if="
[ [
'modified', 'modified',
@ -61,7 +63,7 @@
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div <div
v-else-if="column.key === 'sla_status'" v-else-if="column.key === 'sla_status'"
class="truncate text-base" class="truncate text-base"
@ -135,6 +137,7 @@ import {
ListFooter, ListFooter,
Dropdown, Dropdown,
call, call,
Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { setupBulkActions, createToast } from '@/utils' import { setupBulkActions, createToast } from '@/utils'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
@ -154,6 +157,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -5,6 +5,7 @@
:options="{ :options="{
onRowClick: (row) => emit('showEmailTemplate', row.name), onRowClick: (row) => emit('showEmailTemplate', row.name),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -21,12 +22,13 @@
<!-- <template #prefix> <!-- <template #prefix>
</template> --> </template> -->
<div <Tooltip
:text="item.label"
v-if="['modified', 'creation'].includes(column.key)" v-if="['modified', 'creation'].includes(column.key)"
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div v-else-if="column.key === 'status'" class="truncate text-base"> <div v-else-if="column.key === 'status'" class="truncate text-base">
<Badge <Badge
:variant="'subtle'" :variant="'subtle'"
@ -98,6 +100,7 @@ import {
ListRowItem, ListRowItem,
ListFooter, ListFooter,
call, call,
Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
@ -114,6 +117,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -6,6 +6,7 @@
:options="{ :options="{
getRowRoute: (row) => ({ name: 'Lead', params: { leadId: row.name } }), getRowRoute: (row) => ({ name: 'Lead', params: { leadId: row.name } }),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -57,7 +58,8 @@
<PhoneIcon class="h-4 w-4" /> <PhoneIcon class="h-4 w-4" />
</div> </div>
</template> </template>
<div <Tooltip
:text="item.label"
v-if=" v-if="
[ [
'modified', 'modified',
@ -70,7 +72,7 @@
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div <div
v-else-if="column.key === 'sla_status'" v-else-if="column.key === 'sla_status'"
class="truncate text-base" class="truncate text-base"
@ -144,6 +146,7 @@ import {
ListFooter, ListFooter,
Dropdown, Dropdown,
call, call,
Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { setupBulkActions, createToast } from '@/utils' import { setupBulkActions, createToast } from '@/utils'
import { globalStore } from '@/stores/global' import { globalStore } from '@/stores/global'
@ -163,6 +166,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -8,6 +8,7 @@
params: { organizationId: row.name }, params: { organizationId: row.name },
}), }),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -32,12 +33,13 @@
/> />
</div> </div>
</template> </template>
<div <Tooltip
:text="item.label"
v-if="['modified', 'creation'].includes(column.key)" v-if="['modified', 'creation'].includes(column.key)"
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div v-else-if="column.type === 'Check'"> <div v-else-if="column.type === 'Check'">
<FormControl <FormControl
type="checkbox" type="checkbox"
@ -51,7 +53,11 @@
</ListRows> </ListRows>
<ListSelectBanner> <ListSelectBanner>
<template #actions="{ selections, unselectAll }"> <template #actions="{ selections, unselectAll }">
<Button variant="subtle" label="Edit" @click="editValues(selections, unselectAll)"> <Button
variant="subtle"
label="Edit"
@click="editValues(selections, unselectAll)"
>
<template #prefix> <template #prefix>
<EditIcon class="h-3 w-3" /> <EditIcon class="h-3 w-3" />
</template> </template>
@ -88,6 +94,7 @@ import {
ListSelectBanner, ListSelectBanner,
ListRowItem, ListRowItem,
ListFooter, ListFooter,
Tooltip,
} from 'frappe-ui' } from 'frappe-ui'
import { ref, watch } from 'vue' import { ref, watch } from 'vue'
@ -104,6 +111,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -5,6 +5,7 @@
:options="{ :options="{
onRowClick: (row) => emit('showTask', row.name), onRowClick: (row) => emit('showTask', row.name),
selectable: options.selectable, selectable: options.selectable,
showTooltip: options.showTooltip,
}" }"
row-key="name" row-key="name"
> >
@ -47,12 +48,13 @@
/> />
</div> </div>
</template> </template>
<div <Tooltip
:text="item.label"
v-if="['modified', 'creation'].includes(column.key)" v-if="['modified', 'creation'].includes(column.key)"
class="truncate text-base" class="truncate text-base"
> >
{{ item.timeAgo }} {{ item.timeAgo }}
</div> </Tooltip>
<div v-else-if="column.type === 'Check'"> <div v-else-if="column.type === 'Check'">
<FormControl <FormControl
type="checkbox" type="checkbox"
@ -138,6 +140,7 @@ const props = defineProps({
type: Object, type: Object,
default: () => ({ default: () => ({
selectable: true, selectable: true,
showTooltip: true,
totalCount: 0, totalCount: 0,
rowCount: 0, rowCount: 0,
}), }),

View File

@ -16,6 +16,7 @@
:rows="rows" :rows="rows"
:columns="callLogs.data.columns" :columns="callLogs.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: callLogs.data.row_count, rowCount: callLogs.data.row_count,
totalCount: callLogs.data.total_count, totalCount: callLogs.data.total_count,
}" }"

View File

@ -175,7 +175,7 @@
class="mt-4" class="mt-4"
:rows="rows" :rows="rows"
:columns="columns" :columns="columns"
:options="{ selectable: false }" :options="{ selectable: false, showTooltip: false }"
/> />
<div <div
v-if="!rows.length" v-if="!rows.length"

View File

@ -21,6 +21,7 @@
:rows="rows" :rows="rows"
:columns="contacts.data.columns" :columns="contacts.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: contacts.data.row_count, rowCount: contacts.data.row_count,
totalCount: contacts.data.total_count, totalCount: contacts.data.total_count,
}" }"

View File

@ -22,6 +22,7 @@
:rows="rows" :rows="rows"
:columns="deals.data.columns" :columns="deals.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: deals.data.row_count, rowCount: deals.data.row_count,
totalCount: deals.data.total_count, totalCount: deals.data.total_count,
}" }"

View File

@ -21,6 +21,7 @@
:rows="rows" :rows="rows"
:columns="emailTemplates.data.columns" :columns="emailTemplates.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: emailTemplates.data.row_count, rowCount: emailTemplates.data.row_count,
totalCount: emailTemplates.data.total_count, totalCount: emailTemplates.data.total_count,
}" }"

View File

@ -23,6 +23,7 @@
:rows="rows" :rows="rows"
:columns="leads.data.columns" :columns="leads.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: leads.data.row_count, rowCount: leads.data.row_count,
totalCount: leads.data.total_count, totalCount: leads.data.total_count,
}" }"

View File

@ -184,14 +184,14 @@
v-if="tab.label === 'Deals' && rows.length" v-if="tab.label === 'Deals' && rows.length"
:rows="rows" :rows="rows"
:columns="columns" :columns="columns"
:options="{ selectable: false }" :options="{ selectable: false, showTooltip: false }"
/> />
<ContactsListView <ContactsListView
class="mt-4" class="mt-4"
v-if="tab.label === 'Contacts' && rows.length" v-if="tab.label === 'Contacts' && rows.length"
:rows="rows" :rows="rows"
:columns="columns" :columns="columns"
:options="{ selectable: false }" :options="{ selectable: false, showTooltip: false, }"
/> />
<div <div
v-if="!rows.length" v-if="!rows.length"

View File

@ -25,6 +25,7 @@
:rows="rows" :rows="rows"
:columns="organizations.data.columns" :columns="organizations.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: organizations.data.row_count, rowCount: organizations.data.row_count,
totalCount: organizations.data.total_count, totalCount: organizations.data.total_count,
}" }"

View File

@ -21,6 +21,7 @@
:rows="rows" :rows="rows"
:columns="tasks.data.columns" :columns="tasks.data.columns"
:options="{ :options="{
showTooltip: false,
rowCount: tasks.data.row_count, rowCount: tasks.data.row_count,
totalCount: tasks.data.total_count, totalCount: tasks.data.total_count,
}" }"