From e44ed0d9811b0c53b3288c54d15e2f68b8d650ed Mon Sep 17 00:00:00 2001
From: ulrich
Date: Fri, 09 Apr 2021 14:09:45 +0000
Subject: [PATCH] Entitaetslisten vereinheitlicht
---
www/ui/js/app.js | 95 +++++++++++++++++++++++++++++++++++++++--------
1 files changed, 79 insertions(+), 16 deletions(-)
diff --git a/www/ui/js/app.js b/www/ui/js/app.js
index 7a903d3..6c6d41b 100644
--- a/www/ui/js/app.js
+++ b/www/ui/js/app.js
@@ -105,25 +105,43 @@
}
};
- this.addSelectedTitel = function() {
- var elem = document.querySelector(".selected");
- var titelName = elem.textContent;
- var album = elem.attributes.album.nodeValue;
- var interpret = elem.attributes.interpret.nodeValue;
- var anzName = elem.attributes.titelAnzName.nodeValue;
- var titel;
- if(self.mediaPfad.endsWith('/')) {
- titel = new Titel(titelName, self.mediaPfad, self.ortPfad, interpret, anzName, album);
- } else {
- titel = new Titel(titelName, self.mediaPfad + '/', self.ortPfad, interpret, anzName, album);
- }
- var plname = document.querySelector('#playlist').value;
- self.http_put('../api/alist/' + plname, JSON.stringify(titel), function(responseText) {
- self.meldung_mit_timeout(responseText, 1500);
+ /*
+ * url: '../api/store/Ablageort/liste/'
+ * tpl: "data/tpl/ablageort_liste.tpl"
+ * storeUrl: '../api/store/Ablageort/'
+ * formFunc: "self.ablageort_form"
+ * cb: etwas wie
+ *
+ * function(responseText){
+ * var ablageort = JSON.parse(responseText);
+ * self.ablageort_form(ablageort);
+ * });
+ */
+ this.entitaet_liste = function(listUrl, tpl, storeUrl, formFunc, cb) {
+ self.reset_top_buttons();
+ self.http_get(listUrl, function (responseText) {
+ self.vorlage_laden_und_fuellen(tpl, JSON.parse(responseText), function (html) {
+ document.querySelector(".zentraler-inhalt").innerHTML = html;
+ self.addEvtListener('.entity-eintrag', 'click', function (event) {
+ var t = event.target;
+ self.http_get(storeUrl + t.textContent, cb);
+ });
+ //self.addEvtListener('#neu-btn', 'click', function (event) {
+ self.addEvtListener('#top-neu-btn', 'click', function(event) {
+ eval(formFunc + "(this)");
+ });
+ });
});
};
-
+
this.ablageort_liste = function() {
+ self.entitaet_liste('../api/store/Ablageort/liste/',
+ "data/tpl/ablageort_liste.tpl", '../api/store/Ablageort/',
+ "self.ablageort_form", function(responseText) {
+ var ablageort = JSON.parse(responseText);
+ self.ablageort_form(ablageort);
+ });
+ /*
self.reset_top_buttons();
self.http_get('../api/store/Ablageort/liste/', function (responseText) {
self.vorlage_laden_und_fuellen("data/tpl/ablageort_liste.tpl", JSON.parse(responseText), function (html) {
@@ -141,9 +159,17 @@
});
});
});
+ */
};
this.prefs_liste = function() {
+ self.entitaet_liste('../api/store/Einstellung/liste/',
+ "data/tpl/einstellung_liste.tpl", '../api/store/Einstellung/',
+ "self.prefs_form", function(responseText) {
+ var einstellung = JSON.parse(responseText);
+ self.prefs_form(einstellung);
+ });
+ /*
self.reset_top_buttons();
self.http_get('../api/store/Einstellung/liste/', function (responseText) {
self.vorlage_laden_und_fuellen("data/tpl/einstellung_liste.tpl", JSON.parse(responseText), function (html) {
@@ -160,9 +186,17 @@
});
});
});
+ */
};
this.abspieler_liste = function() {
+ self.entitaet_liste('../api/store/Abspieler/liste/',
+ "data/tpl/abspieler_liste.tpl", '../api/store/Abspieler/',
+ "self.abspieler_form", function(responseText) {
+ var abspieler = JSON.parse(responseText);
+ self.abspieler_form(abspieler);
+ });
+ /*
self.http_get('../api/store/Abspieler/liste/', function (responseText) {
self.vorlage_laden_und_fuellen("data/tpl/abspieler_liste.tpl", JSON.parse(responseText), function (html) {
document.querySelector(".zentraler-inhalt").innerHTML = html;
@@ -179,9 +213,17 @@
});
});
});
+ */
};
this.abspielliste_liste = function() {
+ self.entitaet_liste('../api/store/Abspielliste/liste/',
+ "data/tpl/abspielliste_liste.tpl", '../api/store/Abspielliste/',
+ "self.abspielliste_form", function(responseText) {
+ var abspielliste = JSON.parse(responseText);
+ self.abspielliste_form(abspielliste);
+ });
+ /*
self.http_get('../api/store/Abspielliste/liste/', function (responseText) {
self.vorlage_laden_und_fuellen("data/tpl/abspielliste_liste.tpl", JSON.parse(responseText), function (html) {
document.querySelector(".zentraler-inhalt").innerHTML = html;
@@ -197,6 +239,7 @@
});
});
});
+ */
};
/* -------------------- Entitaets-Formulare ------------------ */
@@ -207,6 +250,7 @@
const form = document.querySelector('form');
form.addEventListener('submit', function(event) {
self.handle_submit(event, al.name, '../api/store/Abspielliste/', '#abspielliste-name', function() {
+ self.abspielliste_auswahl_fuellen();
self.abspielliste_liste();
});
});
@@ -230,6 +274,7 @@
const form = document.querySelector('form');
form.addEventListener('submit', function(event) {
self.handle_submit(event, pl.key, '../api/store/Abspieler/', '#abspieler-name', function() {
+ self.abspieler_auswahl_fuellen();
self.abspieler_liste();
});
});
@@ -324,6 +369,24 @@
});
};
+ this.addSelectedTitel = function() {
+ var elem = document.querySelector(".selected");
+ var titelName = elem.textContent;
+ var album = elem.attributes.album.nodeValue;
+ var interpret = elem.attributes.interpret.nodeValue;
+ var anzName = elem.attributes.titelAnzName.nodeValue;
+ var titel;
+ if(self.mediaPfad.endsWith('/')) {
+ titel = new Titel(titelName, self.mediaPfad, self.ortPfad, interpret, anzName, album);
+ } else {
+ titel = new Titel(titelName, self.mediaPfad + '/', self.ortPfad, interpret, anzName, album);
+ }
+ var plname = document.querySelector('#playlist').value;
+ self.http_put('../api/alist/' + plname, JSON.stringify(titel), function(responseText) {
+ self.meldung_mit_timeout(responseText, 1500);
+ });
+ };
+
/* Unterer Einblendbereich */
this.dialog_unten_zeigen = function() {
--
Gitblit v1.9.3