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

Add property is/is not resource queries to advanced search #2245

Closed
wants to merge 1 commit into from
Closed
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
2 changes: 1 addition & 1 deletion application/asset/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ var Omeka = {
disableQueryTextInput: function() {
var queryType = $(this);
var queryText = queryType.siblings('.query-text');
if (queryType.val() === 'ex' || queryType.val() === 'nex') {
if (['ex', 'nex', 're', 'nre'].includes(queryType.val())) {
queryText.prop('disabled', true);
} else {
queryText.prop('disabled', false);
Expand Down
8 changes: 6 additions & 2 deletions application/src/Api/Adapter/AbstractResourceEntityAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -277,11 +277,11 @@ protected function buildPropertyQuery(QueryBuilder $qb, array $query)
}

$positive = true;
if (in_array($queryType, ['neq', 'nin', 'nsw', 'new', 'nres', 'nex'])) {
if (in_array($queryType, ['neq', 'nin', 'nsw', 'new', 'nre', 'nres', 'nex'])) {
$positive = false;
$queryType = substr($queryType, 1);
}
if (!in_array($queryType, ['eq', 'in', 'sw', 'ew', 'res', 'ex'])) {
if (!in_array($queryType, ['eq', 'in', 'sw', 'ew', 're', 'res', 'ex'])) {
continue;
}

Expand Down Expand Up @@ -378,6 +378,10 @@ protected function buildPropertyQuery(QueryBuilder $qb, array $query)
);
break;

case 're':
$predicateExpr = $qb->expr()->isNotNull("$valuesAlias.valueResource");
break;

case 'ex':
$predicateExpr = $qb->expr()->isNotNull("$valuesAlias.id");
break;
Expand Down
2 changes: 2 additions & 0 deletions application/view/common/advanced-search/properties.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,8 @@ if ($this->status()->isSiteRequest()) {
<?php echo $queryOption('nsw', $property, 'type', $translate('does not start with')); ?>
<?php echo $queryOption('ew', $property, 'type', $translate('ends with')); ?>
<?php echo $queryOption('new', $property, 'type', $translate('does not end with')); ?>
<?php echo $queryOption('re', $property, 'type', $translate('is resource')); ?>
<?php echo $queryOption('nre', $property, 'type', $translate('is not resource')); ?>
<?php echo $queryOption('res', $property, 'type', $translate('is resource with ID')); ?>
<?php echo $queryOption('nres', $property, 'type', $translate('is not resource with ID')); ?>
<?php echo $queryOption('ex', $property, 'type', $translate('has any value')); ?>
Expand Down