UI: Imp create new for entity autocomplete

This commit is contained in:
Artem Dzhereleiko 2025-08-08 18:27:42 +03:00
parent 4f18df907b
commit 8e1cde1a65
8 changed files with 24 additions and 10 deletions

View File

@ -40,6 +40,7 @@ import { map } from 'rxjs/operators';
export interface AIModelDialogData { export interface AIModelDialogData {
AIModel?: AiModel; AIModel?: AiModel;
isAdd?: boolean; isAdd?: boolean;
name?: string;
} }
@Component({ @Component({
@ -110,6 +111,10 @@ export class AIModelDialogComponent extends DialogComponent<AIModelDialogCompone
}) })
}); });
if (this.data.name) {
this.aiModelForms.get('name').patchValue(this.data.name, {emitEvent: false});
}
this.aiModelForms.get('configuration.provider').valueChanges.pipe( this.aiModelForms.get('configuration.provider').valueChanges.pipe(
takeUntilDestroyed() takeUntilDestroyed()
).subscribe((provider: AiProvider) => { ).subscribe((provider: AiProvider) => {

View File

@ -29,7 +29,7 @@
labelText="rule-node-config.ai.model" labelText="rule-node-config.ai.model"
(entityChanged)="onEntityChange($event)" (entityChanged)="onEntityChange($event)"
[entityType]="entityType.AI_MODEL" [entityType]="entityType.AI_MODEL"
(createNew)="createModelAi('modelId')" (createNew)="createModelAi($event, 'modelId')"
formControlName="modelId"> formControlName="modelId">
</tb-entity-autocomplete> </tb-entity-autocomplete>
</section> </section>

View File

@ -99,12 +99,13 @@ export class AiConfigComponent extends RuleNodeConfigurationComponent {
return this.translate.instant(`rule-node-config.ai.response-format-hint-${this.aiConfigForm.get('responseFormat.type').value}`); return this.translate.instant(`rule-node-config.ai.response-format-hint-${this.aiConfigForm.get('responseFormat.type').value}`);
} }
createModelAi(formControl: string) { createModelAi(name: string, formControl: string) {
this.dialog.open<AIModelDialogComponent, AIModelDialogData, AiModel>(AIModelDialogComponent, { this.dialog.open<AIModelDialogComponent, AIModelDialogData, AiModel>(AIModelDialogComponent, {
disableClose: true, disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data: { data: {
isAdd: true isAdd: true,
name
} }
}).afterClosed() }).afterClosed()
.subscribe((model) => { .subscribe((model) => {

View File

@ -29,6 +29,7 @@ import { MobileAppService } from '@core/http/mobile-app.service';
export interface MobileAppDialogData { export interface MobileAppDialogData {
platformType: PlatformType; platformType: PlatformType;
name?: string
} }
@Component({ @Component({
@ -55,6 +56,9 @@ export class MobileAppDialogComponent extends DialogComponent<MobileAppDialogCom
ngAfterViewInit(): void { ngAfterViewInit(): void {
setTimeout(() => { setTimeout(() => {
this.mobileAppComponent.entityForm.markAsDirty(); this.mobileAppComponent.entityForm.markAsDirty();
if (this.data.name) {
this.mobileAppComponent.entityForm.get('title').patchValue(this.data.name, {emitEvent: false});
}
this.mobileAppComponent.entityForm.patchValue({platformType: this.data.platformType}); this.mobileAppComponent.entityForm.patchValue({platformType: this.data.platformType});
this.mobileAppComponent.entityForm.get('platformType').disable({emitEvent: false}); this.mobileAppComponent.entityForm.get('platformType').disable({emitEvent: false});
this.mobileAppComponent.isEdit = true; this.mobileAppComponent.isEdit = true;

View File

@ -58,7 +58,7 @@
labelText="mobile.android-application" labelText="mobile.android-application"
[entityType]="entityType.MOBILE_APP" [entityType]="entityType.MOBILE_APP"
[entitySubtype]="platformType.ANDROID" [entitySubtype]="platformType.ANDROID"
(createNew)="createApplication('androidAppId', platformType.ANDROID)" (createNew)="createApplication($event, 'androidAppId', platformType.ANDROID)"
formControlName="androidAppId"> formControlName="androidAppId">
</tb-entity-autocomplete> </tb-entity-autocomplete>
<tb-entity-autocomplete <tb-entity-autocomplete
@ -68,7 +68,7 @@
labelText="mobile.ios-application" labelText="mobile.ios-application"
[entityType]="entityType.MOBILE_APP" [entityType]="entityType.MOBILE_APP"
[entitySubtype]="platformType.IOS" [entitySubtype]="platformType.IOS"
(createNew)="createApplication('iosAppId', platformType.IOS)" (createNew)="createApplication($event, 'iosAppId', platformType.IOS)"
formControlName="iosAppId"> formControlName="iosAppId">
</tb-entity-autocomplete> </tb-entity-autocomplete>
<mat-form-field appearance="outline"> <mat-form-field appearance="outline">

View File

@ -148,12 +148,13 @@ export class MobileBundleDialogComponent extends DialogComponent<MobileBundleDia
} }
} }
createApplication(formControl: string, platformType: PlatformType) { createApplication(name: string, formControl: string, platformType: PlatformType) {
this.dialog.open<MobileAppDialogComponent, MobileAppDialogData, MobileApp>(MobileAppDialogComponent, { this.dialog.open<MobileAppDialogComponent, MobileAppDialogData, MobileApp>(MobileAppDialogComponent, {
disableClose: true, disableClose: true,
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
data: { data: {
platformType platformType,
name
} }
}).afterClosed() }).afterClosed()
.subscribe((app) => { .subscribe((app) => {

View File

@ -71,6 +71,9 @@
<span> <span>
{{ noEntitiesMatchingText | translate: {entity: searchText} }} {{ noEntitiesMatchingText | translate: {entity: searchText} }}
</span> </span>
<span>
<a translate (click)="createNewEntity($event, searchText)">entity.create-new-key</a>
</span>
</ng-template> </ng-template>
</div> </div>
</mat-option> </mat-option>

View File

@ -142,7 +142,7 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
entityChanged = new EventEmitter<BaseData<EntityId>>(); entityChanged = new EventEmitter<BaseData<EntityId>>();
@Output() @Output()
createNew = new EventEmitter<void>(); createNew = new EventEmitter<string>();
@ViewChild('entityInput', {static: true}) entityInput: ElementRef; @ViewChild('entityInput', {static: true}) entityInput: ElementRef;
@ -451,9 +451,9 @@ export class EntityAutocompleteComponent implements ControlValueAccessor, OnInit
return entityType; return entityType;
} }
createNewEntity($event: Event) { createNewEntity($event: Event, searchText?: string) {
$event.stopPropagation(); $event.stopPropagation();
this.createNew.emit(); this.createNew.emit(searchText);
} }
get showEntityLink(): boolean { get showEntityLink(): boolean {