forked from eileenmcnaughton/civicrm_entity
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/4.0.x' into 4.0.x-pathauto
* origin/4.0.x: 4.0.x field mappings (eileenmcnaughton#430) Adding a raw value function to return value from values array (eileenmcnaughton#465) Add filter for state province. (eileenmcnaughton#453) Update default timezone handling for dates in CiviEntityStorage.php (eileenmcnaughton#461) fix testLoadContact birthdate assertion (eileenmcnaughton#472) port to 4.0.x from 436: Include dblocale table names in list of civicrm entity info (eileenmcnaughton#438) Ignore convert to UTC if custom field is date only (eileenmcnaughton#469) update contact entity referece field on contact merge (eileenmcnaughton#456) update test versions of Drupal 10.2 and CiviCRM 5.69 (eileenmcnaughton#468) Clean value on custom field for Float (Number) and Money field type (eileenmcnaughton#463) From eileenmcnaughton#378 for 4.0.x (eileenmcnaughton#466) Add reset to the file URLs generated. (eileenmcnaughton#458) fix Views field custom date field output for year only (eileenmcnaughton#439)
- Loading branch information
Showing
15 changed files
with
344 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/** | ||
* @file | ||
* civicrm_entity.states.js | ||
*/ | ||
|
||
(function ($, Drupal) { | ||
|
||
/** | ||
* Sets states depending on the chosen country. | ||
* | ||
* @type {Drupal~behavior} | ||
* | ||
* @prop {Drupal~behaviorAttach} attach | ||
*/ | ||
Drupal.behaviors.civicrmEntityStates = { | ||
attach(context, settings) { | ||
$(once('loadStates', '.views-exposed-form [data-drupal-selector="edit-' + settings.civicrm_entity.country_identifier + '"]', context)).on('change', function() { | ||
var countries = $(this).val(); | ||
|
||
var $stateElement = $('[data-drupal-selector="edit-' + settings.civicrm_entity.states_identifier + '"]', $(this).parents('form')); | ||
$stateElement.find('option').not(':first').remove(); | ||
|
||
if (countries != Drupal.t('All')) { | ||
countries = Array.isArray(countries) ? countries : [countries]; | ||
countries.forEach((v) => { | ||
$stateElement.append(settings.civicrm_entity.states[v]); | ||
}); | ||
} | ||
}).trigger('change'); | ||
}, | ||
}; | ||
|
||
})(jQuery, Drupal, drupalSettings); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Plugin/Field/FieldFormatter/ContactReferenceFormatter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
namespace Drupal\civicrm_entity\Plugin\Field\FieldFormatter; | ||
|
||
use Drupal\Core\Access\AccessResult; | ||
use Drupal\Core\Entity\EntityInterface; | ||
use Drupal\Core\Field\Plugin\Field\FieldFormatter\EntityReferenceLabelFormatter; | ||
use Drupal\user\Entity\User; | ||
|
||
/** | ||
* Plugin implementation of the 'civicrm_entity_contact_reference' formatter. | ||
* | ||
* @FieldFormatter( | ||
* id = "civicrm_entity_contact_reference", | ||
* label = @Translation("CiviCRM custom contact reference field"), | ||
* field_types = { | ||
* "entity_reference", | ||
* } | ||
* ) | ||
*/ | ||
class ContactReferenceFormatter extends EntityReferenceLabelFormatter { | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
protected function checkAccess(EntityInterface $entity) { | ||
$permissions = [ | ||
'view all contacts', | ||
'access all custom data' | ||
]; | ||
$account = User::load(\Drupal::currentUser()->id()); | ||
return AccessResult::allowedIfHasPermissions($account, $permissions, 'OR'); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.