komponente finished

This commit is contained in:
darthsandmann 2017-01-17 16:57:36 +01:00
parent d87d70c980
commit 4552aa346a
20 changed files with 156 additions and 51 deletions

View File

@ -64,7 +64,6 @@ class Projekt_cl(object):
retVal_o['data'] = adjustId_p(id, data_o) retVal_o['data'] = adjustId_p(id, data_o)
return retVal_o return retVal_o
#return json.dumps(retVal_o)
#------------------------------------------------------- #-------------------------------------------------------
def PUT(self, data_opl): def PUT(self, data_opl):
@ -190,12 +189,14 @@ class Komponente_cl(object):
def __init__(self): def __init__(self):
#------------------------------------------------------- #-------------------------------------------------------
self.db_o = KomponenteDatabase_cl() self.db_o = KomponenteDatabase_cl()
self.dbProjekt_o = ProjektDatabase_cl()
#------------------------------------------------------- #-------------------------------------------------------
def GET(self): def GET(self, id = None):
#------------------------------------------------------- #-------------------------------------------------------
retVal_o = { retVal_o = {
'data': None 'data': None,
'projekt': None
} }
if id == None: if id == None:
# Anforderung der Liste # Anforderung der Liste
@ -206,23 +207,74 @@ class Komponente_cl(object):
if data_o != None: if data_o != None:
retVal_o['data'] = adjustId_p(id, data_o) retVal_o['data'] = adjustId_p(id, data_o)
retVal_o['projekt'] = self.dbProjekt_o.read_px()
return retVal_o return retVal_o
#return json.dumps(retVal_o)
#------------------------------------------------------- #-------------------------------------------------------
def PUT(self): def PUT(self, data_opl):
#------------------------------------------------------- #-------------------------------------------------------
return json.dumps(retVal_o) # Sichern der Daten: jetzt wird keine vollständige Seite
# zurückgeliefert, sondern nur noch die Information, ob das
# Speichern erfolgreich war
retVal_o = {
'id': None
}
# data_opl: Dictionary mit den gelieferten key-value-Paaren
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
id_s = data_opl["id_s"]
data_o = {
'name': data_opl["name_s"],
'id': data_opl["id_s"],
'projekt-id': data_opl["projekt-id_s"]
}
# Update-Operation
retVal_o['id'] = id_s
if self.db_o.update_px(id_s, data_o):
pass
else:
retVal_o['id'] = None
return retVal_o
#------------------------------------------------------- #-------------------------------------------------------
def POST(self): def POST(self, data_opl):
#------------------------------------------------------- #-------------------------------------------------------
return json.dumps(retVal_o) retVal_o = {
'id': None
}
# data_opl: Dictionary mit den gelieferten key-value-Paaren
# hier müsste man prüfen, ob die Daten korrekt vorliegen!
data_o = {
'name': data_opl["name_s"],
'projekt-id': data_opl["projekt-id_s"]
}
# Create-Operation
id_s = self.db_o.create_px(data_o)
retVal_o['id'] = id_s
return retVal_o
#------------------------------------------------------- #-------------------------------------------------------
def DELETE(self): def DELETE(self, id):
#------------------------------------------------------- #-------------------------------------------------------
return json.dumps(retVal_o) # Eintrag löschen, nur noch Rückmeldung liefern
retVal_o = {
'id': id
}
if self.db_o.delete_px(id):
pass
else:
retVal_o['id'] = None
return retVal_o
# EOF # EOF

View File

@ -0,0 +1,5 @@
{
"name": "Komponente1",
"projekt-id": "3",
"id": "1"
}

View File

@ -0,0 +1,5 @@
{
"name": "Komponente2",
"projekt-id": "3",
"id": "2"
}

View File

@ -0,0 +1,5 @@
{
"name": "Komponente3",
"projekt-id": "4",
"id": "3"
}

View File

@ -0,0 +1,5 @@
{
"name": "Komponente4",
"projekt-id": "5",
"id": "4"
}

View File

@ -0,0 +1,5 @@
{
"name": "Komponente5",
"projekt-id": "6",
"id": "5"
}

View File

@ -1 +1 @@
0 6

View File

@ -0,0 +1,4 @@
{
"name": "Projekt4",
"id": "4"
}

View File

@ -0,0 +1,4 @@
{
"name": "Projekt5",
"id": "5"
}

View File

@ -0,0 +1,4 @@
{
"name": "Projekt6",
"id": "6"
}

View File

@ -0,0 +1,4 @@
{
"name": "Projekt7",
"id": "7"
}

View File

@ -1 +1 @@
3 7

View File

@ -24,6 +24,9 @@ APP.Application_cl = class {
this.listProjekt_o = new APP.ListView_cl('projekt', '/projekt/', 'projektlist.tpl'); this.listProjekt_o = new APP.ListView_cl('projekt', '/projekt/', 'projektlist.tpl');
this.detailProjekt_o = new APP.DetailView_cl('projekt', '/projekt/', 'projektdetail.tpl'); this.detailProjekt_o = new APP.DetailView_cl('projekt', '/projekt/', 'projektdetail.tpl');
this.listKomponente_o = new APP.ListView_cl('komponente', '/komponente/', 'komponentelist.tpl');
this.detailKomponente_o = new APP.DetailView_cl('komponente', '/komponente/', 'komponentedetail.tpl');
// this.listSources_o = new APP.ListView_cl('source', '/source/', 'sourceslist.tpl'); // this.listSources_o = new APP.ListView_cl('source', '/source/', 'sourceslist.tpl');
// this.detailSources_o = new APP.SourceDetailView_cl('source', '/source/', 'sourcedetail.tpl'); // this.detailSources_o = new APP.SourceDetailView_cl('source', '/source/', 'sourcedetail.tpl');
// this.listEvaluated_o = new APP.ListView_cl('evaluated', '/evaluated/', 'evaluatedlist.tpl'); // this.listEvaluated_o = new APP.ListView_cl('evaluated', '/evaluated/', 'evaluatedlist.tpl');
@ -55,6 +58,17 @@ APP.Application_cl = class {
// Detailformular im Content-Bereich anzeigen // Detailformular im Content-Bereich anzeigen
self_opl.setContent_p(self_opl.detailProjekt_o, data_apl[1]); self_opl.setContent_p(self_opl.detailProjekt_o, data_apl[1]);
break; break;
case 'komponente':
self_opl.setContent_p(self_opl.listKomponente_o, data_apl[1]);
break;
case 'komponente.add':
// (leeres) Detailformular im Content-Bereich anzeigen
self_opl.setContent_p(self_opl.detailKomponente_o, data_apl[1]);
break;
case 'komponente.edit':
// Detailformular im Content-Bereich anzeigen
self_opl.setContent_p(self_opl.detailKomponente_o, data_apl[1]);
break;
default: default:
console.warn('[Application_cl] unbekannte app-Notification: '+data_apl[0]); console.warn('[Application_cl] unbekannte app-Notification: '+data_apl[0]);
break; break;

View File

@ -38,6 +38,7 @@ APP.DetailView_cl = class {
context: this context: this
}) })
.done(function (data_opl) { .done(function (data_opl) {
console.log(data_opl);
this.doRender_p(data_opl); this.doRender_p(data_opl);
this.initHandler_p(); this.initHandler_p();
}) })

Binary file not shown.

View File

@ -1,28 +0,0 @@
<!-- Template -->
<form id="idForm" class="clContent">
<h2 id="idContentHeader" class="clContentHeader">
Literaturauswertung / Formular
</h2>
<div id="idContentArea" class="clContentArea">
<input type="hidden" value="#context.data.id#" id="id_s" name="id_s" />
<div class="clFormRow">
<label for="title_s">Titel <span class="clRequired"></span></label>
<input type="text" value="#context.data.title#" id="title_s" name="title_s" autofocus required />
</div>
<div class="clFormRow">
<label for="author_s">Autor <span class="clRequired"></span></label>
<input type="text" value="#context.data.author#" id="author_s" name="author_s" required />
</div>
<div class="clFormRow">
<label for="evalyear_s">Jahr de Auswertung</label>
<input type="url" value="#context.data.evalyear#" id="evalyear_s" name="evalyear_s" />
</div>
</div>
<div id="idButtonArea" class="clButtonArea">
<button data-action="back" class="clButton">Zurück</button>
<button data-action="save" class="clButton">Speichern</button>
</div>
</form>
<!-- EOF -->

View File

@ -1,7 +1,7 @@
<!-- Template --> <!-- Template -->
<form id="idForm" class="clContent"> <form id="idForm" class="clContent">
<h2 id="idContentHeader" class="clContentHeader"> <h2 id="idContentHeader" class="clContentHeader">
Literatur- / Quellenverzeichnis / Formular Pflege Komponenten
</h2> </h2>
<div id="idContentArea" class="clContentArea"> <div id="idContentArea" class="clContentArea">
@ -10,16 +10,16 @@
<label for="name_s">Name <span class="clRequired"></span></label> <label for="name_s">Name <span class="clRequired"></span></label>
<input type="text" value="#context.data.name#" id="name_s" name="name_s" autofocus required /> <input type="text" value="#context.data.name#" id="name_s" name="name_s" autofocus required />
</div> </div>
<div class="clFormRow">
<label for="typ_s">Typ <span class="clRequired"></span></label>
<input type="text" value="#context.data.typ#" id="typ_s" name="typ_s" required />
</div>
<div class="clFormRow">
<label for="referenz_s">Referenz</label>
<input type="url" value="#context.data.referenz#" id="referenz_s" name="referenz_s" />
</div>
</div> <label for="projekt-id_s">Projekt <span class="clRequired"></span></label>
<select name="projekt-id_s">
@var rows_o = context['projekt'];@
@for var key_s in rows_o@
@var row_o = rows_o[key_s];@
<option value="#key_s#">#row_o['name']#</option>
@endfor@
</select>
<div id="idButtonArea" class="clButtonArea"> <div id="idButtonArea" class="clButtonArea">
<button data-action="back" class="clButton">Zurück</button> <button data-action="back" class="clButton">Zurück</button>
<button data-action="save" class="clButton">Speichern</button> <button data-action="save" class="clButton">Speichern</button>

View File

@ -0,0 +1,25 @@
<!-- Template -->
<div id="idListContent" class="clContent">
<h2 id="idContentHeader" class="clContentHeader">
Pflege Komponenten
</h2>
<div id="idContentArea" class="clContentArea">
<table id="idList">
<tr class="listheader"><th>Name</th><th>ID</th><th>Projekt-ID</th></tr>
@var rows_o = context['data'];@
@for var key_s in rows_o@
<tr id='#key_s#'>
@var row_o = rows_o[key_s];@
<td>#row_o['name']#</td><td>#row_o['id']#</td><td>#row_o['projekt-id']#</td>
</tr>
@endfor@
</table>
</div>
<div id="idButtonArea" class="clButtonArea">
<button data-action="add" class="clButton">Hinzufügen</button>
<button data-action="edit" class="clButton">Bearbeiten</button>
<button data-action="delete" class="clButton">Löschen</button>
</div>
</div>
<!-- EOF -->

View File

@ -1,4 +1,4 @@
curl \ curl \
--request GET \ --request GET \
-D- \ -D- \
http://localhost:8080 http://localhost:8080/komponente