diff options
author | emkael <emkael@tlen.pl> | 2016-05-06 13:23:57 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-06 13:23:57 +0200 |
commit | fbc0d1f9860c7891b245acf6e31789b4cac82a58 (patch) | |
tree | 638c2e7e7435242d55b5073eb67ae11738635be7 /app | |
parent | fcc64b0d41bc9a96f7aeb6f81bc1b887a515ccb6 (diff) |
* ability to edit user calendar selection from calendar page
Diffstat (limited to 'app')
-rw-r--r-- | app/php/controls/AddToFilter.php | 41 | ||||
-rw-r--r-- | app/php/controls/AddToFilter.tpl | 8 | ||||
-rw-r--r-- | app/php/controls/scripts/AddToFilter.js | 5 | ||||
-rw-r--r-- | app/php/pages/Calendar.page | 8 |
4 files changed, 62 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); + }); +}); diff --git a/app/php/pages/Calendar.page b/app/php/pages/Calendar.page index e2d4dae..c77c2c5 100644 --- a/app/php/pages/Calendar.page +++ b/app/php/pages/Calendar.page @@ -3,4 +3,12 @@ <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl> </com:CalendarDetails> + <com:AddToFilter> + <prop:Facade><%= CalendarFacade::getInstance() %></prop:Facade> + <prop:UserToManage><%= $this->getUser() %></prop:UserToManage> + <prop:CalendarUrl><%= $this->Request->itemAt('calendar') %></prop:CalendarUrl> + <prop:Description> + calendar visible in current filter selection + </prop:Description> + </com:AddToFilter> </com:TContent> |