Ejemplo n.º 1
0
 public function getSortBy()
 {
     $dummyModel = $this->owner->dummyModel;
     $descriptorField = $dummyModel->descriptorField;
     if (is_array($descriptorField)) {
         $descriptorLabel = $dummyModel->getAttributeLabel('descriptor');
     } else {
         $descriptorLabel = $dummyModel->getAttributeLabel($descriptorField);
     }
     $alias = $dummyModel->tableName();
     $defaultOrder = $dummyModel->getDefaultOrder($alias);
     $sortBy = parent::getSortBy();
     $sortBy['start'] = ['label' => $dummyModel->getAttributeLabel('start'), 'asc' => array_merge([$alias . '.[[start]]' => SORT_ASC], $defaultOrder), 'desc' => array_merge([$alias . '.[[start]]' => SORT_DESC], $defaultOrder)];
     $sortBy['end'] = ['label' => $dummyModel->getAttributeLabel('end'), 'asc' => array_merge([$alias . '.[[end]]' => SORT_ASC], $defaultOrder), 'desc' => array_merge([$alias . '.[[end]]' => SORT_DESC], $defaultOrder)];
     $sortBy['cost'] = ['label' => $dummyModel->getAttributeLabel('cost'), 'asc' => array_merge([$alias . '.[[cost]]' => SORT_ASC], $defaultOrder), 'desc' => array_merge([$alias . '.[[cost]]' => SORT_DESC], $defaultOrder)];
     $sortBy['revenue'] = ['label' => $dummyModel->getAttributeLabel('revenue'), 'asc' => array_merge([$alias . '.[[revenue]]' => SORT_ASC], $defaultOrder), 'desc' => array_merge([$alias . '.[[revenue]]' => SORT_DESC], $defaultOrder)];
     $sortBy['number'] = ['label' => $dummyModel->getAttributeLabel('number'), 'asc' => array_merge([$alias . '.[[number]]' => SORT_ASC], $defaultOrder), 'desc' => array_merge([$alias . '.[[number]]' => SORT_DESC], $defaultOrder)];
     return $sortBy;
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function getMenuItems($model, $key, $index)
 {
     $base = parent::getMenuItems($model, $key, $index);
     $base['map'] = ['icon' => 'fa fa-globe', 'label' => 'View map', 'url' => StringHelper::parseText(Yii::$app->params['helperUrls']['map'], ['object' => $model]), 'linkOptions' => ['target' => '_blank']];
     return $base;
 }
Ejemplo n.º 3
0
 /**
  * @inheritdoc
  */
 public function contentTemplate($model)
 {
     $template = parent::contentTemplate($model);
     $template['note'] = ['class' => 'expanded-only expanded-pre list-group-label-block'];
     return $template;
 }
Ejemplo n.º 4
0
 /**
  * @inheritdoc
  */
 public function renderItemContent($model, $key, $index)
 {
     $descriptorContent = parent::renderItemContent($model, $key, $index);
     $parts = [];
     $parts[] = Html::beginTag('div', ['class' => 'ic-task-item row']);
     $parts[] = Html::beginTag('div', ['class' => 'col-xs-1']);
     $fields = $model->getFields();
     $radioOptions = [];
     $relatedObject = null;
     if (isset(Yii::$app->request->object) && Yii::$app->request->object->primaryKey !== $model->primaryKey) {
         $relatedObject = Yii::$app->request->object;
     }
     if (!$model->can('update')) {
         $radioOptions['disabled'] = true;
     } elseif (!Html::prepareEditInPlace($radioOptions, $model, 'completedStatus', $relatedObject)) {
         $radioOptions['disabled'] = true;
     }
     $radioOptions['uncheckedValue'] = 0;
     $title = 'Task has not been completed';
     if (!empty($model->completed)) {
         $title = 'Task was completed on ' . $model->completed;
     }
     $radioOptions['title'] = $title;
     Html::addCssClass($radioOptions, 'taskCompletedStatus');
     $parts[] = Html::checkbox($fields['completedStatus']->formField->getModelFieldName(), !empty($model->completedStatus), $radioOptions);
     $parts[] = Html::endTag('div');
     $parts[] = Html::beginTag('div', ['class' => 'col-xs-10 expandable-child']);
     $parts[] = $descriptorContent;
     $parts[] = Html::endTag('div');
     $parts[] = Html::endTag('div');
     return implode("", $parts);
 }