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

41662 Geo range search mandatory fields #668

Merged
merged 4 commits into from
Feb 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
10 changes: 10 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -496,4 +496,14 @@ body #post-body-content p.wp-clearfix:nth-child(1){
font-size: 14px;
white-space: nowrap;
}
}

input[name=oopluginlistviews-countryactive]:checked::before,
input[name=oopluginlistviews-radiusactive]:checked::before {
filter: brightness(0) saturate(100%) invert(35%) sepia(4%) saturate(967%) hue-rotate(170deg) brightness(91%) contrast(94%);
}

input[name=oopluginlistviews-countryactive],
input[name=oopluginlistviews-radiusactive] {
pointer-events: none;
}
2 changes: 1 addition & 1 deletion dist/admin.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions js/admin.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
var onOffice = onOffice || {};
onOffice.settings = onOffice_loc_settings;
jQuery(document).ready(function($){
$(document).on('click', '.notice-save-view.notice-dismiss', function () {
$(this).parent().remove();
Expand Down Expand Up @@ -62,6 +64,23 @@ jQuery(document).ready(function($){
$(data).children().attr('typeField', 1);
$(this).parent().parent().remove();
});

const editListViewPage = 'admin_page_onoffice-editlistview';
if (onOffice.settings.page === editListViewPage) {
$('#send_form').on('click', updateRequiredAttributeZipActiveField);
}
function updateRequiredAttributeZipActiveField() {
if ($('#geofields').is(':visible')) {
const isCityActive = $('input[name=oopluginlistviews-cityactive]:checked').is(':visible');
const isZipActive = $('input[name=oopluginlistviews-zipactive]:checked').is(':visible');
$('input[name=oopluginlistviews-zipactive]').attr('required', 'required');

if (isCityActive || isZipActive) {
$('input[name=oopluginlistviews-zipactive]').removeAttr('required');
}
}
}

yeneastgate marked this conversation as resolved.
Show resolved Hide resolved
var getCheckedFieldButton = function(btn) {
var addField = 1;
var removeField = 2;
Expand Down
1 change: 1 addition & 0 deletions plugin/Controller/GeoPositionFieldHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ private function getDefaultConfiguration(): array
$defaultActive = [
GeoPosition::ESTATE_LIST_SEARCH_ZIP,
GeoPosition::ESTATE_LIST_SEARCH_RADIUS,
GeoPosition::ESTATE_LIST_SEARCH_COUNTRY
];
$intersection = array_intersect_key($this->_booleanFields, array_flip($defaultActive));
return array_combine($intersection, array_fill(0, count($intersection), '1'));
Expand Down
3 changes: 2 additions & 1 deletion plugin/Gui/AdminPageEstateListSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ protected function buildForms()
$pFormModelGeoFields->addInputModel($pInputModel);
}

$geoNotice = __('At least the following fields must be active: country, radius and city or postcode.', 'onoffice-for-wp-websites');
$geoNotice = __('At least city or postcode required.', 'onoffice-for-wp-websites');
$pInputModelGeoLabel = new InputModelLabel(null, $geoNotice);
$pInputModelGeoLabel->setValueEnclosure(InputModelLabel::VALUE_ENCLOSURE_ITALIC);
$pFormModelGeoFields->addInputModel($pInputModelGeoLabel);
Expand Down Expand Up @@ -310,5 +310,6 @@ public function doExtraEnqueues()
wp_enqueue_style('onoffice-multiselect');
wp_enqueue_script('oo-sanitize-shortcode-name');
wp_enqueue_script('oo-copy-shortcode');
wp_localize_script('admin-js', 'onOffice_loc_settings', ['page' => get_current_screen()->id]);
yeneastgate marked this conversation as resolved.
Show resolved Hide resolved
}
}
19 changes: 18 additions & 1 deletion plugin/Installer/DatabaseChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
class DatabaseChanges implements DatabaseChangesInterface
{
/** @var int */
const MAX_VERSION = 41;
const MAX_VERSION = 42;

/** @var WPOptionWrapperBase */
private $_pWpOption;
Expand Down Expand Up @@ -298,6 +298,11 @@ public function install()
$dbversion = 41;
}

if ($dbversion == 41) {
$this->updateValueGeoFieldsForEsateList();
$dbversion = 42;
}

$this->_pWpOption->updateOption( 'oo_plugin_db_version', $dbversion, true );
}

Expand Down Expand Up @@ -1115,4 +1120,16 @@ private function updateShowPriceOnRequestOptionForDetailView()
$this->_pWpOption->updateOption('onoffice-default-view', $pDataDetailViewOptions);
}
}

/**
* @return void
*/
public function updateValueGeoFieldsForEsateList()
{
$prefix = $this->getPrefix();
$sql = "UPDATE {$prefix}oo_plugin_listviews
SET country_active = 1, radius_active = 1";

$this->_pWPDB->query($sql);
}
}
4 changes: 2 additions & 2 deletions tests/TestClassDatabaseChanges.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function testInstall(): array
$this->assertGreaterThanOrEqual(self::NUM_NEW_TABLES, count($this->_createQueries));

$dbversion = $this->_pDbChanges->getDbVersion();
$this->assertEquals(41, $dbversion);
$this->assertEquals(42, $dbversion);
return $this->_createQueries;
}

Expand Down Expand Up @@ -271,7 +271,7 @@ public function testDeleteMessageFieldApplicantSearchForm()
*/
public function testMaxVersion()
{
$this->assertEquals(41, DatabaseChanges::MAX_VERSION);
$this->assertEquals(42, DatabaseChanges::MAX_VERSION);
}


Expand Down
1 change: 1 addition & 0 deletions tests/TestClassGeoPositionFieldHandler.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public function testDefaultValues(GeoPositionFieldHandler $pGeoPositionFieldHand
$this->assertEquals([
'radius_active' => 'radius',
'zip_active' => 'zip',
'country_active' => 'country'
], $pGeoPositionFieldHandler->getActiveFields());
}

Expand Down
Loading