From: Coleman Watts Date: Wed, 10 Mar 2021 20:17:43 +0000 (-0500) Subject: SearchKit - Additional link settings for opening in new tab or popup X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=2dbf2d72404de0a94ea0ea860247b424c328d2ef;p=civicrm-core.git SearchKit - Additional link settings for opening in new tab or popup --- diff --git a/css/civicrm.css b/css/civicrm.css index c928b5fb5b..0114b04132 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -24,21 +24,24 @@ flex-wrap: wrap; box-sizing: border-box; } -.crm-container .crm-flex-box > * { +.crm-flex-box > * { flex: 1; box-sizing: border-box; min-width: 0; /* prevents getting squashed by whitespace:nowrap content */ } -.crm-container .crm-flex-box > .crm-flex-2 { +.crm-container .crm-flex-1 { + flex: 1; +} +.crm-container .crm-flex-2 { flex: 2; } -.crm-container .crm-flex-box > .crm-flex-3 { +.crm-container .crm-flex-3 { flex: 3; } -.crm-container .crm-flex-box > .crm-flex-4 { +.crm-container .crm-flex-4 { flex: 4; } -.crm-container .crm-flex-box > .crm-flex-5 { +.crm-container .crm-flex-5 { flex: 5; } diff --git a/ext/search/CRM/Search/Upgrader.php b/ext/search/CRM/Search/Upgrader.php index 670d3ca545..f8fbc76f22 100644 --- a/ext/search/CRM/Search/Upgrader.php +++ b/ext/search/CRM/Search/Upgrader.php @@ -84,4 +84,30 @@ class CRM_Search_Upgrader extends CRM_Search_Upgrader_Base { return TRUE; } + /** + * Upgrade 1002 - embellish search display link data + * @return bool + */ + public function upgrade_1002() { + $this->ctx->log->info('Applying update 1002 - embellish search display link data.'); + $displays = \Civi\Api4\SearchDisplay::get(FALSE) + ->setSelect(['id', 'settings']) + ->execute(); + foreach ($displays as $display) { + $update = FALSE; + foreach ($display['settings']['columns'] ?? [] as $c => $column) { + if (!empty($column['link'])) { + $display['settings']['columns'][$c]['link'] = ['path' => $column['link']]; + $update = TRUE; + } + } + if ($update) { + \Civi\Api4\SearchDisplay::update(FALSE) + ->setValues($display) + ->execute(); + } + } + return TRUE; + } + } diff --git a/ext/search/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js b/ext/search/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js index 560445ff53..f5806fcf40 100644 --- a/ext/search/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js +++ b/ext/search/ang/crmSearchAdmin/crmSearchAdminDisplay.component.js @@ -173,6 +173,31 @@ return values; } + this.toggleLink = function(column) { + if (column.link) { + ctrl.onChangeLink(column, column.link.path, ''); + } else { + var defaultLink = ctrl.getLinks()[0]; + column.link = {path: defaultLink ? defaultLink.path : 'civicrm/'}; + ctrl.onChangeLink(column, null, column.link.path); + } + }; + + this.onChangeLink = function(column, before, after) { + var beforeLink = before && _.findWhere(ctrl.getLinks(), {path: before}), + afterLink = after && _.findWhere(ctrl.getLinks(), {path: after}); + if (!after) { + if (beforeLink && column.title === beforeLink.title) { + delete column.title; + } + delete column.link; + } else if (afterLink && ((!column.title && !before) || (beforeLink && beforeLink.title === column.title))) { + column.title = afterLink.title; + } else if (!afterLink && (beforeLink && beforeLink.title === column.title)) { + delete column.title; + } + }; + this.getLinks = function() { if (!ctrl.links) { ctrl.links = buildLinks(); diff --git a/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js b/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js index b528ad0ba6..3ff0962ecb 100644 --- a/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js +++ b/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.component.js @@ -15,19 +15,8 @@ this.styles = CRM.crmSearchAdmin.styles; - this.setValue = function(val, index) { - var link = ctrl.getLink(val), - item = ctrl.group[index]; - if (item.path === val) { - return; - } - item.path = val; - item.icon = link ? defaultIcons[link.action] : 'fa-external-link'; - if (val === 'civicrm/') { - $timeout(function () { - $('tr:eq(' + index + ') input[type=text]', $element).focus(); - }); - } + this.getStyle = function(item) { + return _.findWhere(this.styles, {key: item.style}); }; this.sortableOptions = { @@ -78,15 +67,11 @@ ctrl.addItem('civicrm/'); } } - $element.on('change', 'select.crm-search-admin-select-path', function() { + $element.on('change', 'select.crm-search-admin-add-link', function() { var $select = $(this); $scope.$apply(function() { - if ($select.closest('tfoot').length) { - ctrl.addItem($select.val()); - $select.val(''); - } else { - ctrl.setValue($select.val(), $select.closest('tr').index()); - } + ctrl.addItem($select.val()); + $select.val(''); }); }); }; diff --git a/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.html b/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.html index 2846b60073..5f5157d488 100644 --- a/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.html +++ b/ext/search/ang/crmSearchAdmin/crmSearchAdminLinkGroup.html @@ -3,6 +3,7 @@ {{:: ts('Icon') }} + {{:: ts('Open') }} {{:: ts('Text') }} {{:: ts('Link') }} {{:: ts('Style') }} @@ -10,34 +11,39 @@ - + - + + + + - - - + - - + +
+ + +
+ + + + + diff --git a/ext/search/ang/crmSearchAdmin/displays/colType/field.html b/ext/search/ang/crmSearchAdmin/displays/colType/field.html index 5960cc5ef2..7b0969cbd2 100644 --- a/ext/search/ang/crmSearchAdmin/displays/colType/field.html +++ b/ext/search/ang/crmSearchAdmin/displays/colType/field.html @@ -1,10 +1,22 @@ - +
+ + + + +
- +
@@ -12,7 +24,7 @@ {{ col.rewrite ? ts('Rewrite:') : ts('Rewrite') }} - +
diff --git a/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayList.html b/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayList.html index 382c808751..bf4870cb93 100644 --- a/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayList.html +++ b/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayList.html @@ -40,7 +40,7 @@ {{ col.label ? ts('Label:') : ts('Label') }} - +
diff --git a/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayTable.html b/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayTable.html index 7aa5d91f68..83b9ef670d 100644 --- a/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayTable.html +++ b/ext/search/ang/crmSearchAdmin/displays/searchAdminDisplayTable.html @@ -21,7 +21,7 @@ {{ $ctrl.parent.getColLabel(col) }}
- + diff --git a/ext/search/ang/crmSearchDisplay.module.js b/ext/search/ang/crmSearchDisplay.module.js index a8f7cb8501..1a27992c4a 100644 --- a/ext/search/ang/crmSearchDisplay.module.js +++ b/ext/search/ang/crmSearchDisplay.module.js @@ -36,7 +36,11 @@ displayValue = column.rewrite ? replaceTokens(column.rewrite, rowData, rowMeta) : formatRawValue(column, rowData[key]), result = _.escape(displayValue); if (column.link) { - result = '' + result + ''; + var target = ''; + if (column.link.target) { + target = column.link.target === 'crm-popup' ? 'class="crm-popup" ' : 'target="' + column.link.target + '" '; + } + result = '' + result + ''; } return result; } diff --git a/ext/search/ang/crmSearchDisplay/colType/buttons.html b/ext/search/ang/crmSearchDisplay/colType/buttons.html index f18030cf3c..7630a9b863 100644 --- a/ext/search/ang/crmSearchDisplay/colType/buttons.html +++ b/ext/search/ang/crmSearchDisplay/colType/buttons.html @@ -1,5 +1,5 @@ - + {{:: item.text }} diff --git a/ext/search/ang/crmSearchDisplay/colType/links.html b/ext/search/ang/crmSearchDisplay/colType/links.html index d0a2480473..d84651693d 100644 --- a/ext/search/ang/crmSearchDisplay/colType/links.html +++ b/ext/search/ang/crmSearchDisplay/colType/links.html @@ -1,5 +1,5 @@ - + {{:: item.text }} diff --git a/ext/search/ang/crmSearchDisplay/colType/menu.html b/ext/search/ang/crmSearchDisplay/colType/menu.html index a11b5319be..213f814424 100644 --- a/ext/search/ang/crmSearchDisplay/colType/menu.html +++ b/ext/search/ang/crmSearchDisplay/colType/menu.html @@ -5,7 +5,7 @@