Skip to content

Commit

Permalink
Fix for search operator dropdown not displaying the "startsWith" value
Browse files Browse the repository at this point in the history
Had to un-hide the case sensitivity option, initially hidden to reduce clutter
  • Loading branch information
RvanderLaan committed Oct 5, 2022
1 parent dcc540f commit e9f0182
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 17 deletions.
8 changes: 4 additions & 4 deletions src/entities/SearchCriteria.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,11 @@ export const NumberOperatorSymbols: Record<NumberOperatorType, string> = {
};

export const StringOperatorLabels: Record<StringOperatorType, string> = {
equalsIgnoreCase: 'Equals',
equals: 'Equals', // not available as dropdown option to user to avoid clutter
equals: 'Equals',
equalsIgnoreCase: 'Equals (case insensitive)',
notEqual: 'Not Equal',
startsWithIgnoreCase: 'Starts With',
startsWith: 'Starts With', // not available as dropdown option to user to avoid clutter
startsWith: 'Starts With',
startsWithIgnoreCase: 'Starts With (case insensitive)',
notStartsWith: 'Not Starts With',
contains: 'Contains',
notContains: 'Not Contains',
Expand Down
16 changes: 3 additions & 13 deletions src/frontend/containers/AdvancedSearch/Inputs.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { camelCaseToSpaced } from 'common/fmt';
import { action } from 'mobx';
import React, { ForwardedRef, forwardRef, useState } from 'react';
import { NumberOperators, StringOperators } from 'src/api/data-storage-search';
import { IMG_EXTENSIONS } from 'src/api/file';
import { NumberOperators, StringOperatorType } from 'src/api/data-storage-search';
import { BinaryOperators, TagOperators } from 'src/api/search-criteria';
import { NumberOperatorSymbols, StringOperatorLabels } from 'src/entities/SearchCriteria';
import { ClientTag } from 'src/entities/Tag';
import { TagSelector } from 'src/frontend/components/TagSelector';
import { useStore } from 'src/frontend/contexts/StoreContext';
import { camelCaseToSpaced } from 'common/fmt';
import { Criteria, defaultQuery, Key, Operator, TagValue, Value } from './data';

type SetCriteria = (fn: (criteria: Criteria) => Criteria) => void;
Expand Down Expand Up @@ -297,17 +297,7 @@ function getOperatorOptions(key: Key) {
} else if (key === 'extension') {
return BinaryOperators.map((op) => toOperatorOption(op));
} else if (key === 'name' || key === 'absolutePath') {
// For performance reasons, we added some extra non-ignoreCase options,
// but these aren't really needed by the user, so hide them to avoid clutter:
const shownStringOperators: StringOperatorType[] = [
'equalsIgnoreCase',
'notEqual',
'contains',
'notContains',
'startsWithIgnoreCase',
'notStartsWith',
];
return shownStringOperators.map((op) => toOperatorOption(op, StringOperatorLabels));
return StringOperators.map((op) => toOperatorOption(op, StringOperatorLabels));
} else if (key === 'tags') {
return TagOperators.map((op) => toOperatorOption(op));
}
Expand Down

0 comments on commit e9f0182

Please sign in to comment.