2
0
mirror of https://github.com/frappe/books.git synced 2024-11-10 07:40:55 +00:00

refactor: inline rendering

This commit is contained in:
18alantom 2022-02-11 18:01:48 +05:30
parent 6701b4f769
commit c6afe59033

View File

@ -12,37 +12,32 @@
@change="(value) => onChange(df, value)" @change="(value) => onChange(df, value)"
/> />
<template v-else> <template v-else>
<template v-if="inlineEditField === df && inlineEditDoc"> <div class="border-b" :key="df.fieldname" v-if="renderInline(df)">
<div class="border-b" :key="df.fieldname"> <TwoColumnForm
<TwoColumnForm ref="inlineEditForm"
ref="inlineEditForm" :doc="inlineEditDoc"
:doc="inlineEditDoc" :fields="inlineEditFields"
:fields="inlineEditFields" :column-ratio="columnRatio"
:column-ratio="columnRatio" :no-border="true"
:no-border="true" :focus-first-input="true"
:focus-first-input="true" :autosave="false"
:autosave="false" @error="(msg) => $emit('error', msg)"
@error="(msg) => $emit('error', msg)" />
/> <div class="flex px-4 pb-2">
<div class="flex px-4 pb-2"> <Button class="w-1/2 text-gray-900" @click="inlineEditField = null">
<Button {{ t('Cancel') }}
class="w-1/2 text-gray-900" </Button>
@click="inlineEditField = null" <Button
> type="primary"
{{ t('Cancel') }} class="ml-2 w-1/2 text-white"
</Button> @click="() => saveInlineEditDoc(df)"
<Button >
type="primary" {{ df.inlineSaveText || t('Save') }}
class="ml-2 w-1/2 text-white" </Button>
@click="() => saveInlineEditDoc(df)"
>
{{ df.inlineSaveText || t('Save') }}
</Button>
</div>
</div> </div>
</template> </div>
<div <div
:key="df.fieldname" :key="df.fieldname + '-else'"
v-else v-else
class="grid" class="grid"
:class="{ 'border-b': !noBorder }" :class="{ 'border-b': !noBorder }"
@ -141,6 +136,11 @@ let TwoColumnForm = {
} }
}, },
methods: { methods: {
renderInline(df) {
return (
this.inlineEditField?.fieldname === df?.fieldname && this.inlineEditDoc
);
},
evaluateBoolean(fieldProp, defaultValue) { evaluateBoolean(fieldProp, defaultValue) {
const type = typeof fieldProp; const type = typeof fieldProp;
switch (type) { switch (type) {