tailbone/tailbone/templates/poser/reports/view.mako
Lance Edgar 1ec1eba496 feat: refactor templates to simplify base/page/form structure
to mimic what has been done in wuttaweb
2024-08-19 23:20:59 -05:00

74 lines
2.3 KiB
Mako

## -*- coding: utf-8; -*-
<%inherit file="/master/view.mako" />
<%def name="render_form_buttons()">
<div v-if="!showUploadForm" class="buttons">
% if master.has_perm('replace'):
<b-button type="is-primary"
@click="showUploadForm = true">
Upload Replacement Module
</b-button>
% endif
<once-button type="is-primary"
tag="a"
% if instance.get('error'):
href="#" disabled
% else:
href="${url('generate_specific_report', type_key=instance['report'].type_key)}"
% endif
text="Generate this Report">
</once-button>
</div>
% if master.has_perm('replace'):
<div v-if="showUploadForm">
${h.form(master.get_action_url('replace', instance), enctype='multipart/form-data', **{'@submit': 'uploadSubmitting = true'})}
${h.csrf_token(request)}
<b-field label="New Module File" horizontal>
<b-field class="file is-primary"
:class="{'has-name': !!uploadFile}"
>
<b-upload name="replacement_module"
v-model="uploadFile"
class="file-label">
<span class="file-cta">
<b-icon class="file-icon" pack="fas" icon="upload"></b-icon>
<span class="file-label">Click to upload</span>
</span>
</b-upload>
<span v-if="uploadFile"
class="file-name">
{{ uploadFile.name }}
</span>
</b-field>
<div class="buttons">
<b-button @click="showUploadForm = false">
Cancel
</b-button>
<b-button type="is-primary"
native-type="submit"
:disabled="uploadSubmitting || !uploadFile"
icon-pack="fas"
icon-left="save">
{{ uploadSubmitting ? "Working, please wait..." : "Save" }}
</b-button>
</div>
</b-field>
${h.end_form()}
</div>
% endif
<br />
</%def>
<%def name="modify_vue_vars()">
${parent.modify_vue_vars()}
% if master.has_perm('replace'):
<script>
${form.vue_component}Data.showUploadForm = false
${form.vue_component}Data.uploadFile = null
${form.vue_component}Data.uploadSubmitting = false
</script>
% endif
</%def>