mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-15 02:48:35 -05:00
handle add column request (#1272)
* handle add column request * comments * rename data to ViewModel
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// The base class for view model object.
|
||||
/// </summary>
|
||||
public abstract class ObjectViewModelBase
|
||||
{
|
||||
public InputBoxProperties Name { get; set; } = new InputBoxProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// The view model of a table column object
|
||||
/// </summary>
|
||||
public class TableColumnViewModel : ObjectViewModelBase
|
||||
{
|
||||
public DropdownProperties Type { get; set; } = new DropdownProperties();
|
||||
|
||||
public InputBoxProperties Length { get; set; } = new InputBoxProperties();
|
||||
|
||||
public CheckBoxProperties AllowNulls { get; set; } = new CheckBoxProperties();
|
||||
|
||||
public InputBoxProperties DefaultValue { get; set; } = new InputBoxProperties();
|
||||
|
||||
public CheckBoxProperties IsPrimaryKey { get; set; } = new CheckBoxProperties();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
//
|
||||
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.TableDesigner.Contracts
|
||||
{
|
||||
/// <summary>
|
||||
/// The view model for a table object
|
||||
/// </summary>
|
||||
public class TableViewModel : ObjectViewModelBase
|
||||
{
|
||||
public DropdownProperties Schema { get; set; } = new DropdownProperties();
|
||||
|
||||
public InputBoxProperties Description { get; set; } = new InputBoxProperties();
|
||||
|
||||
public TableColumnCollection Columns { get; set; } = new TableColumnCollection();
|
||||
|
||||
public InputBoxProperties Script { get; set; } = new InputBoxProperties();
|
||||
}
|
||||
|
||||
public class TableColumnCollection : TableComponentProperties<TableColumnViewModel>
|
||||
{
|
||||
[JsonIgnore]
|
||||
protected override string NewObjectNamePrefix { get { return "column"; } }
|
||||
|
||||
protected override TableColumnViewModel CreateNew(string name)
|
||||
{
|
||||
//TODO: Add the default values
|
||||
var column = new TableColumnViewModel();
|
||||
column.Name.Value = this.GetDefaultNewObjectName();
|
||||
return column;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user