From 5a205b8995d3c7ebb9cf61299bfd572d209d7505 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Tue, 18 Feb 2014 18:43:31 +0530 Subject: [PATCH] CRM-13992 coding neccessary property values / configurable options required for tab table layout orientation --- CRM/Core/SelectValues.php | 1 + CRM/Custom/Form/Field.php | 9 +++++++++ CRM/Custom/Form/Group.php | 4 ++++ CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl | 9 +++++++++ templates/CRM/Custom/Form/Field.tpl | 6 +++++- templates/CRM/Custom/Form/Group.tpl | 4 +++- xml/schema/Core/CustomField.xml | 7 +++++++ xml/schema/Core/CustomGroup.xml | 2 +- 8 files changed, 39 insertions(+), 3 deletions(-) diff --git a/CRM/Core/SelectValues.php b/CRM/Core/SelectValues.php index 88372829e1..089fd4163f 100644 --- a/CRM/Core/SelectValues.php +++ b/CRM/Core/SelectValues.php @@ -277,6 +277,7 @@ class CRM_Core_SelectValues { $customGroupStyle = array( 'Tab' => ts('Tab'), 'Inline' => ts('Inline'), + 'Tab with table' => ts('Tab with table') ); } return $customGroupStyle; diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index 9de5daf921..05988af601 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -261,6 +261,10 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { if (isset($dontShowLink)) { $this->assign('dontShowLink', $dontShowLink); } + if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_multiple', 'id')) { + $defaults['in_selector'] = 1; + } + return $defaults; } @@ -304,6 +308,11 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { '   ' ); $sel->setOptions(array($dt, $it)); + + if (CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_multiple')) { + $this->add('checkbox', 'in_selector', ts('Display in Table?')); + } + if ($this->_action == CRM_Core_Action::UPDATE) { $this->freeze('data_type'); } diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index 697148dc3b..c18e36da4d 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -421,6 +421,10 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $this->assign('showMaxMultiple', FALSE); } + if (($this->_action & CRM_Core_Action::UPDATE) && $defaults['is_multiple']) { + $defaults['collapse_display'] = 0; + } + if (isset($defaults['extends'])) { $extends = $defaults['extends']; unset($defaults['extends']); diff --git a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl index 50fdd85883..6cdcef9d3d 100644 --- a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl @@ -242,3 +242,12 @@ ALTER TABLE `civicrm_contact` CHANGE `preferred_mail_format` `preferred_mail_ -- CRM-14183 INSERT INTO civicrm_state_province (country_id, abbreviation, name) VALUES (1157, "PL", "Plateau"); UPDATE civicrm_state_province SET name = "Abuja Federal Capital Territory" WHERE name = "Abuja Capital Territory"; + +-- CRM-13992 +ALTER TABLE `civicrm_custom_field` + ADD COLUMN `in_selector` tinyint(4) DEFAULT '0' COMMENT 'Should the multi-record custom field values be displayed in tab table listing'; +UPDATE civicrm_custom_field cf + LEFT JOIN civicrm_custom_group cg + ON cf.custom_group_id = cg.id + SET cf.in_selector = 1 + WHERE cg.is_multiple = 1 AND cf.html_type != 'TextArea'; \ No newline at end of file diff --git a/templates/CRM/Custom/Form/Field.tpl b/templates/CRM/Custom/Form/Field.tpl index 684f97c3f1..050bc0b412 100644 --- a/templates/CRM/Custom/Form/Field.tpl +++ b/templates/CRM/Custom/Form/Field.tpl @@ -156,7 +156,11 @@ function custom_option_html_type( ) { {/if} - + + {$form.in_selector.label} + {$form.in_selector.html} + + {$form.text_length.label} {$form.text_length.html} diff --git a/templates/CRM/Custom/Form/Group.tpl b/templates/CRM/Custom/Form/Group.tpl index d11b6e17cb..5ecc5bd2fd 100644 --- a/templates/CRM/Custom/Form/Group.tpl +++ b/templates/CRM/Custom/Form/Group.tpl @@ -146,9 +146,11 @@ cj(function($) { function showRange(onFormLoad) { if(cj("#is_multiple :checked").length) { cj("tr#multiple").show(); - cj("select#style option[value='Tab']").prop("selected", true); + cj('#collapse_display').prop('checked', ''); + cj("select#style option[value='Tab with table']").prop("selected", true); } else { + cj('#collapse_display').prop('checked', 'checked'); cj("tr#multiple").hide(); if (!onFormLoad) { cj("select#style option[value='Inline']").prop("selected", true); diff --git a/xml/schema/Core/CustomField.xml b/xml/schema/Core/CustomField.xml index 3e0f7a57ea..8b2a5fbd59 100644 --- a/xml/schema/Core/CustomField.xml +++ b/xml/schema/Core/CustomField.xml @@ -238,6 +238,13 @@ Stores Contact Get API params contact reference custom fields. May be used for other filters in the future. 4.1 + + in_selector + boolean + 0 + Should the multi-record custom field values be displayed in tab table listing + 4.5 + UI_label_custom_group_id label diff --git a/xml/schema/Core/CustomGroup.xml b/xml/schema/Core/CustomGroup.xml index 68834bcc13..24b6aaa7cb 100644 --- a/xml/schema/Core/CustomGroup.xml +++ b/xml/schema/Core/CustomGroup.xml @@ -68,7 +68,7 @@ style varchar - 8 + 15 Visual relationship between this form and its parent. CRM_Core_SelectValues::customGroupStyle -- 2.25.1