1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-10 05:02:36 +01:00

Right align number and center statuses in data tables

This commit is contained in:
Hillel Coren 2016-12-25 23:43:57 +02:00
parent 7b4df952f4
commit a7858a8561
7 changed files with 50 additions and 8 deletions

View File

@ -64,4 +64,30 @@ class EntityDatatable
return $data;
}
public function rightAlignIndices()
{
return $this->alignIndices(['amount', 'balance', 'cost']);
}
public function centerAlignIndices()
{
return $this->alignIndices(['status']);
}
public function alignIndices($fields)
{
$columns = $this->columnFields();
$indices = [];
foreach ($columns as $index => $column) {
if (in_array($column, $fields)) {
$indices[] = $index + 1;
}
}
return $indices;
}
}

View File

@ -98,7 +98,7 @@ class PaymentDatatable extends EntityDatatable
}
],
[
'payment_status_name',
'status',
function ($model) {
return self::getStatusLabel($model);
}
@ -140,7 +140,7 @@ class PaymentDatatable extends EntityDatatable
private function getStatusLabel($model)
{
$label = trans('texts.status_' . strtolower($model->payment_status_name));
$label = trans('texts.status_' . strtolower($model->status));
$class = 'default';
switch ($model->payment_status_id) {
case PAYMENT_STATUS_PENDING:

View File

@ -62,7 +62,7 @@ class PaymentRepository extends BaseRepository
'invoices.is_deleted as invoice_is_deleted',
'gateways.name as gateway_name',
'gateways.id as gateway_id',
'payment_statuses.name as payment_status_name'
'payment_statuses.name as status'
);
$this->applyFilters($query, ENTITY_PAYMENT);

View File

@ -2225,7 +2225,6 @@ $LANG = array(
'vendor_name' => 'Vendor',
'entity_state' => 'State',
'payment_status_name' => 'Status',
'client_created_at' => 'Date Created',
'postmark_error' => 'There was a problem sending the email through Postmark: :link',
'project' => 'Project',

View File

@ -219,6 +219,7 @@
->setUrl(url('api/activities/'. $client->public_id))
->setCustomValues('entityType', 'activity')
->setCustomValues('clientId', $client->public_id)
->setCustomValues('rightAlign', [2, 3])
->setOptions('sPaginationType', 'bootstrap')
->setOptions('bFilter', false)
->setOptions('aaSorting', [['0', 'desc']])

View File

@ -59,19 +59,19 @@
}
},
"bAutoWidth": false,
@if (isset($hasCheckboxes) && $hasCheckboxes)
// Disable sorting on the first column
"aoColumnDefs": [
@if (isset($hasCheckboxes) && $hasCheckboxes)
// Disable sorting on the first column
{
'bSortable': false,
'aTargets': [ 0, {{ count($columns) - 1 }} ]
},
@endif
{
'sClass': 'right',
'aTargets': {{ isset($values['rightAlign']) ? json_encode($values['rightAlign']) : '[]' }}
}
],
@endif
@foreach ($options as $k => $o)
{!! json_encode($k) !!}: {!! json_encode($o) !!},
@endforeach

View File

@ -65,7 +65,6 @@
{!! Datatable::table()
->addColumn(Utils::trans($datatable->columnFields(), $datatable->entityType))
->setUrl(url('api/' . Utils::pluralizeEntityType($entityType) . '/' . (isset($clientId) ? $clientId : (isset($vendorId) ? $vendorId : ''))))
->setCustomValues('rightAlign', isset($rightAlign) ? $rightAlign : [])
->setCustomValues('entityType', Utils::pluralizeEntityType($entityType))
->setCustomValues('clientId', isset($clientId) && $clientId)
->setOptions('sPaginationType', 'bootstrap')
@ -108,6 +107,23 @@
{!! Former::close() !!}
<style type="text/css">
@foreach ($datatable->rightAlignIndices() as $index)
.listForm_{{ $entityType }} table.dataTable td:nth-child({{ $index }}) {
text-align: right;
}
@endforeach
@foreach ($datatable->centerAlignIndices() as $index)
.listForm_{{ $entityType }} table.dataTable td:nth-child({{ $index }}) {
text-align: center;
}
@endforeach
</style>
<script type="text/javascript">
function submitForm_{{ $entityType }}(action, id) {