Added basic event-table in admin interface.
This commit is contained in:
Родитель
35e48fb6b3
Коммит
87b7bb0a71
|
@ -2,6 +2,7 @@
|
|||
@import "events/details";
|
||||
@import "events/map";
|
||||
@import "events/party";
|
||||
@import "events/admin";
|
||||
|
||||
body#events {
|
||||
* { box-sizing: border-box; }
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
body#events.admin {
|
||||
table#event-list {
|
||||
margin: 4px;
|
||||
|
||||
thead {
|
||||
td {
|
||||
font-weight: bold;
|
||||
}
|
||||
}
|
||||
tbody {
|
||||
a { .clickable }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -139,7 +139,35 @@ module.exports = function (init) {
|
|||
},
|
||||
admin: function(req, res)
|
||||
{
|
||||
res.reply('admin')
|
||||
Event.all().success(function (events) {
|
||||
res.format({
|
||||
html: function () {
|
||||
res.reply('admin', {
|
||||
events: events.map(function (event) {
|
||||
var evt = util.objMap(event, function (v, k) {
|
||||
switch(k) {
|
||||
case 'beginDate':
|
||||
case 'endDate':
|
||||
var date = new Date(v);
|
||||
return date == "Invalid Date"
|
||||
? null
|
||||
: [ date.getMonth() + 1,
|
||||
date.getDate(),
|
||||
date.getFullYear() ].join('/')
|
||||
case 'beginTime':
|
||||
case 'endTime':
|
||||
return v ? fmtTime(v) : null;
|
||||
default:
|
||||
if (SAFE_FIELDS.indexOf(k) != -1)
|
||||
return v
|
||||
}});
|
||||
evt.uri = event.uri();
|
||||
return evt;
|
||||
})
|
||||
})
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -218,15 +246,15 @@ module.exports = function (init) {
|
|||
evt = required.every(function (f) { return !blank(evt[f]) }) ? evt : null;
|
||||
return evt
|
||||
}
|
||||
function event_output_filter(event) {
|
||||
function fmtDate(x) { return new Date(x).toDateString() }
|
||||
function fmtTime(x) {
|
||||
var hms = new Date(x).toTimeString().split(' ')[0].split(':');
|
||||
var h = hms[0] % 12;
|
||||
if (h == 0) h = 12;
|
||||
return h + ':' + hms[1] + (Math.floor(hms[0] / 12) ? 'pm' : 'am');
|
||||
}
|
||||
|
||||
function fmtDate(x) { return new Date(x).toDateString() }
|
||||
function fmtTime(x) {
|
||||
var hms = new Date(x).toTimeString().split(' ')[0].split(':');
|
||||
var h = hms[0] % 12;
|
||||
if (h == 0) h = 12;
|
||||
return h + ':' + hms[1] + (Math.floor(hms[0] / 12) ? 'pm' : 'am');
|
||||
}
|
||||
function event_output_filter(event) {
|
||||
var evt = {};
|
||||
Event.fields.forEach(function (p) {
|
||||
switch(p) {
|
||||
|
|
|
@ -3,15 +3,21 @@
|
|||
{% block title %}Event Admin{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
{% set columns = [ 'id', 'title', 'beginDate', 'endDate', 'beginTime', 'endTime', 'address', 'organizerId' ] %}
|
||||
<table id="event-list">
|
||||
<thead>
|
||||
<tr>
|
||||
{% for c in [ 'id', 'title', 'beginDate', 'endDate', 'beginTime', 'endTime', 'address', 'organizerId' ] %}
|
||||
<td>{{ c }}</td>
|
||||
{% endfor %}
|
||||
</tr>
|
||||
<tr> {% for c in columns %} <td>{{ c }}</td> {% endfor %} </tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
<tbody>
|
||||
{% for event in events %}
|
||||
<tr> {% for c in columns %} <td>{{ event[c] }}</td> {% endfor %}
|
||||
<td><a data-remote="true" data-confirm="Really delete?" data-method="DELETE" href="{{ event.uri }}">
|
||||
<i class="icon-remove-sign"></i></a></td>
|
||||
<td><a href="{{ event.uri }}#edit"><i class="icon-edit-sign"></i></a></td>
|
||||
<td><a href="{{ event.uri }}"><i class="icon-chevron-sign-right"></i></a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
{% endblock %}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче