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

[Table designer] add a few column property edit handlers #1339

Merged
merged 3 commits into from
Dec 14, 2021
Merged
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 @@ -108,8 +108,10 @@ private Task HandleProcessTableDesignerEditRequest(ProcessTableDesignerEditReque
case DesignerEditType.Remove:
this.HandleRemoveItemRequest(requestParams);
break;
case DesignerEditType.Update:
this.HandleUpdateItemRequest(requestParams);
break;
default:
// TODO: Handle 'Update' request
break;
}
await requestContext.SendResult(new ProcessTableDesignerEditResponse()
Expand Down Expand Up @@ -185,6 +187,49 @@ private void HandleRemoveItemRequest(ProcessTableDesignerEditRequestParams reque
}
}

private void HandleUpdateItemRequest(ProcessTableDesignerEditRequestParams requestParams)
{
var table = this.GetTable(requestParams.TableInfo);
var path = requestParams.TableChangeInfo.Path;

if (path.Length == 3)
{
var propertyName = path[0] as string;
switch (propertyName)
{
case TablePropertyNames.Columns:
var colIndex = Convert.ToInt32(path[1]);
var colPropertyName = path[2] as string;
switch (colPropertyName)
{
case TableColumnPropertyNames.Name:
table.Columns.Items[colIndex].Name = requestParams.TableChangeInfo.Value as string;
break;
case TableColumnPropertyNames.Length:
table.Columns.Items[colIndex].Length = requestParams.TableChangeInfo.Value as string;
break;
case TableColumnPropertyNames.AllowNulls:
table.Columns.Items[colIndex].IsNullable = (bool)requestParams.TableChangeInfo.Value;
break;
case TableColumnPropertyNames.Precision:
table.Columns.Items[colIndex].Precision = Int32.Parse(requestParams.TableChangeInfo.Value as string);
break;
case TableColumnPropertyNames.Scale:
table.Columns.Items[colIndex].Scale = Int32.Parse(requestParams.TableChangeInfo.Value as string);
break;
case TableColumnPropertyNames.Type:
table.Columns.Items[colIndex].DataType = requestParams.TableChangeInfo.Value as string;
break;
default:
break;
}
break;
default:
break;
}
}
}

private TableViewModel GetTableViewModel(TableInfo tableInfo)
{
var table = this.GetTable(tableInfo);
Expand Down