2
0
mirror of https://github.com/frappe/books.git synced 2024-09-19 19:19:02 +00:00

refactor: add FormHeader

- add custom vue type shims
This commit is contained in:
18alantom 2022-10-17 12:37:38 +05:30
parent 2efc2908fc
commit ece213d69f
5 changed files with 56 additions and 42 deletions

View File

@ -7,8 +7,8 @@ import {
} from '../../utils/translationHelpers';
import { ValueError } from './errors';
type TranslationArgs = boolean | number | string;
type TranslationLiteral = TemplateStringsArray | TranslationArgs;
export type TranslationArgs = boolean | number | string;
export type TranslationLiteral = TemplateStringsArray | TranslationArgs;
class TranslationString {
args: TranslationLiteral[];

View File

@ -0,0 +1,28 @@
<template>
<div
class="
px-4
text-xl
font-semibold
flex
justify-between
h-row-large
items-center
"
>
<h1>{{ formTitle }}</h1>
<p class="text-gray-600">
{{ formSubTitle }}
</p>
</div>
</template>
<script lang="ts">
import { defineComponent } from 'vue';
export default defineComponent({
props: {
formTitle: { type: String, default: '' },
formSubTitle: { type: String, default: '' },
},
});
</script>

View File

@ -45,28 +45,14 @@
<!-- Invoice Form -->
<template #body v-if="doc">
<div
class="
px-4
text-xl
font-semibold
flex
justify-between
h-row-large
items-center
<FormHeader
:form-title="doc.notInserted ? t`New Entry` : doc.name"
:form-sub-title="
doc.schemaName === 'SalesInvoice'
? t`Sales Invoice`
: t`Purchase Invoice`
"
>
<h1>
{{ doc.notInserted ? t`New Entry` : doc.name }}
</h1>
<p class="text-gray-600">
{{
doc.schemaName === 'SalesInvoice'
? t`Sales Invoice`
: t`Purchase Invoice`
}}
</p>
</div>
/>
<hr />
<div>
@ -298,6 +284,7 @@ import FormControl from 'src/components/Controls/FormControl.vue';
import Table from 'src/components/Controls/Table.vue';
import DropdownWithActions from 'src/components/DropdownWithActions.vue';
import FormContainer from 'src/components/FormContainer.vue';
import FormHeader from 'src/components/FormHeader.vue';
import StatusBadge from 'src/components/StatusBadge.vue';
import { fyo } from 'src/initFyo';
import { docsPathMap } from 'src/utils/misc';
@ -323,6 +310,7 @@ export default {
FormContainer,
QuickEditForm,
ExchangeRate,
FormHeader,
},
provide() {
return {

View File

@ -24,24 +24,10 @@
<!-- Journal Entry Form -->
<template #body v-if="doc">
<div
class="
px-4
text-xl
font-semibold
flex
justify-between
h-row-large
items-center
"
>
<h1>
{{ doc.notInserted ? t`New Entry` : doc.name }}
</h1>
<p class="text-gray-600">
{{ t`Journal Entry` }}
</p>
</div>
<FormHeader
:form-title="doc.notInserted ? t`New Entry` : doc.name"
:form-sub-title="t`Journal Entry`"
/>
<hr />
<div>
<div class="m-4 grid grid-cols-3 gap-y-4 gap-x-4">
@ -148,6 +134,7 @@ import FormControl from 'src/components/Controls/FormControl.vue';
import Table from 'src/components/Controls/Table.vue';
import DropdownWithActions from 'src/components/DropdownWithActions.vue';
import FormContainer from 'src/components/FormContainer.vue';
import FormHeader from 'src/components/FormHeader.vue';
import StatusBadge from 'src/components/StatusBadge.vue';
import { fyo } from 'src/initFyo';
import { docsPathMap } from 'src/utils/misc';
@ -169,7 +156,8 @@ export default {
FormControl,
Table,
FormContainer,
},
FormHeader
},
provide() {
return {
schemaName: this.schemaName,

10
src/shims-vue-custom.d.ts vendored Normal file
View File

@ -0,0 +1,10 @@
import { Fyo } from 'fyo';
import { TranslationLiteral } from 'fyo/utils/translation';
declare module 'vue' {
interface ComponentCustomProperties {
t: (...args: TranslationLiteral[]) => string;
fyo: Fyo;
platform: string;
}
}