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

Revert "Search across translations" #4213

Merged
merged 1 commit into from
Feb 24, 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
@@ -1,5 +1,5 @@
import {DEFAULT_SCHEMA, getVocabularySelectionTypes, getMediaTypeKeys, getMediaTypes} from '../constants';
import {IVocabulary, IVocabularyItem, IVocabularyTag} from 'superdesk-api';
import {IVocabulary, IVocabularyTag} from 'superdesk-api';
import {IDirectiveScope} from 'types/Angular/DirectiveScope';
import {remove, reduce} from 'lodash';
import {gettext, downloadFile} from 'core/utils';
Expand All @@ -11,13 +11,11 @@ function getOther() {
}

export interface IScope extends IDirectiveScope<void> {
filterVocabulary(vocabulary: IVocabulary): boolean;
vocabularies: Array<IVocabulary>;
vocabulary: any;
tags: IVocabulary['tags'];
loading: boolean;
mediaTypes: object;
searchString: string;
openVocabulary(vocabulary: IVocabulary): void;
downloadVocabulary(vocabulary: IVocabulary): void;
uploadConfig(): void;
Expand Down Expand Up @@ -142,22 +140,6 @@ export function VocabularyConfigController($scope: IScope, $route, $routeParams,
$scope.existsVocabulariesForTag = (currentTag: IVocabularyTag, tab: string) =>
($scope.vocabularies || []).some((vocabulary) => checkTag(vocabulary, currentTag, tab));

/**
* Checks if a vocabulary's display_name matches the search
* query or if it matches a translation of that vocabulary.
*/
$scope.filterVocabulary = function(vocabulary: IVocabulary): boolean {
const translationMach = Object.values(vocabulary?.translations?.display_name ?? {})
.find((translation: string) => translation.toLowerCase().indexOf($scope.searchString) !== -1);
const displayNameMatch = vocabulary.display_name.toLowerCase().indexOf($scope.searchString) !== -1;

if (($scope.searchString?.length ?? 0) > 0 || displayNameMatch || translationMach != null) {
return true;
} else {
return false;
}
};

/**
* Don't show OTHER tag if it is the only tag available for current tab
*/
Expand Down
6 changes: 3 additions & 3 deletions scripts/apps/vocabularies/views/vocabulary-config.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<div class="sd-page__flex-helper">
<div class="sd-page__header">
<sd-search-handler ng-model="searchString" data-debounce="200"></sd-search-handler>
<sd-search-handler ng-model="query.display_name" data-debounce="200"></sd-search-handler>
<span class="sd-page__element-grow"></span>
<button class="btn btn--primary"
ng-click="createCustomField('text')" ng-if="tab === 'text-fields'">
Expand All @@ -19,7 +19,7 @@
<i class="icon-plus-sign icon--white"></i>
<span translate>Add New</span>
</button>

<button class="btn btn--primary"
ng-click="createVocabulary()" ng-if="tab === 'vocabularies'">
<i class="icon-plus-sign icon--white"></i>
Expand Down Expand Up @@ -56,7 +56,7 @@
<div class="sd-list-item-group sd-list-item-group--space-between-items" style="max-width: 1000px;">
<div
class="sd-list-item sd-shadow--z1"
ng-repeat="vocabulary in getVocabulariesForTag(tag, tab) | orderBy:'display_name|translate' | filter: filterVocabulary track by vocabulary._id"
ng-repeat="vocabulary in getVocabulariesForTag(tag, tab) | orderBy:'display_name|translate' | filter: query track by vocabulary._id"
data-test-id="vocabulary-item"
>
<div class="sd-list-item__column sd-list-item__column--grow sd-list-item__column--no-border">
Expand Down
5 changes: 0 additions & 5 deletions scripts/core/superdesk-api.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,6 @@ declare module 'superdesk-api' {
service: {};
priority?: number;
unique_field: string;
translations?: {
display_name: {
[key: string]: string;
};
};
schema: {};
field_type:
| 'text'
Expand Down