1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-09 20:52:56 +01:00

Refactoring datatable code

This commit is contained in:
Hillel Coren 2015-11-06 01:14:00 +02:00
parent d147dba542
commit 002c994c0b
9 changed files with 29 additions and 10 deletions

View File

@ -51,7 +51,7 @@ class ClientController extends BaseController
'entityType' => ENTITY_CLIENT,
'title' => trans('texts.clients'),
'sortCol' => '4',
'columns' => Utils::trans(['checkbox', 'client', 'contact', 'email', 'date_created', 'last_login', 'balance', 'action']),
'columns' => Utils::trans(['checkbox', 'client', 'contact', 'email', 'date_created', 'last_login', 'balance', '']),
));
}

View File

@ -37,7 +37,7 @@ class CreditController extends BaseController
'entityType' => ENTITY_CREDIT,
'title' => trans('texts.credits'),
'sortCol' => '4',
'columns' => Utils::trans(['checkbox', 'client', 'credit_amount', 'credit_balance', 'credit_date', 'private_notes', 'action']),
'columns' => Utils::trans(['checkbox', 'client', 'credit_amount', 'credit_balance', 'credit_date', 'private_notes', '']),
));
}

View File

@ -69,7 +69,7 @@ class InvoiceController extends BaseController
'balance_due',
'due_date',
'status',
'action'
''
]),
];

View File

@ -46,7 +46,7 @@ class PaymentController extends BaseController
return View::make('list', array(
'entityType' => ENTITY_PAYMENT,
'title' => trans('texts.payments'),
'columns' => Utils::trans(['checkbox', 'invoice', 'client', 'transaction_reference', 'method', 'payment_amount', 'payment_date', 'action']),
'columns' => Utils::trans(['checkbox', 'invoice', 'client', 'transaction_reference', 'method', 'payment_amount', 'payment_date', '']),
));
}

View File

@ -43,7 +43,7 @@ class TaskController extends BaseController
'entityType' => ENTITY_TASK,
'title' => trans('texts.tasks'),
'sortCol' => '2',
'columns' => Utils::trans(['checkbox', 'client', 'date', 'duration', 'description', 'status', 'action']),
'columns' => Utils::trans(['checkbox', 'client', 'date', 'duration', 'description', 'status', '']),
));
}

View File

@ -150,8 +150,10 @@ class Utils
foreach ($input as $field) {
if ($field == "checkbox") {
$data[] = $field;
} else {
} elseif ($field) {
$data[] = trans("texts.$field");
} else {
$data[] = '';
}
}

View File

@ -40,8 +40,18 @@ class DatatableService
private function createDropdown($entityType, $table, $actions)
{
$table->addColumn('dropdown', function ($model) use ($entityType, $actions) {
$str = '<div class="btn-group tr-action" style="visibility:hidden;">
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown">
$str = '';
if (property_exists($model, 'is_deleted') && $model->is_deleted) {
$str .= '<button type="button" class="btn btn-sm btn-danger tr-status" style="display:inline-block; width:80px">'.trans('texts.deleted').'</button>';
} elseif ($model->deleted_at && $model->deleted_at !== '0000-00-00') {
$str .= '<button type="button" class="btn btn-sm btn-warning tr-status" style="display:inline-block; width:80px">'.trans('texts.archived').'</button>';
} else {
$str .= '<div class="tr-status" style="display:inline-block; width:80px"></div>';
}
$str .= '<div class="btn-group tr-action" style="display:none;">
<button type="button" class="btn btn-xs btn-default dropdown-toggle" data-toggle="dropdown" style="width:80px">
'.trans('texts.select').' <span class="caret"></span>
</button>
<ul class="dropdown-menu" role="menu">';

View File

@ -906,4 +906,6 @@ return array(
'deleted_recurring_invoice' => 'Successfully deleted recurring invoice',
'restore_recurring_invoice' => 'Restore Recurring Invoice',
'restored_recurring_invoice' => 'Successfully restored recurring invoice',
'archived' => 'Archived',
);

View File

@ -135,12 +135,17 @@
});
$('tbody tr').mouseover(function() {
$(this).closest('tr').find('.tr-action').css('visibility', 'visible');
$(this).closest('tr').find('.tr-action').css('display', 'inline-block');
$(this).closest('tr').find('.tr-status').css('display', 'none');
}).mouseout(function() {
//$(this).closest('tr').find('.tr-action').css('display', 'none');
$dropdown = $(this).closest('tr').find('.tr-action');
if (!$dropdown.hasClass('open')) {
$dropdown.css('visibility', 'hidden');
$dropdown.css('display', 'none');
$(this).closest('tr').find('.tr-status').css('display', 'inline-block');
}
});
}