feat: modified webform template

This commit is contained in:
Shivam Mishra 2019-05-11 12:18:26 +05:30
parent 844ff93167
commit 2d12c0fafe

View file

@ -14,189 +14,11 @@
{% endblock %}
{% block header_actions %}
{% if not read_only and has_header %}
<div style="padding-bottom: 15px;">
{% if login_required -%}
<a href="/{{ cancel_url or pathname }}" class="btn btn-light btn-sm">
{{ _("Cancel") }}</a>
{%- endif %}
{% if not is_list %}
<button type="submit" class="btn btn-primary btn-sm btn-form-submit">
{{ _(button_label or "Save") }}</button>
{% endif %}
</div>
{% endif %}
{% if is_list %}
<div class="text-right mt-2">
<a href="/{{ pathname }}{{ delimeter }}new=1{{ params_from_form_dict}}" class="btn btn-primary btn-new">
{{ _("New") }}
</a>
<button class="btn btn-danger btn-delete">
{{ _("Delete") }}
</button>
</div>
{% endif %}
{%- if allow_print and not is_list and not _login_required and doc.name -%}
<div class='text-right'>
<a class='text-muted small' href='/printview?doctype={{ doc.doctype}}&name={{ doc.name }}
{%- if print_format -%}&format={{ print_format }}{%- endif -%}' target="_blank" rel="noopener noreferrer">
<i class='fa fa-print'></i> {{ _("Print") }}</a>
</div>
{%- endif -%}
<div class="web-form-actions"></div>
{% endblock %}
{% block page_content %}
{% if introduction_text %}
<div class="introduction">
<p class="text-muted">{{ _(introduction_text) }}</p>
</div>
{% else %}
<hr style="margin-top: 0;">
{% endif %}
<div class="form-message hide"></div>
{% if _login_required %}
<div class="login-required">
<div class="text-muted">
{{ _("Please sign-up or login to begin") }}
</div>
<p>
<a href="/login?redirect-to=/{{ pathname }}" class="btn btn-primary">
{{ _("Login") }}
</a>
</p>
</div>
{% elif is_list %}
<div class="list-filters row">
<script>{% include "templates/includes/list/filters.js" %}</script>
</div>
{% if show_in_grid %}
<div class="web-form-list">
<div class="results"></div>
<div class="more-block {% if not show_more -%} hidden {%- endif %}">
<button class="btn btn-light btn-more btn-sm">{{ _("More") }}</button>
</div>
</div>
{% else %}
{% include "templates/includes/list/list.html" %}
<script>{% include "templates/includes/list/list.js" %}</script>
{% endif %}
{% else %}
<br>
<!-- pagination -->
{% if not frappe.form_dict.new and layout|len > 1 %}
<div class="text-center slide-progress text-extra-muted">
{% for page in layout %}
<i data-idx="{{ loop.index }}" data-toggle="tooltip" data-placement="top"
title="{{ _(page.label) or _("Page {0}").format(loop.index) }}" class="fa-fw
{% if loop.index==1 %}fa fa-circle{% else %}fa fa-circle-o{% endif %}"></i>
{% endfor %}
</div>
{% endif %}
<div role="form"
data-web-form="{{ name }}" data-owner="{{ doc.owner }}">
{% if frappe.form_dict.name and web_page_link_text %}
<div class="row">
<div class="col-sm-9">
<p class="text-muted">
<a class="btn btn-light btn-sm" href="{{ doc.route }}" target="_blank" rel="noopener noreferrer">
{{ web_page_link_text }}</a>
</p>
</div>
</div>
{% endif %}
{% for page in layout %}
{% set last_page = True if loop.index == layout|len else False %}
<div class="web-form-page{% if loop.index > 1 %} hidden{% endif %}"
data-idx="{{ loop.index }}"
data-label="{{ page.label or _("Page {0}").format(loop.index) }}">
{% if page.label %}
<h2 class='text-center'>{{ _(page.label) }}</h2>
{% endif %}
{% if page.description %}
<p class='text-center text-muted small'>{{ _(page.description) }}</p>
<br>
{% endif %}
<div class="webform-wrapper"></div>
{% if last_page and accept_payment %}
<div class="well payment-details" style="margin-top: 15px">
{% if not doc.paid %}
{% if payment_button_help %}
<div class='text-muted' style='padding-bottom: 15px;'>
{{ payment_button_help }}</div>
{% endif %}
<a class="btn btn-primary btn-payment">
{{ payment_button_label or "Pay"}}</a>
{% else %}
<div>{{ _("Payment Complete") }}</div>
{% endif %}
</div>
{% endif %}
<!-- page footer buttons -->
<div>
{% if layout|len > 1 %}
<p class='text-muted small text-center'>
{{ _("Page {0} of {1}").format(loop.index, layout|len) }}</p>
{% endif %}
<br>
<p class='text-right'>
{%- if loop.index > 1 -%}
<button class='btn btn-sm btn-light btn-change-section'
data-idx="{{ loop.index - 1 }}">
{{ _("Previous") }}</button>
{%- endif -%}
<!-- save/next button -->
{% if (loop.index == layout|len or frappe.form_dict.new) %}
{% if not read_only %}
<button type="submit" class="btn btn-primary btn-sm btn-form-submit footer-button">
{{ _("Save") }}</button>
{% endif %}
{% elif layout|len > 1 %}
<button class="btn btn-primary btn-sm btn-change-section"
data-idx="{{ loop.index + 1 }}">
{{ _("Next") }}</button>
{% endif %}
</p>
</div>
</div>
{% endfor %}
</div>
{% if show_attachments and not frappe.form_dict.new -%}
<div class="attachments">
<h3>{{ _("Attachments") }}</h3>
{% for attachment in attachments %}
<div class="attachment">
<a class="no-underline attachment-link" href="{{ attachment.file_url }}" target="blank">
<div class="row">
<div class="col-9">
<span class="file-name">{{ attachment.file_name }}</span>
</div>
<div class="col-3">
<span class="pull-right file-size">{{ attachment.file_size }}</span>
</div>
</div>
</a>
</div>
{% endfor %}
</div>
{%- endif %}
{% if allow_comments and not frappe.form_dict.new -%}
<div class="comments">
<br><br>
<h3>{{ _("Comments") }}</h3>
{% include 'templates/includes/comments/comments.html' %}
</div>
{%- endif %}
{% endif %}
<div class="padding"></div>
<div role="form" class="web-form-wrapper" data-web-form="{{ name }}" data-owner="{{ doc.owner }}">
{% endblock %}
{% block script %}
@ -244,7 +66,7 @@ frappe.sys_defaults = frappe.boot.sysdefaults;
Vue.prototype.frappe = window.frappe;
</script>
<script type="text/javascript" src="/assets/js/web_form.min.js"></script>
<script type="text/javascript" src="assets/js/bootstrap-4-web.min.js"></script>
<script type="text/javascript" src="/assets/js/bootstrap-4-web.min.js"></script>
<script>
{% if script is defined %}
{{ script }}