From 4f52778b238f92c29ae8fb58de53ed5393ac24ea Mon Sep 17 00:00:00 2001 From: "konrad.lys@eu.equinix.com" Date: Mon, 29 May 2023 17:30:28 +0200 Subject: [PATCH] BUGFIX add MATCH_NONE to tag matching options --- .../matching_algorithm_localization_mapper.dart | 4 ++++ lib/features/edit_label/view/label_form.dart | 7 +++++-- lib/l10n/intl_en.arb | 4 ++++ packages/mock_server/pubspec.yaml | 2 +- .../lib/src/models/labels/matching_algorithm.dart | 1 + 5 files changed, 15 insertions(+), 3 deletions(-) diff --git a/lib/core/translation/matching_algorithm_localization_mapper.dart b/lib/core/translation/matching_algorithm_localization_mapper.dart index ae27c60..77c5292 100644 --- a/lib/core/translation/matching_algorithm_localization_mapper.dart +++ b/lib/core/translation/matching_algorithm_localization_mapper.dart @@ -19,6 +19,8 @@ String translateMatchingAlgorithmDescription( return S.of(context)!.documentContainsAWordSimilarToThisWord; case MatchingAlgorithm.auto: return S.of(context)!.learnMatchingAutomatically; + case MatchingAlgorithm.none: + return S.of(context)!.disableMatching; } } @@ -39,5 +41,7 @@ String translateMatchingAlgorithmName( return S.of(context)!.fuzzy; case MatchingAlgorithm.auto: return S.of(context)!.auto; + case MatchingAlgorithm.none: + return S.of(context)!.none; } } diff --git a/lib/features/edit_label/view/label_form.dart b/lib/features/edit_label/view/label_form.dart index 366a436..ed6074f 100644 --- a/lib/features/edit_label/view/label_form.dart +++ b/lib/features/edit_label/view/label_form.dart @@ -103,7 +103,8 @@ class _LabelFormState extends State> { onChanged: (val) { setState(() { _errors = {}; - _enableMatchFormField = val != MatchingAlgorithm.auto.value; + _enableMatchFormField = val != MatchingAlgorithm.auto.value && + val != MatchingAlgorithm.none.value; }); }, items: MatchingAlgorithm.values @@ -147,7 +148,9 @@ class _LabelFormState extends State> { ..._formKey.currentState!.value }; if (mergedJson[Label.matchingAlgorithmKey] == - MatchingAlgorithm.auto.value) { + MatchingAlgorithm.auto.value || + mergedJson[Label.matchingAlgorithmKey] == + MatchingAlgorithm.none.value) { // If auto is selected, the match will be removed. mergedJson[Label.matchKey] = ''; } diff --git a/lib/l10n/intl_en.arb b/lib/l10n/intl_en.arb index 8984f3b..c775580 100644 --- a/lib/l10n/intl_en.arb +++ b/lib/l10n/intl_en.arb @@ -574,6 +574,10 @@ "@documentMatchesThisRegularExpression": {}, "regularExpression": "Regular Expression", "@regularExpression": {}, + "disableMatching": "Do not tag documents automatically", + "@disableMatching": {}, + "none": "None", + "@none": {}, "anInternetConnectionCouldNotBeEstablished": "An internet connection could not be established.", "@anInternetConnectionCouldNotBeEstablished": {}, "done": "Done", diff --git a/packages/mock_server/pubspec.yaml b/packages/mock_server/pubspec.yaml index 35f9ea4..4963a32 100644 --- a/packages/mock_server/pubspec.yaml +++ b/packages/mock_server/pubspec.yaml @@ -13,7 +13,7 @@ dependencies: logging: ^1.1.1 flutter: sdk: flutter - http: ^1.0.0 + http: ^0.13.4 dev_dependencies: flutter_test: diff --git a/packages/paperless_api/lib/src/models/labels/matching_algorithm.dart b/packages/paperless_api/lib/src/models/labels/matching_algorithm.dart index b4229f9..23f900e 100644 --- a/packages/paperless_api/lib/src/models/labels/matching_algorithm.dart +++ b/packages/paperless_api/lib/src/models/labels/matching_algorithm.dart @@ -2,6 +2,7 @@ import 'package:json_annotation/json_annotation.dart'; @JsonEnum(valueField: 'value') enum MatchingAlgorithm { + none(0, "None: Disable matching"), anyWord(1, "Any: Match one of the following words"), allWords(2, "All: Match all of the following words"), exactMatch(3, "Exact: Match the following string"),