Sortieren von Einheiten auf Drag-n-Drop & AJAX mittels jQuery UI Sortable umgestellt
[kivitendo-erp.git] / templates / webpages / am / edit_units.html
index ddc9539..4d3b3e3 100644 (file)
@@ -1,5 +1,9 @@
-[%- USE T8 %][%- USE LxERP %]
-[% USE HTML %]<body>
+[%- USE T8 %][%- USE LxERP %][% USE L %]
+[% USE HTML %]
+
+<script type="text/javascript" src="js/jquery-ui.js"></script>
+
+<body>
 
  [% IF saved_message %]
   <p>[% saved_message %]</p>
   [% 'You can declare different translations for singular and plural for each unit (e.g. &quot;day&quot; and &quot;days).' | $T8 %]
  </p>
 
- <table>
+ <table id="unit_list">
+  <thead>
   <tr class="listheading">
-   <th width="32" align="center" valign="center"><img alt="[% 'up' | $T8 %]" src="image/up.png"><img alt="[% 'down' | $T8 %]" src="image/down.png"></th>
+   <th align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></th>
    <th>[% 'Delete' | $T8 %]</th>
    <th>[% 'Unit' | $T8 %]</th>
    <th>[% 'Base unit' | $T8 %]</th>
     <th>[% language.description %]</th>
    [% END %]
   </tr>
+  </thead>
 
+  <tbody>
   [% FOREACH row = UNITS %]
-   <tr class="listrow[% loop.count % 2 %]">
-    <td width="32" align="center" valign="center">[% IF loop.first %]<img src="image/transparent16x16.gif">[% ELSE %]<a href="[% updownlink %]&dir=up&name=[% HTML.url(row.name) %]"><img alt="[% 'up' | $T8 %]" src="image/up.png" border="0"></a>[% END %][% IF loop.last %]<img src="image/transparent16x16.gif">[% ELSE %]<a href="[% updownlink %]&dir=down&name=[% HTML.url(row.name) %]"><img alt="[% 'down' | $T8 %]" src="image/down.png" border="0"></a>[% END %]</td>
+   <tr class="listrow[% loop.count % 2 %]" id="unit_id_[% row.id %]">
+    <td align="center"><img src="image/updown.png" alt="[ LxERP.t8('reorder item') %]"></td>
     [% IF row.in_use %]
      <td>
       <input type="hidden" name="unchangeable_[% loop.count %]" value="1">
      </td>
     [% END %]
    </tr>
-
-   [% IF loop.last %]<input type="hidden" name="rowcount" value="[% loop.count %]">[% END %]
   [% END %]
+  </tbody>
  </table>
 
+ <input type="hidden" name="rowcount" value="[% UNITS.size %]">
+
  <input type="submit" class="submit" name="action" value="[% 'Save' | $T8 %]">
 
  </form>
 
+ [% L.sortable_element('#unit_list tbody', 'url' => 'controller.pl?action=Unit/reorder', 'with' => 'unit_id') %]
+
 </body>
 </html>