Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert relationship start & end dates to datepicker #15637

Merged
merged 1 commit into from
Oct 29, 2019

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Convert relationship start & end dates to datepicker

Before

Jcalendar

After

Datepicker

Technical Details

Seems to work like this - @seamuslee001 I'll be interested to see if you find anything kicking the tyres on this - needs the others merged to 'clean it up'

Comments

@civibot
Copy link

civibot bot commented Oct 28, 2019

(Standard links)

@civibot civibot bot added the master label Oct 28, 2019
@@ -511,9 +538,6 @@ public static function relationship(&$form) {
['id' => 'relation_target_group', 'multiple' => 'multiple', 'class' => 'crm-select2']
);
}
CRM_Core_Form_Date::buildDateRange($form, 'relation_start_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
CRM_Core_Form_Date::buildDateRange($form, 'relation_end_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);

CRM_Core_Form_Date::buildDateRange($form, 'relation_active_period_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton not wanting to convert this one yet?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 nope - next round

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 also - I feel like

CRM_Core_Form_Date::buildDateRange($form, 'relation_date', 1, '_low', '_high', ts('From:'), FALSE, FALSE);
can just be removed???

@seamuslee001
Copy link
Contributor

@eileenmcnaughton i tested this and it feels like its got some birth_date stuff in there etc but thats ok, i also notice you haven't done the upgrade for the relationship date stuff. However when i manually put in the upgrade stuff its all good and smart groups work right.

@seamuslee001
Copy link
Contributor

@eileenmcnaughton needs a rebase and needs the relationship date upgrade steps added

@eileenmcnaughton eileenmcnaughton force-pushed the relationdates branch 2 times, most recently from 12ccd8b to 1cbe1bf Compare October 28, 2019 22:30
@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 hopefully that is right now

@seamuslee001
Copy link
Contributor

All looks good to me now Merge on pass

@seamuslee001
Copy link
Contributor

actaully @eileenmcnaughton one thing you have missed you need to update the array in CRM/Upgrade/Increment/SmartGroups.php so that relation_end and relation_start which are the relative saved names get correctly upgraded

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001
Copy link
Contributor

@eileenmcnaughton no because it will only process the fields
relationship_start_date_high relationship_start_date relationship_start_date_relative relationship_start_date_low as per https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/SmartGroups.php#L78 which is why we have https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/SmartGroups.php#L59 which takes the relative date mappings from the old way and converts to the new way as per https://github.com/civicrm/civicrm-core/blob/master/CRM/Upgrade/Incremental/SmartGroups.php#L86

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 but didn't we rename the fields first?

@seamuslee001
Copy link
Contributor

we don't rename the fields within the relative array

@seamuslee001
Copy link
Contributor

also its like relation_end and relation_start in the relative array key of formValues

@seamuslee001
Copy link
Contributor

seamuslee001 commented Oct 28, 2019

@eileenmcnaughton

This is a sample form values before upgrade

a:10:{i:0;a:5:{i:0;s:8:"entryURL";i:1;s:1:"=";i:2;s:48:"http://47-test/civicrm/contribute/search?reset=1";i:3;i:0;i:4;i:0;}i:1;a:5:{i:0;s:21:"group_search_selected";i:1;s:1:"=";i:2;s:5:"group";i:3;i:0;i:4;i:0;}i:2;a:5:{i:0;s:16:"privacy_operator";i:1;s:1:"=";i:2;s:2:"OR";i:3;i:0;i:4;i:0;}i:3;a:5:{i:0;s:14:"privacy_toggle";i:1;s:1:"=";i:2;s:1:"1";i:3;i:0;i:4;i:0;}i:4;a:5:{i:0;s:15:"relation_status";i:1;s:1:"=";i:2;s:1:"0";i:3;i:0;i:4;i:0;}i:5;a:5:{i:0;s:23:"relation_start_date_low";i:1;s:1:"=";i:2;s:14:"20191001000000";i:3;i:0;i:4;i:0;}i:6;a:5:{i:0;s:24:"relation_start_date_high";i:1;s:1:"=";i:2;s:14:"20191031235959";i:3;i:0;i:4;i:0;}s:14:"relative_dates";a:1:{s:14:"relation_start";s:10:"this.month";}i:7;a:5:{i:0;s:8:"operator";i:1;s:1:"=";i:2;s:3:"AND";i:3;i:0;i:4;i:0;}i:8;a:5:{i:0;s:14:"component_mode";i:1;s:1:"=";i:2;s:1:"1";i:3;i:0;i:4;i:0;}}

After the upgrade with your PR applied this is the form values

a:10:{i:0;a:5:{i:0;s:8:"entryURL";i:1;s:1:"=";i:2;s:48:"http://47-test/civicrm/contribute/search?reset=1";i:3;s:1:"0";i:4;s:1:"0";}i:1;a:5:{i:0;s:21:"group_search_selected";i:1;s:1:"=";i:2;s:5:"group";i:3;s:1:"0";i:4;s:1:"0";}i:2;a:5:{i:0;s:16:"privacy_operator";i:1;s:1:"=";i:2;s:2:"OR";i:3;s:1:"0";i:4;s:1:"0";}i:3;a:5:{i:0;s:14:"privacy_toggle";i:1;s:1:"=";i:2;s:1:"1";i:3;s:1:"0";i:4;s:1:"0";}i:4;a:5:{i:0;s:15:"relation_status";i:1;s:1:"=";i:2;s:1:"0";i:3;s:1:"0";i:4;s:1:"0";}i:5;a:5:{i:0;s:27:"relationship_start_date_low";i:1;s:1:"=";i:2;s:19:"2019-10-01 00:00:00";i:3;s:1:"0";i:4;s:1:"0";}i:6;a:5:{i:0;s:28:"relationship_start_date_high";i:1;s:1:"=";i:2;s:19:"2019-10-31 23:59:59";i:3;s:1:"0";i:4;s:1:"0";}s:14:"relative_dates";a:1:{s:14:"relation_start";s:10:"this.month";}i:7;a:5:{i:0;s:8:"operator";i:1;s:1:"=";i:2;s:3:"AND";i:3;s:1:"0";i:4;s:1:"0";}i:8;a:5:{i:0;s:14:"component_mode";i:1;s:1:"=";i:2;s:1:"1";i:3;s:1:"0";i:4;s:1:"0";}}

Note we still have the relative_dates array and also note that rather than having relationship_start_date_relative in the formValues we still have the high & low values

@eileenmcnaughton
Copy link
Contributor Author

@seamuslee001 then we should move the coverting to above the renaming for all the fields in the upgrade I think

@seamuslee001
Copy link
Contributor

@eileenmcnaughton why we have always done re-nameing then converting ever since you brought in this routine

This seems to work OK - look forwards to seeing you kick the tyres on it & see if you find any issues
@@ -71,6 +71,8 @@ public function datePickerConversion($fields) {
'case_start_date' => 'case_from',
'case_end_date' => 'case_to',
'mailing_job_start_date' => 'mailing_date',
'relationship_start_date' => 'relation_start_date',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the old name was just relation_start i think and relation_end for the other i think

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

odd one because when i created from an advanced search the form values was

s:14:"relative_dates";a:1:{s:14:"relation_start";s:10:"this.month";}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ug

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well I guess that is authoritive if you did that test

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 actually the UI ALSO has the field relation_date - which I hadn't made sense of - maybe it's the equivalent of the event_date? Although my initial assumption (ie it's just broken) may also be true & the resulting smart group from the pre-this change search might not actually work .... I guess we need to test that

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton i can't even see where that relation_date date search is exposed on the form its self, i think just get rid of it

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looking at this @eileenmcnaughton
https://github.com/civicrm/civicrm-core/pull/15637/files#diff-54576153cb6a72d6ea7e22a5e8ca63f2R410 it would suggest it only goes until it hits either _date or _relative which i think matches with it storing relation_start in the db

@seamuslee001
Copy link
Contributor

I'm going to merge this and do a follow up tidy up fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants