summaryrefslogtreecommitdiff
path: root/app/php/controls
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-09 10:37:30 +0200
committeremkael <emkael@tlen.pl>2016-05-09 12:38:03 +0200
commitbd9ca1eea24cfa98c0bcbea1ee546d131d5c10c1 (patch)
tree5b6cc479f6a34a35eaa8afa8f027b75d19347e60 /app/php/controls
parent92e7aa7f13390e80c6f12f3be5676b80670b7728 (diff)
* group filter control for calendars
Diffstat (limited to 'app/php/controls')
-rw-r--r--app/php/controls/CalendarGroupFilter.php21
-rw-r--r--app/php/controls/CalendarGroupFilter.tpl16
-rw-r--r--app/php/controls/scripts/CalendarGroupFilter.js29
3 files changed, 66 insertions, 0 deletions
diff --git a/app/php/controls/CalendarGroupFilter.php b/app/php/controls/CalendarGroupFilter.php
new file mode 100644
index 0000000..6f19bcd
--- /dev/null
+++ b/app/php/controls/CalendarGroupFilter.php
@@ -0,0 +1,21 @@
+<?php
+
+Prado::using('Application.web.FacadeTemplateControl');
+
+Prado::using('Application.facades.CalendarFacade');
+
+class CalendarGroupFilter extends FacadeTemplateControl {
+
+ public function onPreRender($param) {
+ parent::onPreRender($param);
+ $this->Categories->DataSource = $this->Facade->getCategories();
+ $this->Categories->dataBind();
+ }
+
+ public function getPradoScriptDependencies() {
+ return ['jquery'];
+ }
+
+}
+
+?>
diff --git a/app/php/controls/CalendarGroupFilter.tpl b/app/php/controls/CalendarGroupFilter.tpl
new file mode 100644
index 0000000..e9ae79a
--- /dev/null
+++ b/app/php/controls/CalendarGroupFilter.tpl
@@ -0,0 +1,16 @@
+<com:TRepeater ID="Categories">
+ <prop:HeaderTemplate>
+ <div class="selectAllGroups">
+ All
+ <com:TCheckBox CssClass="box" Checked="True" />
+ </div>
+ </prop:HeaderTemplate>
+ <prop:ItemTemplate>
+ <div class="selectGroup">
+ <%# $this->Data->Name %>
+ <com:TCheckBox CssClass="box" Checked="True">
+ <prop:Value><%# $this->Data->ID %></prop:Value>
+ </com:TCheckBox>
+ </div>
+ </prop:ItemTemplate>
+</com:TRepeater>
diff --git a/app/php/controls/scripts/CalendarGroupFilter.js b/app/php/controls/scripts/CalendarGroupFilter.js
new file mode 100644
index 0000000..e6c1d73
--- /dev/null
+++ b/app/php/controls/scripts/CalendarGroupFilter.js
@@ -0,0 +1,29 @@
+$(document).on('ready', function() {
+ var selectBoxes = $('.selectGroup input.box');
+ var selectAllBox = $('.selectAllGroups input.box');
+ selectBoxes.on('change', function() {
+ var groups = [];
+ var allSelected = true;
+ $('.selectGroup input.box').each(function() {
+ var box = $(this);
+ if (box.is(':checked')) {
+ groups.push(box.val());
+ } else {
+ allSelected = false;
+ }
+ });
+ if (allSelected) {
+ selectAllBox.prop('checked', true);
+ } else {
+ selectAllBox.removeAttr('checked');
+ }
+ $(document).trigger('Application.calendarGroupFilterChanged', {groups: groups});
+ });
+ selectAllBox.on('change', function() {
+ if ($(this).is(':checked')) {
+ selectBoxes.prop('checked', true).trigger('change');
+ } else {
+ selectBoxes.removeAttr('checked').trigger('change');
+ }
+ });
+});