Skip to content

Commit

Permalink
Add property "is/is not data type" to advanced search
Browse files Browse the repository at this point in the history
  • Loading branch information
jimsafley committed Dec 10, 2024
1 parent 2a7334e commit 25ef320
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions application/asset/js/advanced-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ $(document).ready(function () {
var template = fieldContainer.data('field-template');
var newValue = $(template);
newValue.children('input[type="text"]').val(null);
newValue.find('.query-text-data-type').prop('disabled', true).hide();
newValue.children('select').prop('selectedIndex', 0);
newValue.appendTo(fieldContainer.find('.inputs'));
newValue.trigger('o:value-created');
Expand Down
8 changes: 7 additions & 1 deletion application/asset/js/global.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,10 +322,16 @@ var Omeka = {
disableQueryTextInput: function() {
var queryType = $(this);
var queryText = queryType.siblings('.query-text');
if (queryType.val() === 'ex' || queryType.val() === 'nex') {
var queryTextDataType = queryType.siblings('.query-text-data-type');
if (['dt', 'ndt'].includes(queryType.val())) {
queryText.prop('disabled', true);
queryTextDataType.prop('disabled', false).show();
} else if (['ex', 'nex'].includes(queryType.val())) {
queryText.prop('disabled', true);
queryTextDataType.prop('disabled', true).hide();
} else {
queryText.prop('disabled', false);
queryTextDataType.prop('disabled', true).hide();
}
},

Expand Down
11 changes: 9 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', 'nres', 'nex', 'ndt'])) {
$positive = false;
$queryType = substr($queryType, 1);
}
if (!in_array($queryType, ['eq', 'in', 'sw', 'ew', 'res', 'ex'])) {
if (!in_array($queryType, ['eq', 'in', 'sw', 'ew', 'res', 'ex', 'dt'])) {
continue;
}

Expand Down Expand Up @@ -382,6 +382,13 @@ protected function buildPropertyQuery(QueryBuilder $qb, array $query)
$predicateExpr = $qb->expr()->isNotNull("$valuesAlias.id");
break;

case 'dt':
$predicateExpr = $qb->expr()->eq(
"$valuesAlias.type",
$this->createNamedParameter($qb, $value)
);
break;

default:
continue 2;
}
Expand Down
3 changes: 3 additions & 0 deletions application/view/common/advanced-search/properties.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,11 @@ if ($this->status()->isSiteRequest()) {
<?php echo $queryOption('nres', $property, 'type', $translate('is not resource with ID')); ?>
<?php echo $queryOption('ex', $property, 'type', $translate('has any value')); ?>
<?php echo $queryOption('nex', $property, 'type', $translate('has no values')); ?>
<?php echo $queryOption('dt', $property, 'type', $translate('is data type')); ?>
<?php echo $queryOption('ndt', $property, 'type', $translate('is not data type')); ?>
</select>
<?php echo $queryText($property, $index); ?>
<?php echo $this->dataType()->getSelect($stem . '[text]', $property['text'] ?? null, ['class' => 'query-text-data-type']); ?>
<button type="button" class="o-icon-delete remove-value button" aria-label="<?php echo $translate('Remove value'); ?>" title="<?php echo $translate('Remove value'); ?>"></button>
</div>
<?php
Expand Down

0 comments on commit 25ef320

Please sign in to comment.