mirror of
https://github.com/frappe/books.git
synced 2024-12-23 03:19:01 +00:00
fix(ui): full scale printview only if it fits
This commit is contained in:
parent
40d889ae73
commit
a4729e2a6c
@ -1,5 +1,4 @@
|
||||
<template>
|
||||
<div class="flex">
|
||||
<div class="flex flex-col flex-1 bg-gray-25">
|
||||
<PageHeader :border="true">
|
||||
<template #left>
|
||||
@ -43,7 +42,6 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script lang="ts">
|
||||
import { Doc } from 'fyo/model/doc';
|
||||
@ -61,6 +59,7 @@ import { PrintValues } from 'src/utils/types';
|
||||
import { getFormRoute, openSettings, routeTo } from 'src/utils/ui';
|
||||
import { defineComponent } from 'vue';
|
||||
import PrintContainer from '../TemplateBuilder/PrintContainer.vue';
|
||||
import { showSidebar } from 'src/utils/refs';
|
||||
|
||||
export default defineComponent({
|
||||
name: 'PrintView',
|
||||
@ -204,11 +203,22 @@ export default defineComponent({
|
||||
this.values = await getPrintTemplatePropValues(this.doc as Doc);
|
||||
}
|
||||
},
|
||||
setScale() {
|
||||
this.scale = 1;
|
||||
const width = (this.templateDoc?.width ?? 21) * 37.8;
|
||||
let containerWidth = window.innerWidth - 32;
|
||||
if (showSidebar.value) {
|
||||
containerWidth -= 12 * 16;
|
||||
}
|
||||
|
||||
this.scale = Math.min(containerWidth / width, 1);
|
||||
},
|
||||
reset() {
|
||||
this.doc = null;
|
||||
this.values = null;
|
||||
this.templateList = [];
|
||||
this.templateDoc = null;
|
||||
this.scale = 1;
|
||||
},
|
||||
async onTemplateNameChange(value: string | null): Promise<void> {
|
||||
if (!value) {
|
||||
@ -225,6 +235,7 @@ export default defineComponent({
|
||||
} catch (error) {
|
||||
await handleErrorWithDialog(error);
|
||||
}
|
||||
this.setScale();
|
||||
},
|
||||
async setTemplateList(): Promise<void> {
|
||||
const list = (await this.fyo.db.getAllRaw(ModelNameEnum.PrintTemplate, {
|
||||
|
Loading…
Reference in New Issue
Block a user