From 72e9df5460b77cffe9260449efe8d07c4695e5fd Mon Sep 17 00:00:00 2001 From: Faris Ansari Date: Tue, 19 Oct 2021 19:22:23 +0530 Subject: [PATCH] fix: section fields orientation - Option to render fields in a section in left-right orientation - this is useful in cases where rendering currency values one below the other makes more sense --- .../PrintFormatSection.vue | 137 ++++++++++++------ .../templates/print_format/macros/Data.html | 13 +- 2 files changed, 105 insertions(+), 45 deletions(-) diff --git a/frappe/public/js/print_format_builder/PrintFormatSection.vue b/frappe/public/js/print_format_builder/PrintFormatSection.vue index b278a593f7..9a065e5e26 100644 --- a/frappe/public/js/print_format_builder/PrintFormatSection.vue +++ b/frappe/public/js/print_format_builder/PrintFormatSection.vue @@ -8,60 +8,54 @@ :placeholder="__('Section Title')" v-model="section.label" /> -
-
+
-
+
{{ __("Page Break") }}
@@ -124,6 +121,57 @@ export default { get_fields(column) { return column.fields.filter(df => !df.remove); } + }, + computed: { + section_options() { + return [ + { + label: __("Add section above"), + action: () => this.$emit("add_section_above") + }, + { + label: __("Add column"), + action: this.add_column, + condition: () => this.section.columns.length < 4 + }, + { + label: __("Remove column"), + action: this.remove_column, + condition: () => this.section.columns.length > 1 + }, + { + label: __("Add page break"), + action: this.add_page_break, + condition: () => !this.section.page_break + }, + { + label: __("Remove page break"), + action: this.remove_page_break, + condition: () => this.section.page_break + }, + { + label: __("Remove section"), + action: () => this.$set(this.section, "remove", true) + }, + { + label: __("Field Orientation (Left-Right)"), + condition: () => !this.section.field_orientation, + action: () => + this.$set( + this.section, + "field_orientation", + "left-right" + ) + }, + { + label: __("Field Orientation (Top-Down)"), + condition: () => + this.section.field_orientation == "left-right", + action: () => + this.$set(this.section, "field_orientation", "") + } + ].filter(option => (option.condition ? option.condition() : true)); + } } }; @@ -192,5 +240,6 @@ export default { .drag-container { height: 100%; min-height: 2rem; + border-radius: var(--border-radius); } diff --git a/frappe/templates/print_format/macros/Data.html b/frappe/templates/print_format/macros/Data.html index d0c294ccf5..2fa0e1484b 100644 --- a/frappe/templates/print_format/macros/Data.html +++ b/frappe/templates/print_format/macros/Data.html @@ -1,4 +1,14 @@ -{% if doc.get(fieldname) %} +{% if doc.get(df.fieldname) %} +{%- if df.section.field_orientation == 'left-right' -%} +
+
+ {{ df.label }} +
+
+ {{ doc.get_formatted(df.fieldname) }} +
+
+{%- else -%}
{{ df.label }} @@ -7,4 +17,5 @@ {{ doc.get_formatted(df.fieldname) }}
+{%- endif -%} {% endif %}