feat: added view controls on notes view
This commit is contained in:
parent
d4789e8e3c
commit
684ab8871e
@ -6,4 +6,14 @@ from frappe.model.document import Document
|
|||||||
|
|
||||||
|
|
||||||
class CRMNote(Document):
|
class CRMNote(Document):
|
||||||
pass
|
@staticmethod
|
||||||
|
def default_list_data():
|
||||||
|
rows = [
|
||||||
|
"name",
|
||||||
|
"title",
|
||||||
|
"content",
|
||||||
|
"reference_doctype",
|
||||||
|
"reference_docname",
|
||||||
|
"modified",
|
||||||
|
]
|
||||||
|
return {'columns': [], 'rows': rows}
|
||||||
|
|||||||
@ -41,6 +41,7 @@
|
|||||||
/>
|
/>
|
||||||
<SortBy v-model="list" :doctype="doctype" @update="updateSort" />
|
<SortBy v-model="list" :doctype="doctype" @update="updateSort" />
|
||||||
<ColumnSettings
|
<ColumnSettings
|
||||||
|
v-if="!options.hideColumnsButton"
|
||||||
v-model="list"
|
v-model="list"
|
||||||
:doctype="doctype"
|
:doctype="doctype"
|
||||||
@update="(isDefault) => updateColumns(isDefault)"
|
@update="(isDefault) => updateColumns(isDefault)"
|
||||||
@ -97,6 +98,13 @@ const props = defineProps({
|
|||||||
type: Object,
|
type: Object,
|
||||||
default: {},
|
default: {},
|
||||||
},
|
},
|
||||||
|
options: {
|
||||||
|
type: Object,
|
||||||
|
default: {
|
||||||
|
hideColumnsButton: false,
|
||||||
|
defaultViewName: '',
|
||||||
|
},
|
||||||
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const { $dialog } = globalStore()
|
const { $dialog } = globalStore()
|
||||||
@ -117,7 +125,7 @@ const showViewModal = ref(false)
|
|||||||
const currentView = computed(() => {
|
const currentView = computed(() => {
|
||||||
let _view = getView(route.query.view)
|
let _view = getView(route.query.view)
|
||||||
return {
|
return {
|
||||||
label: _view?.label || 'List View',
|
label: _view?.label || props.options?.defaultViewName || 'List View',
|
||||||
icon: _view?.icon || 'list',
|
icon: _view?.icon || 'list',
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@ -232,7 +240,7 @@ function reload() {
|
|||||||
|
|
||||||
const defaultViews = [
|
const defaultViews = [
|
||||||
{
|
{
|
||||||
label: 'List View',
|
label: props.options?.defaultViewName || 'List View',
|
||||||
icon: 'list',
|
icon: 'list',
|
||||||
onClick() {
|
onClick() {
|
||||||
viewUpdated.value = false
|
viewUpdated.value = false
|
||||||
|
|||||||
@ -9,12 +9,21 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</LayoutHeader>
|
</LayoutHeader>
|
||||||
|
<ViewControls
|
||||||
|
v-model="notes"
|
||||||
|
v-model:loadMore="loadMore"
|
||||||
|
doctype="CRM Note"
|
||||||
|
:options="{
|
||||||
|
hideColumnsButton: true,
|
||||||
|
defaultViewName: 'Notes View',
|
||||||
|
}"
|
||||||
|
/>
|
||||||
<div
|
<div
|
||||||
v-if="notes.data?.length"
|
v-if="notes.data?.data?.length"
|
||||||
class="grid grid-cols-4 gap-4 overflow-y-auto p-5"
|
class="grid grid-cols-4 gap-4 overflow-y-auto px-5 pb-3"
|
||||||
>
|
>
|
||||||
<div
|
<div
|
||||||
v-for="note in notes.data"
|
v-for="note in notes.data.data"
|
||||||
class="group flex h-56 cursor-pointer flex-col justify-between gap-2 rounded-lg border px-5 py-4 shadow-sm hover:bg-gray-50"
|
class="group flex h-56 cursor-pointer flex-col justify-between gap-2 rounded-lg border px-5 py-4 shadow-sm hover:bg-gray-50"
|
||||||
@click="editNote(note)"
|
@click="editNote(note)"
|
||||||
>
|
>
|
||||||
@ -61,6 +70,16 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<ListFooter
|
||||||
|
v-if="notes.data?.data?.length"
|
||||||
|
class="border-t px-5 py-2"
|
||||||
|
v-model="notes.data.page_length_count"
|
||||||
|
:options="{
|
||||||
|
rowCount: notes.data.row_count,
|
||||||
|
totalCount: notes.data.total_count,
|
||||||
|
}"
|
||||||
|
@loadMore="() => loadMore++"
|
||||||
|
/>
|
||||||
<div v-else class="flex h-full items-center justify-center">
|
<div v-else class="flex h-full items-center justify-center">
|
||||||
<div
|
<div
|
||||||
class="flex flex-col items-center gap-3 text-xl font-medium text-gray-500"
|
class="flex flex-col items-center gap-3 text-xl font-medium text-gray-500"
|
||||||
@ -84,14 +103,15 @@ import LayoutHeader from '@/components/LayoutHeader.vue'
|
|||||||
import UserAvatar from '@/components/UserAvatar.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
import NoteIcon from '@/components/Icons/NoteIcon.vue'
|
import NoteIcon from '@/components/Icons/NoteIcon.vue'
|
||||||
import NoteModal from '@/components/Modals/NoteModal.vue'
|
import NoteModal from '@/components/Modals/NoteModal.vue'
|
||||||
|
import ViewControls from '@/components/ViewControls.vue'
|
||||||
import { timeAgo, dateFormat, dateTooltipFormat } from '@/utils'
|
import { timeAgo, dateFormat, dateTooltipFormat } from '@/utils'
|
||||||
import {
|
import {
|
||||||
createListResource,
|
|
||||||
TextEditor,
|
TextEditor,
|
||||||
call,
|
call,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
Tooltip,
|
Tooltip,
|
||||||
Breadcrumbs,
|
Breadcrumbs,
|
||||||
|
ListFooter,
|
||||||
} from 'frappe-ui'
|
} from 'frappe-ui'
|
||||||
import { ref } from 'vue'
|
import { ref } from 'vue'
|
||||||
import { usersStore } from '@/stores/users'
|
import { usersStore } from '@/stores/users'
|
||||||
@ -109,16 +129,8 @@ const breadcrumbs = [{ label: list.title, route: { name: 'Notes' } }]
|
|||||||
const showNoteModal = ref(false)
|
const showNoteModal = ref(false)
|
||||||
const currentNote = ref(null)
|
const currentNote = ref(null)
|
||||||
|
|
||||||
const notes = createListResource({
|
const notes = ref({})
|
||||||
type: 'list',
|
const loadMore = ref(1)
|
||||||
doctype: 'CRM Note',
|
|
||||||
cache: 'Notes',
|
|
||||||
fields: ['name', 'title', 'content', 'owner', 'modified'],
|
|
||||||
filters: {},
|
|
||||||
orderBy: 'modified desc',
|
|
||||||
pageLength: 20,
|
|
||||||
auto: true,
|
|
||||||
})
|
|
||||||
|
|
||||||
function createNote() {
|
function createNote() {
|
||||||
currentNote.value = {
|
currentNote.value = {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user