1
0
forked from test/crm

feat: added ability to pin unpin a view

This commit is contained in:
Shariq Ansari 2024-01-01 17:53:47 +05:30
parent 6842affa31
commit a760a2fa6a
6 changed files with 94 additions and 4 deletions

View File

@ -9,6 +9,7 @@
"user",
"column_break_zacm",
"dt",
"pinned",
"columns_tab",
"default_columns",
"columns",
@ -84,11 +85,17 @@
"fieldname": "default_columns",
"fieldtype": "Check",
"label": "Default Columns"
},
{
"default": "0",
"fieldname": "pinned",
"fieldtype": "Check",
"label": "Pinned"
}
],
"index_web_pages_for_search": 1,
"links": [],
"modified": "2023-12-30 19:28:02.541487",
"modified": "2024-01-01 17:42:37.789865",
"modified_by": "Administrator",
"module": "FCRM",
"name": "CRM View Settings",

View File

@ -72,6 +72,12 @@ def delete(name):
if frappe.db.exists("CRM View Settings", name):
frappe.delete_doc("CRM View Settings", name)
@frappe.whitelist()
def pin(name, value):
doc = frappe.get_doc("CRM View Settings", name)
doc.pinned = value
doc.save()
def remove_duplicates(l):
return list(dict.fromkeys(l))

View File

@ -0,0 +1,16 @@
<template>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M6.72124 1.6001C5.61667 1.6001 4.72124 2.49553 4.72124 3.6001V4.42747H5.72124V3.6001C5.72124 3.04781 6.16895 2.6001 6.72124 2.6001H12.9997C13.552 2.6001 13.9997 3.04781 13.9997 3.6001V8.82643C13.9997 9.37871 13.552 9.82643 12.9997 9.82643H12.1801V10.8264H12.9997C14.1043 10.8264 14.9997 9.931 14.9997 8.82643V3.6001C14.9997 2.49553 14.1043 1.6001 12.9997 1.6001H6.72124ZM3 5.28494C1.89543 5.28494 1 6.18037 1 7.28494V12.5113C1 13.6158 1.89543 14.5113 3 14.5113H9.27846C10.383 14.5113 11.2785 13.6158 11.2785 12.5113V7.28494C11.2785 6.18037 10.383 5.28494 9.27846 5.28494H3ZM2 7.28494C2 6.73266 2.44772 6.28494 3 6.28494H9.27846C9.83075 6.28494 10.2785 6.73266 10.2785 7.28494V12.5113C10.2785 13.0636 9.83075 13.5113 9.27846 13.5113H3C2.44771 13.5113 2 13.0636 2 12.5113V7.28494Z"
fill="currentColor"
/>
</svg>
</template>

View File

@ -0,0 +1,16 @@
<template>
<svg
width="16"
height="16"
viewBox="0 0 16 16"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M6.17683 1C4.89138 1 3.81543 1.97482 3.68896 3.25405L3.19111 8.2899C3.16577 8.54615 3.0749 8.79156 2.92723 9.00252L1.98134 10.3538C1.51739 11.0166 1.99155 11.9273 2.80057 11.9273H7.53349V14.4999C7.53349 14.7761 7.75735 14.9999 8.03349 14.9999C8.30963 14.9999 8.53349 14.7761 8.53349 14.4999V11.9273H13.2016C14.0107 11.9273 14.4848 11.0166 14.0209 10.3538L13.068 8.99254C12.9236 8.78634 12.8335 8.54713 12.8059 8.29695L12.246 3.22567C12.1062 1.95882 11.0357 1 9.76113 1H6.17683ZM4.68411 3.35243C4.75999 2.5849 5.40556 2 6.17683 2H9.76113C10.5259 2 11.1682 2.57529 11.2521 3.3354L11.8119 8.40668C11.858 8.82365 12.0082 9.22233 12.2488 9.566L13.2016 10.9273H2.80057L3.74646 9.57598C3.99257 9.22439 4.14403 8.81536 4.18625 8.38828L4.68411 3.35243Z"
fill="currentColor"
/>
</svg>
</template>

View File

@ -0,0 +1,25 @@
<template>
<svg
width="15"
height="14"
viewBox="0 0 15 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M5.1783 0C3.89284 0 2.81689 0.974825 2.69042 2.25405L2.19257 7.2899C2.16724 7.54615 2.07636 7.79156 1.92869 8.00252L0.982801 9.35379C0.518857 10.0166 0.99301 10.9273 1.80203 10.9273H6.53506V13.4998C6.53506 13.776 6.75892 13.9998 7.03506 13.9998C7.31121 13.9998 7.53506 13.776 7.53506 13.4998V10.9273H12.2031C13.0121 10.9273 13.4863 10.0166 13.0223 9.35379L12.0695 7.99254C11.9251 7.78634 11.835 7.54713 11.8074 7.29695L11.2475 2.22567C11.1076 0.958818 10.0371 0 8.76259 0H5.1783ZM3.68557 2.35243C3.76145 1.5849 4.40702 1 5.1783 1H8.76259C9.52732 1 10.1696 1.57529 10.2535 2.3354L10.8134 7.40668C10.8594 7.82365 11.0097 8.22233 11.2502 8.566L12.2031 9.92725H1.80203L2.74793 8.57598C2.99404 8.22439 3.1455 7.81536 3.18772 7.38828L3.68557 2.35243Z"
fill="currentColor"
/>
<rect
x="0.792893"
width="2"
height="17"
rx="1"
transform="rotate(-45 0.792893 0)"
fill="currentColor"
stroke="white"
/>
</svg>
</template>

View File

@ -63,6 +63,9 @@
/>
</template>
<script setup>
import DuplicateIcon from '@/components/Icons/DuplicateIcon.vue'
import PinIcon from '@/components/Icons/PinIcon.vue'
import UnpinIcon from '@/components/Icons/UnpinIcon.vue'
import ViewModal from '@/components/Modals/ViewModal.vue'
import SortBy from '@/components/SortBy.vue'
import Filter from '@/components/Filter.vue'
@ -71,7 +74,7 @@ import { globalStore } from '@/stores/global'
import { viewsStore } from '@/stores/views'
import { useDebounceFn } from '@vueuse/core'
import { createResource, FeatherIcon, Dropdown, call } from 'frappe-ui'
import { computed, ref, defineModel, onMounted, watch } from 'vue'
import { computed, ref, defineModel, onMounted, watch, h } from 'vue'
import { useRouter, useRoute } from 'vue-router'
const props = defineProps({
@ -111,6 +114,7 @@ const view = ref({
columns: '',
rows: '',
default_columns: false,
pinned: false,
})
function getParams() {
@ -129,6 +133,7 @@ function getParams() {
columns: _view.columns,
rows: _view.rows,
default_columns: _view.row,
pinned: _view.pinned,
}
} else {
view.value = {
@ -139,6 +144,7 @@ function getParams() {
columns: '',
rows: '',
default_columns: true,
pinned: false,
}
}
@ -273,8 +279,8 @@ const viewActions = computed(() => {
hideLabel: true,
items: [
{
label: 'Duplicate View',
icon: 'copy',
label: 'Duplicate',
icon: () => h(DuplicateIcon, { class: 'h-4 w-4' }),
onClick: () => {
view.value.name = ''
view.value.label = view.value.label + ' New'
@ -286,6 +292,20 @@ const viewActions = computed(() => {
]
if (route.query.view) {
o[0].items.push({
label: view.value.pinned ? 'Unpin View' : 'Pin View',
icon: () =>
h(view.value.pinned ? UnpinIcon : PinIcon, { class: 'h-4 w-4' }),
onClick: () => {
call('crm.fcrm.doctype.crm_view_settings.crm_view_settings.pin', {
name: route.query.view,
value: !view.value.pinned,
}).then(() => {
view.value.pinned = !view.value.pinned
})
},
})
o.push({
group: 'Delete View',
hideLabel: true,