diff options
author | emkael <emkael@tlen.pl> | 2016-05-13 16:16:40 +0200 |
---|---|---|
committer | emkael <emkael@tlen.pl> | 2016-05-13 16:16:40 +0200 |
commit | 2bc5a4cc767b582b8a5cc5de5667c3687ec236a0 (patch) | |
tree | dc298c0a8a953618c3c2c2a5c5be0f7016ed4a50 /app/php/controls | |
parent | 3ed90e8e054c4ad73017de3b2e23a79726487661 (diff) |
* calendar grid display control
Diffstat (limited to 'app/php/controls')
-rw-r--r-- | app/php/controls/CalendarGrid.php | 59 | ||||
-rw-r--r-- | app/php/controls/CalendarGrid.tpl | 28 | ||||
-rw-r--r-- | app/php/controls/styles/CalendarGrid.css | 16 |
3 files changed, 103 insertions, 0 deletions
diff --git a/app/php/controls/CalendarGrid.php b/app/php/controls/CalendarGrid.php new file mode 100644 index 0000000..4ebfacd --- /dev/null +++ b/app/php/controls/CalendarGrid.php @@ -0,0 +1,59 @@ +<?php + +Prado::using('Application.web.FacadeTemplateControl'); +Prado::using('Application.facades.EventFacade'); +Prado::using('Application.user.DbUser'); + +class CalendarGrid extends FacadeTemplateControl { + + public function setMonth($month) { + $this->setControlState('Month', $month); + } + + public function getMonth() { + return $this->getControlState('Month'); + } + + public function setYear($year) { + $this->setControlState('Year', $year); + } + + public function getYear() { + return $this->getControlState('Year'); + } + + public function setUserToDisplay(DbUser $user) { + $this->setControlState('User', $user); + } + + public function getUserToDisplay() { + return $this->getControlState('User'); + } + + private function _getGrid() { + return $this->getFacade()->getCalendarListForUser( + $this->UserToDisplay, + $this->Month, + $this->Year + ); + } + + public function onPreRender($param) { + parent::onPreRender($param); + $this->Weeks->DataSource = $this->_getGrid()->Weeks; + $this->Weeks->dataBind(); + } + + public function weekDataBind($sender, $param) { + $param->Item->Days->DataSource = $param->Item->Data; + $param->Item->Days->dataBind(); + } + + public function dayDataBind($sender, $param) { + $param->Item->Events->DataSource = $param->Item->Data->Events; + $param->Item->Events->dataBind(); + } + +} + +?> diff --git a/app/php/controls/CalendarGrid.tpl b/app/php/controls/CalendarGrid.tpl new file mode 100644 index 0000000..2b3ada8 --- /dev/null +++ b/app/php/controls/CalendarGrid.tpl @@ -0,0 +1,28 @@ +<com:TRepeater ID="Weeks" OnItemDataBound="weekDataBind"> + <prop:ItemTemplate> + <div class="gridWeek"> + <com:TRepeater ID="Days" OnItemDataBound="SourceTemplateControl.dayDataBind"> + <prop:ItemTemplate> + <div class="gridDay"> + <%# $this->Data->Date %> + <com:TRepeater ID="Events"> + <prop:ItemTemplate> + <com:TConditional Condition="$this->Data"> + <prop:TrueTemplate> + <com:THtmlElement TagName="div"> + <prop:CssClass>gridEvent <%# $this->Parent->Parent->Data->Date == $this->Data->DateFrom ? 'beginDate' : '' %> <%# $this->Parent->Parent->Data->Date == $this->Data->DateTo ? 'endDate' : '' %></prop:CssClass> + <%# $this->Data->Name %> + </com:THtmlElement> + </prop:TrueTemplate> + <prop:FalseTemplate> + <div class="gridItem"> </div> + </prop:FalseTemplate> + </com:TConditional> + </prop:ItemTemplate> + </com:TRepeater> + </div> + </prop:ItemTemplate> + </com:TRepeater> + </div> + </prop:ItemTemplate> +</com:TRepeater> diff --git a/app/php/controls/styles/CalendarGrid.css b/app/php/controls/styles/CalendarGrid.css new file mode 100644 index 0000000..4710993 --- /dev/null +++ b/app/php/controls/styles/CalendarGrid.css @@ -0,0 +1,16 @@ +div.gridWeek { + clear: both; + display: flex; + flex-flow: row nowrap; +} +div.gridDay { + width: 14%; + min-height: 8em; + flex: 1 1 auto; +} +div.gridEvent, div.gridItem { height: 1.5em; padding: 0.3em 0.5em; margin: 0.1em 0; } +div.gridEvent { overflow: hidden; white-space: nowrap; background: #ddd } +div.gridEvent.beginDate { border-top-left-radius: 1.5em; + border-bottom-left-radius: 1.5em } +div.gridEvent.endDate { border-top-right-radius: 1.5em; + border-bottom-right-radius: 1.5em } |