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

Vol 216 location column #388

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CRM/Volunteer/Form/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,13 @@ function buildQuickForm() {
array("placeholder" => ts("- none -", array('domain' => 'org.civicrm.volunteer')), "multiple" => "multiple", "class" => "crm-select2")
);

//Add field for Displaying project location to opportunities page
$this->addYesNo(
'volunteer_general_show_project_location_public',
ts('Display Project Location', array('domain' => 'org.civicrm.volunteer'))
);


$this->addButtons(array(
array(
'type' => 'submit',
Expand Down Expand Up @@ -188,6 +195,7 @@ function setDefaultValues() {
//General Settings
$defaults['volunteer_general_campaign_filter_type'] = CRM_Utils_Array::value('volunteer_general_campaign_filter_type', $this->_settings);
$defaults['volunteer_general_campaign_filter_list'] = CRM_Utils_Array::value('volunteer_general_campaign_filter_list', $this->_settings);
$defaults['volunteer_general_show_project_location_public'] = CRM_Utils_Array::value('volunteer_general_show_project_location_public', $this->_settings);

return $defaults;
}
Expand Down Expand Up @@ -242,6 +250,11 @@ function postProcess() {
"volunteer_general_campaign_filter_list" => CRM_Utils_Array::value('volunteer_general_campaign_filter_list', $values, array())
));

//Display Project Location
civicrm_api3('Setting', 'create', array(
"volunteer_general_show_project_location_public" => CRM_Utils_Array::value('volunteer_general_show_project_location_public', $values, false)
));

CRM_Core_Session::setStatus(ts("Changes Saved", array('domain' => 'org.civicrm.volunteer')), "Saved", "success");
parent::postProcess();
}
Expand Down
2 changes: 2 additions & 0 deletions ang/volunteer/VolOppsCtrl.html
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ <h2>{{ts('Available Volunteer Opportunities')}}</h2>
<thead>
<tr role="row">
<th class="ui-state-default crm-vol-opp-project">{{ts('Project')}}</th>
<th ng-if="showLocationColumn" class="ui-state-default crm-vol-opp-beneficiary">{{ts('Location')}}</th>
<th class="ui-state-default crm-vol-opp-beneficiary">{{ts('With')}}</th>
<th class="ui-state-default crm-vol-opp-role">{{ts('Role')}}</th>
<th class="ui-state-default crm-vol-opp-time">{{ts('Time')}}</th>
Expand All @@ -222,6 +223,7 @@ <h2>{{ts('Available Volunteer Opportunities')}}</h2>
ng-click="showProjectDescription(need.project)">
</span>
</td>
<td ng-if="showLocationColumn" class="crm-vol-opp-time">{{formatLocation(need.project.location)}}</td>
<td class="crm-vol-opp-beneficiary">
<span class="beneficiary" ng-repeat="ben in need.project.beneficiaries">{{ben.display_name}}</span>
</td>
Expand Down
26 changes: 26 additions & 0 deletions ang/volunteer/VolOppsCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,9 @@
}


//VOL-216: Conditionally show a location column
$scope.showLocationColumn = supporting_data.values.show_location || false;

$scope.countries = countries;
$scope.roles = supporting_data.values.roles;
$scope.searchParams = volOppSearch.getParams;
Expand Down Expand Up @@ -212,6 +215,29 @@
}
});
}

//This function is used to visually format address/location data
$scope.formatLocation = function(location) {
var locString = "";

if (location.street_address) {
locString = locString + location.street_address + ", ";
}

if (location.city) {
locString = locString + location.city + ", ";
}

if (location.state_province) {
locString = locString + location.state_province;
}

if(!locString && location.postal_code) {
locString = location.postal_code;
}

return locString;
};
});

})(angular, CRM.$, CRM._);
3 changes: 3 additions & 0 deletions api/v3/VolunteerUtil.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ function civicrm_api3_volunteer_util_getsupportingdata($params) {

if ($controller === 'VolOppsCtrl') {
$results['roles'] = CRM_Core_OptionGroup::values('volunteer_role', FALSE, FALSE, TRUE);
$results['show_location'] = civicrm_api3('Setting', 'getvalue', array(
'name' => 'volunteer_general_show_project_location_public',
));
}

$results['use_profile_editor'] = CRM_Volunteer_Permission::check(array("access CiviCRM","profile listings and forms"));
Expand Down
12 changes: 12 additions & 0 deletions settings/volunteer.setting.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,5 +103,17 @@
'description' => 'Campaign Type(s)',
'help_text' => 'Depending on the value of the Campaign Filter Whitelist/Blacklist setting, the campaign types in this list will either be shown or hidden from CiviVolunteer screens.',
),
'volunteer_general_show_project_location_public' => array(
'group_name' => 'CiviVolunteer Global Settings',
'group' => 'org.civicrm.volunteer',
'name' => 'volunteer_general_show_project_location_public',
'type' => 'Boolean',
'default' => false,
'add' => '4.5',
'is_domain' => 1,
'is_contact' => 0,
'description' => 'Show Opportunity Location Column',
'help_text' => 'When searching for Volunteer Opportunities, display a location column.',
),

);