Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Displaying Default Values #887

Open
wants to merge 1 commit into
base: feature/default-value
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,15 @@ <h3 class="title">
</td>
</ng-container>

<ng-container matColumnDef="srcDefaultValue">
<th mat-header-cell class="table_header" *matHeaderCellDef>Default Value</th>
<td mat-cell *matCellDef="let element">
<div class="trimmed-text">
{{ element.get('srcDefaultValue').value }}
</div>
</td>
</ng-container>

<tr mat-header-row *matHeaderRowDef="['srcDatabase']"></tr>
<tr mat-header-row *matHeaderRowDef="srcDisplayedColumns"></tr>
<tr mat-row [ngClass]="{ 'scr-column-data-edit-mode': isEditMode }"
Expand Down Expand Up @@ -328,6 +337,15 @@ <h3 class="title">
</td>
</ng-container>

<ng-container matColumnDef="spDefaultValue">
<th class="table_header" mat-header-cell *matHeaderCellDef>Default Value</th>
<td mat-cell *matCellDef="let element">
<div class="trimmed-text">
{{ element.get('spDefaultValue').value }}
</div>
</td>
</ng-container>

<ng-container matColumnDef="dropButton">
<th mat-header-cell class="table_header" *matHeaderCellDef></th>
<td mat-cell *matCellDef="let element" [ngClass]="{ 'drop-button-left-border': isEditMode }">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@
min-width: 100px;
}

.mat-column-srcIsNotNull,
.mat-column-srcDefaultValue,
NirnayaSindhuSuthari marked this conversation as resolved.
Show resolved Hide resolved
.mat-column-srcDatabase,
.mat-column-srcIndexOrder {
border-right: 1px solid #cdcccd;
Expand All @@ -222,6 +222,13 @@
border-left: 1px solid #cdcccd;
}

.trimmed-text {
width: 200px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}

.sp-datatype-data-cells {
display: flex;
flex-direction: row;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ describe('ObjectDetailComponent', () => {
srcIsPk: true,
spIsNotNull: true,
srcIsNotNull: true,
srcDefaultValue: '',
spDefaultValue: '',
srcId: '1',
spId: '1',
srcColMaxLength: 50,
Expand All @@ -97,6 +99,8 @@ describe('ObjectDetailComponent', () => {
srcIsPk: false,
spIsNotNull: false,
srcIsNotNull: false,
srcDefaultValue: '',
spDefaultValue: '',
srcId: '2',
spId: '2',
srcColMaxLength: 50,
Expand Down
14 changes: 10 additions & 4 deletions ui/src/app/components/object-detail/object-detail.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export class ObjectDetailComponent implements OnInit {
}
}

srcDisplayedColumns = ['srcOrder', 'srcColName', 'srcDataType', 'srcColMaxLength', 'srcIsPk', 'srcIsNotNull']
srcDisplayedColumns = ['srcOrder', 'srcColName', 'srcDataType', 'srcColMaxLength', 'srcIsPk', 'srcIsNotNull', 'srcDefaultValue']

spDisplayedColumns = ['spColName', 'spDataType', 'spColMaxLength', 'spIsPk', 'spIsNotNull', 'dropButton']
spDisplayedColumns = ['spColName', 'spDataType', 'spColMaxLength', 'spIsPk', 'spIsNotNull', 'spDefaultValue', 'dropButton']
displayedFkColumns = [
'srcName',
'srcColumns',
Expand Down Expand Up @@ -172,8 +172,8 @@ export class ObjectDetailComponent implements OnInit {
})
pkObj: IPrimaryKey = {} as IPrimaryKey
dataTypesWithColLen: string[] = ColLength.DataTypes
spColspan : number = 6
srcColspan : number = 6
spColspan : number = 7
srcColspan : number = 7

ngOnChanges(changes: SimpleChanges): void {
this.fkData = changes['fkData']?.currentValue || this.fkData
Expand Down Expand Up @@ -258,6 +258,7 @@ export class ObjectDetailComponent implements OnInit {
srcDataType: new FormControl(row.srcDataType),
srcIsPk: new FormControl(row.srcIsPk),
srcIsNotNull: new FormControl(row.srcIsNotNull),
srcDefaultValue: new FormControl(row.srcDefaultValue),
srcColMaxLength: new FormControl(row.srcColMaxLength),
srcAutoGen: new FormControl(row.srcAutoGen),
spOrder: new FormControl(row.srcOrder),
Expand All @@ -268,6 +269,7 @@ export class ObjectDetailComponent implements OnInit {
spDataType: new FormControl(row.spDataType),
spIsPk: new FormControl(row.spIsPk),
spIsNotNull: new FormControl(row.spIsNotNull), spId: new FormControl(row.spId),
spDefaultValue: new FormControl(row.spDefaultValue),
srcId: new FormControl(row.srcId),
spColMaxLength: new FormControl(row.spColMaxLength, [
Validators.required]),
Expand Down Expand Up @@ -309,13 +311,15 @@ export class ObjectDetailComponent implements OnInit {
srcDataType: new FormControl(col.srcDataType),
srcIsPk: new FormControl(col.srcIsPk),
srcIsNotNull: new FormControl(col.srcIsNotNull),
srcDefaultValue: new FormControl(col.srcDefaultValue),
srcColMaxLength: new FormControl(col.srcColMaxLength),
srcAutoGen: new FormControl(col.srcAutoGen),
spOrder: new FormControl(col.spOrder),
spColName: new FormControl(col.spColName),
spDataType: new FormControl(col.spDataType),
spIsPk: new FormControl(col.spIsPk),
spIsNotNull: new FormControl(col.spIsNotNull),
spDefaultValue: new FormControl(col.spDefaultValue),
spId: new FormControl(col.spId),
srcId: new FormControl(col.srcId),
spColMaxLength: new FormControl(col.spColMaxLength),
Expand Down Expand Up @@ -345,6 +349,7 @@ export class ObjectDetailComponent implements OnInit {
srcDataType: new FormControl(col.srcDataType),
srcIsPk: new FormControl(col.srcIsPk),
srcIsNotNull: new FormControl(col.srcIsNotNull),
srcDefaultValue: new FormControl(col.srcDefaultValue),
srcColMaxLength: new FormControl(col.srcColMaxLength),
srcAutoGen: new FormControl(col.srcAutoGen),
spOrder: new FormControl(col.srcOrder),
Expand All @@ -354,6 +359,7 @@ export class ObjectDetailComponent implements OnInit {
),
spIsPk: new FormControl(col.srcIsPk),
spIsNotNull: new FormControl(col.srcIsNotNull),
spDefaultValue: new FormControl(col.srcDefaultValue),
spColMaxLength: new FormControl(droppedColumnSpMaxLength),
spAutoGen: new FormControl(col.spAutoGen)
})
Expand Down
7 changes: 7 additions & 0 deletions ui/src/app/model/conv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export interface IColumn {
Ignored: IIgnored
Id: string
AutoGen: AutoGen
DefaultValue: IDefaultValue
}

export interface IIgnored {
Expand Down Expand Up @@ -152,6 +153,12 @@ export interface IColumnDef {
NotNull: boolean
Comment: string
AutoGen: IAutoGen
DefaultValue: IDefaultValue
}

export interface IDefaultValue {
IsPresent: boolean
Value: string
}

export interface IType {
Expand Down
2 changes: 2 additions & 0 deletions ui/src/app/model/edit-table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export default interface IColumnTabData {
srcIsPk: boolean
spIsNotNull: boolean
srcIsNotNull: boolean
srcDefaultValue: string
spDefaultValue: string
srcId: string
spId: string
srcColMaxLength: Number | string | undefined
Expand Down
4 changes: 4 additions & 0 deletions ui/src/app/services/conversion/conversion.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,8 @@ export class ConversionService {
srcIsPk: srcPks ? srcPks.map((pk) => pk.ColId).indexOf(colId) !== -1 : false,
spIsNotNull: spannerColDef && spTableName ? spannerColDef.NotNull : false,
srcIsNotNull: data.SrcSchema[tableId].ColDefs[colId].NotNull,
srcDefaultValue: data.SrcSchema[tableId].ColDefs[colId].DefaultValue.Value,
spDefaultValue: spannerColDef && spannerColDef.DefaultValue.IsPresent ? spannerColDef.DefaultValue.Value : '',
srcId: colId,
spId: spannerColDef ? colId : '',
spColMaxLength: spannerColDef?.T.Len != 0 ? (spannerColDef?.T.Len != spColMax ? spannerColDef?.T.Len: 'MAX') : '',
Expand Down Expand Up @@ -351,6 +353,8 @@ export class ConversionService {
srcIsPk: false,
spIsNotNull: spColumn.NotNull,
srcIsNotNull: false,
srcDefaultValue: '',
spDefaultValue: spColumn.DefaultValue.Value,
srcId: '',
spId: colId,
srcColMaxLength: '',
Expand Down
Loading