2
0
mirror of https://github.com/frappe/books.git synced 2025-01-03 15:17:30 +00:00

incr: rebase master

- clearout PrintView
- move doc status and barcode to the left
- fix color field display
This commit is contained in:
18alantom 2023-03-06 11:56:54 +05:30
parent 44f172316f
commit be999269e2
9 changed files with 65 additions and 73 deletions

View File

@ -19,7 +19,7 @@ export class PrintTemplate extends Doc {
static getListViewSettings(): ListViewSettings {
return {
formRoute: ({ name }) => `/template-builder/${name}`,
formRoute: (name) => `/template-builder/${name}`,
columns: ['name', 'type', 'isCustom'],
};
}

View File

@ -44,6 +44,7 @@
:placeholder="t`Custom Hex`"
:class="[inputClasses, containerClasses]"
:value="value"
style="padding: 0"
@change="(e) => setColorValue(e.target.value)"
/>
</div>

View File

@ -3,6 +3,9 @@
<div class="flex flex-1 flex-col">
<!-- Page Header (Title, Buttons, etc) -->
<PageHeader :title="title" :border="false" :searchborder="searchborder">
<template #left>
<slot name="header-left" />
</template>
<slot name="header" />
</PageHeader>

View File

@ -16,6 +16,9 @@
<h1 class="text-xl font-semibold select-none" v-if="title">
{{ title }}
</h1>
<div class="flex items-stretch window-no-drag gap-2">
<slot name="left" />
</div>
<div
class="flex items-stretch window-no-drag gap-2 ms-auto"
:class="platform === 'Mac' && languageDirection === 'rtl' ? 'me-18' : ''"
@ -59,7 +62,7 @@ export default {
opacity: 0;
width: 0px;
margin-right: 0px;
border-eight-width: 0px;
border-right-width: 0px;
}
.spacer-enter-to,
@ -67,7 +70,7 @@ export default {
opacity: 1;
width: var(--w-trafficlights);
margin-right: 1rem;
border-eight-width: 1px;
border-right-width: 1px;
}
.spacer-enter-active,

View File

@ -1,7 +1,9 @@
<template>
<FormContainer>
<template #header-left v-if="hasDoc">
<StatusBadge :status="status" class="h-8" />
</template>
<template #header v-if="hasDoc">
<StatusBadge :status="status" />
<DropdownWithActions
v-for="group of groupedActions"
:key="group.label"

View File

@ -1,8 +1,15 @@
<template>
<FormContainer>
<!-- Page Header (Title, Buttons, etc) -->
<template #header-left v-if="doc">
<StatusBadge :status="status" class="h-8" />
<Barcode
class="h-8"
v-if="doc.canEdit && fyo.singles.InventorySettings?.enableBarcodes"
@item-selected="(name) => doc.addItem(name)"
/>
</template>
<template #header v-if="doc">
<StatusBadge :status="status" />
<ExchangeRate
v-if="doc.isMultiCurrency"
:disabled="doc?.isSubmitted || doc?.isCancelled"
@ -13,10 +20,6 @@
async (exchangeRate) => await doc.set('exchangeRate', exchangeRate)
"
/>
<Barcode
v-if="doc.canEdit && fyo.singles.InventorySettings?.enableBarcodes"
@item-selected="(name) => doc.addItem(name)"
/>
<Button
v-if="!doc.isCancelled && !doc.dirty"
:icon="true"

View File

@ -2,89 +2,56 @@
<div class="flex">
<div class="flex flex-col flex-1 bg-gray-25">
<PageHeader class="z-10" :border="false">
<Button
class="text-gray-900 text-xs"
@click="showCustomiser = !showCustomiser"
>
{{ t`Customise` }}
<Button class="text-xs" @click="openPrintSettings">
{{ t`Settings` }}
</Button>
<Button class="text-gray-900 text-xs" @click="makePDF">
<Button class="text-xs" type="primary" @click="makePDF">
{{ t`Save as PDF` }}
</Button>
</PageHeader>
<!-- Printview Preview -->
<div
v-if="doc && printSettings"
class="flex justify-center flex-1 overflow-auto relative"
>
<div v-if="doc" class="flex justify-center flex-1 overflow-auto relative">
<div
class="h-full shadow mb-4 absolute bg-white"
style="
width: 21cm;
height: 29.7cm;
transform: scale(0.65) translateY(-300px);
"
ref="printContainer"
>
<component
class="flex-1"
:is="printTemplate"
v-bind="{ doc, printSettings }"
/>
</div>
></div>
</div>
</div>
<!-- Printview Customizer -->
<Transition name="quickedit">
<div class="border-s w-quick-edit" v-if="showCustomiser">
<div
class="px-4 flex items-center justify-between h-row-largest border-b"
>
<h2 class="font-semibold">{{ t`Customise` }}</h2>
<Button :icon="true" @click="showCustomiser = false">
<feather-icon name="x" class="w-4 h-4" />
</Button>
</div>
<TwoColumnForm
:doc="printSettings"
:autosave="true"
class="border-none"
/>
</div>
</Transition>
</div>
</template>
<script>
<script lang="ts">
import { Doc } from 'fyo/model/doc';
import { Verb } from 'fyo/telemetry/types';
import { ModelNameEnum } from 'models/types';
import Button from 'src/components/Button.vue';
import PageHeader from 'src/components/PageHeader.vue';
import TwoColumnForm from 'src/components/TwoColumnForm.vue';
import { fyo } from 'src/initFyo';
import { makePDF } from 'src/utils/ipcCalls';
import { getPathAndMakePDF } from 'src/utils/printTemplates';
import { openSettings } from 'src/utils/ui';
import { defineComponent } from 'vue';
export default {
export default defineComponent({
name: 'PrintView',
props: { schemaName: String, name: String },
props: {
schemaName: { type: String, required: true },
name: { type: String, required: true },
},
components: {
PageHeader,
Button,
TwoColumnForm,
},
data() {
return {
doc: null,
showCustomiser: false,
printSettings: null,
};
} as { doc: null | Doc };
},
async mounted() {
this.doc = await fyo.doc.getDoc(this.schemaName, this.name);
this.printSettings = await fyo.doc.getDoc('PrintSettings');
if (fyo.store.isDevelopment) {
// @ts-ignore
window.pv = this;
}
},
@ -94,11 +61,15 @@ export default {
},
},
methods: {
async openPrintSettings() {
await openSettings(ModelNameEnum.PrintSettings);
},
async makePDF() {
// @ts-ignore
const innerHTML = this.$refs.printContainer.innerHTML;
await getPathAndMakePDF(this.name, innerHTML);
fyo.telemetry.log(Verb.Exported, 'SalesInvoice', { extension: 'pdf' });
},
},
};
});
</script>

View File

@ -1,5 +1,4 @@
import { ModelNameEnum } from 'models/types';
import TemplateBuilder from 'src/pages/TemplateBuilder/TemplateBuilder.vue';
import ChartOfAccounts from 'src/pages/ChartOfAccounts.vue';
import CommonForm from 'src/pages/CommonForm/CommonForm.vue';
import Dashboard from 'src/pages/Dashboard/Dashboard.vue';
@ -11,12 +10,8 @@ import PrintView from 'src/pages/PrintView/PrintView.vue';
import QuickEditForm from 'src/pages/QuickEditForm.vue';
import Report from 'src/pages/Report.vue';
import Settings from 'src/pages/Settings/Settings.vue';
import {
createRouter,
createWebHistory,
RouteLocationRaw,
RouteRecordRaw,
} from 'vue-router';
import TemplateBuilder from 'src/pages/TemplateBuilder/TemplateBuilder.vue';
import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
function getCommonFormItems(): RouteRecordRaw[] {
return [

View File

@ -141,8 +141,8 @@ function replaceAndAppendMount(app: App<Element>, replaceId: string) {
parent!.append(clone);
}
export function openSettings(tab: SettingsTab) {
routeTo({ path: '/settings', query: { tab } });
export async function openSettings(tab: SettingsTab) {
await routeTo({ path: '/settings', query: { tab } });
}
export async function routeTo(route: RouteLocationRaw) {
@ -337,11 +337,24 @@ function getDeleteAction(doc: Doc): Action {
};
}
async function openEdit(doc: Doc) {
async function openEdit({ name, schemaName }: Doc) {
if (!name) {
return;
}
const route = getFormRoute(schemaName, name);
return await routeTo(route);
/*
const listConfig = fyo.models[doc.schemaName]?.getListViewSettings?.(fyo);
const formRoute = listConfig?.formRoute;
if (!doc.name) {
return;
}
if (formRoute) {
return await routeTo(formRoute(doc));
const route = formRoute(doc.name);
return await routeTo(route);
}
const isFormEdit = [
@ -356,10 +369,11 @@ async function openEdit(doc: Doc) {
].includes(doc.schemaName as ModelNameEnum);
if (isFormEdit) {
return await routeTo(`/edit/${doc.schemaName}/${doc.name!}`);
return await routeTo(`/edit/${doc.schemaName}/${doc.name}`);
}
await openQuickEdit({ schemaName: doc.schemaName, name: doc.name! });
await openQuickEdit({ schemaName: doc.schemaName, name: doc.name });
*/
}
function getDuplicateAction(doc: Doc): Action {