Merge pull request #35 from shariquerik/reset-to-default
This commit is contained in:
commit
04160126c1
@ -57,10 +57,13 @@ def get_list_data(doctype: str, filters: dict, order_by: str):
|
||||
]
|
||||
rows = ["name"]
|
||||
|
||||
is_default = True
|
||||
|
||||
if frappe.db.exists("CRM List View Settings", doctype):
|
||||
list_view_settings = frappe.get_doc("CRM List View Settings", doctype)
|
||||
columns = frappe.parse_json(list_view_settings.columns)
|
||||
rows = frappe.parse_json(list_view_settings.rows)
|
||||
is_default = False
|
||||
else:
|
||||
list = get_controller(doctype)
|
||||
|
||||
@ -113,7 +116,13 @@ def get_list_data(doctype: str, filters: dict, order_by: str):
|
||||
if field not in fields:
|
||||
fields.append(field)
|
||||
|
||||
return {'data': data, 'columns': columns, 'rows': rows, 'fields': fields}
|
||||
return {
|
||||
"data": data,
|
||||
"columns": columns,
|
||||
"rows": rows,
|
||||
"fields": fields,
|
||||
"is_default": is_default,
|
||||
}
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
|
||||
@ -43,3 +43,8 @@ def sync_default_list_rows(doctype):
|
||||
rows = list.default_list_data().get("rows")
|
||||
|
||||
return rows
|
||||
|
||||
@frappe.whitelist()
|
||||
def reset_to_default(doctype):
|
||||
if frappe.db.exists("CRM List View Settings", doctype):
|
||||
frappe.delete_doc("CRM List View Settings", doctype)
|
||||
22
frontend/src/components/Icons/ReloadIcon.vue
Normal file
22
frontend/src/components/Icons/ReloadIcon.vue
Normal file
@ -0,0 +1,22 @@
|
||||
<template>
|
||||
<svg
|
||||
width="16"
|
||||
height="16"
|
||||
viewBox="0 0 16 16"
|
||||
fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
>
|
||||
<path
|
||||
d="M2.35619 8.42909C2.35644 9.77009 2.84031 11.066 3.719 12.079C4.5977 13.092 5.81226 13.7542 7.13977 13.9439C8.46729 14.1336 9.8187 13.8382 10.946 13.1119C12.0732 12.3856 12.9008 11.2771 13.2766 9.98982C13.6525 8.70258 13.5515 7.32295 12.9922 6.10414C12.4329 4.88534 11.4528 3.90914 10.2318 3.35469C9.0108 2.80025 7.63079 2.70476 6.34504 3.08576C5.0593 3.46675 3.95409 4.29867 3.23226 5.42883"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
<path
|
||||
d="M3.21297 2V5.42886H6.64183"
|
||||
stroke="currentColor"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</template>
|
||||
@ -45,7 +45,7 @@
|
||||
</div>
|
||||
</template>
|
||||
</Draggable>
|
||||
<div class="mt-1.5 border-t pt-1.5">
|
||||
<div class="mt-1.5 flex flex-col gap-1 border-t pt-1.5">
|
||||
<Autocomplete
|
||||
value=""
|
||||
:options="fields"
|
||||
@ -64,6 +64,17 @@
|
||||
</Button>
|
||||
</template>
|
||||
</Autocomplete>
|
||||
<Button
|
||||
v-if="!is_default"
|
||||
class="w-full !justify-start !text-gray-600"
|
||||
variant="ghost"
|
||||
@click="resetToDefault"
|
||||
label="Reset to Default"
|
||||
>
|
||||
<template #prefix>
|
||||
<ReloadIcon class="h-4" />
|
||||
</template>
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
<div v-else>
|
||||
@ -115,6 +126,7 @@
|
||||
import SettingsIcon from '@/components/Icons/SettingsIcon.vue'
|
||||
import EditIcon from '@/components/Icons/EditIcon.vue'
|
||||
import DragIcon from '@/components/Icons/DragIcon.vue'
|
||||
import ReloadIcon from '@/components/Icons/ReloadIcon.vue'
|
||||
import NestedPopover from '@/components/NestedPopover.vue'
|
||||
import Autocomplete from '@/components/frappe-ui/Autocomplete.vue'
|
||||
import Draggable from 'vuedraggable'
|
||||
@ -137,6 +149,13 @@ const column = ref({
|
||||
width: '10rem',
|
||||
})
|
||||
|
||||
const is_default = computed({
|
||||
get: () => list.value?.data?.is_default,
|
||||
set: (val) => {
|
||||
list.value.data.is_default = val
|
||||
},
|
||||
})
|
||||
|
||||
const columns = computed({
|
||||
get: () => list.value?.data?.columns,
|
||||
set: (val) => {
|
||||
@ -207,6 +226,7 @@ function cancelUpdate() {
|
||||
}
|
||||
|
||||
async function updateColumnDetails() {
|
||||
is_default.value = false
|
||||
await call(
|
||||
'crm.fcrm.doctype.crm_list_view_settings.crm_list_view_settings.update',
|
||||
{
|
||||
@ -216,4 +236,14 @@ async function updateColumnDetails() {
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
async function resetToDefault() {
|
||||
await call(
|
||||
'crm.fcrm.doctype.crm_list_view_settings.crm_list_view_settings.reset_to_default',
|
||||
{
|
||||
doctype: props.doctype,
|
||||
}
|
||||
)
|
||||
list.value.reload()
|
||||
}
|
||||
</script>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user