mirror of
https://github.com/invoiceninja/invoiceninja.git
synced 2025-06-12 13:14:35 -04:00
Inject Javascript that'll filter for hidden columns
This commit is contained in:
parent
329c72128c
commit
ae534b146b
@ -184,11 +184,38 @@ trait DesignHelpers
|
|||||||
|
|
||||||
public function sharedFooterElements()
|
public function sharedFooterElements()
|
||||||
{
|
{
|
||||||
// return ['element' => 'div', 'properties' => ['style' => 'display: flex; justify-content: space-between; margin-top: 1.5rem; page-break-inside: avoid;'], 'elements' => [
|
// Unminified version, just for the reference.
|
||||||
// ['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 5rem;', 'hidden' => $this->entity->user->account->isPaid() ? 'true' : 'false']],
|
// By default all table headers are hidden with HTML `hidden` property.
|
||||||
// ]];
|
// This will check for table data values & if they're not empty it will remove hidden from the column itself.
|
||||||
|
|
||||||
return ['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 3rem; position: fixed; bottom: 0; left: 0; padding: 5px; margin: 5px;', 'hidden' => $this->entity->user->account->isPaid() ? 'true' : 'false', 'id' => 'invoiceninja-whitelabel-logo']];
|
/* document.querySelectorAll("tbody > tr > td").forEach(e => {
|
||||||
|
if ("" !== e.innerText) {
|
||||||
|
let t = e.getAttribute("data-ref").slice(0, -3);
|
||||||
|
document.querySelector(`th[data-ref="${t}-th"]`).removeAttribute("hidden");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.querySelectorAll("tbody > tr > td").forEach(e => {
|
||||||
|
let t = e.getAttribute("data-ref").slice(0, -3);
|
||||||
|
t = document.querySelector(`th[data-ref="${t}-th"]`);
|
||||||
|
|
||||||
|
if (!t.hasAttribute('hidden')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("" == e.innerText) {
|
||||||
|
e.setAttribute('hidden', 'true');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
$javascript = 'document.querySelectorAll("tbody > tr > td").forEach(t=>{if(""!==t.innerText){let e=t.getAttribute("data-ref").slice(0,-3);document.querySelector(`th[data-ref="${e}-th"]`).removeAttribute("hidden")}}),document.querySelectorAll("tbody > tr > td").forEach(t=>{let e=t.getAttribute("data-ref").slice(0,-3);(e=document.querySelector(`th[data-ref="${e}-th"]`)).hasAttribute("hidden")&&""==t.innerText&&t.setAttribute("hidden","true")});';
|
||||||
|
|
||||||
|
return ['element' => 'div', 'elements' => [
|
||||||
|
['element' => 'img', 'properties' => ['src' => '$invoiceninja.whitelabel', 'style' => 'height: 3rem; position: fixed; bottom: 0; left: 0; padding: 5px; margin: 5px;', 'hidden' => $this->entity->user->account->isPaid() ? 'true' : 'false', 'id' => 'invoiceninja-whitelabel-logo']],
|
||||||
|
['element' => 'script', 'content' => $javascript],
|
||||||
|
]];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function entityVariableCheck(string $variable): bool
|
public function entityVariableCheck(string $variable): bool
|
||||||
|
Loading…
x
Reference in New Issue
Block a user