2
0
mirror of https://github.com/frappe/books.git synced 2025-02-02 20:18:26 +00:00

refactor: use slot shorthand

- more minor fixes
- remove redundant file
This commit is contained in:
18alantom 2022-02-10 13:12:43 +05:30
parent 1ff861ee56
commit 51c066e926
20 changed files with 144 additions and 162 deletions

View File

@ -1,4 +1,4 @@
<template v-slot:title> <template #title>
<a <a
class="cursor-pointer font-semibold flex items-center" class="cursor-pointer font-semibold flex items-center"
@click="$router.back()" @click="$router.back()"

View File

@ -4,7 +4,7 @@
{{ df.label }} {{ df.label }}
</div> </div>
<Popover placement="bottom-end"> <Popover placement="bottom-end">
<template v-slot:target="{ togglePopover }"> <template #target="{ togglePopover }">
<div <div
tabindex="0" tabindex="0"
:class="inputClasses" :class="inputClasses"
@ -25,7 +25,7 @@
</div> </div>
</div> </div>
</template> </template>
<template v-slot:content> <template #content>
<div class="text-sm py-3 px-2 text-center"> <div class="text-sm py-3 px-2 text-center">
<div> <div>
<Row class="border-none" :column-count="5" gap="0.5rem"> <Row class="border-none" :column-count="5" gap="0.5rem">

View File

@ -1,6 +1,6 @@
<template> <template>
<Popover @open="selectCurrentMonthYear"> <Popover @open="selectCurrentMonthYear">
<template v-slot:target="{ togglePopover, handleBlur }"> <template #target="{ togglePopover, handleBlur }">
<input <input
type="text" type="text"
:class="inputClass" :class="inputClass"
@ -11,7 +11,7 @@
@blur="handleBlur" @blur="handleBlur"
/> />
</template> </template>
<template v-slot:content="{ togglePopover }"> <template #content="{ togglePopover }">
<div class="text-left p-3 select-none"> <div class="text-left p-3 select-none">
<div class="flex items-center justify-between"> <div class="flex items-center justify-between">
<span class="font-medium text-blue-500 text-base"> <span class="font-medium text-blue-500 text-base">

View File

@ -4,7 +4,7 @@
:hide-arrow="true" :hide-arrow="true"
:placement="right ? 'bottom-end' : 'bottom-start'" :placement="right ? 'bottom-end' : 'bottom-start'"
> >
<template v-slot:target> <template #target>
<div class="h-full" v-on-outside-click="() => (isShown = false)"> <div class="h-full" v-on-outside-click="() => (isShown = false)">
<slot <slot
:toggleDropdown="toggleDropdown" :toggleDropdown="toggleDropdown"
@ -14,7 +14,7 @@
></slot> ></slot>
</div> </div>
</template> </template>
<template v-slot:content> <template #content>
<div class="bg-white rounded w-full min-w-40"> <div class="bg-white rounded w-full min-w-40">
<div class="p-1 max-h-64 overflow-auto text-sm"> <div class="p-1 max-h-64 overflow-auto text-sm">
<div v-if="isLoading" class="p-2 text-gray-600 italic"> <div v-if="isLoading" class="p-2 text-gray-600 italic">

View File

@ -1,22 +0,0 @@
<template>
<Dropdown v-bind="$attrs">
<template v-slot="{ toggleDropdown }">
<div @click="toggleDropdown()">
<slot></slot>
</div>
</template>
</Dropdown>
</template>
<script>
import Dropdown from './Dropdown';
export default {
name: 'DropdownWithAction',
components: {
Dropdown
}
};
</script>
<style></style>

View File

@ -1,6 +1,6 @@
<template> <template>
<Popover @close="emitFilterChange" placement="bottom-end"> <Popover @close="emitFilterChange" placement="bottom-end">
<template v-slot:target="{ togglePopover }"> <template #target="{ togglePopover }">
<Button :icon="true" @click="togglePopover()"> <Button :icon="true" @click="togglePopover()">
<span class="flex items-center"> <span class="flex items-center">
<Icon name="filter" size="12" class="stroke-current text-gray-800" /> <Icon name="filter" size="12" class="stroke-current text-gray-800" />
@ -15,7 +15,7 @@
</span> </span>
</Button> </Button>
</template> </template>
<template v-slot:content> <template #content>
<div> <div>
<div class="p-3"> <div class="p-3">
<template v-if="filters.length"> <template v-if="filters.length">

View File

@ -1,20 +1,19 @@
<template> <template>
<div class="flex flex-col overflow-y-hidden"> <div class="flex flex-col overflow-y-hidden">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<h1 class="text-2xl font-bold"> <h1 class="text-2xl font-bold">
{{ t('Chart of Accounts') }} {{ t('Chart of Accounts') }}
</h1> </h1>
</template> </template>
<template v-slot:actions> <template #actions>
<SearchBar class="ml-2" /> <SearchBar class="ml-2" />
</template> </template>
</PageHeader> </PageHeader>
<div class="flex-1 flex px-8 overflow-y-auto"> <div class="flex-1 flex px-8 overflow-y-auto">
<div class="flex-1" v-if="root"> <div class="flex-1" v-if="root">
<div v-for="account in allAccounts" :key="account.name">
<div <div
v-for="account in allAccounts"
:key="account.name"
class=" class="
mt-2 mt-2
px-4 px-4
@ -39,7 +38,10 @@
> >
{{ account.name }} {{ account.name }}
</div> </div>
<div v-if="account.isGroup" class="ml-6 hidden group-hover:block"> <div
v-if="account.isGroup"
class="ml-6 hidden group-hover:block"
>
<button <button
class=" class="
text-xs text-gray-800 text-xs text-gray-800
@ -124,6 +126,7 @@
</div> </div>
</div> </div>
</div> </div>
</div>
</template> </template>
<script> <script>
import frappe from 'frappe'; import frappe from 'frappe';

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="flex flex-col"> <div class="flex flex-col">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<h1 class="text-2xl font-bold">{{ t('Dashboard') }}</h1> <h1 class="text-2xl font-bold">{{ t('Dashboard') }}</h1>
</template> </template>
<template v-slot:actions> <template #actions>
<SearchBar class="ml-2" /> <SearchBar class="ml-2" />
</template> </template>
</PageHeader> </PageHeader>

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="flex flex-col h-full"> <div class="flex flex-col h-full">
<SectionHeader> <SectionHeader>
<template v-slot:title>{{ t('Top Expenses') }}</template> <template #title>{{ t('Top Expenses') }}</template>
<template v-slot:action> <template #action>
<PeriodSelector :value="period" @change="(value) => (period = value)" /> <PeriodSelector :value="period" @change="(value) => (period = value)" />
</template> </template>
</SectionHeader> </SectionHeader>

View File

@ -1,8 +1,8 @@
<template> <template>
<div class="flex flex-col h-full"> <div class="flex flex-col h-full">
<SectionHeader> <SectionHeader>
<template v-slot:title>{{ t('Profit and Loss') }}</template> <template #title>{{ t('Profit and Loss') }}</template>
<template v-slot:action> <template #action>
<PeriodSelector <PeriodSelector
:value="period" :value="period"
:options="['This Year', 'This Quarter']" :options="['This Year', 'This Quarter']"

View File

@ -6,8 +6,8 @@
:key="invoice.title" :key="invoice.title"
> >
<SectionHeader> <SectionHeader>
<template v-slot:title>{{ invoice.title }}</template> <template #title>{{ invoice.title }}</template>
<template v-slot:action> <template #action>
<PeriodSelector <PeriodSelector
v-if="invoice.hasData" v-if="invoice.hasData"
:value="$data[invoice.periodKey]" :value="$data[invoice.periodKey]"

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="flex flex-col overflow-y-hidden"> <div class="flex flex-col overflow-y-hidden">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<h1 class="text-2xl font-bold"> <h1 class="text-2xl font-bold">
{{ t('Setup your workspace') }} {{ t('Setup your workspace') }}
</h1> </h1>

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="flex flex-col" v-if="doc"> <div class="flex flex-col" v-if="doc">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<BackLink /> <BackLink />
</template> </template>
<template v-slot:actions> <template #actions>
<StatusBadge :status="status" /> <StatusBadge :status="status" />
<Button <Button
v-if="doc.submitted" v-if="doc.submitted"
@ -271,7 +271,7 @@ export default {
let query = this.$route.query; let query = this.$route.query;
if (query.values && query.doctype === this.doctype) { if (query.values && query.doctype === this.doctype) {
this.doc.set(this.$router.currentRoute.query.values); this.doc.set(this.$router.currentRoute.value.query.values);
} }
this.status = getInvoiceStatus(this.doc); this.status = getInvoiceStatus(this.doc);
}, },

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="flex flex-col"> <div class="flex flex-col">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<BackLink /> <BackLink />
</template> </template>
<template v-slot:actions v-if="doc"> <template #actions v-if="doc">
<StatusBadge :status="status" /> <StatusBadge :status="status" />
<DropdownWithActions class="ml-2" :actions="actions" /> <DropdownWithActions class="ml-2" :actions="actions" />
<Button <Button

View File

@ -1,12 +1,12 @@
<template> <template>
<div class="flex flex-col"> <div class="flex flex-col">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<h1 class="text-2xl font-bold" v-if="title"> <h1 class="text-2xl font-bold" v-if="title">
{{ title }} {{ title }}
</h1> </h1>
</template> </template>
<template v-slot:actions> <template #actions>
<FilterDropdown <FilterDropdown
ref="filterDropdown" ref="filterDropdown"
@change="applyFilter" @change="applyFilter"

View File

@ -2,10 +2,10 @@
<div class="flex"> <div class="flex">
<div class="flex flex-col flex-1"> <div class="flex flex-col flex-1">
<PageHeader class="bg-white z-10"> <PageHeader class="bg-white z-10">
<template v-slot:title> <template #title>
<BackLink /> <BackLink />
</template> </template>
<template v-slot:actions> <template #actions>
<Button <Button
class="text-gray-900 text-xs ml-2" class="text-gray-900 text-xs ml-2"
@click="showCustomiser = !showCustomiser" @click="showCustomiser = !showCustomiser"
@ -54,7 +54,6 @@
import frappe from 'frappe'; import frappe from 'frappe';
import PageHeader from '@/components/PageHeader'; import PageHeader from '@/components/PageHeader';
import SearchBar from '@/components/SearchBar'; import SearchBar from '@/components/SearchBar';
import DropdownWithAction from '@/components/DropdownWithAction';
import Button from '@/components/Button'; import Button from '@/components/Button';
import BackLink from '@/components/BackLink'; import BackLink from '@/components/BackLink';
import TwoColumnForm from '@/components/TwoColumnForm'; import TwoColumnForm from '@/components/TwoColumnForm';
@ -68,7 +67,6 @@ export default {
components: { components: {
PageHeader, PageHeader,
SearchBar, SearchBar,
DropdownWithAction,
Button, Button,
BackLink, BackLink,
TwoColumnForm, TwoColumnForm,

View File

@ -1,10 +1,10 @@
<template> <template>
<div class="flex flex-col max-w-full"> <div class="flex flex-col max-w-full">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<h1 class="text-2xl font-bold">{{ report.title }}</h1> <h1 class="text-2xl font-bold">{{ report.title }}</h1>
</template> </template>
<template v-slot:actions> <template #actions>
<DropdownWithActions <DropdownWithActions
v-for="group of actionGroups" v-for="group of actionGroups"
@click="group.action(reportData, filters)" @click="group.action(reportData, filters)"

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="flex flex-col overflow-hidden"> <div class="flex flex-col overflow-hidden">
<PageHeader> <PageHeader>
<template v-slot:title> <template #title>
<h1 class="text-2xl font-bold"> <h1 class="text-2xl font-bold">
{{ t('Settings') }} {{ t('Settings') }}
</h1> </h1>
@ -62,7 +62,7 @@ import PageHeader from '@/components/PageHeader';
import StatusBadge from '@/components/StatusBadge'; import StatusBadge from '@/components/StatusBadge';
import { callInitializeMoneyMaker } from '../../utils'; import { callInitializeMoneyMaker } from '../../utils';
import { showToast } from '../../utils'; import { showToast } from '../../utils';
import { h } from 'vue'; import { h, markRaw } from 'vue';
export default { export default {
name: 'Settings', name: 'Settings',
@ -82,17 +82,17 @@ export default {
{ {
label: t('Invoice'), label: t('Invoice'),
icon: 'invoice', icon: 'invoice',
component: TabInvoice, component: markRaw(TabInvoice),
}, },
{ {
label: t('General'), label: t('General'),
icon: 'general', icon: 'general',
component: TabGeneral, component: markRaw(TabGeneral),
}, },
{ {
label: t('System'), label: t('System'),
icon: 'system', icon: 'system',
component: TabSystem, component: markRaw(TabSystem),
}, },
], ],
}; };

View File

@ -29,7 +29,7 @@
:autofocus="true" :autofocus="true"
/> />
<Popover placement="auto" :show-popup="Boolean(emailError)"> <Popover placement="auto" :show-popup="Boolean(emailError)">
<template v-slot:target> <template #target>
<FormControl <FormControl
:df="meta.getField('email')" :df="meta.getField('email')"
:value="doc.email" :value="doc.email"
@ -41,7 +41,7 @@
" "
/> />
</template> </template>
<template v-slot:content> <template #content>
<div class="p-2 text-sm"> <div class="p-2 text-sm">
{{ emailError }} {{ emailError }}
</div> </div>

View File

@ -147,7 +147,7 @@ export function openQuickEdit({
showFields, showFields,
defaults = {}, defaults = {},
}) { }) {
let currentRoute = router.currentRoute; let currentRoute = router.currentRoute.value;
let query = currentRoute.query; let query = currentRoute.query;
let method = 'push'; let method = 'push';
if (query.edit && query.doctype === doctype) { if (query.edit && query.doctype === doctype) {
@ -271,7 +271,10 @@ export function getInvoiceStatus(doc) {
export function routeTo(route) { export function routeTo(route) {
let routeOptions = route; let routeOptions = route;
if (typeof route === 'string' && route === router.currentRoute.fullPath) { if (
typeof route === 'string' &&
route === router.currentRoute.value.fullPath
) {
return; return;
} }