Skip to content

Commit

Permalink
[Table designer] add a few column property edit handlers (#1339)
Browse files Browse the repository at this point in the history
  • Loading branch information
caohai authored Dec 14, 2021
1 parent c3936a3 commit adb82f2
Showing 1 changed file with 46 additions and 1 deletion.
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

0 comments on commit adb82f2

Please sign in to comment.