fix: pass list title and plural/singular label to listview

This commit is contained in:
Shariq Ansari 2023-07-27 12:08:08 +05:30
parent 1d768acf09
commit ce1c07ed34
5 changed files with 28 additions and 12 deletions

View File

@ -1,7 +1,7 @@
<template> <template>
<div id="header" class="flex justify-between items-center px-5 py-4"> <div id="header" class="flex justify-between items-center px-5 py-4">
<div class="left flex space-x-2"> <div class="left flex space-x-2">
<h1 class="font-semibold text-xl">{{ title }}s</h1> <h1 class="font-semibold text-xl">{{ list.title }}</h1>
</div> </div>
<div class="right flex space-x-2"> <div class="right flex space-x-2">
<Button variant="solid" label="Create"> <Button variant="solid" label="Create">
@ -161,8 +161,8 @@ import IndicatorIcon from './Icons/IndicatorIcon.vue'
import { reactive, ref, computed } from 'vue' import { reactive, ref, computed } from 'vue'
const props = defineProps({ const props = defineProps({
title: { list: {
type: String, type: Object,
required: true, required: true,
}, },
columns: { columns: {
@ -239,7 +239,7 @@ function getValue(value) {
let selections = reactive(new Set()) let selections = reactive(new Set())
let selectedText = computed(() => { let selectedText = computed(() => {
let title = selections.size === 1 ? props.title : `${props.title}s` let title = selections.size === 1 ? props.list.singular_label : props.list.plural_label
return `${selections.size} ${title} selected` return `${selections.size} ${title} selected`
}) })

View File

@ -1,5 +1,5 @@
<template> <template>
<ListView :title="title" :columns="columns" :rows="rows" row-key="name" /> <ListView :list="list_details" :columns="columns" :rows="rows" row-key="name" />
</template> </template>
<script setup> <script setup>
@ -7,7 +7,11 @@ import ListView from '../components/ListView.vue'
import { computed } from 'vue' import { computed } from 'vue'
import { createListResource } from 'frappe-ui' import { createListResource } from 'frappe-ui'
const title = 'Contact' const list_details = {
title: 'Contacts',
plural_label: 'Contacts',
singular_label: 'Contact',
}
const contacts = createListResource({ const contacts = createListResource({
type: 'list', type: 'list',

View File

@ -1,9 +1,13 @@
<template> <template>
<ListView :title="title"/> <ListView :list="list_details"/>
</template> </template>
<script setup> <script setup>
import ListView from '../components/ListView.vue'; import ListView from '../components/ListView.vue';
let title = 'Deals' const list_details = {
title: 'Deals',
plural_label: 'Deals',
singular_label: 'Deal',
}
</script> </script>

View File

@ -1,9 +1,13 @@
<template> <template>
<ListView :title="title"/> <ListView :list="list_details"/>
</template> </template>
<script setup> <script setup>
import ListView from '../components/ListView.vue'; import ListView from '../components/ListView.vue';
let title = 'Inbox' const list_details = {
title: 'Inbox',
plural_label: 'Emails',
singular_label: 'Email',
}
</script> </script>

View File

@ -1,5 +1,5 @@
<template> <template>
<ListView :title="title" :columns="columns" :rows="rows" row-key="name" /> <ListView :list="list_details" :columns="columns" :rows="rows" row-key="name" />
</template> </template>
<script setup> <script setup>
@ -8,7 +8,11 @@ import { computed } from 'vue'
import { createListResource } from 'frappe-ui' import { createListResource } from 'frappe-ui'
import { usersStore } from '../stores/users' import { usersStore } from '../stores/users'
const title = 'Lead' const list_details = {
title: 'Leads',
plural_label: 'Leads',
singular_label: 'Lead',
}
const { getUser } = usersStore() const { getUser } = usersStore()
const leads = createListResource({ const leads = createListResource({