Skip to content

Commit

Permalink
Resolve civicrm#533 by ensuring entity details are correctly loaded f…
Browse files Browse the repository at this point in the history
…or use by the interactive profile editor

Pass in an empty array for used for value
  • Loading branch information
seamuslee001 committed Feb 6, 2023
1 parent 5919a75 commit 27fbcf7
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 10 deletions.
8 changes: 8 additions & 0 deletions CRM/Volunteer/Angular/Tab/Event.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public static function prepareTab($eventId) {
$event = $project->getEntityAttributes();
$entityTitle = $event['title'];

CRM_UF_Page_ProfileEditor::registerProfileScripts();
extract(CRM_Volunteer_Form_IncludeProfile::getProfileSelectorTypes());
CRM_UF_Page_ProfileEditor::registerSchemas(CRM_Utils_Array::collect('entity_type', $profileEntities));
CRM_Core_Resources::singleton()
->addStyleFile('org.civicrm.volunteer', 'css/volunteer_app.css')
->addStyleFile('org.civicrm.volunteer', 'css/volunteer_events.css')
Expand All @@ -54,6 +57,11 @@ public static function prepareTab($eventId) {
'entityId' => $project->entity_id,
'entityTitle' => $entityTitle,
'context' => 'eventTab',
'dataGroupType' => CRM_Core_BAO_UFGroup::encodeGroupType($allowCoreTypes, $allowSubTypes, ';;'),
'dataEntities' => json_encode($profileEntities),
'dataDefault' => FALSE,
'dataUsedFor' => json_encode($usedFor),

));
}

Expand Down
13 changes: 7 additions & 6 deletions CRM/Volunteer/Form/IncludeProfile.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ public static function buildProfileWidget(&$form, $count, $prefix = '', $label =
* @return array( 'allowCoreTypes' => array(), 'allowSubTypes' => array(), 'profileEntities' => array() )
*/
static function getProfileSelectorTypes() {
$configs = array(
'allowCoreTypes' => array(),
'allowSubTypes' => array(),
'profileEntities' => array(),
);
$configs = [
'allowCoreTypes' => [],
'allowSubTypes' => [],
'profileEntities' => [],
'usedFor' => [],
];

$configs['allowCoreTypes'][] = 'Contact';
$configs['allowCoreTypes'][] = 'Individual';
Expand All @@ -53,4 +54,4 @@ static function getProfileSelectorTypes() {

return $configs;
}
}
}
4 changes: 2 additions & 2 deletions ang/volunteer/Project.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@
<label>{{:: ts("Profile:") }}</label>
</div>
<div class="content">
<input ng-if="supporting_data.use_profile_editor" crm-profile-selector="{}"
ng-model="profile.uf_group_id" ng-change="validateProfileSelections()"/>
<input ng-if="supporting_data.use_profile_editor"
ng-model="profile.uf_group_id" ng-change="validateProfileSelections()" class="crm-profile-selector" id="profile-field" data-entities="{{data_entities}}" data-default="{{data_default}}" data-usedfor="{{data_used_for}}" data-group-type="{{data_group_type}}"/>

<select ng-if="!supporting_data.use_profile_editor" class="big crm-form-select crm-vol-simple-profile-selector"
crm-ui-select="{placeholder: '', allowClear:true}" ng-change="validateProfileSelections()"
Expand Down
8 changes: 6 additions & 2 deletions ang/volunteer/Project.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(function(angular, $, _) {
(function(angular, $, _, CRM) {

angular.module('volunteer').config(function($routeProvider) {
$routeProvider.when('/volunteer/manage/:projectId', {
Expand Down Expand Up @@ -171,6 +171,10 @@
$scope.phone_types = supporting_data.values.phone_types;
$scope.supporting_data = supporting_data.values;
$scope.profile_status = profile_status;
$scope.data_entities = CRM.vars['org.civicrm.volunteer'].dataEntities;
$scope.data_used_for = CRM.vars['org.civicrm.volunteer'].dataUsedFor;
$scope.data_default = CRM.vars['org.civicrm.volunteer'].dataDefault;
$scope.data_group_type = CRM.vars['org.civicrm.volunteer'].dataGroupType;
project.is_active = (project.is_active == "1");
$scope.project = project;
$scope.profiles = $scope.project.profiles;
Expand Down Expand Up @@ -449,4 +453,4 @@

});

})(angular, CRM.$, CRM._);
})(angular, CRM.$, CRM._, CRM);

0 comments on commit 27fbcf7

Please sign in to comment.