Ejemplo n.º 1
0
 /**
  * @inheritdoc
  */
 public function contentTemplate($model)
 {
     $contentTemplate = ['descriptor' => ['class' => 'list-group-item-heading expanded-pre', 'tag' => 'h5']];
     $contentTemplate[] = ['settings' => ['class' => 'expanded-only list-group-label-block'], function ($widget, $model, $settings) {
         $parts = [];
         $parent = null;
         foreach ($model->objectTypeItem->parents as $parentRelationship) {
             if ($parentRelationship->parent->systemId === 'Individual') {
                 continue;
             }
             $parent = $model->getForeignField('parent:' . $parentRelationship->parent->systemId, [], $this->getContext());
             if (!empty($parent)) {
                 break;
             }
         }
         if (!empty($parent)) {
             $parts[] = Html::tag('span', $parent->model->objectType->title->upperSingular, ['class' => 'list-group-sub-label']);
             $parts[] = Html::tag('span', $parent->model->viewLink, ['class' => 'list-group-sub-value']);
         } else {
             $parts[] = Html::tag('span', 'Assigned To', ['class' => 'list-group-sub-label']);
             $assigned = $widget->getItemFieldValue($model, 'parent:Individual:viewLink:assignee', []);
             if (empty($assigned)) {
                 $parts[] = Html::tag('span', '<span class="empty">no one</span>', ['class' => 'list-group-sub-value']);
             } else {
                 $parts[] = Html::tag('span', $assigned, ['class' => 'list-group-sub-value']);
             }
         }
         return implode($parts);
     }, function ($widget, $model, $settings) {
         $parts = [];
         $parts[] = Html::tag('span', 'Deferred Date', ['class' => 'list-group-sub-label']);
         if (empty($model->start)) {
             $parts[] = Html::tag('span', '<span class="empty">none set</span>', ['class' => 'list-group-sub-value']);
         } else {
             $parts[] = Html::tag('span', $model->start, ['class' => 'list-group-sub-value']);
         }
         return implode($parts);
     }, function ($widget, $model, $settings) {
         $parts = [];
         $parts[] = Html::tag('span', 'Due Date', ['class' => 'list-group-sub-label']);
         $valueOptions = ['class' => 'list-group-sub-value'];
         if ($model->isDueToday()) {
             Html::addCssClass($valueOptions, 'text-warning');
         } elseif ($model->isPassedDue()) {
             Html::addCssClass($valueOptions, 'text-danger');
         }
         if (empty($model->end)) {
             $parts[] = Html::tag('span', '<span class="empty">none set</span>', ['class' => 'list-group-sub-value']);
         } else {
             $parts[] = Html::tag('span', $model->end, $valueOptions);
         }
         return implode($parts);
     }];
     return $contentTemplate;
 }
Ejemplo n.º 2
0
 /**
  * @inheritdoc
  */
 public function contentTemplate($model)
 {
     $template = ['descriptor' => ['class' => 'list-group-item-heading', 'tag' => 'h5'], 'description' => ['class' => 'list-group-item-text']];
     $row = ['settings' => ['class' => 'expanded-only list-group-label-block']];
     $context = $this->getContext();
     $row[] = function ($widget, $model, $settings) {
         $parts = [];
         $parent = null;
         foreach ($model->objectTypeItem->parents as $parentRelationship) {
             if ($parentRelationship->parent->systemId === 'Individual') {
                 continue;
             }
             if ($parentRelationship->parent->systemId === 'Invoice') {
                 continue;
             }
             $parent = $model->getForeignField('parent:' . $parentRelationship->parent->systemId, [], $this->getContext());
             if (!empty($parent)) {
                 break;
             }
         }
         if (!empty($parent)) {
             $parts[] = Html::tag('span', $parent->model->objectType->title->upperSingular, ['class' => 'list-group-sub-label']);
             $parts[] = Html::tag('span', $parent->model->viewLink, ['class' => 'list-group-sub-value']);
         } else {
             $parts[] = Html::tag('span', 'Contributor', ['class' => 'list-group-sub-label']);
             $contributor = $widget->getItemFieldValue($model, 'parent:Individual:viewLink:contributor', []);
             if (empty($contributor)) {
                 $parts[] = Html::tag('span', '<span class="empty">no one</span>', ['class' => 'list-group-sub-value']);
             } else {
                 $parts[] = Html::tag('span', $contributor, ['class' => 'list-group-sub-value']);
             }
         }
         return implode($parts);
     };
     if (!isset($context['relation']) || !in_array('parent:Invoice', $context['relation'])) {
         $row[] = function ($widget, $model, $settings) {
             $parts = [];
             $parts[] = Html::tag('span', 'Invoice', ['class' => 'list-group-sub-label']);
             $invoice = $widget->getItemFieldValue($model, 'parent:Invoice:viewLink', []);
             if (empty($invoice)) {
                 $parts[] = Html::tag('span', '<span class="empty">none</span>', ['class' => 'list-group-sub-value']);
             } else {
                 $parts[] = Html::tag('span', $invoice, ['class' => 'list-group-sub-value']);
             }
             return implode($parts);
         };
     } else {
         $row[] = function ($widget, $model, $settings) {
             $parts = [];
             $parts[] = Html::tag('span', 'Contributor', ['class' => 'list-group-sub-label']);
             $contributor = $widget->getItemFieldValue($model, 'parent:Individual:viewLink:contributor', []);
             if (empty($contributor)) {
                 $parts[] = Html::tag('span', '<span class="empty">none</span>', ['class' => 'list-group-sub-value']);
             } else {
                 $parts[] = Html::tag('span', $contributor, ['class' => 'list-group-sub-value']);
             }
             return implode($parts);
         };
     }
     $template[] = $row;
     if ($model->can('read')) {
         return $template;
     } else {
         return ['descriptor' => ['class' => 'list-group-item-heading', 'tag' => 'h5']];
     }
 }