-
-
Notifications
You must be signed in to change notification settings - Fork 812
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
dev/core#111 Support Custom Data for MembershipType entity #12439
dev/core#111 Support Custom Data for MembershipType entity #12439
Conversation
(Standard links)
|
test this please |
api/v3/MembershipType.php
Outdated
@@ -47,6 +47,10 @@ function civicrm_api3_membership_type_create($params) { | |||
$params[$field] = implode(CRM_Core_DAO::VALUE_SEPARATOR, $params[$field]); | |||
} | |||
} | |||
|
|||
if (!isset($params['domain_id'])) { | |||
$params['domain_id'] = CRM_Core_Config::domainID(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would incorrectly be set if 'id' is set - I think we should spin this out & resolve it first - but I think we should support 'current_domain' in the same way we support 'user_contact_id', now - ie. ie would look like
$params['domain_id']['api.default'] => 'current_domain_id';
I would need to understand from @totten why the code in utils handles '('or similar') but I guess we could just 'special-handle' the specific string 'current_domain_id'
if (!empty($fieldValue) || $fieldValue === '0' || $fieldValue === 0) {
// if value = 'user_contact_id' (or similar), replace value with contact id
if (!is_numeric($fieldValue) && is_scalar($fieldValue)) {
$realContactId = _civicrm_api3_resolve_contactID($fieldValue);
if ('unknown-user' === $realContactId) {
throw new API_Exception("\"$fieldName\" \"{$fieldValue}\" cannot be resolved to a contact ID", 2002, array('error_field' => $fieldName, "type" => "integer"));
}
This is in support of civicrm#12439 & making domain_id optional
CRM/Admin/Form/RelationshipType.php
Outdated
@@ -97,7 +97,7 @@ public function getDefaultEntity() { | |||
* We do this from the constructor in order to do a translation. | |||
*/ | |||
public function setDeleteMessage() { | |||
$this->deleteMessage = ts('WARNING: Deleting this option will result in the loss of all Relationship records of this type.') . ts('This may mean the loss of a substantial amount of data, and the action cannot be undone.') . ts('Do you want to continue?'); | |||
self::setEntityDeleteMessage(ts('Relationship')); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mlutfy can you comment on whether this interpolation is equally good from your point of view? I originally assumed that the way it was before (with a line for each entity) was 'better' but not so sure now...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I started changing it separately for each entity but then realised that nearly every entity with a delete action shares exactly the same wording (except the entity name) so I think this will reduce the number of strings that need translating significantly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not strongly opposed, but it is a loss of usability for non-English.
- CiviCRM does tend to have very verbose messages, which do not always communicate the right thing.
- We do tend to have a lot of copy-paste strings, and when updating them, we should try to be consistent.
- For example, the user might not care about the type of entity, but will react differently if this is going to delete 5000 records, vs deleting 5 records.
Grammatically:
- Assumes that the gender of "records" in other languages will always be the same (since 'records' is in the common string, it forces translators to do acrobatics to choose a gender-neutral word)
- Assumes that the noun (relationship, %1, etc) will be declined in the same way no matter of the context (can cause issues for some Slavic languages, I think)
- Assumes that the word "relationship" will have enough context for translators to use the correct word (this is probably minor, since those entities are well-known, but worth keeping in mind for words such as "Home" or "From").
For French, it forces us to translate in this form:
WARNING: Deleting this option will result in the loss of all records of this type (%1).
i.e.:
Avertissement: La suppression de cette option entraînera la perte de toutes les entrées de ce type (Relation).
Where as, it is currently translated as:
Avertissement: La suppression de cette option entraînera la perte de toutes les relations de ce type.
The latter makes it much more clear that we are deleting relationships, not just abstract records.
If the message looks awkward, users will ignore it. The parenthesis and incorrect capitalisation communicates to the user that this is a nerdy message, so they can glance over and look for the nearest "OK" button without thinking about it.
Conclusion: if it's clear from the context, we can remove the entity type (%1) completely. This way the user is more likely to read the message and think about what they are doing, but it can lead to frustration if they don't really know what the impact is. If we really want to communicate something useful, tell the user how many records will be deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So - I'm not sure if it is clear without the world - I'm not inclined to make a change with a negative impact on usability for non-anglophones where there is such a minor code repetition decrease
This is in support of civicrm#12439 & making domain_id optional
d50399c
to
f12c37e
Compare
This is in support of civicrm#12439 & making domain_id optional
1660e1f
to
03594b8
Compare
@eileenmcnaughton This is now updated and rebased. I removed the "translation" helper for setDeleteMessage() I realise it doesn't really help (per @mlutfy comments). Also removed the domain_id as MembershipType API has already been updated in core to make this optional. Pending tests passing I think this should be ok to merge. |
@mattwire I'm not ready to accept that we can't use the entity fields.tpl yet - I want to try to push a bit further on that before accepting it. The main reason is that I want to set a bar for adding custom fields to an entity. I'm happy to merge this without the one line that delivers the main functionality - {include file="CRM/common/customDataBlock.tpl"} and then take a look at how we can go further on this |
03594b8
to
2147e32
Compare
Per previous comments - adding merge on pass - I'll take a look & see if we can do anything with the tpl |
test this please |
Overview
Enable custom data support on the MembershipType form.
Before
Could not view/edit custom data on MembershipType form.
After
Can view/edit custom data on MembershipType form.
Technical Details
Comments
@eileenmcnaughton This is a follow on from all the previous ones (eg. #12117, #12118). It should address all the previous issues. Also note that I'm now using cg_extends to add MembershipType (you'll either need to add it manually, or install this extension: https://github.com/mattwire/uk.co.mjwconsult.variablerecurpayments
Which will setup cg_extends for you as well as provide some handy MembershipType custom fields for testing :-)