From b05a0fb6038c34cb75a6978fc83f23c8ea244176 Mon Sep 17 00:00:00 2001 From: Pratik Joshi Date: Thu, 27 Feb 2014 21:39:55 +0530 Subject: [PATCH] CRM-13992 : QA fixes mentioned in #comment-57745 --- CRM/Custom/Form/Group.php | 6 +++- .../Page/MultipleRecordFieldsListing.php | 19 +++++++++++-- CRM/Upgrade/Incremental/php/FourFive.php | 1 + .../Incremental/sql/4.5.alpha1.mysql.tpl | 6 ++-- .../CRM/Contact/Page/View/CustomData.tpl | 8 +++--- templates/CRM/Custom/Form/Field.hlp | 28 +++++++++++++++++++ templates/CRM/Custom/Form/Field.tpl | 2 +- templates/CRM/Custom/Page/CustomDataView.tpl | 11 ++++++-- templates/CRM/Custom/Page/Group.hlp | 2 +- .../Page/MultipleRecordFieldsListing.tpl | 16 +++++++++-- xml/schema/Core/CustomGroup.xml | 1 - 11 files changed, 82 insertions(+), 18 deletions(-) create mode 100644 templates/CRM/Custom/Form/Field.hlp diff --git a/CRM/Custom/Form/Group.php b/CRM/Custom/Form/Group.php index c18e36da4d..e4af426b6a 100644 --- a/CRM/Custom/Form/Group.php +++ b/CRM/Custom/Form/Group.php @@ -155,6 +155,10 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $self->assign('showMultiple', TRUE); } + if (empty($fields['is_multiple']) && $fields['style'] == 'Tab with table') { + $errors['style'] = ts("Display Style 'Tab with table' is only supported for multiple custom data set'"); + } + //checks the given custom set doesnot start with digit $title = $fields['title']; if (!empty($title)) { @@ -421,7 +425,7 @@ class CRM_Custom_Form_Group extends CRM_Core_Form { $this->assign('showMaxMultiple', FALSE); } - if (($this->_action & CRM_Core_Action::UPDATE) && $defaults['is_multiple']) { + if (($this->_action & CRM_Core_Action::UPDATE) && !empty($defaults['is_multiple'])) { $defaults['collapse_display'] = 0; } diff --git a/CRM/Profile/Page/MultipleRecordFieldsListing.php b/CRM/Profile/Page/MultipleRecordFieldsListing.php index 99e6442224..a8fe335ff7 100644 --- a/CRM/Profile/Page/MultipleRecordFieldsListing.php +++ b/CRM/Profile/Page/MultipleRecordFieldsListing.php @@ -171,6 +171,8 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { * @access public */ function browse() { + $dateFields = NULL; + $dateFieldsVals = NULL; if ($this->_pageViewType == 'profileDataView' && $this->_profileId) { $fields = CRM_Core_BAO_UFGroup::getFields($this->_profileId, FALSE, NULL, NULL, NULL, @@ -225,6 +227,9 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $param = array('id' => $fieldIDs[$key]); $returnValues = array( ); CRM_Core_DAO::commonRetrieve('CRM_Core_DAO_CustomField', $param, $returnValues, $returnProperities); + if ($returnValues['data_type'] == 'Date') { + $dateFields[$fieldIDs[$key]] = 1; + } $optionValuePairs = CRM_Core_BAO_CustomOption::getCustomOption($fieldIDs[$key]); if (!empty($optionValuePairs)) { @@ -284,7 +289,14 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { foreach ($value as $fieldId => &$val) { if (is_numeric($fieldId)) { $customValue = &$val; - $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options); + if (array_key_exists($fieldId, $dateFields)) { + // formated date capture value capture + $dateFieldsVals[$fieldId][$recId] = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options); + } + else { + // assign to $result + $customValue = CRM_Core_BAO_CustomField::getDisplayValue($customValue, $fieldId, $options); + } if (!$customValue) { $customValue = ""; } @@ -305,8 +317,9 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $actionParams['newCgCount'] = $newCgCount; // DELETE action links + $redirectUrl = CRM_Core_Session::singleton()->readUserContext(); $links[CRM_Core_Action::DELETE]['url'] = '#'; - $links[CRM_Core_Action::DELETE]['extra'] = " onclick='showDeleteInDialog({$recId}, {$this->_customGroupId}, {$this->_contactId})' "; + $links[CRM_Core_Action::DELETE]['extra'] = " onclick=' var ru = \"{$redirectUrl}\"; showDeleteInDialog({$recId}, {$this->_customGroupId}, {$this->_contactId}, ru)' "; $links[CRM_Core_Action::DELETE]['class'] = 'ignore-jshref'; } if (!empty($pageCheckSum)) { @@ -336,6 +349,8 @@ class CRM_Profile_Page_MultipleRecordFieldsListing extends CRM_Core_Page_Basic { $headers[$fieldID] = ($this->_pageViewType == 'profileDataView') ? $customGroupInfo[$fieldID]['fieldLabel'] : $fieldLabels[$fieldID]['label']; } } + $this->assign('dateFields', $dateFields); + $this->assign('dateFieldsVals',$dateFieldsVals); $this->assign('cgcount', $cgcount); $this->assign('customGroupTitle', $this->_customGroupTitle); $this->assign('headers', $headers); diff --git a/CRM/Upgrade/Incremental/php/FourFive.php b/CRM/Upgrade/Incremental/php/FourFive.php index ec5940f9b2..3666f945c6 100644 --- a/CRM/Upgrade/Incremental/php/FourFive.php +++ b/CRM/Upgrade/Incremental/php/FourFive.php @@ -61,6 +61,7 @@ class CRM_Upgrade_Incremental_php_FourFive { function setPostUpgradeMessage(&$postUpgradeMessage, $rev) { if ($rev == '4.5.alpha1') { $postUpgradeMessage .= '

' . ts('Default versions of the following System Workflow Message Templates have been modified to handle new functionality: If you have modified these templates, please review the new default versions and implement updates as needed to your copies (Administer > Communications > Message Templates > System Workflow Messages).'); + $postUpgradeMessage .= '

' . ts('This release allows you to view and edit multiple-record custom field sets in a table format which will be more usable in some cases. You can try out the format by navigating to Administer > Custom Data & Screens > Custom Fields. Click Settings for a custom field set and change Display Style to "Tab with Tables".'); } } diff --git a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl index 6cdcef9d3d..a1bbff9a8f 100644 --- a/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl +++ b/CRM/Upgrade/Incremental/sql/4.5.alpha1.mysql.tpl @@ -1,6 +1,4 @@ {* file to handle db changes in 4.5.alpha1 during upgrade *} -{include file='../CRM/Upgrade/4.4.alpha1.msg_template/civicrm_msg_template.tpl'} - {include file='../CRM/Upgrade/4.5.alpha1.msg_template/civicrm_msg_template.tpl'} ALTER TABLE `civicrm_contact` @@ -250,4 +248,6 @@ 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 + WHERE cg.is_multiple = 1 AND cf.html_type != 'TextArea'; +ALTER TABLE `civicrm_custom_group` + CHANGE COLUMN `style` `style` varchar(15) COLLATE utf8_unicode_ci DEFAULT NULL COMMENT 'Visual relationship between this form and its parent.'; \ No newline at end of file diff --git a/templates/CRM/Contact/Page/View/CustomData.tpl b/templates/CRM/Contact/Page/View/CustomData.tpl index 06d751e99b..08f9f3f6f3 100644 --- a/templates/CRM/Contact/Page/View/CustomData.tpl +++ b/templates/CRM/Contact/Page/View/CustomData.tpl @@ -31,7 +31,7 @@ {include file='CRM/Profile/Page/MultipleRecordFieldsListing.tpl' showListing=1 dontShowTitle=1 pageViewType='customDataView'} {literal}