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

[NFC] Preferences form template cleanup #13046

Merged
merged 5 commits into from
Nov 1, 2018

Conversation

eileenmcnaughton
Copy link
Contributor

@eileenmcnaughton eileenmcnaughton commented Nov 1, 2018

Overview

Moves code around to a more logical place.

Before

When the invoicing code was added it was added to the preferences template...badly. Instead of adding code related to invoicing to the relevant preferences template it was added to a shared template, wrapped in 'ifs'.

After

Code specific to only one preference form moved back to it's own template & shared code simplified.

Technical Details

Just moves code around - no change. Note each commit is a distinct small step in this process

Comments

There are still a couple of things to fix on the php side on this form - but this neither creates or fixes those issues.

This is part of disentangling the invoicing mess out of the shared code
Contribute.tpl no longer relies on basicForm.tpl so we can clean that up now
Contribute.tpl no longer shares this form
@civibot
Copy link

civibot bot commented Nov 1, 2018

(Standard links)

@eileenmcnaughton
Copy link
Contributor Author

@mattwire almost there for the cleanup round - ping

@mattwire
Copy link
Contributor

mattwire commented Nov 1, 2018

@eileenmcnaughton I don't understand why but the checkbox to show/hide tax/invoicing settings seems to have changed it's ID following this PR to #invoicing_invoicing which stopped the jQuery from working. The jQuery was also rather old in that function, I replaced it as follows:

{literal}
  <script type="text/javascript">
    CRM.$(document).ready(function() {
      if (CRM.$("#invoicing_invoicing").prop('checked')) {
        CRM.$("#invoicing_blocks").show();
      }
      else {
        CRM.$("#invoicing_blocks").hide();
      }
    });
    CRM.$(function() {
      CRM.$("input[type=checkbox]").click(function() {
        if (CRM.$("#invoicing_invoicing").prop('checked')) {
          CRM.$("#invoicing_blocks").show();
        }
        else {
          CRM.$("#invoicing_blocks").hide();
        }
      });
    });
  </script>
{/literal}

@pradpnayak
Copy link
Contributor

pradpnayak commented Nov 1, 2018

Hi @mattwire

How about below code to hide/show invoice block

{literal}
  <script type="text/javascript">
    CRM.$(function($) {
      hideShowInvoiceBlocks();
      $("#invoicing_invoicing").click(hideShowInvoiceBlocks);

      function hideShowInvoiceBlocks() {
        if ($("#invoicing_invoicing").prop('checked')) {
          $("#invoicing_blocks").show();
        }
        else {
          $("#invoicing_blocks").hide();
        }
      }
    });
  </script>
{/literal}

@mattwire
Copy link
Contributor

mattwire commented Nov 1, 2018

@pradpnayak Yes, much better and cleaner. I've just tested your version and it works perfectly.

@pradpnayak
Copy link
Contributor

pradpnayak commented Nov 1, 2018

@JoeMurray / @Edzelopez / @monishdeb

You might need to update your extension code like EasyBatch, Edit Line Item, Close Accounting Period etc which add's some settings using jQuery and CiviCRM hooks on Contribute Settings page.

Thanks
Pradeep

@eileenmcnaughton
Copy link
Contributor Author

@mattwire @pradpnayak can we merge this & then @pradpnayak's version as a follow up? There is one more PR based on this #13047 which isolates that form

@eileenmcnaughton
Copy link
Contributor Author

also @pradpnayak you may not have seen this https://lab.civicrm.org/dev/core/issues/495 - if I can get the last fix-ups merged I'll work on that & it will give better options for extensions

@eileenmcnaughton
Copy link
Contributor Author

@mattwire I think with #13047 merged the jquery works again - this neither breaks or fixes it

@eileenmcnaughton
Copy link
Contributor Author

(but agree @pradpnayak's is an improvement)

@mattwire
Copy link
Contributor

mattwire commented Nov 1, 2018

@eileenmcnaughton Ok, I see it is currently broken in master too. In which case let's merge this and resolve see if the jquery is fixed by #13047 (but still be good to update to use @pradpnayak changes afterwards).

@eileenmcnaughton
Copy link
Contributor Author

@mattwire thanks - merging - once #13047 is merged we need to do a good audit!

@eileenmcnaughton eileenmcnaughton merged commit f87c35c into civicrm:master Nov 1, 2018
@eileenmcnaughton eileenmcnaughton deleted the settings_address branch November 1, 2018 11:04
@eileenmcnaughton
Copy link
Contributor Author

& yes agree re @pradpnayak improvement - also, I don't understand WHY the id changed - but at the moment I think merge #13047 & then look at that

@pradpnayak
Copy link
Contributor

Hi @eileenmcnaughton

I just tested on my local machine on current state of code. It appears that labels for field is printed twice. Is this something fixed in your other PR?

screen shot 2018-11-01 at 16 35 01

@eileenmcnaughton
Copy link
Contributor Author

@pradpnayak let's hope so :-)

@pradpnayak
Copy link
Contributor

@eileenmcnaughton I am going to test #13047 now

@eileenmcnaughton
Copy link
Contributor Author

thanks @pradpnayak

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.

3 participants