Allow to edit gas station in place
authorJoey Schulze <joey@infodrom.org>
Mon, 17 Jul 2017 21:21:22 +0000 (23:21 +0200)
committerJoey Schulze <joey@infodrom.org>
Mon, 17 Jul 2017 21:36:51 +0000 (23:36 +0200)
class/spritlog.class.php
src/InfoCon/sprit/list.wml

index 451edc4..275a427 100644 (file)
@@ -22,11 +22,11 @@ class SpritLog extends DatabaseTable {
     $total_liter = 0;
     $total_price = 0;
     foreach ($this->db->fetchObjectList($sql) as $row) {
-      $out .= sprintf('<tr id="%d"><td>%s</td><td>%s</td><td>%s</td>' .
+      $out .= sprintf('<tr id="%d"><td>%s</td><td>%s</td><td><span route="SpritLog/EditTankstelle" item_id="%d">%s</span></td>' .
                      '<td class="right">%.2f</td><td class="right">%.2f</td><td class="right">%.2f</td>' .
                      '<td class="right">%d</td><td class="right">%d</td></tr>',
                      $row->id, assert_german_date($row->date),
-                     $row->city, $row->tankstelle,
+                     $row->city, $row->id, $row->tankstelle,
                      $row->price_liter, $row->liter,$row->price,
                      $row->km, $row->km_total);
       $total_km += $row->km;
@@ -107,4 +107,10 @@ class SpritLog extends DatabaseTable {
     return array('suggestions' => $list);
   }
 
+  public function ajaxEditTankstelle(Array $data)
+  {
+    if (!strlen($data['content'])) return false;
+    return $this->modify('tankstelle', $data['content']);
+  }
+
 }
index e857fa5..3527477 100644 (file)
@@ -3,6 +3,7 @@
 <future>
 <page func=InfoCon title="Tankbuch">
 <script type="text/javascript" src="<root_prefix>jquery.autocomplete.min.js"></script>
+<script type="text/javascript" src="<root_prefix>jquery.editable.js"></script>
 <calendar_init -5>
 <popups>
 <style type="text/css">
@@ -144,6 +145,8 @@ function toggle_year(event)
 function load_year(year)
 {
     $('div#list_'+year).show();
-    $.invoke('SpritLog/List', {year: year});
+    $.invoke('SpritLog/List', {year: year}, function(data){
+       make_editable('div#list_'+year+' td span');
+    });
 }
 </script></protect>