mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-24 10:49:00 +02:00
Removed useless permissions checks, as the permissions are now always granted automatically, if the user has read access to parts
This commit is contained in:
parent
185c88fa3e
commit
470df57f58
1 changed files with 49 additions and 64 deletions
|
@ -123,29 +123,20 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||||
])
|
])
|
||||||
->add('description', MarkdownColumn::class, [
|
->add('description', MarkdownColumn::class, [
|
||||||
'label' => $this->translator->trans('part.table.description'),
|
'label' => $this->translator->trans('part.table.description'),
|
||||||
]);
|
])
|
||||||
|
->add('category', EntityColumn::class, [
|
||||||
if ($this->security->isGranted('@categories.read')) {
|
|
||||||
$this->csh->add('category', EntityColumn::class, [
|
|
||||||
'label' => $this->translator->trans('part.table.category'),
|
'label' => $this->translator->trans('part.table.category'),
|
||||||
'property' => 'category',
|
'property' => 'category',
|
||||||
]);
|
])
|
||||||
}
|
->add('footprint', EntityColumn::class, [
|
||||||
|
|
||||||
if ($this->security->isGranted('@footprints.read')) {
|
|
||||||
$this->csh->add('footprint', EntityColumn::class, [
|
|
||||||
'property' => 'footprint',
|
'property' => 'footprint',
|
||||||
'label' => $this->translator->trans('part.table.footprint'),
|
'label' => $this->translator->trans('part.table.footprint'),
|
||||||
]);
|
])
|
||||||
}
|
->add('manufacturer', EntityColumn::class, [
|
||||||
if ($this->security->isGranted('@manufacturers.read')) {
|
|
||||||
$this->csh->add('manufacturer', EntityColumn::class, [
|
|
||||||
'property' => 'manufacturer',
|
'property' => 'manufacturer',
|
||||||
'label' => $this->translator->trans('part.table.manufacturer'),
|
'label' => $this->translator->trans('part.table.manufacturer'),
|
||||||
]);
|
])
|
||||||
}
|
->add('storelocation', TextColumn::class, [
|
||||||
if ($this->security->isGranted('@storelocations.read')) {
|
|
||||||
$this->csh->add('storelocation', TextColumn::class, [
|
|
||||||
'label' => $this->translator->trans('part.table.storeLocations'),
|
'label' => $this->translator->trans('part.table.storeLocations'),
|
||||||
'orderField' => 'storelocations.name',
|
'orderField' => 'storelocations.name',
|
||||||
'render' => function ($value, Part $context): string {
|
'render' => function ($value, Part $context): string {
|
||||||
|
@ -165,66 +156,60 @@ final class PartsDataTable implements DataTableTypeInterface
|
||||||
|
|
||||||
return implode('<br>', $tmp);
|
return implode('<br>', $tmp);
|
||||||
},
|
},
|
||||||
], alias: 'storage_location');
|
], alias: 'storage_location')
|
||||||
}
|
->add('amount', TextColumn::class, [
|
||||||
|
'label' => $this->translator->trans('part.table.amount'),
|
||||||
|
'render' => function ($value, Part $context) {
|
||||||
|
$amount = $context->getAmountSum();
|
||||||
|
$expiredAmount = $context->getExpiredAmountSum();
|
||||||
|
|
||||||
$this->csh->add('amount', TextColumn::class, [
|
$ret = '';
|
||||||
'label' => $this->translator->trans('part.table.amount'),
|
|
||||||
'render' => function ($value, Part $context) {
|
|
||||||
$amount = $context->getAmountSum();
|
|
||||||
$expiredAmount = $context->getExpiredAmountSum();
|
|
||||||
|
|
||||||
$ret = '';
|
if ($context->isAmountUnknown()) {
|
||||||
|
//When all amounts are unknown, we show a question mark
|
||||||
if ($context->isAmountUnknown()) {
|
if ($amount === 0.0) {
|
||||||
//When all amounts are unknown, we show a question mark
|
$ret .= sprintf('<b class="text-primary" title="%s">?</b>',
|
||||||
if ($amount === 0.0) {
|
$this->translator->trans('part_lots.instock_unknown'));
|
||||||
$ret .= sprintf('<b class="text-primary" title="%s">?</b>',
|
} else { //Otherwise mark it with greater equal and the (known) amount
|
||||||
$this->translator->trans('part_lots.instock_unknown'));
|
$ret .= sprintf('<b class="text-primary" title="%s">≥</b>',
|
||||||
} else { //Otherwise mark it with greater equal and the (known) amount
|
$this->translator->trans('part_lots.instock_unknown')
|
||||||
$ret .= sprintf('<b class="text-primary" title="%s">≥</b>',
|
);
|
||||||
$this->translator->trans('part_lots.instock_unknown')
|
$ret .= htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
|
||||||
);
|
}
|
||||||
|
} else {
|
||||||
$ret .= htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
|
$ret .= htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
$ret .= htmlspecialchars($this->amountFormatter->format($amount, $context->getPartUnit()));
|
|
||||||
}
|
|
||||||
|
|
||||||
//If we have expired lots, we show them in parentheses behind
|
//If we have expired lots, we show them in parentheses behind
|
||||||
if ($expiredAmount > 0) {
|
if ($expiredAmount > 0) {
|
||||||
$ret .= sprintf(' <span title="%s" class="text-muted">(+%s)</span>',
|
$ret .= sprintf(' <span title="%s" class="text-muted">(+%s)</span>',
|
||||||
$this->translator->trans('part_lots.is_expired'),
|
$this->translator->trans('part_lots.is_expired'),
|
||||||
htmlspecialchars($this->amountFormatter->format($expiredAmount, $context->getPartUnit())));
|
htmlspecialchars($this->amountFormatter->format($expiredAmount, $context->getPartUnit())));
|
||||||
}
|
}
|
||||||
|
|
||||||
//When the amount is below the minimum amount, we highlight the number red
|
//When the amount is below the minimum amount, we highlight the number red
|
||||||
if ($context->isNotEnoughInstock()) {
|
if ($context->isNotEnoughInstock()) {
|
||||||
$ret = sprintf('<b class="text-danger" title="%s">%s</b>',
|
$ret = sprintf('<b class="text-danger" title="%s">%s</b>',
|
||||||
$this->translator->trans('part.info.amount.less_than_desired'),
|
$this->translator->trans('part.info.amount.less_than_desired'),
|
||||||
$ret);
|
$ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $ret;
|
return $ret;
|
||||||
},
|
},
|
||||||
'orderField' => 'amountSum'
|
'orderField' => 'amountSum'
|
||||||
])
|
])
|
||||||
->add('minamount', TextColumn::class, [
|
->add('minamount', TextColumn::class, [
|
||||||
'label' => $this->translator->trans('part.table.minamount'),
|
'label' => $this->translator->trans('part.table.minamount'),
|
||||||
'render' => fn($value, Part $context): string => htmlspecialchars($this->amountFormatter->format($value,
|
'render' => fn($value, Part $context): string => htmlspecialchars($this->amountFormatter->format($value,
|
||||||
$context->getPartUnit())),
|
$context->getPartUnit())),
|
||||||
]);
|
])
|
||||||
|
->add('partUnit', TextColumn::class, [
|
||||||
if ($this->security->isGranted('@footprints.read')) {
|
|
||||||
$this->csh->add('partUnit', TextColumn::class, [
|
|
||||||
'field' => 'partUnit.name',
|
'field' => 'partUnit.name',
|
||||||
'label' => $this->translator->trans('part.table.partUnit'),
|
'label' => $this->translator->trans('part.table.partUnit'),
|
||||||
]);
|
])
|
||||||
}
|
->add('addedDate', LocaleDateTimeColumn::class, [
|
||||||
|
'label' => $this->translator->trans('part.table.addedDate'),
|
||||||
$this->csh->add('addedDate', LocaleDateTimeColumn::class, [
|
])
|
||||||
'label' => $this->translator->trans('part.table.addedDate'),
|
|
||||||
])
|
|
||||||
->add('lastModified', LocaleDateTimeColumn::class, [
|
->add('lastModified', LocaleDateTimeColumn::class, [
|
||||||
'label' => $this->translator->trans('part.table.lastModified'),
|
'label' => $this->translator->trans('part.table.lastModified'),
|
||||||
])
|
])
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue