| 1 |
<?php if (! defined('ABSPATH')) exit; // Exit if accessed directly |
| 2 |
#[AllowDynamicProperties] |
| 3 |
class SH4_Calendars_Html_Admin_View_Edit |
| 4 |
{ |
| 5 |
public function __construct( |
| 6 |
HC3_Hooks $hooks, |
| 7 |
HC3_Ui $ui, |
| 8 |
HC3_Ui_Layout1 $layout, |
| 9 |
SH4_Calendars_Query $query |
| 10 |
) |
| 11 |
{ |
| 12 |
$this->ui = $ui; |
| 13 |
$this->layout = $layout; |
| 14 |
$this->self = $hooks->wrap($this); |
| 15 |
$this->query = $hooks->wrap($query); |
| 16 |
} |
| 17 |
|
| 18 |
public function render( $id ) |
| 19 |
{ |
| 20 |
$model = $this->query->findById( $id ); |
| 21 |
|
| 22 |
$form = $this->ui->makeForm( |
| 23 |
'admin/calendars/' . $id, |
| 24 |
$this->self->form($model) |
| 25 |
); |
| 26 |
|
| 27 |
$this->layout |
| 28 |
->setContent( $form ) |
| 29 |
->setBreadcrumb( $this->self->breadcrumb($model) ) |
| 30 |
->setHeader( $this->self->header($model) ) |
| 31 |
; |
| 32 |
|
| 33 |
$out = $this->layout->render(); |
| 34 |
return $out; |
| 35 |
} |
| 36 |
|
| 37 |
public function header( $model ) |
| 38 |
{ |
| 39 |
$out = '__Edit__'; |
| 40 |
return $out; |
| 41 |
} |
| 42 |
|
| 43 |
public function breadcrumb( $model ) |
| 44 |
{ |
| 45 |
$return = array(); |
| 46 |
$return['admin'] = array( 'admin', '__Administration__' ); |
| 47 |
$return['calendars'] = array( 'admin/calendars', '__Calendars__' ); |
| 48 |
return $return; |
| 49 |
} |
| 50 |
|
| 51 |
public function form( $model ) |
| 52 |
{ |
| 53 |
$inputs = array(); |
| 54 |
$idView = $model->getId(); |
| 55 |
|
| 56 |
$idLabel = $this->ui->makeBlock('id') |
| 57 |
->tag('mute') |
| 58 |
->tag('font-size', 2) |
| 59 |
; |
| 60 |
$idView = $this->ui->makeListInline( array($idLabel, $idView) ) |
| 61 |
->gutter(1) |
| 62 |
; |
| 63 |
|
| 64 |
$inputs[] = $idView; |
| 65 |
$inputs[] = $this->ui->makeInputText( 'title', '__Title__', $model->getTitle() )->bold(); |
| 66 |
$inputs[] = $this->ui->makeInputRichTextarea( 'description', '__Description__', $model->getDescription() )->setRows(6); |
| 67 |
|
| 68 |
$typeOptions = array( |
| 69 |
SH4_Calendars_Model::TYPE_SHIFT => '__Shift__', |
| 70 |
SH4_Calendars_Model::TYPE_TIMEOFF => '__Time Off__', |
| 71 |
// SH4_Calendars_Model::TYPE_AVAILABILITY => '__Availability__', |
| 72 |
); |
| 73 |
|
| 74 |
// if( ! $this->availability->hasAvailability() ){ |
| 75 |
// $typeOptions[SH4_Calendars_Model::TYPE_AVAILABILITY] = '__Availability__'; |
| 76 |
// } |
| 77 |
|
| 78 |
$typeView = $this->ui->makeInputRadioSet( 'calendar_type', '__Type__', $typeOptions, $model->getType() ); |
| 79 |
// $typeView = $typeOptions[ $model->getType() ]; |
| 80 |
// $typeView = $this->ui->makeLabelled( '__Type__', $typeView ); |
| 81 |
$inputs[] = $typeView; |
| 82 |
|
| 83 |
$inputs[] = $this->ui->makeInputColorpicker( 'color', '__Color__', $model->getColor() ); |
| 84 |
|
| 85 |
$inputs = $this->ui->makeList( $inputs ); |
| 86 |
|
| 87 |
$buttons = $this->ui->makeInputSubmit( '__Save__') |
| 88 |
->tag('primary') |
| 89 |
; |
| 90 |
|
| 91 |
$out = $this->ui->makeList( array($inputs, $buttons) ); |
| 92 |
|
| 93 |
return $out; |
| 94 |
} |
| 95 |
} |