mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-07-09 03:14:30 -04:00
Refactor presenters
This commit is contained in:
parent
ffd7e7bdc6
commit
0f37d5f618
@ -335,4 +335,15 @@ class EntityModel extends Eloquent
|
||||
|
||||
return $class::getStatuses($entityType);
|
||||
}
|
||||
|
||||
public function statusClass()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
public function statusLabel()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -29,15 +29,16 @@ class EntityPresenter extends Presenter
|
||||
|
||||
if ($this->entity->is_deleted) {
|
||||
$class = 'danger';
|
||||
$text = trans('texts.deleted');
|
||||
$label = trans('texts.deleted');
|
||||
} elseif ($this->entity->trashed()) {
|
||||
$class = 'warning';
|
||||
$text = trans('texts.archived');
|
||||
$label = trans('texts.archived');
|
||||
} else {
|
||||
return '';
|
||||
$class = $this->entity->statusClass();
|
||||
$label = $this->entity->statusLabel();
|
||||
}
|
||||
|
||||
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$text}</span>";
|
||||
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$label}</span>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -34,19 +34,4 @@ class ExpensePresenter extends EntityPresenter
|
||||
return $this->entity->expense_category ? $this->entity->expense_category->name : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function statusLabel()
|
||||
{
|
||||
if ($label = parent::statusLabel()) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
$class = $this->entity->statusClass();
|
||||
$label = $this->entity->statusLabel();
|
||||
|
||||
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$label}</span>";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -90,18 +90,6 @@ class InvoicePresenter extends EntityPresenter {
|
||||
}
|
||||
}
|
||||
|
||||
public function statusLabel()
|
||||
{
|
||||
if ($label = parent::statusLabel()) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
$class = $this->entity->statusClass();
|
||||
$label = $this->entity->statusLabel();
|
||||
|
||||
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$label}</span>";
|
||||
}
|
||||
|
||||
public function invoice_date()
|
||||
{
|
||||
return Utils::fromSqlDate($this->entity->invoice_date);
|
||||
|
@ -27,16 +27,4 @@ class PaymentPresenter extends EntityPresenter {
|
||||
return $this->entity->payment_type->name;
|
||||
}
|
||||
}
|
||||
|
||||
public function statusLabel()
|
||||
{
|
||||
if ($label = parent::statusLabel()) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
$class = $this->entity->statusClass();
|
||||
$label = $this->entity->statusLabel();
|
||||
|
||||
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$label}</span>";
|
||||
}
|
||||
}
|
||||
|
@ -57,20 +57,4 @@ class TaskPresenter extends EntityPresenter
|
||||
return implode("\n", $times);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function statusLabel()
|
||||
{
|
||||
if ($label = parent::statusLabel()) {
|
||||
return $label;
|
||||
}
|
||||
|
||||
$class = $this->entity->statusClass();
|
||||
$label = $this->entity->statusLabel();
|
||||
|
||||
return "<span style=\"font-size:13px\" class=\"label label-{$class}\">{$label}</span>";
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user