From 923afc779a94bc2c988257b761b1adcd2bd4bfd3 Mon Sep 17 00:00:00 2001 From: arlen Date: Thu, 23 Sep 2021 15:18:18 -0400 Subject: [PATCH 1/3] Matchgrid Records: truncate length of field value output (i.e. Reference ID) to shrink the width of columns, but allow the full value to be displayed and copied (CO-2137) --- app/templates/MatchgridRecords/columns.inc | 8 ++++-- app/templates/Standard/index.php | 29 ++++++++++++++++++++++ app/templates/element/javascript.php | 5 ++++ app/webroot/css/co-base.css | 18 +++++++++++--- 4 files changed, 54 insertions(+), 6 deletions(-) diff --git a/app/templates/MatchgridRecords/columns.inc b/app/templates/MatchgridRecords/columns.inc index 4c98d35a8..f82683876 100644 --- a/app/templates/MatchgridRecords/columns.inc +++ b/app/templates/MatchgridRecords/columns.inc @@ -48,8 +48,12 @@ $indexColumns = [ 'sortable' => true ], 'referenceid' => [ - 'type' => 'echo', - 'sortable' => true + 'type' => 'button', + 'buttonText' => 'fieldVal', + 'buttonAttrs' => ['class' => 'btn link referenceid'], + 'truncate' => 8, + 'popover' => 'fieldVal', + 'sortable' => true ] ]; diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 4e3dd1a63..2de9fd408 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -214,6 +214,35 @@ function _column_key($modelsName, $c, $tz=null) { print $entity->$col; } break; + case 'button': + $buttonAttrs = []; + $buttonText = $entity->$col; + if(!empty($cfg['buttonAttrs'])) { + $buttonAttrs = $cfg['buttonAttrs']; + } + $buttonAttrs['type'] = 'button'; + if(!empty($cfg['buttonText']) && $cfg['buttonText'] != 'fieldVal') { + $buttonText = $cfg['buttonText']; + } + if(!empty($cfg['truncate']) && is_int($cfg['truncate'])) { + $buttonText = (strlen($buttonText) > $cfg['truncate']) ? substr($buttonText,0,$cfg['truncate']).'...' : $buttonText; + } + if(!empty($cfg['popover'])) { + if($cfg['popover'] == 'fieldVal') { + $buttonAttrs['data-content'] = $entity->$col; + } else { + $buttonAttrs['data-content'] = $cfg['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'; + $buttonAttrs['data-dismiss'] = 'popover'; + } + print $this->Form->button($buttonText, $buttonAttrs); + break; case 'link': case 'echo': default: diff --git a/app/templates/element/javascript.php b/app/templates/element/javascript.php index 91553638b..ecef779dd 100644 --- a/app/templates/element/javascript.php +++ b/app/templates/element/javascript.php @@ -171,6 +171,11 @@ // Make all select form controls Bootstrappy $("select").addClass("form-control"); + + // Enable Bootstrap Popovers. Unless needed elsewhere, constrain this to #content + $(function () { + $('#content [data-toggle="popover"]').popover() + }); // Other buttons (jQuery) $(".addbutton").button({ diff --git a/app/webroot/css/co-base.css b/app/webroot/css/co-base.css index 17f100cac..d42631385 100644 --- a/app/webroot/css/co-base.css +++ b/app/webroot/css/co-base.css @@ -716,7 +716,14 @@ body.logged-in #top-menu { color: #222; margin-right: 0.5em; } -/* Pagination */ +/* MATCHGRID RECORDS INDEX */ +body.matchgridrecords .popover { + max-width: unset; +} +body.matchgridrecords .popover-header { + font-size: 1em; +} +/* PAGINATION */ #pagination { margin: 0; min-height: 1.5em; @@ -1190,9 +1197,6 @@ td.indented { color: white !important; text-decoration: none !important; } -.btn:focus { - border: 1px dotted white; -} .btn-primary.disabled, .btn-primary:disabled { color: #fff; @@ -1214,6 +1218,12 @@ td.indented { background-color: #c33; /* red */ color: white; } +.btn.link { + font-size: 1em; + text-decoration: underline; + color: var(--cmg-blue-primary); + border: none; +} /* Call to Action Blocks */ .call-to-action { margin-bottom: 2em; From 5a7afb88b69953c29cc5f3f889fb2840fe4661c6 Mon Sep 17 00:00:00 2001 From: arlen Date: Thu, 23 Sep 2021 15:21:59 -0400 Subject: [PATCH 2/3] Matchgrid Records: remove popover attribute (CO-2137) --- app/templates/Standard/index.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index 2de9fd408..be5eff9c6 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -239,7 +239,6 @@ function _column_key($modelsName, $c, $tz=null) { $buttonAttrs['data-container'] = 'body'; $buttonAttrs['data-placement'] = 'top'; $buttonAttrs['data-animation'] = 'false'; - $buttonAttrs['data-dismiss'] = 'popover'; } print $this->Form->button($buttonText, $buttonAttrs); break; From def3baca3cb4d6e16fbbb29bbff1e7ee525776f9 Mon Sep 17 00:00:00 2001 From: arlen Date: Thu, 30 Sep 2021 14:08:53 -0400 Subject: [PATCH 3/3] Gather button-specific options together in columns.inc (CO-2137) --- app/templates/MatchgridRecords/columns.inc | 14 ++++++++------ app/templates/Standard/index.php | 14 +++++++------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/app/templates/MatchgridRecords/columns.inc b/app/templates/MatchgridRecords/columns.inc index f82683876..5472432e1 100644 --- a/app/templates/MatchgridRecords/columns.inc +++ b/app/templates/MatchgridRecords/columns.inc @@ -48,12 +48,14 @@ $indexColumns = [ 'sortable' => true ], 'referenceid' => [ - 'type' => 'button', - 'buttonText' => 'fieldVal', - 'buttonAttrs' => ['class' => 'btn link referenceid'], - 'truncate' => 8, - 'popover' => 'fieldVal', - 'sortable' => true + 'type' => 'button', + 'button' => [ + 'text' => 'fieldVal', + 'attrs' => ['class' => 'btn link referenceid'], + 'popover' => 'fieldVal', + ], + 'truncate' => 8, + 'sortable' => true ] ]; diff --git a/app/templates/Standard/index.php b/app/templates/Standard/index.php index be5eff9c6..3bad83f09 100644 --- a/app/templates/Standard/index.php +++ b/app/templates/Standard/index.php @@ -217,21 +217,21 @@ function _column_key($modelsName, $c, $tz=null) { case 'button': $buttonAttrs = []; $buttonText = $entity->$col; - if(!empty($cfg['buttonAttrs'])) { - $buttonAttrs = $cfg['buttonAttrs']; + if(!empty($cfg['button']['attrs'])) { + $buttonAttrs = $cfg['button']['attrs']; } $buttonAttrs['type'] = 'button'; - if(!empty($cfg['buttonText']) && $cfg['buttonText'] != 'fieldVal') { - $buttonText = $cfg['buttonText']; + 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['popover'])) { - if($cfg['popover'] == 'fieldVal') { + if(!empty($cfg['button']['popover'])) { + if($cfg['button']['popover'] == 'fieldVal') { $buttonAttrs['data-content'] = $entity->$col; } else { - $buttonAttrs['data-content'] = $cfg['popover']; + $buttonAttrs['data-content'] = $cfg['button']['popover']; } $label = !empty($cfg['label']) ? $cfg['label'] : _column_key($modelsName, $col, $vv_tz); $buttonAttrs['title'] = $label;