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

30333 Document enterprise filters #424

Merged
merged 3 commits into from
Jan 18, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,10 @@ public function createInputModelFilter()
$pInputModelFiltername->setValuesAvailable($availableFilters);
$filteridSelected = $this->getValue($pInputModelFiltername->getField());
$pInputModelFiltername->setValue($filteridSelected);
$linkUrl = __("https://de.enterprisehilfe.onoffice.com/help_entries/property-filter/?lang=en","onoffice-for-wp-websites");
$linkLabel = '<a href="' . $linkUrl . '" >' . __( 'Learn more.', 'onoffice-for-wp-websites' ) . '</a>';
$pInputModelFiltername->setHintHtml( sprintf( __( 'Choose an estate filter from onOffice enterprise. %s',
'onoffice-for-wp-websites' ), $linkLabel ) );

return $pInputModelFiltername;
}
Expand Down
23 changes: 14 additions & 9 deletions plugin/Renderer/InputFieldSelectRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,19 @@ public function __construct($name, $value = array())

public function render()
{
$textHtml = '';
if ( ! empty( $this->getHint() ) ) {
if($this->getName() === "oopluginlistviews-showreferenceestate"){
$textHtml = '<div class="memssageReference">' . $this->getHint() . '</div>';
echo '<script>'
.'if (jQuery("select[name=oopluginlistviews-showreferenceestate").val() === "0") {'
. 'jQuery(".memssageReference").hide();'
.'}';
echo '</script>';
} else {
$textHtml = '<div style="text-align: right">' . $this->getHint() . '</div>';
}
}
echo '<select name="'.esc_html($this->getName()).'" '
.($this->_multiple ? ' multiple = "multiple" ' : null)
.$this->renderAdditionalAttributes()
Expand All @@ -75,15 +88,7 @@ public function render()
}
}

echo '</select>';
if ( $this->getHint() ) {
echo '<div class="memssageReference">' . $this->getHint() . '</div>';
echo '<script>'
.'if (jQuery("select[name=oopluginlistviews-showreferenceestate").val() === "0") {'
. 'jQuery(".memssageReference").hide();'
.'}';
echo '</script>';
}
echo '</select>'. $textHtml;
}


Expand Down
3 changes: 2 additions & 1 deletion tests/TestClassFormModelBuilderDBEstateListSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,7 @@ public function testCreateInputModelFilter()
{
$pInstance = $this->getMockBuilder(FormModelBuilderDBEstateListSettings::class)
->disableOriginalConstructor()
->setMethods(['getInputModelDBFactory', 'getValue', 'getOnlyDefaultSortByFields', "readFilters"])
->setMethods(['getInputModelDBFactory', 'getValue', 'getOnlyDefaultSortByFields', "readFilters", 'getHintHtml'])
->getMock();

$pInstance->method('getInputModelDBFactory')->willReturn($this->_pInputModelFactoryDBEntry);
Expand All @@ -497,6 +497,7 @@ public function testCreateInputModelFilter()
$this->assertEquals($pInputModelDB->getValue(), '0');
$this->assertEquals($pInputModelDB->getValuesAvailable(), [""]);
$this->assertEquals('select', $pInputModelDB->getHtmlType());
$this->assertEquals('Choose an estate filter from onOffice enterprise. <a href="https://de.enterprisehilfe.onoffice.com/help_entries/property-filter/?lang=en" >Learn more.</a>', $pInputModelDB->getHintHtml());
}

/**
Expand Down
33 changes: 33 additions & 0 deletions tests/TestClassInputFieldSelectRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -92,4 +92,37 @@ public function testRenderWithValuesAndLabelOnlyValuesAndSelectedValue()
.'<optgroup label="John Doe" ></optgroup><option value="konradzuse" selected="selected" >'
.'Konrad Zuse</option></select>', $output);
}

/**
*
*/
public function testRenderWithValuesAndHint()
{
$pSubject = new InputFieldSelectRenderer('testRenderer');
$pSubject->setValue(['johndoe' => 'John Doe', 'konradzuse' => 'Konrad Zuse']);
$pSubject->setHint('test');
$pSubject->getName('test');
ob_start();
$pSubject->render();
$output = ob_get_clean();
$this->assertEquals('<select name="testRenderer" id="select_1">'
.'<option value="johndoe" >John Doe</option><option value="konradzuse" >Konrad Zuse</option>'
.'</select><div style="text-align: right">test</div>', $output);
}
/**
*
*/
public function testRenderWithValuesAndNameShowReferenceEstate()
{
$pSubject = new InputFieldSelectRenderer('oopluginlistviews-showreferenceestate');
$pSubject->setValue(['johndoe' => 'John Doe', 'konradzuse' => 'Konrad Zuse']);
$pSubject->setHint('test');
ob_start();
$pSubject->render();
$output = ob_get_clean();
$this->assertEquals('<script>if (jQuery("select[name=oopluginlistviews-showreferenceestate").val() === "0") {jQuery(".memssageReference").hide();}</script>'
.'<select name="oopluginlistviews-showreferenceestate" id="select_1">'
.'<option value="johndoe" >John Doe</option><option value="konradzuse" >Konrad Zuse</option>'
.'</select><div class="memssageReference">test</div>', $output);
}
}