diff --git a/html/fragments.html b/html/fragments.html index ee6f993..1e0e633 100644 --- a/html/fragments.html +++ b/html/fragments.html @@ -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> diff --git a/include/Page.php b/include/Page.php index 8a79123..1d2607e 100644 --- a/include/Page.php +++ b/include/Page.php @@ -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']); } diff --git a/include/Product.php b/include/Product.php index 9a4798c..1f4468c 100644 --- a/include/Product.php +++ b/include/Product.php @@ -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; } diff --git a/include/SearchPage.php b/include/SearchPage.php index ffe29fd..1d47bf3 100644 --- a/include/SearchPage.php +++ b/include/SearchPage.php @@ -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.'; diff --git a/style.css b/style.css index 76a9990..61c9529 100644 --- a/style.css +++ b/style.css @@ -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; }