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

Disable inline-edit of multi-record custom fields in profiles #12312

Merged
merged 1 commit into from
Jul 15, 2018

Conversation

colemanw
Copy link
Member

@colemanw colemanw commented Jun 15, 2018

Overview

Fixes a bug when editing multirecord custom fields in a profile form.

Steps to Reproduce

  1. Create a multirecord set of custom fields for contacts (Type "Tab with Table")
  2. Create a profile; add the fields to the profile (selecting "Include in multi-record listing?" for each field)
  3. Use the profile in edit mode for an existing contact
  4. Once you have at least one row of values, click on a value to edit in-place.
  5. Javascript error.

After

Profile does not allow inline-edit.

Notes

This was reported on StackExchange: https://civicrm.stackexchange.com/questions/25166/disable-inline-editing-of-fields-in-profile-form

@civibot
Copy link

civibot bot commented Jun 15, 2018

(Standard links)

@bmango
Copy link

bmango commented Jun 15, 2018

I applied these changes to a test site I had set up using Civi 5.1.2. The changes worked when I was logged in as the administrator. No more error was appearing, and I was able to use the inline editing for the dropdown lists in the profile to update values. However, the changes produced another jquery error, a 403 Forbidden error, when I was not logged in as the administrator, but had view edit and delete privileges for the profile. The error was:

jquery.min.js?pacwi7:4 GET http://drupal.benmango.co.uk/civicrm/ajax/rest?entity=contact&action=getoptions&json=%7B%22field%22%3A%22custom_7%22%2C%22context%22%3A%22create%22%7D 403 (Forbidden)
send	@	jquery.min.js?pacwi7:4
ajax	@	jquery.min.js?pacwi7:4
getData	@	jquery.crmEditable.js:216
(anonymous)	@	jquery.jeditable.min.js:17
dispatch	@	jquery.min.js?pacwi7:3
r.handle	@	jquery.min.js?pacwi7:3

This was then followed by the original jQuery error:

jquery.jeditable.min.js:34 Uncaught TypeError: Cannot read property 'constructor' of undefined
    at n.fn.init.content (jquery.jeditable.min.js:34)
    at HTMLDivElement.<anonymous> (jquery.jeditable.min.js:18)
    at HTMLDivElement.dispatch (jquery.min.js?pacwi7:3)
    at HTMLDivElement.r.handle (jquery.min.js?pacwi7:3)

You can see the new error produced when clicking on the profile dropdowns at the test profile page at http://drupal.benmango.co.uk/civicrm/profile/edit?gid=14&reset=1&id=109.

@colemanw
Copy link
Member Author

@bmango does your user have "access ajax api" permission?

@bmango
Copy link

bmango commented Jun 15, 2018

@colemanw - no they didn't. I have now given them permission, and this has solved the first jQuery error (403 Forbidden), but the second jQuery error is still there:

Uncaught TypeError: Cannot read property 'constructor' of undefined
    at n.fn.init.content (jquery.jeditable.min.js:34)
    at HTMLDivElement.<anonymous> (jquery.jeditable.min.js:18)
    at HTMLDivElement.dispatch (jquery.min.js?pad5qd:3)
    at HTMLDivElement.r.handle (jquery.min.js?pad5qd:3)
content	@	jquery.jeditable.min.js:34
(anonymous)	@	jquery.jeditable.min.js:18
dispatch	@	jquery.min.js?pad5qd:3
r.handle	@	jquery.min.js?pad5qd:3

@colemanw
Copy link
Member Author

I've just attempted to reproduce this by creating a new user and taking away "administer CiviCRM" permission but the profile still worked ok. There must be some permission at play here but I'm not sure which one it is. Can you try adding more permissions to your test user until it works? Let's try to figure out which one it is and then add some code to the JS to check for that permission before attempting the inline edit.

@bmango
Copy link

bmango commented Jun 15, 2018

I have tried adding individual permissions. The only one that fixed it was when I added "access CiviCRM". I had already added "administer CiviCRM" as well as add, edit, view and deleting all contacts, which had not fixed the issue.

On the test site I was allowing anonymous visitors access to the form, but I also created a user as well and this didn't make any difference.

@colemanw
Copy link
Member Author

@bmango I've updated this PR to simply not allow inline-edit via profiles instead of trying to fix it, as I don't think it was ever intended to be used in that context anyway.

@colemanw colemanw changed the title Fix inline-edit of multi-record custom fields in profiles Disable inline-edit of multi-record custom fields in profiles Jul 10, 2018
@bmango
Copy link

bmango commented Jul 11, 2018

@colemanw Thanks very much for looking at this. Disabling the inline edit makes total sense.

@colemanw
Copy link
Member Author

@bmango thanks. If you get a chance to test this PR and confirm it works, we're good to merge :)

@colemanw colemanw added the merge ready PR will be merged after a few days if there are no objections label Jul 11, 2018
@colemanw
Copy link
Member Author

@civicrm-builder retest this please

@bmango
Copy link

bmango commented Jul 11, 2018

@colemanw - I have tested that and it works great. There is no longer the ability to edit the fields inline. Everything else is working fine. Many thanks!

@colemanw colemanw added merge on pass and removed merge ready PR will be merged after a few days if there are no objections labels Jul 11, 2018
@seamuslee001
Copy link
Contributor

Jenkins re test this please

@seamuslee001
Copy link
Contributor

(CiviCRM Review Template WORD-1.1)

@seamuslee001 seamuslee001 merged commit 9249572 into civicrm:master Jul 15, 2018
@colemanw colemanw deleted the multiRecordCustomProfile branch July 15, 2018 04:09
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.

4 participants