Browse Source

UI: fix trackby and add customtranslation title

pull/6534/head
fe-dev 4 years ago
parent
commit
370919ef48
  1. 4
      ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.html
  2. 15
      ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.ts
  3. 3
      ui-ngx/src/app/modules/home/components/queue/queue-form.component.ts
  4. 19
      ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts

4
ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.html

@ -24,7 +24,7 @@
<mat-expansion-panel-header>
<div fxFlex fxLayout="row" fxLayoutAlign="start center">
<mat-panel-title>
{{ queuesControl.value.name }}
{{ getTitle(queuesControl.value.name) }}
</mat-panel-title>
<span fxFlex></span>
<button *ngIf="!($index === 0) && !disabled" mat-icon-button style="min-width: 40px;"
@ -37,7 +37,7 @@
</div>
</mat-expansion-panel-header>
<ng-template matExpansionPanelContent>
<tb-queue-form [formControl]="queuesControl"></tb-queue-form>
<tb-queue-form [formControl]="queuesControl" [newQueue]="newQueue"></tb-queue-form>
</ng-template>
</mat-expansion-panel>
</div>

15
ui-ngx/src/app/modules/home/components/profile/queue/tenant-profile-queues.component.ts

@ -56,6 +56,7 @@ export class TenantProfileQueuesComponent implements ControlValueAccessor, Valid
tenantProfileQueuesFormGroup: FormGroup;
newQueue = false;
idMap = [];
private requiredValue: boolean;
get required(): boolean {
@ -116,7 +117,13 @@ export class TenantProfileQueuesComponent implements ControlValueAccessor, Valid
}
const queuesControls: Array<AbstractControl> = [];
if (queues) {
queues.forEach((queue) => {
queues.forEach((queue, index) => {
if (!queue.id) {
if (!this.idMap[index]) {
this.idMap.push(guid());
}
queue.id = this.idMap[index];
}
queuesControls.push(this.fb.control(queue, [Validators.required]));
});
}
@ -140,6 +147,7 @@ export class TenantProfileQueuesComponent implements ControlValueAccessor, Valid
public removeQueue(index: number) {
(this.tenantProfileQueuesFormGroup.get('queues') as FormArray).removeAt(index);
this.idMap.splice(index, 1);
}
public addQueue() {
@ -166,6 +174,7 @@ export class TenantProfileQueuesComponent implements ControlValueAccessor, Valid
description: ''
}
};
this.idMap.push(queue.id);
this.newQueue = true;
const queuesArray = this.tenantProfileQueuesFormGroup.get('queues') as FormArray;
queuesArray.push(this.fb.control(queue, []));
@ -175,6 +184,10 @@ export class TenantProfileQueuesComponent implements ControlValueAccessor, Valid
}
}
getTitle(value): string {
return this.utils.customTranslation(value, value);
}
public validate(c: AbstractControl): ValidationErrors | null {
return this.tenantProfileQueuesFormGroup.valid ? null : {
queues: {

3
ui-ngx/src/app/modules/home/components/queue/queue-form.component.ts

@ -159,9 +159,6 @@ export class QueueFormComponent implements ControlValueAccessor, OnInit, OnDestr
if (isDefinedAndNotNull(this.modelValue)) {
this.queueFormGroup.patchValue(this.modelValue, {emitEvent: false});
this.submitStrategyTypeChanged();
if (!this.modelValue.name) {
this.queueFormGroup.get('name').enable({emitEvent: false});
}
}
if (!this.disabled && !this.queueFormGroup.valid) {
this.updateModel();

19
ui-ngx/src/app/modules/home/pages/tenant-profile/tenant-profiles-table-config.resolver.ts

@ -86,12 +86,7 @@ export class TenantProfilesTableConfigResolver implements Resolve<EntityTableCon
this.config.deleteEntitiesContent = () => this.translate.instant('tenant-profile.delete-tenant-profiles-text');
this.config.entitiesFetchFunction = pageLink => this.tenantProfileService.getTenantProfiles(pageLink);
this.config.loadEntity = id => this.tenantProfileService.getTenantProfile(id.id).pipe(
map(tenantProfile => ({
...tenantProfile,
profileData: {...tenantProfile.profileData, queueConfiguration: this.addId(tenantProfile.profileData.queueConfiguration)},
}))
);
this.config.loadEntity = id => this.tenantProfileService.getTenantProfile(id.id);
this.config.saveEntity = tenantProfile => this.tenantProfileService.saveTenantProfile(tenantProfile);
this.config.deleteEntity = id => this.tenantProfileService.deleteTenantProfile(id.id);
this.config.onEntityAction = action => this.onTenantProfileAction(action);
@ -100,18 +95,6 @@ export class TenantProfilesTableConfigResolver implements Resolve<EntityTableCon
this.config.addActionDescriptors = this.configureAddActions();
}
addId(queues) {
if (queues) {
const queuesWithId = [];
queues.forEach(value => {
value.id = guid();
queuesWithId.push(value);
});
return queuesWithId;
}
return null;
}
resolve(): EntityTableConfig<TenantProfile> {
this.config.tableTitle = this.translate.instant('tenant-profile.tenant-profiles');

Loading…
Cancel
Save