Skip to content

Commit

Permalink
feat: allow signature in dynamic text (#298)
Browse files Browse the repository at this point in the history
  • Loading branch information
maharshivpatel authored Jun 24, 2024
2 parents e80ad3d + 7ca2cad commit 4fd5e74
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,25 @@
{%- set value = _(frappe.db.get_value(field.doctype, doc[field.parentField], field.fieldname)) -%}
{{ frappe.format(value, {'fieldtype': field.fieldtype, 'options': field.options}) }}
{%- elif row -%}
{%- if field.fieldtype == "Image" and row.get(field['options']) -%}
<img class="print-item-image" src="{{ row.get(field['options']) }}" alt="">
{%- if field.fieldtype == "Image" and row.get(field['options']) -%}
<img class="print-item-image" src="{{ row.get(field['options']) }}" alt="">
{%- elif field.fieldtype == "Signature" -%}
{%- if doc.get_formatted(field.fieldname) != "/assets/frappe/images/signature-placeholder.png" -%}
<img class="print-item-image" src="{{doc.get_formatted(field.fieldname)}}" alt="">
{%- endif -%}
{%- else -%}
{{row.get_formatted(field.fieldname)}}
{%- endif -%}
{%- else -%}
{{row.get_formatted(field.fieldname)}}
{%- endif -%}
{%- else -%}
{{doc.get_formatted(field.fieldname)}}
{%- if field.fieldtype == "Image" and doc.get(field['options']) -%}
<img class="print-item-image" src="{{ doc.get(field['options']) }}" alt="">
{%- elif field.fieldtype == "Signature" -%}
{%- if doc.get_formatted(field.fieldname) != "/assets/frappe/images/signature-placeholder.png" -%}
<img class="print-item-image" src="{{doc.get_formatted(field.fieldname)}}" alt="">
{%- endif -%}
{%- else -%}
{{doc.get_formatted(field.fieldname)}}
{%- endif -%}
{%- endif -%}
{%- endmacro -%}

Expand Down
5 changes: 4 additions & 1 deletion print_designer/public/js/print_designer/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ export const getFormattedValue = async (field, row = null) => {
MainStore.docData
);
if (!formattedValue.value) {
if (["Image, Attach Image"].indexOf(field.fieldtype) != -1) {
if (["Image", "Attach Image"].indexOf(field.fieldtype) != -1) {
formattedValue.value = null;
} else {
switch (field.fieldname) {
Expand All @@ -467,6 +467,9 @@ export const getFormattedValue = async (field, row = null) => {
}
}
}
if (field.fieldtype == "Signature") {
formattedValue.value = `<img class="print-item-image" src="${formattedValue.value}" alt="">`;
}
return formattedValue.value;
};

Expand Down

0 comments on commit 4fd5e74

Please sign in to comment.