From 48c8160e1f01cab7de5c0e6a7315bf85805f6ec5 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Fri, 6 Dec 2024 09:54:03 +0200 Subject: [PATCH 1/5] UI: Add no text for resources autocomplete --- .../resource/resource-autocomplete.component.html | 13 +++++++++++-- .../resource/resource-autocomplete.component.ts | 8 +++++++- ui-ngx/src/assets/locale/locale.constant-en_US.json | 4 +++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html index 7d0c9ffb9f..bcc566aeea 100644 --- a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html +++ b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html @@ -41,8 +41,17 @@ - - {{ searchText }} + +
+
+ {{ 'js-func.no-js-module-text' | translate }} +
+ + + {{ translate.get('js-func.no-js-module-matching', {module: searchText}) | async }} + + +
diff --git a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts index 0cf13f2052..b87cfe8c4f 100644 --- a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts @@ -33,6 +33,7 @@ import { TbResourceId } from '@shared/models/id/tb-resource-id'; import { ResourceService } from '@core/http/resource.service'; import { PageLink } from '@shared/models/page/page-link'; import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field'; +import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'tb-resource-autocomplete', @@ -95,7 +96,8 @@ export class ResourceAutocompleteComponent implements ControlValueAccessor, OnIn private propagateChange: (value: any) => void = () => {}; constructor(private fb: FormBuilder, - private resourceService: ResourceService) { + private resourceService: ResourceService, + public translate: TranslateService) { } ngOnInit(): void { @@ -210,6 +212,10 @@ export class ResourceAutocompleteComponent implements ControlValueAccessor, OnIn } } + textIsNotEmpty(text: string): boolean { + return (text && text.length > 0); + } + private fetchResources(searchText?: string): Observable> { this.searchText = searchText; return this.resourceService.getResources(new PageLink(50, 0, searchText), ResourceType.JS_MODULE, this.subType, {ignoreLoading: true}).pipe( diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index c2f45da84f..6b50deb6ab 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3332,7 +3332,9 @@ "module-no-members": "Module has no exported members", "module-load-error": "Module load error", "source-code": "Source code", - "source-code-load-error": "Source code load error" + "source-code-load-error": "Source code load error", + "no-js-module-text": "No JS module found", + "no-js-module-matching": "No JS module matching '{{module}}' were found." }, "key-val": { "key": "Key", From 845f2099965b3d787fe19bfe3656fce9413151e9 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 9 Dec 2024 10:36:51 +0200 Subject: [PATCH 2/5] UI: Refactoring no text option for extension --- .../resource-autocomplete.component.html | 25 ++++++++++++------- .../resource-autocomplete.component.ts | 2 ++ 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html index bcc566aeea..04e7a4dbc6 100644 --- a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html +++ b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html @@ -41,17 +41,24 @@ - -
-
- {{ 'js-func.no-js-module-text' | translate }} -
- + + +
+
+ {{ 'js-func.no-js-module-text' | translate }} +
+ {{ translate.get('js-func.no-js-module-matching', {module: searchText}) | async }} - -
-
+
+
+
+ + + + {{ searchText }} + + diff --git a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts index b87cfe8c4f..1b5a541368 100644 --- a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts @@ -79,6 +79,8 @@ export class ResourceAutocompleteComponent implements ControlValueAccessor, OnIn @Input() subType = ResourceSubType.EXTENSION; + ResourceSubType = ResourceSubType; + resourceFormGroup = this.fb.group({ resource: this.fb.control(null) }); From 7d34e038de53e93e36af1b0bf7270aefb86eb501 Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 9 Dec 2024 10:53:20 +0200 Subject: [PATCH 3/5] UI: translate pipe and truncate --- .../components/resource/resource-autocomplete.component.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html index 04e7a4dbc6..513bee2808 100644 --- a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html +++ b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.html @@ -49,7 +49,7 @@ - {{ translate.get('js-func.no-js-module-matching', {module: searchText}) | async }} + {{ 'js-func.no-js-module-matching' | translate: {module: searchText | truncate: true: 6: '...'} }} From 928a34611ae00164a654d67f736671bf71ba0ddf Mon Sep 17 00:00:00 2001 From: Artem Dzhereleiko Date: Mon, 9 Dec 2024 10:57:24 +0200 Subject: [PATCH 4/5] UI: Refactoring --- .../components/resource/resource-autocomplete.component.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts index 1b5a541368..3aab98a394 100644 --- a/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts +++ b/ui-ngx/src/app/shared/components/resource/resource-autocomplete.component.ts @@ -33,7 +33,6 @@ import { TbResourceId } from '@shared/models/id/tb-resource-id'; import { ResourceService } from '@core/http/resource.service'; import { PageLink } from '@shared/models/page/page-link'; import { MatFormFieldAppearance, SubscriptSizing } from '@angular/material/form-field'; -import { TranslateService } from '@ngx-translate/core'; @Component({ selector: 'tb-resource-autocomplete', @@ -98,8 +97,7 @@ export class ResourceAutocompleteComponent implements ControlValueAccessor, OnIn private propagateChange: (value: any) => void = () => {}; constructor(private fb: FormBuilder, - private resourceService: ResourceService, - public translate: TranslateService) { + private resourceService: ResourceService) { } ngOnInit(): void { From 5b2eb75c92f56106bced631a1d7328663e122d74 Mon Sep 17 00:00:00 2001 From: Igor Kulikov Date: Mon, 9 Dec 2024 18:25:14 +0200 Subject: [PATCH 5/5] Update locale.constant-en_US.json --- ui-ngx/src/assets/locale/locale.constant-en_US.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ui-ngx/src/assets/locale/locale.constant-en_US.json b/ui-ngx/src/assets/locale/locale.constant-en_US.json index 6b50deb6ab..362df078ab 100644 --- a/ui-ngx/src/assets/locale/locale.constant-en_US.json +++ b/ui-ngx/src/assets/locale/locale.constant-en_US.json @@ -3333,8 +3333,8 @@ "module-load-error": "Module load error", "source-code": "Source code", "source-code-load-error": "Source code load error", - "no-js-module-text": "No JS module found", - "no-js-module-matching": "No JS module matching '{{module}}' were found." + "no-js-module-text": "No JS modules found", + "no-js-module-matching": "No JS modules matching '{{module}}' were found." }, "key-val": { "key": "Key",