]> git.agnieray.net Git - galette.git/blob - galette/templates/default/pages/import.html.twig
Fixes and improvements on small screens display
[galette.git] / galette / templates / default / pages / import.html.twig
1 {% extends 'page.html.twig' %}
2
3 {% block content %}
4 <div class="ui icon yellow icon message with-transition">
5 <i class="exclamation triangle icon"></i>
6 <div class="content">
7 {{ _T("Warning: Don't forget to backup your current database.") }}
8 </div>
9 </div>
10 <div class="ui basic fitted segment">
11 <div class="ui styled fluid accordion row">
12 <div class="active title">
13 <i class="jsonly displaynone icon dropdown"></i>
14 {{ _T('Existing files') }}
15 </div>
16 <div class="active content field">
17 <form class="ui form" action="{{ url_for('doImport') }}" method="post">
18 {% if existing|length > 0 %}
19 <p>{{ _T('The following files seems ready to import on the disk:') }}</p>
20 <table class="listing ui celled striped table">
21 <thead>
22 <tr>
23 <th>{{ _T('Name') }}</th>
24 <th>{{ _T('Date') }}</th>
25 <th>{{ _T('Size') }}</th>
26 <th class="actions_row">{{ _T('Actions') }}</th>
27 </tr>
28 </thead>
29 <tbody>
30 {% for import in existing %}
31 <tr>
32 <td data-scope="row">
33 <input type="radio" name="import_file" id="file{{ loop.index }}" value="{{ import.name }}"{% if import_file is defined and import_file == import.name %} checked="checked"{% endif %}/>
34 <label for="file{{ loop.index }}">{{ import.name }}</label> (<a href="{{ url_for("getCsv", {"type": "import", "file": import.name}) }}">{{ _T('see') }}</a>)
35 </td>
36 <td data-title="{{ _T('Date') }}">
37 {{ import.date }}
38 </td>
39 <td data-title="{{ _T('Size') }}">
40 {{ import.size }}
41 </td>
42 <td class="actions_row">
43 <a
44 href="{{ url_for("removeCsv", {"type": "import", "file": import.name}) }}"
45 class="delete"
46 >
47 <i class="ui trash red icon tooltip"></i>
48 <span class="ui special popup">{{ _T('Remove \'%file\' from disk')|replace({'%file': import.name}) }}</span>
49 </a>
50 </td>
51 </tr>
52 {% endfor %}
53 </tbody>
54 </table>
55 <div class="ui basic center aligned segment">
56 <div class="ui tooltip toggle checkbox" title="{{ _T('Run the import process, but do *not* store anything in the database') }}">
57 <label for="dryrun">{{ _T('Dry run') }}</label>
58 <input type="checkbox" name="dryrun" id="dryrun" value="1"{% if dryrun is defined and dryrun == true %} checked="checked"{% endif %}/>
59 </div>
60 <button type="submit" name="import" id="import" class="ui labeled icon button">
61 <i class="ui file import blue icon"></i>
62 {{ _T('Import') }}
63 </button>
64 {% include "components/forms/csrf.html.twig" %}
65 </div>
66 {% else %}
67 <p>{{ _T('No import file actually exists.') }}<br/>{{ _T('Use upload form below to send a new file on server, or copy it directly in the imports directory.') }}</p>
68 {% endif %}
69 </form>
70 </div>
71 </div>
72 </div>
73 <form class="ui form" action="{{ url_for('uploadImportFile') }}" method="post" enctype="multipart/form-data">
74 <div class="ui basic fitted segment">
75 <div class="ui styled fluid accordion row">
76 <div class="active title">
77 <i class="jsonly displaynone icon dropdown"></i>
78 {{ _T('Upload new file') }}
79 </div>
80 <div class="active content field">
81 <div class="field wide">
82 <div class="ui file action input">
83 <input type="file" name="new_file" accept="text/csv" id="new_file"/>
84 <label for="new_file" class="ui button">
85 <i class="blue file csv icon"></i>
86 {{ _T('Choose a file') }}
87 </label>
88 </div>
89 </div>
90 </div>
91 </div>
92 </div>
93 <div class="ui basic center aligned segment">
94 <div class="ui wrapping spaced buttons">
95 <button type="submit" name="upload" id="upload" class="ui primary labeled icon button">
96 <i class="upload icon" aria-hidd="true"></i>
97 {{ _T('Upload file') }}
98 </button>
99 <a
100 href="{{ url_for('importModel') }}"
101 class="ui labeled icon button"
102 >
103 <i class="cogs icon" aria-hidden="true"></i>
104 {{ _T('Configure import model') }}
105 </a>
106 {% include "components/forms/csrf.html.twig" %}
107 </div>
108 </div>
109 </form>
110 {% endblock %}
111
112 {% block javascripts %}
113 <script type="text/javascript">
114 $(function() {
115 //bind import click to check if one is selected
116 $('#import').on('click', function(){
117 if ( $('input[name=import_file]:checked').length > 0 ) {
118 return true;
119 } else {
120 {% include "elements/js/modal.js.twig" with {
121 modal_title_twig: _T("No file selected")|e("js"),
122 modal_content_twig: _T("Please make sure to select one file to import.")|e("js"),
123 modal_class: "tiny",
124 modal_deny_only: true,
125 modal_cancel_text: _T("Close")|e("js"),
126 modal_classname: "redalert",
127 } %}
128 return false;
129 }
130 });
131
132 $('#upload').click(function(){
133 var _selected = $('#new_file')[0].files.length;
134 if ( _selected == 0 ) {
135 {% include "elements/js/modal.js.twig" with {
136 modal_title_twig: _T("No file selected")|e("js"),
137 modal_content_twig: _T("Please make sure to select one file to upload.")|e("js"),
138 modal_class: "tiny",
139 modal_deny_only: true,
140 modal_cancel_text: _T("Close")|e("js"),
141 modal_classname: "redalert",
142 } %}
143 return false;
144 } else {
145 return true;
146 }
147 });
148 });
149 {% include "elements/js/removal.js.twig" with {
150 single_action: "true"
151 } %}
152 </script>
153 {% endblock %}