3
* Xibo - Digital Signage - http://www.xibo.org.uk
4
* Copyright (C) 2012-2016 Spring Signage Ltd - http://www.springsignage.com
6
* This file is part of Xibo.
8
* Xibo is free software: you can redistribute it and/or modify
9
* it under the terms of the GNU Affero General Public License as published by
10
* the Free Software Foundation, either version 3 of the License, or
13
* Xibo is distributed in the hope that it will be useful,
14
* but WITHOUT ANY WARRANTY; without even the implied warranty of
15
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
* GNU Affero General Public License for more details.
18
* You should have received a copy of the GNU Affero General Public License
19
* along with Xibo. If not, see <http://www.gnu.org/licenses/>.
24
{% extends "authed.twig" %}
25
{% import "inline.twig" as inline %}
27
{% block actionMenu %}
28
<ul class="nav nav-pills pull-right">
29
<li class="btn btn-success btn-xs"><a class="XiboFormButton btns" href="{{ urlFor("daypart.add.form") }}"><i class="fa fa-plus-circle" aria-hidden="true"></i> {% trans "Add Daypart" %}</a></li>
33
{% block pageContent %}
35
<div class="widget-title">{% trans "Dayparting" %}</div>
36
<div class="widget-body">
37
<div class="XiboGrid" id="{{ random() }}">
38
<div class="XiboFilter">
39
<div class="FilterDiv" id="Filter">
40
<form class="form-inline">
45
<div class="XiboData">
46
<table id="dayparts" class="table table-striped">
49
<th>{% trans "Name" %}</th>
50
<th>{% trans "Description" %}</th>
51
<th>{% trans "Start Time" %}</th>
52
<th>{% trans "End Time" %}</th>
66
{% block javaScript %}
67
<script type="text/javascript">
68
Handlebars.registerHelper('if_eq', function(a, b, opts) {
69
if(a == b) // Or === depending on your needs
72
return opts.inverse(this);
75
var table = $("#dayparts").DataTable({ "language": dataTablesLanguage,
76
serverSide: true, stateSave: true, stateDuration: 0,
77
stateLoadCallback: function (settings, callback) {
82
url: "{{ urlFor("user.pref") }}?preference=daypartGrid",
84
success: function (json) {
86
data = JSON.parse(json.data.value);
91
stateSaveCallback: function (settings, data) {
94
url: "{{ urlFor("user.pref") }}",
97
option: "daypartGrid",
98
value: JSON.stringify(data)
105
"order": [[ 1, "asc"]],
107
"url": "{{ urlFor("daypart.search") }}",
108
"data": function(d) {
109
$.extend(d, $("#dayparts").closest(".XiboGrid").find(".FilterDiv form").serializeObject());
113
{ "data": "name", "render": dataTableSpacingPreformatted },
114
{ "data": "description" },
115
{ "data": "startTime" },
116
{ "data": "endTime" },
119
"data": dataTableButtonsColumn
124
table.on('draw', dataTableDraw);
125
table.on('processing.dt', dataTableProcessing);
127
function dayPartFormOpen(dialog) {
128
// Render a set of exceptions
129
$exceptions = $(dialog).find("#dayPartExceptions");
131
// Days of the week translations
132
var daysOfTheWeek = [
133
{ day: "Mon", title: "{% trans "Monday" %}" },
134
{ day: "Tue", title: "{% trans "Tuesday" %}" },
135
{ day: "Wed", title: "{% trans "Wednesday" %}" },
136
{ day: "Thu", title: "{% trans "Thursday" %}" },
137
{ day: "Fri", title: "{% trans "Friday" %}" },
138
{ day: "Sat", title: "{% trans "Saturday" %}" },
139
{ day: "Sun", title: "{% trans "Sunday" %}" }
142
// Compile the handlebars template
143
var exceptionsTemplate = Handlebars.compile($("#dayPartExceptionsTemplate").html());
145
if (dialog.data().extra.exceptions.length == 0) {
146
// Contexts for template
148
daysOfWeek: daysOfTheWeek,
149
buttonGlyph: "fa-plus",
157
$exceptions.append(exceptionsTemplate(context));
159
XiboInitialise("#" + $exceptions.prop("id"));
161
// For each of the existing exceptions, create form components
163
$.each(dialog.data().extra.exceptions, function (index, field) {
167
daysOfWeek: daysOfTheWeek,
168
buttonGlyph: ((i == 1) ? "fa-plus" : "fa-minus"),
169
exceptionDay: field.day,
170
exceptionStart: field.start,
171
exceptionEnd: field.end,
175
$exceptions.append(exceptionsTemplate(context));
177
XiboInitialise("#" + $exceptions.prop("id"));
181
// Nabble the resulting buttons
182
$exceptions.on("click", "button", function (e) {
186
if ($(this).find("i").hasClass("fa-plus")) {
188
daysOfWeek: daysOfTheWeek,
189
buttonGlyph: "fa-minus",
193
fieldId: $exceptions.find('.form-group').length + 1
196
$exceptions.append(exceptionsTemplate(context));
198
XiboInitialise("#" + $exceptions.prop("id"));
201
$(this).closest(".form-group").remove();
207
<script type="text/x-handlebars-template" id="dayPartExceptionsTemplate">
208
<div class="form-group">
209
<div class="col-sm-3">
210
<select class="form-control" name="exceptionDay[]">
211
<option value=""></option>
213
<option value="{{ day }}" {{#if_eq day ../exceptionDay}}selected{{/if_eq}}>{{ title }}</option>
217
<div class="col-sm-3">
218
<input type="hidden" name="exceptionStartTimes[]" id="exceptionStartTimes_{{ fieldId }}" value="{{ exceptionStart }}" />
219
<input class="form-control timePicker dateControl" name="exceptionStartTimesLink_{{ fieldId }}" type="text" id="exceptionStartTimesLink_{{ fieldId }}" data-link-field="exceptionStartTimes_{{ fieldId }}" data-link-format="hh:ii"/>
221
<div class="col-sm-3">
222
<input type="hidden" name="exceptionEndTimes[]" id="exceptionEndTimes_{{ fieldId }}" value="{{ exceptionEnd }}" />
223
<input class="form-control timePicker dateControl" name="exceptionEndTimesLink_{{ fieldId }}" type="text" id="exceptionEndTimesLink_{{ fieldId }}" data-link-field="exceptionEndTimes_{{ fieldId }}" data-link-format="hh:ii"/>
225
<div class="col-sm-1">
226
<button class="btn btn-default btn-sm"><i class="fa {{ buttonGlyph }}"></i></button>
b'\\ No newline at end of file'