Move upload fields out of pgwui_common
authorKarl O. Pinc <kop@karlpinc.com>
Tue, 30 Jul 2024 23:30:04 +0000 (18:30 -0500)
committerKarl O. Pinc <kop@karlpinc.com>
Tue, 30 Jul 2024 23:30:04 +0000 (18:30 -0500)
Inheriting templates call "main_form" and initiate execution

src/pgwui_upload_core/templates/upload.mak

index 6a8f6ed73adc3afbb6d4cad0d14da8aa7e907049..16c584df96275fb51193a60894a27e8035253019 100644 (file)
     from pgwui_upload_core.template_utils import show_choice
     from pgwui_common.path import asset_abspath
 
-    auth_base_mak = asset_abspath('pgwui_common:templates/auth_base.mak')
+    db_base_mak = asset_abspath('pgwui_common:templates/db_base.mak')
 %>
 
-<%inherit file="${auth_base_mak}" />
+<%inherit file="${db_base_mak}" />
 
 <%block name="title">${pgwui['upload_settings']['menu_label']}</%block>
 
+<%def name="format_row(tab_index)">
+  <tr>
+    <td class="label">Uploaded Data Format:</td>
+    <td>
+      <input name="upload_fmt"
+             id="upload_fmt_csv_id"
+             tabindex="${tab_index.val}"
+             type="radio"
+             value="${csv_value}"
+             ${csv_checked | n}
+             />
+      <label class="label" for="upload_fmt_csv_id">CSV</label>
+      <br />
+      <input name="upload_fmt"
+             id="upload_fmt_tab_id"
+             tabindex="${tab_index.val + 1}"
+             type="radio"
+             value="${tab_value}"
+             ${tab_checked | n}
+             />
+      <label class="label" for="upload_fmt_tab_id">Tab delimited</label>
+    </td>
+  </tr>
+  <% tab_index.inc(2) %>
+</%def>
+
+<%def name="nulls_row(tab_index)">
+  % if show_choice(pgwui, 'null'):
+    <tr>
+      <td class="label">
+        <label for="upload_null_id">Upload NULL Values: </label>
+      </td>
+      <td>
+        <input name="upload_null"
+               id="upload_null_id"
+               tabindex="${tab_index.val}"
+               type="checkbox"
+               ${upload_null | n}
+               />
+      </td>
+    </tr>
+    <tr>
+      <td class="label">
+        <label for="null_rep_id">NULL Representation: </label>
+      </td>
+      <td>
+        <input name="null_rep"
+               id="null_rep_id"
+               tabindex="${tab_index.val + 1}"
+               type="text"
+               size="10"
+               value="${null_rep}"
+               />
+      </td>
+    </tr>
+    <% tab_index.inc(2) %>
+  % endif
+</%def>
+
+<%def name="file_row(tab_index)">
+  <tr>
+    <td class="label">
+      <label for="datafile_id">
+        File to upload:
+      </label>
+    </td>
+    <td colspan="2">
+      <input name="datafile"
+             tabindex="${tab_index.val}"
+             id="datafile_id"
+             type="file"
+             size="75"
+             />
+    </td>
+  </tr>
+  <% tab_index.inc() %>
+</%def>
+
 <%def name="trim_row(tab_index)">
   % if show_choice(pgwui, 'trim'):
       <tr>
   % endif
 </%def>
 
-<%self:upload_form args="tab_index">
-  <%parent:upload_form args="tab_index">
+<%def name="main_form(tab_index)">
+  <%parent:main_form tab_index="${tab_index}" args="tab_index">
     <%
     caller.body(tab_index)
+    format_row(tab_index)
+    nulls_row(tab_index)
     trim_row(tab_index)
     literal_row(tab_index)
+    file_row(tab_index)
     %>
-  </%parent:upload_form>
-</%self:upload_form>
+  </%parent:main_form>
+</%def>