summaryrefslogtreecommitdiff
path: root/app/php/controls
diff options
context:
space:
mode:
authoremkael <emkael@tlen.pl>2016-05-06 13:23:57 +0200
committeremkael <emkael@tlen.pl>2016-05-06 13:23:57 +0200
commitfbc0d1f9860c7891b245acf6e31789b4cac82a58 (patch)
tree638c2e7e7435242d55b5073eb67ae11738635be7 /app/php/controls
parentfcc64b0d41bc9a96f7aeb6f81bc1b887a515ccb6 (diff)
* ability to edit user calendar selection from calendar page
Diffstat (limited to 'app/php/controls')
-rw-r--r--app/php/controls/AddToFilter.php41
-rw-r--r--app/php/controls/AddToFilter.tpl8
-rw-r--r--app/php/controls/scripts/AddToFilter.js5
3 files changed, 54 insertions, 0 deletions
diff --git a/app/php/controls/AddToFilter.php b/app/php/controls/AddToFilter.php
new file mode 100644
index 0000000..9146f3b
--- /dev/null
+++ b/app/php/controls/AddToFilter.php
@@ -0,0 +1,41 @@
+<?php
+
+Prado::using('System.Web.UI.ActiveControls.TActiveCheckBox');
+
+class AddToFilter extends UrlBasedCalendarControl {
+
+ public function setDescription($val) {
+ $this->setViewState('Description', TPropertyValue::ensureString($val));
+ }
+
+ public function getDescription() {
+ return $this->getViewState('Description');
+ }
+
+ public function setUserPreference($sender, $param) {
+ $user = $this->getUserToManage();
+ if ($user && !$user->IsGuest) {
+ if ($sender->Checked) {
+ $this->getFacade()->addToPreference($user, $this->getCalendar()->ID);
+ } else {
+ $this->getFacade()->removeFromPreference($user, $this->getCalendar()->ID);
+ }
+ $this->Page->CallbackClient->jQuery($this->Box, 'removeAttr', 'disabled');
+ }
+ }
+
+ public function getUserToManage() {
+ return $this->getControlState('user');
+ }
+
+ public function setUserToManage($user) {
+ $this->setControlState('user', $user);
+ }
+
+ public function getPradoScriptDependencies() {
+ return ['jquery'];
+ }
+
+}
+
+?>
diff --git a/app/php/controls/AddToFilter.tpl b/app/php/controls/AddToFilter.tpl
new file mode 100644
index 0000000..0c38584
--- /dev/null
+++ b/app/php/controls/AddToFilter.tpl
@@ -0,0 +1,8 @@
+<com:TActiveCheckBox ID="Box" OnCheckedChanged="setUserPreference" CssClass="addToFilterBox">
+ <prop:Enabled><%= !$this->UserToManage->IsGuest %></prop:Enabled>
+ <prop:Checked><%= $this->User->isCalendarPreferred($this->getCalendar()->ID) %></prop:Checked>
+ <prop:ToolTip><%= $this->UserToManage->IsGuest ? 'log in to manage your selections' : '' %></prop:ToolTip>
+</com:TActiveCheckBox>
+<com:TLabel ForControl="Box">
+ <prop:Text><%= $this->getDescription() %></prop:Text>
+</com:TLabel>
diff --git a/app/php/controls/scripts/AddToFilter.js b/app/php/controls/scripts/AddToFilter.js
new file mode 100644
index 0000000..e6d7b39
--- /dev/null
+++ b/app/php/controls/scripts/AddToFilter.js
@@ -0,0 +1,5 @@
+$(document).on('ready', function() {
+ $('input.addToFilterBox').on('change', function() {
+ $(this).attr('disabled', true);
+ });
+});