]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
Fix switch from title_content search 1865/head
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 25 Oct 2022 22:31:01 +0000 (15:31 -0700)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Tue, 25 Oct 2022 22:31:01 +0000 (15:31 -0700)
src-ui/src/app/components/document-list/filter-editor/filter-editor.component.ts
src-ui/src/styles.scss

index e5163c7e08ae42438a5a883542fb036fac1d14d3..14643875fce6730d254f398d5841fb8170e7ff75 100644 (file)
@@ -271,8 +271,9 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
           this.textFilterTarget = TEXT_FILTER_TARGET_ASN
           break
         case FILTER_FULLTEXT_QUERY:
-          let queryArgs = rule.value.split(',')
-          queryArgs.forEach((arg) => {
+          let allQueryArgs = rule.value.split(',')
+          let textQueryArgs = []
+          allQueryArgs.forEach((arg) => {
             if (arg.match(RELATIVE_DATE_QUERY_REGEXP_CREATED)) {
               ;[...arg.matchAll(RELATIVE_DATE_QUERY_REGEXP_CREATED)].forEach(
                 (match) => {
@@ -284,9 +285,7 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
                   }
                 }
               )
-              queryArgs.splice(queryArgs.indexOf(arg), 1)
-            }
-            if (arg.match(RELATIVE_DATE_QUERY_REGEXP_ADDED)) {
+            } else if (arg.match(RELATIVE_DATE_QUERY_REGEXP_ADDED)) {
               ;[...arg.matchAll(RELATIVE_DATE_QUERY_REGEXP_ADDED)].forEach(
                 (match) => {
                   if (match[1]?.length) {
@@ -297,11 +296,12 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
                   }
                 }
               )
-              queryArgs.splice(queryArgs.indexOf(arg), 1)
+            } else {
+              textQueryArgs.push(arg)
             }
           })
-          if (queryArgs.length) {
-            this._textFilter = queryArgs.join(',')
+          if (textQueryArgs.length) {
+            this._textFilter = textQueryArgs.join(',')
             this.textFilterTarget = TEXT_FILTER_TARGET_FULLTEXT_QUERY
           }
           break
@@ -533,9 +533,24 @@ export class FilterEditorComponent implements OnInit, OnDestroy {
       this.dateCreatedRelativeDate !== null
     ) {
       let queryArgs: Array<string> = []
-      const existingRule = filterRules.find(
+      let existingRule = filterRules.find(
         (fr) => fr.rule_type == FILTER_FULLTEXT_QUERY
       )
+
+      // if had a title / content search and added a relative date we need to carry it over...
+      if (
+        !existingRule &&
+        this._textFilter?.length > 0 &&
+        (this.textFilterTarget == TEXT_FILTER_TARGET_TITLE_CONTENT ||
+          this.textFilterTarget == TEXT_FILTER_TARGET_TITLE)
+      ) {
+        existingRule = filterRules.find(
+          (fr) =>
+            fr.rule_type == FILTER_TITLE_CONTENT || fr.rule_type == FILTER_TITLE
+        )
+        existingRule.rule_type = FILTER_FULLTEXT_QUERY
+      }
+
       let existingRuleArgs = existingRule?.value.split(',')
       if (this.dateCreatedRelativeDate !== null) {
         queryArgs.push(
index f096e7a33dd5ad81903766148db5f2eef87ff8b6..4efbf4937c6aeef9609dcca82b9ce1d72fb98334 100644 (file)
@@ -372,6 +372,10 @@ textarea,
   &:hover, &:focus {
     background-color: var(--bs-body-bg);
   }
+
+  &:focus {
+    color: var(--bs-body-color);
+  }
 }
 
 .dropdown-menu {