Merge pull request #27818 from cogk/feat-add-hide-label-checkbox-on-print-format
feat(print_format): Add checkbox to hide label
This commit is contained in:
commit
7b0c4f495c
3 changed files with 24 additions and 2 deletions
|
|
@ -484,6 +484,11 @@ frappe.PrintFormatBuilder = class PrintFormatBuilder {
|
|||
{ label: __("Right", null, "alignment"), value: "right" },
|
||||
],
|
||||
},
|
||||
{
|
||||
label: __("Hide Label"),
|
||||
fieldname: "nolabel",
|
||||
fieldtype: "Check",
|
||||
},
|
||||
{
|
||||
label: __("Remove Field"),
|
||||
fieldtype: "Button",
|
||||
|
|
@ -497,10 +502,12 @@ frappe.PrintFormatBuilder = class PrintFormatBuilder {
|
|||
});
|
||||
|
||||
d.set_value("label", field.attr("data-label"));
|
||||
d.set_value("nolabel", field.attr("data-nolabel"));
|
||||
|
||||
d.set_primary_action(__("Update"), function () {
|
||||
field.attr("data-align", d.get_value("align"));
|
||||
field.attr("data-label", d.get_value("label"));
|
||||
field.attr("data-nolabel", d.get_value("nolabel"));
|
||||
field.find(".field-label").html(d.get_value("label"));
|
||||
d.hide();
|
||||
});
|
||||
|
|
@ -608,6 +615,7 @@ frappe.PrintFormatBuilder = class PrintFormatBuilder {
|
|||
var parent = $(this).parents(".print-format-builder-field:first"),
|
||||
doctype = parent.attr("data-doctype"),
|
||||
label = parent.attr("data-label"),
|
||||
nolabel = parent.attr("data-nolabel"),
|
||||
columns = parent.attr("data-columns").split(","),
|
||||
column_names = $.map(columns, function (v) {
|
||||
return v.split("|")[0];
|
||||
|
|
@ -792,6 +800,7 @@ frappe.PrintFormatBuilder = class PrintFormatBuilder {
|
|||
fieldtype = $this.attr("data-fieldtype"),
|
||||
align = $this.attr("data-align"),
|
||||
label = $this.attr("data-label"),
|
||||
nolabel = $this.attr("data-nolabel"),
|
||||
df = {
|
||||
fieldname: $this.attr("data-fieldname"),
|
||||
print_hide: 0,
|
||||
|
|
@ -805,6 +814,10 @@ frappe.PrintFormatBuilder = class PrintFormatBuilder {
|
|||
df.label = label;
|
||||
}
|
||||
|
||||
if (cint(nolabel)) {
|
||||
df.nolabel = 1;
|
||||
}
|
||||
|
||||
if (fieldtype === "Table") {
|
||||
// append the user selected columns to visible_columns
|
||||
var columns = $this.attr("data-columns").split(",");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
title="{{ __("Hidden") }}"{% } %}
|
||||
data-fieldname="{%= field.fieldname %}"
|
||||
data-label="{{ __(field.label, context=field.parent) }}"
|
||||
data-nolabel="{%= field.nolabel ? 1 : 0 %}"
|
||||
|
||||
{% if field.align %}data-align="{{ field.align }}"{% endif %}
|
||||
data-fieldtype="{%= field.fieldtype %}"
|
||||
|
|
|
|||
|
|
@ -88,7 +88,13 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
|
|||
}) -%}
|
||||
|
||||
{% set render_field = doc.get(df.fieldname) != 0 if df.fieldtype == "Check" else doc.get(df.fieldname) != None %}
|
||||
{% if render_field %}
|
||||
{% if render_field and df.nolabel %}
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}>
|
||||
<div class="col-xs-12 {{ get_align_class(df, no_of_cols) }} value">
|
||||
{{ _(print_value(df, doc)) }}
|
||||
</div>
|
||||
</div>
|
||||
{% elif render_field %}
|
||||
<div class="row {% if df.bold %}important{% endif %} data-field" {{ fieldmeta(df) }}>
|
||||
<div class="{{label_col_class}}
|
||||
{%- if doc.align_labels_right %} text-right{%- endif -%}">
|
||||
|
|
@ -107,7 +113,9 @@ data-fieldname="{{ df.fieldname }}" data-fieldtype="{{ df.fieldtype }}"
|
|||
{%- macro render_text_field(df, doc) -%}
|
||||
{%- if doc.get(df.fieldname) != None -%}
|
||||
<div style="padding: 10px 0px" {{ fieldmeta(df) }}>
|
||||
{%- if df.fieldtype in ("Text", "Code", "Long Text") %}<label>{{ _(df.label, context=df.parent) }}</label>{%- endif %}
|
||||
{%- if df.fieldtype in ("Text", "Code", "Long Text") and not df.nolabel -%}
|
||||
<label>{{ _(df.label, context=df.parent) }}</label>
|
||||
{%- endif %}
|
||||
{%- if df.fieldtype=="Code" %}
|
||||
<pre class="value">{{ doc.get(df.fieldname)|e }}</pre>
|
||||
{% else -%}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue