Skip to content

Commit

Permalink
fix: close edit component and add space to default field name #WIK-16285
Browse files Browse the repository at this point in the history
  • Loading branch information
huanhuanwa committed Aug 9, 2024
1 parent 73b376a commit af32481
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/grid/src/core/utils/field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getDefaultFieldValue(field: AITableField) {
export function createDefaultFieldName(aiTable: AITable, type: AITableFieldType = AITableFieldType.text) {
const fields = aiTable.fields();
const count = fields.filter((item) => item.type === type).length;
return count === 0 ? FieldsMap[type].name : FieldsMap[type].name + count;
return count === 0 ? FieldsMap[type].name : FieldsMap[type].name + ' ' + count;
}

export function createDefaultField(aiTable: AITable, type: AITableFieldType = AITableFieldType.text) {
Expand Down
6 changes: 5 additions & 1 deletion packages/grid/src/services/event.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { GRID_CELL_EDITOR_MAP } from '../constants/editor';
import { AITable, AITableField, AITableFieldType, AITableRecord } from '../core';
import { AITableGridCellRenderSchema } from '../types';
import { getRecordOrField } from '../utils';
import { Overlay } from '@angular/cdk/overlay';

@Injectable()
export class AITableGridEventService {
Expand All @@ -25,6 +26,8 @@ export class AITableGridEventService {

private destroyRef = inject(DestroyRef);

private overlay = inject(Overlay);

private thyPopover = inject(ThyPopover);

initialize(aiTable: AITable, aiFieldRenderers?: Partial<Record<AITableFieldType, AITableGridCellRenderSchema>>) {
Expand Down Expand Up @@ -101,7 +104,8 @@ export class AITableGridEventService {
hasBackdrop: false,
manualClosure: true,
animationDisabled: true,
autoAdaptive: true
autoAdaptive: true,
scrollStrategy: this.overlay.scrollStrategies.close()
});
return ref;
}
Expand Down
4 changes: 3 additions & 1 deletion src/app/app.component.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<router-outlet></router-outlet>
<div cdkScrollable class="table-container">
<router-outlet></router-outlet>
</div>
2 changes: 1 addition & 1 deletion src/app/app.component.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
app-root {
.table-container {
display: block;
margin: 0 20px;
margin-bottom: 0;
Expand Down
3 changes: 2 additions & 1 deletion src/app/app.component.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { CdkScrollable } from '@angular/cdk/scrolling';
import { ChangeDetectionStrategy, Component } from '@angular/core';
import { RouterOutlet } from '@angular/router';
@Component({
selector: 'app-root',
standalone: true,
imports: [RouterOutlet],
imports: [RouterOutlet, CdkScrollable],
templateUrl: './app.component.html',
styleUrl: './app.component.scss',
changeDetection: ChangeDetectionStrategy.OnPush
Expand Down

0 comments on commit af32481

Please sign in to comment.