From fbc0d1f9860c7891b245acf6e31789b4cac82a58 Mon Sep 17 00:00:00 2001 From: emkael Date: Fri, 6 May 2016 13:23:57 +0200 Subject: * ability to edit user calendar selection from calendar page --- app/php/controls/AddToFilter.php | 41 +++++++++++++++++++++++++++++++++ app/php/controls/AddToFilter.tpl | 8 +++++++ app/php/controls/scripts/AddToFilter.js | 5 ++++ app/php/pages/Calendar.page | 8 +++++++ 4 files changed, 62 insertions(+) create mode 100644 app/php/controls/AddToFilter.php create mode 100644 app/php/controls/AddToFilter.tpl create mode 100644 app/php/controls/scripts/AddToFilter.js 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 @@ +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 @@ + + <%= !$this->UserToManage->IsGuest %> + <%= $this->User->isCalendarPreferred($this->getCalendar()->ID) %> + <%= $this->UserToManage->IsGuest ? 'log in to manage your selections' : '' %> + + + <%= $this->getDescription() %> + 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 @@ <%= CalendarFacade::getInstance() %> <%= $this->Request->itemAt('calendar') %> + + <%= CalendarFacade::getInstance() %> + <%= $this->getUser() %> + <%= $this->Request->itemAt('calendar') %> + + calendar visible in current filter selection + + -- cgit v1.2.3