浏览代码

fix: make clear button link which trigger warning dialog

(cherry picked from commit ce67ee1bc6)
version-14
Shariq Ansari 2 年前
committed by Mergify
父节点
当前提交
627a72fa97
共有 3 个文件被更改,包括 31 次插入2 次删除
  1. +20
    -0
      frappe/public/js/frappe/web_form/web_form.js
  2. +9
    -0
      frappe/public/scss/website/web_form.scss
  3. +2
    -2
      frappe/website/doctype/web_form/templates/web_form.html

+ 20
- 0
frappe/public/js/frappe/web_form/web_form.js 查看文件

@@ -28,6 +28,7 @@ export default class WebForm extends frappe.ui.FieldGroup {

if (this.is_new || this.in_edit_mode) {
this.setup_primary_action();
this.setup_clear_action();
}

this.setup_previous_next_button();
@@ -157,6 +158,25 @@ export default class WebForm extends frappe.ui.FieldGroup {
$(".web-form").on("submit", () => this.save());
}

setup_clear_action() {
$(".web-form-footer .clear-btn").on("click", () => this.clear_form());
}

clear_form() {
let title = __("Clear Form?");
let message = __("Are you sure you want to clear the form? It cannot be undone.");
let clear_button_text = __("Clear Form");

if (location.href.includes("/edit")) {
title = __("Reset Form?");
message = __("Are you sure you want to reset all field values?");
clear_button_text = __("Reset Form");
}

frappe.warn(title, message, () => location.reload(true), clear_button_text);
return false;
}

validate_section() {
if (this.allow_incomplete) return true;



+ 9
- 0
frappe/public/scss/website/web_form.scss 查看文件

@@ -140,6 +140,15 @@
font-size: var(--text-base);
}

.btn-link {
padding-left: 0px;
color: var(--text-color);

&:hover {
color: var(--text-on-light-blue);
}
}

.left-area {
display: flex;
flex: 1;


+ 2
- 2
frappe/website/doctype/web_form/templates/web_form.html 查看文件

@@ -21,13 +21,13 @@
<div class="left-area">
{% if not in_view_mode %}
<!-- clear button -->
<a href="/{{ path }}" class="clear-btn btn btn-default btn-sm hide">
<button class="clear-btn btn btn-link btn-sm hide">
{% if in_edit_mode %}
{{ _("Reset Form", null, "Button in web form") }}
{% else %}
{{ _("Clear Form", null, "Button in web form") }}
{% endif %}
</a>
</button>
{% endif %}
</div>
<div class="center-area paging"></div>


正在加载...
取消
保存