From e9dd1ffabd9c09d86b9203ab23354877a9abf0c1 Mon Sep 17 00:00:00 2001 From: Tobias Lounsbury Date: Tue, 7 Jun 2016 10:49:37 -0700 Subject: [PATCH 1/3] Added setting for showing location column to settings and added it to the settings form --- CRM/Volunteer/Form/Settings.php | 13 +++++++++++++ settings/volunteer.setting.php | 12 ++++++++++++ 2 files changed, 25 insertions(+) diff --git a/CRM/Volunteer/Form/Settings.php b/CRM/Volunteer/Form/Settings.php index 273658db..89dafd1b 100644 --- a/CRM/Volunteer/Form/Settings.php +++ b/CRM/Volunteer/Form/Settings.php @@ -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', @@ -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; } @@ -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(); } diff --git a/settings/volunteer.setting.php b/settings/volunteer.setting.php index a9754a11..78aedcad 100644 --- a/settings/volunteer.setting.php +++ b/settings/volunteer.setting.php @@ -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.', + ), ); From 09afab5c106f64ab09d58ea377abb12c668cc250 Mon Sep 17 00:00:00 2001 From: Tobias Lounsbury Date: Tue, 7 Jun 2016 11:52:03 -0700 Subject: [PATCH 2/3] Added showLocationColumn to supporting data for opportunity page --- api/v3/VolunteerUtil.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/v3/VolunteerUtil.php b/api/v3/VolunteerUtil.php index 873c3a2b..02b940e6 100644 --- a/api/v3/VolunteerUtil.php +++ b/api/v3/VolunteerUtil.php @@ -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")); From 63c2a1df9537d31eaa602fc306254d00085ffcc0 Mon Sep 17 00:00:00 2001 From: Tobias Lounsbury Date: Tue, 7 Jun 2016 11:52:23 -0700 Subject: [PATCH 3/3] Added location column, filtered on showLocationColumn --- ang/volunteer/VolOppsCtrl.html | 2 ++ ang/volunteer/VolOppsCtrl.js | 26 ++++++++++++++++++++++++++ 2 files changed, 28 insertions(+) diff --git a/ang/volunteer/VolOppsCtrl.html b/ang/volunteer/VolOppsCtrl.html index f6bf9f2c..b8bee1f1 100644 --- a/ang/volunteer/VolOppsCtrl.html +++ b/ang/volunteer/VolOppsCtrl.html @@ -206,6 +206,7 @@

{{ts('Available Volunteer Opportunities')}}

{{ts('Project')}} + {{ts('Location')}} {{ts('With')}} {{ts('Role')}} {{ts('Time')}} @@ -222,6 +223,7 @@

{{ts('Available Volunteer Opportunities')}}

ng-click="showProjectDescription(need.project)"> + {{formatLocation(need.project.location)}} {{ben.display_name}} diff --git a/ang/volunteer/VolOppsCtrl.js b/ang/volunteer/VolOppsCtrl.js index 42dc1f02..80b98447 100644 --- a/ang/volunteer/VolOppsCtrl.js +++ b/ang/volunteer/VolOppsCtrl.js @@ -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; @@ -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._);