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 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
10 changes: 10 additions & 0 deletions css/admin.css
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,16 @@ body #post-body-content p.wp-clearfix:nth-child(1){
min-height: 30px;
}

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

.oo-poststuff .custom-input-field input[name=oopluginlistviews-countryactive],
.oo-poststuff .custom-input-field input[name=oopluginlistviews-radiusactive] {
pointer-events: none;
}

#listSettings .custom-input-field,
#viewpicturetypes .custom-input-field {
display: block;
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
2 changes: 1 addition & 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 are required.', 'onoffice-for-wp-websites');
$pInputModelGeoLabel = new InputModelLabel(null, $geoNotice);
$pInputModelGeoLabel->setValueEnclosure(InputModelLabel::VALUE_ENCLOSURE_ITALIC);
$pFormModelGeoFields->addInputModel($pInputModelGeoLabel);
Expand Down
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