fix: added cancel button in clear form dialog

This commit is contained in:
Shariq Ansari 2022-08-17 19:39:42 +05:30
parent ce67ee1bc6
commit 68318aacd3
4 changed files with 11 additions and 7 deletions

View file

@ -32,10 +32,7 @@ frappe.get_modal = function (title, content) {
${content}
</div>
<div class="modal-footer hidden">
<button type="button" class="btn btn-default btn-sm btn-modal-close" data-dismiss="modal">
<i class="octicon octicon-x visible-xs" style="padding: 1px 0px;"></i>
<span class="hidden-xs">${__("Close")}</span>
</button>
<button type="button" class="btn btn-sm btn-secondary hidden"></button>
<button type="button" class="btn btn-sm btn-primary hidden"></button>
</div>
</div>
@ -49,11 +46,19 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.Dialog {
return this.$wrapper.find(".modal-footer .btn-primary");
}
get_secondary_btn() {
return this.$wrapper.find(".modal-footer .btn-secondary");
}
set_primary_action(label, click) {
this.$wrapper.find(".modal-footer").removeClass("hidden");
return super.set_primary_action(label, click).removeClass("hidden");
}
set_secondary_action(click) {
return super.set_secondary_action(click).removeClass("hidden");
}
make() {
super.make();
if (this.fields) {

View file

@ -168,7 +168,7 @@ frappe.ui.Dialog = class Dialog extends frappe.ui.FieldGroup {
set_secondary_action(click) {
this.footer.removeClass("hide");
this.get_secondary_btn().removeClass("hide").off("click").on("click", click);
return this.get_secondary_btn().removeClass("hide").off("click").on("click", click);
}
set_secondary_action_label(label) {

View file

@ -72,7 +72,6 @@ frappe.warn = function (title, message_html, proceed_action, primary_label, is_m
d.$body.append(`<div class="frappe-confirm-message">${message_html}</div>`);
d.standard_actions.find(".btn-primary").removeClass("btn-primary").addClass("btn-danger");
d.standard_actions.find(".btn-primary").removeClass("btn-primary").addClass("btn-danger");
d.show();
return d;

View file

@ -317,7 +317,7 @@ def get_context(context):
context.reference_doc.doctype, context.reference_doc.name
)
context.reference_doc = json.loads(context.reference_doc.as_json())
context.reference_doc = context.reference_doc.as_dict(no_nulls=True)
def add_custom_context_and_script(self, context):
"""Update context from module if standard and append script"""