Admin page: delete feed / project
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
<th>[#]lang:start[#]</th>
|
||||
<th>[#]lang:end[#]</th>
|
||||
<th>[#]lang:time_zone[#]</th>
|
||||
<th>[#]lang:delete[#]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@@ -29,6 +30,7 @@
|
||||
<th>[#]lang:name[#]</th>
|
||||
<th>[#]lang:status[#]</th>
|
||||
<th>[#]lang:last_update[#]</th>
|
||||
<th>[#]lang:delete[#]</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
@@ -53,11 +55,12 @@
|
||||
<script type="text/javascript">
|
||||
oSpot.pageInit = function(asHash) {
|
||||
self.get('admin_get', setProjects);
|
||||
$('#new').addInput('button', 'new', 'New Project', [{on:'click', callback:createProject}]);
|
||||
$('#new').addButton('new', 'New Project', 'new', createProject, 'main-btn');
|
||||
};
|
||||
|
||||
oSpot.onFeedback = function(sType, sMsg, asContext) {
|
||||
delete asContext.a;
|
||||
delete asContext.t;
|
||||
sMsg += ' (';
|
||||
$.each(asContext, function(sKey, sElem) {
|
||||
sMsg += sKey+'='+sElem+' / ' ;
|
||||
@@ -73,40 +76,45 @@ function setProjects(asElemTypes) {
|
||||
$.each(aoElems, function(iKey, oElem) {
|
||||
var sElemId = sElemType+'_'+oElem.id;
|
||||
var bNew = ($('#'+sElemId).length == 0);
|
||||
|
||||
|
||||
var $Elem = (bNew?$('<tr>', {'id': sElemId}):$('#'+sElemId).empty())
|
||||
.data('type', sElemType)
|
||||
.data('id', oElem.id)
|
||||
.append($('<td>').text(oElem.id || ''));
|
||||
|
||||
switch(sElemType) {
|
||||
case 'project':
|
||||
$Elem
|
||||
.append($('<td>').addInput('text', 'name', oElem.name, aoEvents))
|
||||
.append($('<td>', {'class': 'mode'}).text(oElem.mode))
|
||||
.append($('<td>').addInput('text', 'codename', oElem.codename, aoEvents))
|
||||
.append($('<td>').addInput('date', 'active_from', oElem.active_from.substr(0, 10), aoEvents))
|
||||
.append($('<td>').addInput('date', 'active_to', oElem.active_to.substr(0, 10), aoEvents))
|
||||
.append($('<td>').addInput('text', 'timezone', oElem.timezone, aoEvents));
|
||||
break;
|
||||
case 'feed':
|
||||
$Elem
|
||||
.append($('<td>').addInput('text', 'ref_feed_id', oElem.ref_feed_id, aoEvents))
|
||||
.append($('<td>').addInput('number', 'spot_id', oElem.id_spot, aoEvents))
|
||||
.append($('<td>').addInput('number', 'project_id', oElem.id_project, aoEvents))
|
||||
.append($('<td>').text(oElem.name))
|
||||
.append($('<td>').text(oElem.status))
|
||||
.append($('<td>').text(oElem.last_update));
|
||||
break;
|
||||
case 'spot':
|
||||
$Elem
|
||||
.append($('<td>').text(oElem.ref_spot_id))
|
||||
.append($('<td>').text(oElem.name))
|
||||
.append($('<td>').text(oElem.model))
|
||||
break;
|
||||
if(oElem.del) $Elem.remove();
|
||||
else {
|
||||
switch(sElemType) {
|
||||
case 'project':
|
||||
$Elem
|
||||
.append($('<td>').addInput('text', 'name', oElem.name, aoEvents))
|
||||
.append($('<td>', {'class': 'mode'}).text(oElem.mode))
|
||||
.append($('<td>').addInput('text', 'codename', oElem.codename, aoEvents))
|
||||
.append($('<td>').addInput('date', 'active_from', oElem.active_from.substr(0, 10), aoEvents))
|
||||
.append($('<td>').addInput('date', 'active_to', oElem.active_to.substr(0, 10), aoEvents))
|
||||
.append($('<td>').addInput('text', 'timezone', oElem.timezone, aoEvents))
|
||||
.append($('<td>').addButton('close fa-lg', '', 'del_proj', del));
|
||||
break;
|
||||
case 'feed':
|
||||
$Elem
|
||||
.append($('<td>').addInput('text', 'ref_feed_id', oElem.ref_feed_id, aoEvents))
|
||||
.append($('<td>').addInput('number', 'spot_id', oElem.id_spot, aoEvents))
|
||||
.append($('<td>').addInput('number', 'project_id', oElem.id_project, aoEvents))
|
||||
.append($('<td>').text(oElem.name))
|
||||
.append($('<td>').text(oElem.status))
|
||||
.append($('<td>').text(oElem.last_update))
|
||||
.append($('<td>').addButton('close fa-lg', '', 'del_feed', del));
|
||||
break;
|
||||
case 'spot':
|
||||
$Elem
|
||||
.append($('<td>').text(oElem.ref_spot_id))
|
||||
.append($('<td>').text(oElem.name))
|
||||
.append($('<td>').text(oElem.model))
|
||||
break;
|
||||
}
|
||||
|
||||
if(bNew) $Elem.appendTo($('#'+sElemType+'s').find('table tbody'));
|
||||
}
|
||||
|
||||
if(bNew) $Elem.appendTo($('#'+sElemType+'s').find('table tbody'));
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -145,4 +153,20 @@ function waitAndCommit(event) {
|
||||
if(typeof self.tmp('wait') != 'undefined') clearTimeout(self.tmp('wait'));
|
||||
self.tmp('wait', setTimeout(()=>{commit(event,$(this));}, 2000));
|
||||
}
|
||||
|
||||
function del() {
|
||||
var $Record = $(this).closest('tr');
|
||||
var asInputs = {type: $Record.data('type'), id: $Record.data('id')};
|
||||
self.get(
|
||||
'admin_del',
|
||||
function(asData){
|
||||
oSpot.onFeedback('success', self.lang('admin_save_success'), asInputs);
|
||||
setProjects(asData);
|
||||
},
|
||||
asInputs,
|
||||
function(sError){
|
||||
oSpot.onFeedback('error', sError, asInputs);
|
||||
}
|
||||
);
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user