From 0950430a94e5691e3ae1b97acf7e1bfd96b5722d Mon Sep 17 00:00:00 2001 From: Benn Oshrin Date: Sun, 3 Oct 2021 10:52:13 -0400 Subject: [PATCH] Minor fixes to standard index (NOJIRA) --- app/templates/Standard/index.php | 99 ++++++++++++++++---------------- 1 file changed, 49 insertions(+), 50 deletions(-) diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 4c0b7dc1d..cee45194a 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -1,6 +1,6 @@ name = Models $modelsName = $this->name; // $tablefk = model_id @@ -60,33 +57,31 @@ } function _column_key($modelsName, $c, $tz=null) { - $product = __('product.code'); - if(strpos($c, "_id", strlen($c)-3)) { // Key is of the form field_id, use .ct label instead $k = Inflector::camelize(Inflector::pluralize(substr($c, 0, strlen($c)-3))); - return __($product.'.ct.'.$k, [1]); + return __('match.ct.'.$k, [1]); } // Look for a model specific key first - $label = __($product.'.fd.'.$modelsName.'.'.$c); + $label = __('match.fd.'.$modelsName.'.'.$c); - if($label != $product.'.fd.'.$modelsName.'.'.$c) { + if($label != 'match.fd.'.$modelsName.'.'.$c) { return $label; } if($tz) { // If there is a timezone aware label, use that - $label = __($product.'.fd.'.$c.'.tz', [$tz]); + $label = __('match.fd.'.$c.'.tz', [$tz]); - if($label != $product.'.fd.'.$c.'.tz') { + if($label != 'match.fd.'.$c.'.tz') { return $label; } } // Otherwise look for the general key - return __($product.'.fd.'.$c); + return __('match.fd.'.$c); } ?>
@@ -161,7 +156,7 @@ function _column_key($modelsName, $c, $tz=null) { } ?> - + $col) && $entity->$col) { - print __($product.'.en.'.$cfg['class'].'.1'); + print __('match.en.'.$cfg['class'].'.1'); } else { - print __($product.'.en.'.$cfg['class'].'.0'); + print __('match.en.'.$cfg['class'].'.0'); } break; case 'datetime': @@ -191,7 +186,7 @@ function _column_key($modelsName, $c, $tz=null) { break; case 'enum': if($entity->$col) { - print __($product.'.en.'.$cfg['class'].'.'.$entity->$col); + print __('match.en.'.$cfg['class'].'.'.$entity->$col); } break; case 'fk': @@ -215,32 +210,36 @@ function _column_key($modelsName, $c, $tz=null) { } break; case 'button': - $buttonAttrs = []; - $buttonText = $entity->$col; - if(!empty($cfg['button']['attrs'])) { - $buttonAttrs = $cfg['button']['attrs']; - } - $buttonAttrs['type'] = 'button'; - if(!empty($cfg['button']['text']) && $cfg['button']['text'] != 'fieldVal') { - $buttonText = $cfg['button']['text']; - } - if(!empty($cfg['truncate']) && is_int($cfg['truncate'])) { - $buttonText = (strlen($buttonText) > $cfg['truncate']) ? substr($buttonText,0,$cfg['truncate']).'...' : $buttonText; - } - if(!empty($cfg['button']['popover'])) { - if($cfg['button']['popover'] == 'fieldVal') { - $buttonAttrs['data-content'] = $entity->$col; - } else { - $buttonAttrs['data-content'] = $cfg['button']['popover']; + if(!empty($entity->$col)) { + $buttonAttrs = []; + $buttonText = $entity->$col; + if(!empty($cfg['button']['attrs'])) { + $buttonAttrs = $cfg['button']['attrs']; + } + $buttonAttrs['type'] = 'button'; + if(!empty($cfg['button']['text']) && $cfg['button']['text'] != 'fieldVal') { + $buttonText = $cfg['button']['text']; + } + if(!empty($cfg['truncate']) && is_int($cfg['truncate'])) { + // We check for $truncate + 1 because there's no point trimming + // the last character if we're just going to replace it with ... + $buttonText = (strlen($buttonText) > $cfg['truncate'] + 1) ? substr($buttonText,0,$cfg['truncate']).'...' : $buttonText; + } + if(!empty($cfg['button']['popover'])) { + if($cfg['button']['popover'] == 'fieldVal') { + $buttonAttrs['data-content'] = $entity->$col; + } else { + $buttonAttrs['data-content'] = $cfg['button']['popover']; + } + $label = !empty($cfg['label']) ? $cfg['label'] : _column_key($modelsName, $col, $vv_tz); + $buttonAttrs['title'] = $label; + $buttonAttrs['data-toggle'] = 'popover'; + $buttonAttrs['data-container'] = 'body'; + $buttonAttrs['data-placement'] = 'top'; + $buttonAttrs['data-animation'] = 'false'; } - $label = !empty($cfg['label']) ? $cfg['label'] : _column_key($modelsName, $col, $vv_tz); - $buttonAttrs['title'] = $label; - $buttonAttrs['data-toggle'] = 'popover'; - $buttonAttrs['data-container'] = 'body'; - $buttonAttrs['data-placement'] = 'top'; - $buttonAttrs['data-animation'] = 'false'; + print $this->Form->button($buttonText, $buttonAttrs); } - print $this->Form->button($buttonText, $buttonAttrs); break; case 'link': case 'echo': @@ -284,7 +283,7 @@ function _column_key($modelsName, $c, $tz=null) { Html->link( - __($product.'.op.edit'), + __('match.op.edit'), array_merge_recursive(['action' => 'edit'], $linkArgs), ['class' => 'editbutton'] ); @@ -292,7 +291,7 @@ function _column_key($modelsName, $c, $tz=null) { if(isset($vv_permissions['duplicate']) && $vv_permissions['duplicate']) { print $this->Html->link( - __($product.'.op.duplicate'), + __('match.op.duplicate'), array_merge_recursive(['action' => 'duplicate'], $linkArgs), ['class' => 'copybutton'] ); @@ -302,10 +301,10 @@ function _column_key($modelsName, $c, $tz=null) { // XXX this is throwing CSRF error even though delete button on edit-record page is working? // probably because this is using Form helper, but we're outside of a form? print $this->Form->postLink( - __($product.'.op.delete'), + __('match.op.delete'), array_merge_recursive(['action' => 'delete'], $linkArgs), // XXX should be configurable which field we put in, maybe displayField? - ['confirm' => __($product.'.op.delete.confirm', [$entity->id]), + ['confirm' => __('match.op.delete.confirm', [$entity->id]), 'class' => 'deletebutton nospin'] ); } @@ -318,14 +317,14 @@ function _column_key($modelsName, $c, $tz=null) { if($vv_permissions[ $a['action'] ]) { // If we have a .confirm text, use postLink instead - $confirmKey = $product.'.op.'.$a['action'].'.confirm'; + $confirmKey = 'match.op.'.$a['action'].'.confirm'; $confirmTxt = __($confirmKey); if($confirmTxt != $confirmKey) { // We found the localized string print $this->Form->postLink( - __($product.'.op.' . $a['action']), + __('match.op.' . $a['action']), array_merge_recursive(['action' => $a['action']], $linkArgs), // XXX should be configurable which field we put in, maybe displayField? ['confirm' => __($confirmKey, [$entity->id]), @@ -342,7 +341,7 @@ function _column_key($modelsName, $c, $tz=null) { ); } else { print $this->Html->link( - __($product.'.op.' . $a['action']), + __('match.op.' . $a['action']), array_merge_recursive(['action' => $a['action']], $linkArgs), ['class' => $a['class']] );