Co-authored-by: Shariq Ansari <30859809+shariquerik@users.noreply.github.com>version-14
@@ -20,19 +20,13 @@ context("Web Form", () => { | |||||
cy.get(".title-area .indicator-pill").contains("Published"); | cy.get(".title-area .indicator-pill").contains("Published"); | ||||
}); | }); | ||||
it("Open Web Form (Logged in User)", () => { | |||||
it("Open Web Form", () => { | |||||
cy.visit("/note"); | cy.visit("/note"); | ||||
cy.fill_field("title", "Note 1"); | cy.fill_field("title", "Note 1"); | ||||
cy.get(".web-form-actions button").contains("Save").click(); | cy.get(".web-form-actions button").contains("Save").click(); | ||||
cy.url().should("include", "/note/Note%201"); | |||||
cy.visit("/note"); | |||||
cy.url().should("include", "/note/Note%201"); | |||||
}); | |||||
cy.url().should("include", "/note/new"); | |||||
it("Open Web Form (Guest)", () => { | |||||
cy.request("/api/method/logout"); | cy.request("/api/method/logout"); | ||||
cy.visit("/note"); | cy.visit("/note"); | ||||
@@ -226,8 +220,8 @@ context("Web Form", () => { | |||||
cy.visit("/note"); | cy.visit("/note"); | ||||
cy.url().should("include", "/note/list"); | cy.url().should("include", "/note/list"); | ||||
cy.get('.web-list-table tbody tr[id="Note 1"] .list-col-checkbox').click(); | |||||
cy.get('.web-list-table tbody tr[id="Note 2"] .list-col-checkbox').click(); | |||||
cy.get('.web-list-table tbody tr[id="Note 1"] .list-col-checkbox input').click(); | |||||
cy.get('.web-list-table tbody tr[id="Note 2"] .list-col-checkbox input').click(); | |||||
cy.get(".web-list-actions button:visible").contains("Delete").click({ force: true }); | cy.get(".web-list-actions button:visible").contains("Delete").click({ force: true }); | ||||
cy.get(".web-list-actions button").contains("Delete").should("not.be.visible"); | cy.get(".web-list-actions button").contains("Delete").should("not.be.visible"); | ||||
@@ -293,9 +293,9 @@ export default class WebForm extends frappe.ui.FieldGroup { | |||||
// validation hack: get_values will check for missing data | // validation hack: get_values will check for missing data | ||||
let doc_values = super.get_values(this.allow_incomplete); | let doc_values = super.get_values(this.allow_incomplete); | ||||
if (!doc_values) return; | |||||
if (!doc_values) return false; | |||||
if (window.saving) return; | |||||
if (window.saving) return false; | |||||
// TODO: remove this (used for payments app) | // TODO: remove this (used for payments app) | ||||
let for_payment = Boolean(this.accept_payment && !this.doc.paid); | let for_payment = Boolean(this.accept_payment && !this.doc.paid); | ||||
@@ -383,6 +383,6 @@ export default class WebForm extends frappe.ui.FieldGroup { | |||||
} | } | ||||
} | } | ||||
window.location.href = path; | window.location.href = path; | ||||
}, 1000); | |||||
}, 3000); | |||||
} | } | ||||
} | } |
@@ -42,7 +42,7 @@ | |||||
</div> | </div> | ||||
</div> | </div> | ||||
<div class="web-form-body"> | <div class="web-form-body"> | ||||
{% if introduction_text %} | |||||
{% if is_new and introduction_text %} | |||||
<div class="web-form-introduction">{{ introduction_text }}</div> | <div class="web-form-introduction">{{ introduction_text }}</div> | ||||
{% endif %} | {% endif %} | ||||
<div class="web-form-wrapper"></div> | <div class="web-form-wrapper"></div> | ||||
@@ -2,6 +2,7 @@ | |||||
"allow_comments": 0, | "allow_comments": 0, | ||||
"allow_edit": 1, | "allow_edit": 1, | ||||
"allow_multiple": 1, | "allow_multiple": 1, | ||||
"show_list": 1, | |||||
"doc_type": "Event", | "doc_type": "Event", | ||||
"docstatus": 0, | "docstatus": 0, | ||||
"doctype": "Web Form", | "doctype": "Web Form", | ||||
@@ -36,7 +36,6 @@ | |||||
"button_label", | "button_label", | ||||
"column_break_29", | "column_break_29", | ||||
"success_message", | "success_message", | ||||
"route_to_success_link", | |||||
"success_url", | "success_url", | ||||
"list_settings_tab", | "list_settings_tab", | ||||
"list_setting_message", | "list_setting_message", | ||||
@@ -101,13 +100,6 @@ | |||||
"fieldtype": "Check", | "fieldtype": "Check", | ||||
"label": "Login Required" | "label": "Login Required" | ||||
}, | }, | ||||
{ | |||||
"default": "0", | |||||
"depends_on": "eval:doc.login_required", | |||||
"fieldname": "route_to_success_link", | |||||
"fieldtype": "Check", | |||||
"label": "Route to Success Link" | |||||
}, | |||||
{ | { | ||||
"default": "0", | "default": "0", | ||||
"depends_on": "login_required", | "depends_on": "login_required", | ||||
@@ -211,7 +203,6 @@ | |||||
"label": "Success Message" | "label": "Success Message" | ||||
}, | }, | ||||
{ | { | ||||
"depends_on": "route_to_success_link", | |||||
"description": "Go to this URL after completing the form", | "description": "Go to this URL after completing the form", | ||||
"fieldname": "success_url", | "fieldname": "success_url", | ||||
"fieldtype": "Data", | "fieldtype": "Data", | ||||
@@ -325,7 +316,7 @@ | |||||
"icon": "icon-edit", | "icon": "icon-edit", | ||||
"is_published_field": "published", | "is_published_field": "published", | ||||
"links": [], | "links": [], | ||||
"modified": "2022-07-24 20:29:23.059834", | |||||
"modified": "2022-07-27 18:19:10.748079", | |||||
"modified_by": "Administrator", | "modified_by": "Administrator", | ||||
"module": "Website", | "module": "Website", | ||||
"name": "Web Form", | "name": "Web Form", | ||||
@@ -172,6 +172,7 @@ def get_context(context): | |||||
if ( | if ( | ||||
frappe.session.user != "Guest" | frappe.session.user != "Guest" | ||||
and self.login_required | |||||
and not self.allow_multiple | and not self.allow_multiple | ||||
and not frappe.form_dict.name | and not frappe.form_dict.name | ||||
and not frappe.form_dict.is_list | and not frappe.form_dict.is_list | ||||
@@ -183,7 +184,7 @@ def get_context(context): | |||||
# Show new form when | # Show new form when | ||||
# - User is Guest | # - User is Guest | ||||
# - Login not required | # - Login not required | ||||
route_to_new = frappe.session.user == "Guest" and not self.login_required | |||||
route_to_new = frappe.session.user == "Guest" or not self.login_required | |||||
if not frappe.form_dict.is_new and route_to_new: | if not frappe.form_dict.is_new and route_to_new: | ||||
frappe.redirect(f"/{self.route}/new") | frappe.redirect(f"/{self.route}/new") | ||||
@@ -245,7 +246,7 @@ def get_context(context): | |||||
if self.breadcrumbs: | if self.breadcrumbs: | ||||
context.parents = frappe.safe_eval(self.breadcrumbs, {"_": _}) | context.parents = frappe.safe_eval(self.breadcrumbs, {"_": _}) | ||||
if frappe.form_dict.is_new: | |||||
if self.show_list and frappe.form_dict.is_new: | |||||
context.title = _("New {0}").format(context.title) | context.title = _("New {0}").format(context.title) | ||||
context.has_header = (frappe.form_dict.name or frappe.form_dict.is_new) and ( | context.has_header = (frappe.form_dict.name or frappe.form_dict.is_new) and ( | ||||
@@ -287,7 +288,7 @@ def get_context(context): | |||||
"route": f"{self.route}/{context.doc_name}", | "route": f"{self.route}/{context.doc_name}", | ||||
} | } | ||||
) | ) | ||||
context.title = _("Edit") | |||||
context.title = _("Editing {0}").format(context.title) | |||||
context.reference_doc.add_seen() | context.reference_doc.add_seen() | ||||
context.reference_doctype = context.reference_doc.doctype | context.reference_doctype = context.reference_doc.doctype | ||||
context.reference_name = context.reference_doc.name | context.reference_name = context.reference_doc.name | ||||