fix: made notes grid view and removed list view
used dialog to show notes instead of new note page
This commit is contained in:
parent
0e48885521
commit
f729e7d530
@ -9,40 +9,74 @@
|
|||||||
</Button>
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
</LayoutHeader>
|
</LayoutHeader>
|
||||||
<div class="flex justify-between items-center px-5 pb-2.5 border-b">
|
<div class="border-b"></div>
|
||||||
<div class="flex items-center gap-2">
|
<div v-if="notes.data" class="grid grid-cols-4 gap-4 p-5">
|
||||||
<TabButtons
|
<div
|
||||||
v-model="currentView"
|
v-for="note in notes.data"
|
||||||
:buttons="[{ label: 'List' }, { label: 'Grid' }]"
|
class="flex flex-col justify-between gap-2 px-5 py-4 border rounded-lg h-52 shadow-sm hover:bg-gray-50 cursor-pointer"
|
||||||
class="w-max"
|
@click="openNoteModal(note)"
|
||||||
|
>
|
||||||
|
<div class="text-lg font-medium truncate">
|
||||||
|
{{ note.title }}
|
||||||
|
</div>
|
||||||
|
<div
|
||||||
|
class="flex-1 text-base leading-5 text-gray-700 overflow-hidden"
|
||||||
|
v-html="note.content"
|
||||||
/>
|
/>
|
||||||
</div>
|
<div class="flex items-center justify-between gap-2">
|
||||||
<div class="flex items-center gap-2">
|
<div class="flex items-center gap-2">
|
||||||
<Button label="Sort">
|
<UserAvatar :user="note.owner" size="xs" />
|
||||||
<template #prefix><SortIcon class="h-4" /></template>
|
<div class="text-sm text-gray-800">
|
||||||
</Button>
|
{{ note.owner }}
|
||||||
<Button label="Filter">
|
</div>
|
||||||
<template #prefix><FilterIcon class="h-4" /></template>
|
</div>
|
||||||
</Button>
|
<div class="text-sm text-gray-700">
|
||||||
<Button icon="more-horizontal" />
|
{{ timeAgo(note.modified) }}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ListView :list="list" :columns="columns" :rows="rows" row-key="name" />
|
<Dialog
|
||||||
|
v-model="showNoteModal"
|
||||||
|
:options="{ size: '4xl' }"
|
||||||
|
@close="updateNote"
|
||||||
|
>
|
||||||
|
<template #body-title><div></div></template>
|
||||||
|
<template #body-content>
|
||||||
|
<div
|
||||||
|
class="flex flex-col gap-2 px-20 mt-5 mb-10 min-h-[400px] max-h-[500px] overflow-auto"
|
||||||
|
>
|
||||||
|
<TextInput
|
||||||
|
type="text"
|
||||||
|
class="!text-[30px] !h-10 !font-semibold bg-white border-none hover:bg-white focus-visible:ring-0 focus:shadow-none"
|
||||||
|
v-model="currentNote.title"
|
||||||
|
/>
|
||||||
|
<TextEditor
|
||||||
|
editor-class="!prose-sm max-w-none p-2 overflow-auto focus:outline-none"
|
||||||
|
:bubbleMenu="true"
|
||||||
|
:content="currentNote.content"
|
||||||
|
@change="(val) => (currentNote.content = val)"
|
||||||
|
placeholder="Type something and press enter"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
</Dialog>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import ListView from '@/components/ListView.vue'
|
|
||||||
import LayoutHeader from '@/components/LayoutHeader.vue'
|
import LayoutHeader from '@/components/LayoutHeader.vue'
|
||||||
import Breadcrumbs from '@/components/Breadcrumbs.vue'
|
import Breadcrumbs from '@/components/Breadcrumbs.vue'
|
||||||
import SortIcon from '@/components/Icons/SortIcon.vue'
|
import UserAvatar from '@/components/UserAvatar.vue'
|
||||||
import FilterIcon from '@/components/Icons/FilterIcon.vue'
|
import { timeAgo } from '@/utils'
|
||||||
import { usersStore } from '@/stores/users'
|
import {
|
||||||
import { FeatherIcon, Button, createListResource, TabButtons } from 'frappe-ui'
|
FeatherIcon,
|
||||||
import { computed, ref } from 'vue'
|
Button,
|
||||||
|
createListResource,
|
||||||
const { getUser } = usersStore()
|
TextEditor,
|
||||||
|
TextInput,
|
||||||
const currentView = ref('List')
|
call,
|
||||||
|
} from 'frappe-ui'
|
||||||
|
import { ref } from 'vue'
|
||||||
|
|
||||||
const list = {
|
const list = {
|
||||||
title: 'Notes',
|
title: 'Notes',
|
||||||
@ -50,9 +84,14 @@ const list = {
|
|||||||
singular_label: 'Note',
|
singular_label: 'Note',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const showNoteModal = ref(false)
|
||||||
|
const currentNote = ref(null)
|
||||||
|
const oldNote = ref(null)
|
||||||
|
|
||||||
const notes = createListResource({
|
const notes = createListResource({
|
||||||
type: 'list',
|
type: 'list',
|
||||||
doctype: 'CRM Note',
|
doctype: 'CRM Note',
|
||||||
|
cache: 'Notes',
|
||||||
fields: ['name', 'title', 'content', 'owner', 'modified'],
|
fields: ['name', 'title', 'content', 'owner', 'modified'],
|
||||||
filters: {},
|
filters: {},
|
||||||
orderBy: 'modified desc',
|
orderBy: 'modified desc',
|
||||||
@ -60,42 +99,27 @@ const notes = createListResource({
|
|||||||
auto: true,
|
auto: true,
|
||||||
})
|
})
|
||||||
|
|
||||||
const columns = [
|
const openNoteModal = (note) => {
|
||||||
{
|
let noteCopy = { ...note }
|
||||||
label: 'Title',
|
oldNote.value = note
|
||||||
key: 'title',
|
currentNote.value = noteCopy
|
||||||
type: 'data',
|
showNoteModal.value = true
|
||||||
size: 'w-48',
|
}
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Content',
|
|
||||||
key: 'content',
|
|
||||||
type: 'html',
|
|
||||||
size: 'w-96',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Created by',
|
|
||||||
key: 'owner',
|
|
||||||
type: 'avatar',
|
|
||||||
size: 'w-36',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: 'Last modified',
|
|
||||||
key: 'modified',
|
|
||||||
type: 'pretty_date',
|
|
||||||
size: 'w-28',
|
|
||||||
},
|
|
||||||
]
|
|
||||||
|
|
||||||
const rows = computed(() => {
|
async function updateNote() {
|
||||||
return notes.data?.map((note) => {
|
if (
|
||||||
return {
|
currentNote.value.title === oldNote.value.title &&
|
||||||
name: note.name,
|
currentNote.value.content === oldNote.value.content
|
||||||
title: note.title,
|
) {
|
||||||
content: note.content,
|
return
|
||||||
owner: note.owner && getUser(note.owner),
|
}
|
||||||
modified: note.modified,
|
let d = await call('frappe.client.set_value', {
|
||||||
}
|
doctype: 'CRM Note',
|
||||||
|
name: currentNote.value.name,
|
||||||
|
fieldname: currentNote.value,
|
||||||
})
|
})
|
||||||
})
|
if (d.name) {
|
||||||
|
notes.reload()
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user