Search overhaul possibly finished?

This commit is contained in:
Erik Thuning 2022-03-03 11:37:35 +01:00
parent 0f66c8212f
commit 3fae0ce1ff
5 changed files with 63 additions and 36 deletions

@ -85,7 +85,7 @@
</th>
</tr>
</thead>
<tbody>
<tbody class="¤type¤">
¤rows¤
</tbody>
</table>
@ -110,20 +110,19 @@
<td class="status ¤status¤">
</td>
<td colspan="3">
<div class="minitable">
<dl>
¤details¤
</div>
</dl>
</td>
</tr>
¤¤ product_detail ¤¤
<span class="minitable_name">
¤name¤
</span>
<span class="minitable_value">
<dt>
¤name¤:
</dt>
<dd>
¤value¤
</span>
<br/>
</dd>
¤¤ template_management ¤¤
<div>

@ -128,6 +128,16 @@ abstract class Page extends Responder {
$this->fragments['user_table']);
}
final protected function build_product_table($products) {
$rows = '';
foreach($products as $product) {
$rows .= $this->build_product_row($product);
}
return replace(array('rows' => $rows,
'type' => 'single'),
$this->fragments['product_table']);
}
final protected function build_product_row($product, $matches = null) {
$prodlink = replace(array('id' => $product->get_id(),
'name' => $product->get_name(),
@ -183,22 +193,13 @@ abstract class Page extends Responder {
if(is_array($value)) {
$value = implode(', ', $value);
}
$out .= replace(array('name' => ucfirst($name),
$out .= replace(array('name' => $product->get_label($name),
'value' => $value),
$this->fragments['product_detail']);
}
return $out;
}
final protected function build_product_table($products) {
$rows = '';
foreach($products as $product) {
$rows .= $this->build_product_row($product);
}
return replace(array('rows' => $rows),
$this->fragments['product_table']);
}
final protected function build_user_loan_table($loans) {
$rows = '';
foreach($loans as $loan) {
@ -284,7 +285,8 @@ abstract class Page extends Responder {
'note' => $note),
$this->fragments['product_row']);
}
return replace(array('rows' => $rows),
return replace(array('rows' => $rows,
'type' => 'single'),
$this->fragments['product_table']);
}

@ -228,6 +228,29 @@ class Product extends Entity {
return $matches;
}
public function get_label($name) {
switch($name) {
case 'brand':
return 'Tillverkare';
break;
case 'name':
return 'Namn';
break;
case 'invoice':
return 'Fakturanummer';
break;
case 'serial':
return 'Serienummer';
break;
case 'tags':
return 'Taggar';
break;
default:
return ucfirst($name);
break;
}
}
public function get_id() {
return $this->id;
}

@ -115,7 +115,7 @@ class SearchPage extends Page {
$value = substr($value, 1);
}
// Collect the new SearchTerm
$translated[] = new SearchTerm($key, $value, $flag);
$translated[] = new SearchTerm($newkey, $value, $flag);
}
}
return $translated;
@ -188,7 +188,8 @@ class SearchPage extends Page {
foreach($this->product_hits as $hit) {
$products .= $this->build_product_row($hit[0], $hit[1]);
}
$prod_table = replace(array('rows' => $products),
$prod_table = replace(array('rows' => $products,
'type' => 'double'),
$this->fragments['product_table']);
}
$user_table = 'Inga användare hittade.';

@ -104,10 +104,25 @@ tbody tr {
background-color: #d7e0eb;
}
tbody tr:nth-child(odd) {
tbody.single tr:nth-child(odd) {
background-color: #ebf0f5;
}
tbody.double tr:is(:nth-child(4n+1), :nth-child(4n+2)) {
background-color: #ebf0f5;
}
tbody dl {
margin: 0;
display: grid;
grid-template-columns: 2fr 5fr;
}
tbody dd {
margin: 0;
grid-column: 2;
}
thead th, tfoot tr {
background-color: #c3d1e2;
}
@ -117,19 +132,6 @@ thead th:nth-last-child(-n+2) {
word-break: break-word;
}
.minitable {
display: grid;
grid-template-columns: [col] auto [col] auto [col] auto [col];
}
.minitable_name {
grid-column: col 1;
}
.minitable_value {
grid-column: col 2;
}
input:disabled, textarea:disabled {
background-color: #ededed;
}