Skip to content

Commit

Permalink
Add property is/is not resource queries to advanced search
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Dec 9, 2024
1 parent 2a7334e commit 51340ca
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
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

0 comments on commit 51340ca

Please sign in to comment.