Skip to content

Commit 75f6345

Browse files
committed
feat(): update taiga version
1 parent bf2cd3e commit 75f6345

File tree

9 files changed

+239
-192
lines changed

9 files changed

+239
-192
lines changed

apps/mix-cms/src/app/pages/portal/database/components/database-relationship/database-relationship.component.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
<div class="mt-1 notification --info">
2+
Currently we suppored relationship type:
3+
<span class="text-highlight">One to Many</span>
4+
</div>
5+
16
<div class="card-list">
27
<div class="card-list__header mt-3 mb-1">
38
<div class="row">

apps/mix-cms/src/app/pages/portal/database/components/relationship-record/database-relationship-record.component.html

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
1-
<div class="card-01-wrap" [class.--new]="value.new">
1+
<div class="card-01-wrap" [class.--new]="value.new" [formGroup]="form">
22
<div class="card-01">
33
<div class="row">
44
<div class="col-4 d-flex align-items-center gap-2">
55
<span class="mix-icon cursor-grab">drag_indicator</span>
66

7-
<mix-input placeHolder="Display name"></mix-input>
7+
<mix-input
8+
placeHolder="Display name"
9+
formControlName="displayName"
10+
></mix-input>
811
</div>
912

1013
<div class="col-4">
1114
<mix-select
12-
[labelKey]="'displayName'"
1315
class="w-100"
14-
[items]="(databaseStore.vm$ | async)?.data"
16+
[items]="allDatabaseIds"
17+
[labelProcess]="labelProcess"
1518
placeHolder="Choose database"
19+
formControlName="parentId"
1620
></mix-select>
1721
</div>
22+
23+
<div class="col-4 align-items-center d-flex">
24+
<span class="text-500"> One to Many </span>
25+
</div>
1826
</div>
1927

2028
<div class="card-01__action">

apps/mix-cms/src/app/pages/portal/database/components/relationship-record/database-relationship-record.component.ts

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,15 @@ import {
66
Input,
77
inject,
88
} from '@angular/core';
9-
import { MixRelationShip } from '@mixcore/lib/model';
9+
import { takeUntilDestroyed } from '@angular/core/rxjs-interop';
10+
import { FormBuilder, ReactiveFormsModule, Validators } from '@angular/forms';
11+
import { MixDatabase, MixRelationShip } from '@mixcore/lib/model';
12+
import { ArrayUtil } from '@mixcore/share/form';
1013
import { MixButtonComponent } from '@mixcore/ui/button';
1114
import { MixInputComponent } from '@mixcore/ui/input';
1215
import { MixSelectComponent } from '@mixcore/ui/select';
1316
import { DatabaseStore } from 'apps/mix-cms/src/app/stores/database.store';
17+
import { filter } from 'rxjs';
1418

1519
@Component({
1620
selector: 'mix-database-relationship-record',
@@ -21,12 +25,40 @@ import { DatabaseStore } from 'apps/mix-cms/src/app/stores/database.store';
2125
MixInputComponent,
2226
MixSelectComponent,
2327
DragDropModule,
28+
ReactiveFormsModule,
2429
],
2530
templateUrl: './database-relationship-record.component.html',
2631
styleUrls: ['./database-relationship-record.component.scss'],
2732
changeDetection: ChangeDetectionStrategy.OnPush,
2833
})
2934
export class DatabaseRelationshipRecordComponent {
30-
@Input() value!: Partial<MixRelationShip>;
35+
@Input() public value!: Partial<MixRelationShip>;
3136
public databaseStore = inject(DatabaseStore);
37+
38+
public allDatabaseIds: number[] = [];
39+
public allDatabaseDict: Record<number, MixDatabase> = {};
40+
public form = inject(FormBuilder).group({
41+
displayName: ['', Validators.required],
42+
parentId: [<number | undefined>undefined, Validators.required],
43+
});
44+
45+
public labelProcess = (dbId: number) => {
46+
return this.allDatabaseDict[dbId].displayName;
47+
};
48+
49+
constructor() {
50+
this.databaseStore.vm$
51+
.pipe(
52+
takeUntilDestroyed(),
53+
filter((s) => s.status === 'Success')
54+
)
55+
.subscribe((v) => {
56+
this.allDatabaseIds = v.data.map((x) => x.id);
57+
this.allDatabaseDict = ArrayUtil.toRecord(v.data, 'id');
58+
});
59+
}
60+
61+
ngOnInit() {
62+
this.form.patchValue(this.value);
63+
}
3264
}

libs/mix-share/src/form/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export * from './error-map';
22
export * from './form-error.component';
33
export * from './form.helper';
4+
export * from './object.helper';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export type RecordableKeys<T> = {
2+
// for each key in T
3+
[K in keyof T]: T[K] extends string | number | symbol // is the value a valid object key?
4+
? // Yes, return the key itself
5+
K
6+
: // No. Return `never`
7+
never;
8+
}[keyof T];
9+
10+
export class ArrayUtil {
11+
public static toRecord<
12+
T extends { [P in RecordableKeys<T>]: string | number | symbol },
13+
K extends RecordableKeys<T>
14+
>(array: T[], selector: K): Record<T[K], T> {
15+
return array.reduce(
16+
(acc, item) => ((acc[item[selector]] = item), acc),
17+
{} as Record<T[K], T>
18+
);
19+
}
20+
}

libs/mix-ui/src/modal/modal.service.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export class ModalService extends AbstractTuiDialogService<
3737
heading: title,
3838
borderShadowColor: this.modalShadowColor.info,
3939
};
40+
4041
return this.open(message, options);
4142
}
4243

@@ -46,6 +47,7 @@ export class ModalService extends AbstractTuiDialogService<
4647
heading: 'Confirmation',
4748
borderShadowColor: this.modalShadowColor.confirm,
4849
};
50+
4951
return this.open(message, options);
5052
}
5153

@@ -65,6 +67,7 @@ export class ModalService extends AbstractTuiDialogService<
6567
heading: 'Congratulation',
6668
borderShadowColor: this.modalShadowColor.success,
6769
};
70+
6871
return this.open(message, options);
6972
}
7073

@@ -74,6 +77,7 @@ export class ModalService extends AbstractTuiDialogService<
7477
heading: 'Error !',
7578
borderShadowColor: this.modalShadowColor.success,
7679
};
80+
7781
return this.open(message, options);
7882
}
7983

@@ -83,6 +87,7 @@ export class ModalService extends AbstractTuiDialogService<
8387
heading: 'Warning',
8488
borderShadowColor: this.modalShadowColor.warning,
8589
};
90+
8691
return this.open(message, options);
8792
}
8893

libs/mix-ui/src/select/select.component.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { CommonModule } from '@angular/common';
22
import {
3+
ChangeDetectionStrategy,
34
Component,
45
EventEmitter,
56
Input,
@@ -36,6 +37,7 @@ import { takeUntil } from 'rxjs';
3637
templateUrl: './select.component.html',
3738
styleUrls: ['./select.component.scss'],
3839
providers: [TuiDestroyService],
40+
changeDetection: ChangeDetectionStrategy.OnPush,
3941
})
4042
export class MixSelectComponent
4143
extends BaseTextControl

package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,15 @@
4848
"@nrwl/angular": "17.1.1",
4949
"@swimlane/ngx-charts": "^20.1.2",
5050
"@taiga-ui/addon-editor": "^3.24.0",
51-
"@taiga-ui/addon-mobile": "3.39.1",
52-
"@taiga-ui/addon-preview": "3.39.1",
53-
"@taiga-ui/addon-table": "3.39.1",
54-
"@taiga-ui/cdk": "3.39.1",
55-
"@taiga-ui/core": "3.39.1",
56-
"@taiga-ui/icons": "3.39.1",
57-
"@taiga-ui/kit": "3.39.1",
51+
"@taiga-ui/addon-mobile": "3.54.0",
52+
"@taiga-ui/addon-preview": "3.54.0",
53+
"@taiga-ui/addon-table": "3.54.0",
54+
"@taiga-ui/cdk": "3.54.0",
55+
"@taiga-ui/core": "3.54.0",
56+
"@taiga-ui/icons": "3.54.0",
57+
"@taiga-ui/kit": "3.54.0",
5858
"@tinkoff/ng-dompurify": "^4.0.0",
59-
"@tinkoff/ng-polymorpheus": "4.1.0",
59+
"@tinkoff/ng-polymorpheus": "4.2.0",
6060
"ag-grid-angular": "^30.0.6",
6161
"ag-grid-community": "^30.0.6",
6262
"ang-jsoneditor": "^3.1.0",

0 commit comments

Comments
 (0)