| 1 | {{define "head"}} |
| 2 | {{/* Drag and drop only. Everything the drop zone does, the form below |
| 3 | it already does with scripting off — drop.js fills that same file |
| 4 | input and submits that same form, so there is one route, one CSRF |
| 5 | check and one code path either way. |
| 6 | |
| 7 | This moved here with the form it decorates. It used to sit on the |
| 8 | sheet list, which is where the import form used to be. */}} |
| 9 | <script defer src="{{asset "static/drop.js"}}"></script> |
| 10 | {{end}} |
| 11 | |
| 12 | {{define "content"}} |
| 13 | <header rst-page-header> |
| 14 | <div rst-page-header-titles> |
| 15 | <h1>Import a spreadsheet</h1> |
| 16 | {{/* The limits are stated BEFORE the import, not discovered after it. |
| 17 | Import reads one worksheet (xlsx.Import), and a workbook with |
| 18 | three of them would otherwise arrive looking whole — the quiet |
| 19 | kind of wrong PRODUCT.md's first principle forbids. |
| 20 | |
| 21 | They are a subhead here rather than a hint under the field |
| 22 | because this page has the room the dropdown they nearly went in |
| 23 | did not, and because drop.js overwrites the hint to speak about |
| 24 | a drop — which would take the file limits down with it. */}} |
| 25 | <p rst-page-header-sub>Excel .xlsx or .xlsm, up to 20 MB. The first |
| 26 | worksheet is imported.</p> |
| 27 | </div> |
| 28 | </header> |
| 29 | |
| 30 | {{if .Data.Error}} |
| 31 | {{/* A refusal renders HERE, on the page holding the form, rather than |
| 32 | back on the sheet list. The list is not where the person is and |
| 33 | no longer carries a form to try again with. */}} |
| 34 | <div rst-callout rst-tone="negative"> |
| 35 | <div rst-callout-body> |
| 36 | <p>{{.Data.Error}}</p> |
| 37 | </div> |
| 38 | </div> |
| 39 | {{end}} |
| 40 | |
| 41 | <form rst-form method="post" action="/sheets/import" enctype="multipart/form-data"> |
| 42 | <div data-drop> |
| 43 | <div rst-field-row> |
| 44 | <div rst-field> |
| 45 | <label rst-field-label for="file">Choose a file</label> |
| 46 | <input rst-input id="file" name="file" type="file" accept=".xlsx,.xlsm"> |
| 47 | <p rst-field-hint data-drop-hint>You can also drag a file onto this box.</p> |
| 48 | </div> |
| 49 | <button rst-btn="primary" type="submit">Import</button> |
| 50 | </div> |
| 51 | </div> |
| 52 | </form> |
| 53 | {{end}} |
| 54 | |