8000 fix: Signature form by DrZoidberg09 · Pull Request #18477 · frappe/frappe · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: Signature form #18477

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 20 additions & 26 deletions frappe/public/js/frappe/form/controls/signature.js
< 8000 td class="blob-num blob-num-addition empty-cell">
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,37 @@ frappe.ui.form.ControlSignature = class ControlSignature extends frappe.ui.form.
this.loading = false;
super.make();

this.load_lib().then(() => {
if (this.df.label) {
$(this.wrapper).find("label").text(__(this.df.label));
}

frappe.require("/assets/frappe/js/lib/jSignature.min.js").then(() => {
// make jSignature field
this.body = $('<div class="signature-field"></div>').appendTo(me.wrapper);
me.body = $('<div class="signature-field"></div>').prependTo(me.$input_wrapper);

if (this.body.is(":visible")) {
this.make_pad();
} else {
$(document).on("frappe.ui.Dialog:shown", () => {
this.make_pad();
});
}
new ResizeObserver(() => me.make_pad()).observe(me.body[0]);
});

this.img_wrapper = $(`<div class="signature-display">
<div class="missing-image attach-missing-image">
${frappe.utils.icon("restriction", "md")}</i>
</div></div>`).prependTo(this.$input_wrapper);
this.img = $("<img class='img-responsive attach-image-display'>")
.appendTo(this.img_wrapper)
.toggle(false);
}

make_pad() {
let width = this.body.width();
if (width > 0 && !this.$pad) {
this.$pad = this.body
.jSignature({
height: 200,
color: "var(--text-color)",
width: this.body.width(),
decorColor: "black",
width,
lineWidth: 2,
"background-color": "var(--control-bg)",
backgroundColor: "var(--control-bg)",
})
.on("change", this.on_save_sign.bind(this));
this.load_pad();
Expand All @@ -43,15 +51,8 @@ frappe.ui.form.ControlSignature = class ControlSignature extends frappe.ui.form.
this.on_reset_sign();
return false;
});
this.refresh_input();
}

this.img_wrapper = $(`<div class="signature-display">
<div class="missing-image attach-missing-image">
${frappe.utils.icon("restriction", "md")}</i>
</div></div>`).appendTo(this.wrapper);
this.img = $("<img class='img-responsive attach-image-display'>")
.appendTo(this.img_wrapper)
.toggle(false);
}
refresh_input() {
// signature dom is not ready
Expand Down Expand Up @@ -131,11 +132,4 @@ frappe.ui.form.ControlSignature = class ControlSignature extends frappe.ui.form.
this.set_my_value(base64_img);
this.set_image(this.get_value());
}

load_lib() {
if (!this.load_lib_promise) {
this.load_lib_promise = frappe.require("/assets/frappe/js/lib/jSignature.min.js");
}
return this.load_lib_promise;
}
};
3 changes: 1 addition & 2 deletions frappe/public/scss/common/controls.scss
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,11 @@ textarea.form-control {
border: 1px solid var(--border-color);
border-radius: var(--border-radius);
position: relative;
margin-top: -10px;
}

.signature-display {
margin: 7px 0px;
background: var(--control-bg);
border-radius: var(--border-radius);
.attach-missing-image,
.attach-image-display {
cursor: pointer;
Expand Down
0