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

Setting form - start to sync preferences with Setting, using trait #12731

Merged
merged 3 commits into from
Oct 8, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

Overview

Adds a trait class & starts to align Settings form with preferences form

Before

The settings form & the preferences form do the same thing but evolved separately. Settings uses metadata, preferences doesn't.

After

This adds a trait that can be shared & the parts of both that use metadata can use the shared section

Technical Details

Over time we should remove both forms in favour of a new clean one based on the trait. I think the trait would be merged into that form.

Note that one issue TBC is how to define 'serialize' on the form. In the DAO we use a string but the generator converts it to a constant. I used just a constant here.

I can break this down into some smaller commits.

Comments

@mattwire I think part of #12714 is resolving the form interaction. I took a look on the first setting.

@civibot
Copy link

civibot bot commented Aug 26, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

test this please

@colemanw
Copy link
Member

@eileenmcnaughton this needs rebase now that the other PR merged.

@eileenmcnaughton
Copy link
Contributor Author

@colemanw I rebased it - but I also created #12744 as a more reviewable chunk - which is a very replicable extraction

@mlutfy
Copy link
Member

mlutfy commented Aug 29, 2018

jenkins, test this please

1 similar comment
@mlutfy
Copy link
Member

mlutfy commented Aug 30, 2018

jenkins, test this please

@eileenmcnaughton
Copy link
Contributor Author

@colemanw @mattwire I think this is readable enough to review as one chunk now?

catch (CiviCRM_API3_Exception $e) {
CRM_Core_Session::setStatus($e->getMessage(), ts('Save Failed'), 'error');
}

foreach ($this->_varNames as $groupName => $groupValues) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

going forwards we basically migrate settings out of varNames into protected $_settings per below

'is_domain' => '1',
'is_contact' => 0,
'description' => NULL,
'description' => ts("Select the tabs that should be displayed when viewing a contact record. EXAMPLE: If your organization does not keep track of 'Relationships', then un-check this option to simplify the screen display. Tabs for Contributions, Pledges, Memberships, Events, Grants and Cases are also hidden if the corresponding component is not enabled. Go to Administer > System Settings > Enable Components to modify the components which are available for your site."),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ideally we also use this for the tpl help text rather than duplicating - I haven't looked at that as yet

@colemanw
Copy link
Member

@eileenmcnaughton what forms should I try when testing this?

@eileenmcnaughton
Copy link
Contributor Author

@colemanw so far literally only one setting is converted - the top one on display preferences

screenshot 2018-09-03 12 19 46

But ideally you would tinker with converting a few more to test the methodology a bit - @mattwire put up a PR with a lot more in it https://github.com/civicrm/civicrm-core/pull/12714/files#diff-cd9367d6c33a74944159c2f7623db4a7R69

An end goal would be to start using code like SettingsForm.tpl in Display.tpl - replacing the hard coded settings with metadata

@eileenmcnaughton
Copy link
Contributor Author

Re the tpl - see this commit mattwire@73dad36 - although I'm making the case for aligning settings & preferences forms as part of this change

@mattwire
Copy link
Contributor

mattwire commented Sep 8, 2018

@eileenmcnaughton When I test this there seems to be something wrong with the checkbox save/load logic. Pledges and mailings are always unchecked and if I uncheck grants cases gets unchecked as well.

@colemanw
Copy link
Member

@eileenmcnaughton see last comment from @mattwire

@eileenmcnaughton
Copy link
Contributor Author

@mattwire just figured it out - the setDefaults was the issue - can you recheck?

@mattwire
Copy link
Contributor

mattwire commented Oct 8, 2018

@eileenmcnaughton Now working fine. Can you fix the two style warnings reported by jenkins and then we can merge.

@eileenmcnaughton
Copy link
Contributor Author

unrelated fails

@eileenmcnaughton eileenmcnaughton merged commit 2e9a385 into civicrm:master Oct 8, 2018
@eileenmcnaughton eileenmcnaughton deleted the setting_form branch October 8, 2018 16:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants