From 18af7c28471d8ea28ad50a061b7d815e710bfd7f Mon Sep 17 00:00:00 2001
From: hilgeru <hilgeru@msgn07482.int.root.msg.ag>
Date: Tue, 27 Feb 2018 14:43:52 +0000
Subject: [PATCH] SenderApi fertig

---
 src/java/de/uhilger/radiozentrale/api/SenderApi.java |   10 +++++++++-
 web/app.js                                           |   23 +++++++++++++++++------
 2 files changed, 26 insertions(+), 7 deletions(-)

diff --git a/src/java/de/uhilger/radiozentrale/api/SenderApi.java b/src/java/de/uhilger/radiozentrale/api/SenderApi.java
index 3b8616a..8937d19 100644
--- a/src/java/de/uhilger/radiozentrale/api/SenderApi.java
+++ b/src/java/de/uhilger/radiozentrale/api/SenderApi.java
@@ -18,7 +18,6 @@
 
 package de.uhilger.radiozentrale.api;
 
-import de.uhilger.baselink.GenericRecord;
 import de.uhilger.baselink.PersistenceManager;
 import de.uhilger.radiozentrale.daten.Sender;
 import de.uhilger.radiozentrale.web.Initialiser;
@@ -63,6 +62,15 @@
     return geaendert;
   }
   
+  public Sender senderLoeschen(Sender sender) {
+    Sender geloescht = null;
+    Object o = getDb().delete(sender, getMapper(Initialiser.MP_SENDER));
+    if(o instanceof Sender) {
+      geloescht = (Sender) o;
+    }
+    return geloescht;
+  }
+  
   public List senderliste() {
     return getDb().select(getSql(SQL_GET_SENDER), getMapper(Initialiser.MP_SENDER));
   }
diff --git a/web/app.js b/web/app.js
index e2a07e8..b474eb6 100644
--- a/web/app.js
+++ b/web/app.js
@@ -221,6 +221,9 @@
         */
         $('#sender-loeschen').on('click', function() {
           $('#sender-loeschen').off('click');
+          
+          app_sender_entfernen(s);
+          
           app_kachel_entfernen(s);
           app_dialog_schliessen();
           app_meldung_mit_timeout('Loeschen gewaehlt ' + s.name, 1500);
@@ -463,17 +466,25 @@
   });
 }
 
+/* SenderApi */
+
+var URL_SENDER_API = "api?c=de.uhilger.radiozentrale.api.SenderApi&m=";
+
 function app_neuen_sender_speichern(sender) {
-  var obj = serialisieren(sender);
-  var url = 'api?c=de.uhilger.radiozentrale.api.SenderApi&m=neuerSender';
-  $.post( url, 'p=' + obj, function( result ) {
-    console.log( result );
-  }, "json");
+  app_sender_api('neuerSender', sender);
 }
 
 function app_sender_aendern(sender) {
+  app_sender_api('senderAendern', sender);
+}
+
+function app_sender_entfernen(sender) {
+  app_sender_api('senderLoeschen', sender);
+}
+
+function app_sender_api(methode, sender) {
   var obj = serialisieren(sender);
-  var url = 'api?c=de.uhilger.radiozentrale.api.SenderApi&m=senderAendern';
+  var url = URL_SENDER_API + methode;
   $.post( url, 'p=' + obj, function( result ) {
     console.log( result );
   }, "json");

--
Gitblit v1.9.3