From 7ca2cad9cc69d67bfefd6c6330914e09a3498193 Mon Sep 17 00:00:00 2001 From: Maharshi Patel Date: Fri, 21 Jun 2024 11:31:37 +0530 Subject: [PATCH] feat: allow signature in dynamic text signature field is saved as base64 encoded string in the database. i just added img tag and set the src attribute to the base64 encoded string. --- .../print_designer/jinja/macros/spantag.html | 24 ++++++++++++++----- .../public/js/print_designer/utils.js | 5 +++- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/print_designer/print_designer/page/print_designer/jinja/macros/spantag.html b/print_designer/print_designer/page/print_designer/jinja/macros/spantag.html index a96ffe9..8db1003 100644 --- a/print_designer/print_designer/page/print_designer/jinja/macros/spantag.html +++ b/print_designer/print_designer/page/print_designer/jinja/macros/spantag.html @@ -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']) -%} - + {%- if field.fieldtype == "Image" and row.get(field['options']) -%} + + {%- elif field.fieldtype == "Signature" -%} + {%- if doc.get_formatted(field.fieldname) != "/assets/frappe/images/signature-placeholder.png" -%} + + {%- 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']) -%} + + {%- elif field.fieldtype == "Signature" -%} + {%- if doc.get_formatted(field.fieldname) != "/assets/frappe/images/signature-placeholder.png" -%} + + {%- endif -%} + {%- else -%} + {{doc.get_formatted(field.fieldname)}} + {%- endif -%} {%- endif -%} {%- endmacro -%} diff --git a/print_designer/public/js/print_designer/utils.js b/print_designer/public/js/print_designer/utils.js index d757ed0..d65e630 100644 --- a/print_designer/public/js/print_designer/utils.js +++ b/print_designer/public/js/print_designer/utils.js @@ -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) { @@ -467,6 +467,9 @@ export const getFormattedValue = async (field, row = null) => { } } } + if (field.fieldtype == "Signature") { + formattedValue.value = ``; + } return formattedValue.value; };