rename dataModel to viewModel (#17387)

This commit is contained in:
Alan Ren
2021-10-19 09:52:03 -07:00
committed by GitHub
parent e1a8885e43
commit 569d5cf694
10 changed files with 72 additions and 72 deletions

View File

@@ -1030,12 +1030,12 @@ export namespace GetSqlMigrationAssessmentItemsRequest {
export interface TableDesignerEditRequestParams { export interface TableDesignerEditRequestParams {
tableInfo: azdata.designers.TableInfo, tableInfo: azdata.designers.TableInfo,
tableChangeInfo: azdata.designers.DesignerEdit, tableChangeInfo: azdata.designers.DesignerEdit,
data: azdata.designers.DesignerData viewModel: azdata.designers.DesignerViewModel
} }
export interface SaveTableDesignerChangesRequestParams { export interface SaveTableDesignerChangesRequestParams {
tableInfo: azdata.designers.TableInfo, tableInfo: azdata.designers.TableInfo,
data: azdata.designers.DesignerData viewModel: azdata.designers.DesignerViewModel
} }
export namespace GetTableDesignerInfoRequest { export namespace GetTableDesignerInfoRequest {

View File

@@ -1117,10 +1117,10 @@ export class TableDesignerFeature extends SqlOpsFeature<undefined> {
return Promise.reject(e); return Promise.reject(e);
} }
}; };
const processTableEdit = (tableInfo: azdata.designers.TableInfo, data: azdata.designers.DesignerData, tableChangeInfo: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> => { const processTableEdit = (tableInfo: azdata.designers.TableInfo, viewModel: azdata.designers.DesignerViewModel, tableChangeInfo: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> => {
let params: contracts.TableDesignerEditRequestParams = { let params: contracts.TableDesignerEditRequestParams = {
tableInfo: tableInfo, tableInfo: tableInfo,
data: data, viewModel: viewModel,
tableChangeInfo: tableChangeInfo tableChangeInfo: tableChangeInfo
}; };
try { try {
@@ -1132,10 +1132,10 @@ export class TableDesignerFeature extends SqlOpsFeature<undefined> {
} }
}; };
const saveTable = (tableInfo: azdata.designers.TableInfo, data: azdata.designers.DesignerData): Thenable<void> => { const saveTable = (tableInfo: azdata.designers.TableInfo, viewModel: azdata.designers.DesignerViewModel): Thenable<void> => {
let params: contracts.SaveTableDesignerChangesRequestParams = { let params: contracts.SaveTableDesignerChangesRequestParams = {
tableInfo: tableInfo, tableInfo: tableInfo,
data: data viewModel: viewModel
}; };
try { try {
return client.sendRequest(contracts.SaveTableDesignerChangesRequest.type, params); return client.sendRequest(contracts.SaveTableDesignerChangesRequest.type, params);

View File

@@ -1017,17 +1017,17 @@ declare module 'azdata' {
/** /**
* Process the table change. * Process the table change.
* @param table the table information * @param table the table information
* @param data the object contains the state of the table designer * @param viewModel the object contains the state of the table designer
* @param tableChangeInfo the information about the change user made through the UI. * @param tableChangeInfo the information about the change user made through the UI.
*/ */
processTableEdit(table: TableInfo, data: DesignerData, tableChangeInfo: DesignerEdit): Thenable<DesignerEditResult>; processTableEdit(table: TableInfo, viewModel: DesignerViewModel, tableChangeInfo: DesignerEdit): Thenable<DesignerEditResult>;
/** /**
* Save the table * Save the table
* @param table the table information * @param table the table information
* @param data the object contains the state of the table designer * @param viewModel the object contains the state of the table designer
*/ */
saveTable(table: TableInfo, data: DesignerData): Thenable<void>; saveTable(table: TableInfo, viewModel: DesignerViewModel): Thenable<void>;
} }
/** /**
@@ -1073,9 +1073,9 @@ declare module 'azdata' {
*/ */
view: TableDesignerView; view: TableDesignerView;
/** /**
* The data model. * The initial state of the designer.
*/ */
data: DesignerData; viewModel: DesignerViewModel;
/** /**
* The supported column types * The supported column types
*/ */
@@ -1121,17 +1121,17 @@ declare module 'azdata' {
/** /**
* Additional table column properties.Common table properties are handled by Azure Data Studio. see {@link TableColumnProperty} * Additional table column properties.Common table properties are handled by Azure Data Studio. see {@link TableColumnProperty}
*/ */
addtionalTableColumnProperties?: DesignerDataPropertyInfo[]; additionalTableColumnProperties?: DesignerDataPropertyInfo[];
/** /**
* Additional tabs. * Additional tabs.
*/ */
addtionalTabs?: DesignerTab[]; additionalTabs?: DesignerTab[];
} }
/** /**
* The data model object of the designer. * The view model of the designer.
*/ */
export interface DesignerData { export interface DesignerViewModel {
[key: string]: InputBoxProperties | CheckBoxProperties | DropDownProperties | DesignerTableProperties; [key: string]: InputBoxProperties | CheckBoxProperties | DropDownProperties | DesignerTableProperties;
} }
@@ -1254,9 +1254,9 @@ declare module 'azdata' {
*/ */
export interface DesignerEditResult { export interface DesignerEditResult {
/** /**
* The data model object. * The view model object.
*/ */
data: DesignerData; viewModel: DesignerViewModel;
/** /**
* Whether the current state is valid. * Whether the current state is valid.
*/ */

View File

@@ -3,7 +3,7 @@
* Licensed under the Source EULA. See License.txt in the project root for license information. * Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { DesignerComponentInput, DesignerEditType, DesignerTab, DesignerEdit, DesignerEditIdentifier, DesignerData, DesignerDataPropertyInfo, DesignerTableComponentRowData, DesignerTableProperties, InputBoxProperties, DropDownProperties, CheckBoxProperties, DesignerComponentTypeName } from 'sql/base/browser/ui/designer/interfaces'; import { DesignerComponentInput, DesignerEditType, DesignerTab, DesignerEdit, DesignerEditIdentifier, DesignerViewModel, DesignerDataPropertyInfo, DesignerTableComponentRowData, DesignerTableProperties, InputBoxProperties, DropDownProperties, CheckBoxProperties, DesignerComponentTypeName } from 'sql/base/browser/ui/designer/interfaces';
import { IPanelTab, ITabbedPanelStyles, TabbedPanel } from 'sql/base/browser/ui/panel/panel'; import { IPanelTab, ITabbedPanelStyles, TabbedPanel } from 'sql/base/browser/ui/panel/panel';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { Event } from 'vs/base/common/event'; import { Event } from 'vs/base/common/event';
@@ -41,7 +41,7 @@ export interface IDesignerStyle {
export type DesignerUIComponent = InputBox | Checkbox | Table<Slick.SlickData> | SelectBox; export type DesignerUIComponent = InputBox | Checkbox | Table<Slick.SlickData> | SelectBox;
export type CreateComponentFunc = (container: HTMLElement, component: DesignerDataPropertyInfo, editIdentifier: DesignerEditIdentifier) => DesignerUIComponent; export type CreateComponentFunc = (container: HTMLElement, component: DesignerDataPropertyInfo, editIdentifier: DesignerEditIdentifier) => DesignerUIComponent;
export type SetComponentValueFunc = (definition: DesignerDataPropertyInfo, component: DesignerUIComponent, data: DesignerData) => void; export type SetComponentValueFunc = (definition: DesignerDataPropertyInfo, component: DesignerUIComponent, data: DesignerViewModel) => void;
export class Designer extends Disposable implements IThemable { export class Designer extends Disposable implements IThemable {
private _horizontalSplitViewContainer: HTMLElement; private _horizontalSplitViewContainer: HTMLElement;
@@ -140,8 +140,8 @@ export class Designer extends Disposable implements IThemable {
this._propertiesPane = new DesignerPropertiesPane(this._propertiesPaneContainer, (container, component, identifier) => { this._propertiesPane = new DesignerPropertiesPane(this._propertiesPaneContainer, (container, component, identifier) => {
return this.createComponent(container, component, identifier, false, false); return this.createComponent(container, component, identifier, false, false);
}, (definition, component, data) => { }, (definition, component, viewModel) => {
this.setComponentValue(definition, component, data); this.setComponentValue(definition, component, viewModel);
}, (component) => { }, (component) => {
this.styleComponent(component); this.styleComponent(component);
}); });
@@ -220,45 +220,45 @@ export class Designer extends Disposable implements IThemable {
} }
private async updatePropertiesPane(newContext: PropertiesPaneObjectContext): Promise<void> { private async updatePropertiesPane(newContext: PropertiesPaneObjectContext): Promise<void> {
const data = await this._input.getData(); const viewModel = await this._input.getViewModel();
let type: string; let type: string;
let components: DesignerDataPropertyInfo[]; let components: DesignerDataPropertyInfo[];
let inputData: DesignerData; let inputViewModel: DesignerViewModel;
let context: PropertiesPaneObjectContext; let context: PropertiesPaneObjectContext;
if (newContext !== 'root') { if (newContext !== 'root') {
context = newContext; context = newContext;
const tableData = data[newContext.parentProperty] as DesignerTableProperties; const tableData = viewModel[newContext.parentProperty] as DesignerTableProperties;
const tableProperties = this._componentMap.get(newContext.parentProperty).defintion.componentProperties as DesignerTableProperties; const tableProperties = this._componentMap.get(newContext.parentProperty).defintion.componentProperties as DesignerTableProperties;
inputData = tableData.data[newContext.index] as DesignerData; inputViewModel = tableData.data[newContext.index] as DesignerViewModel;
components = tableProperties.itemProperties; components = tableProperties.itemProperties;
type = tableProperties.objectTypeDisplayName; type = tableProperties.objectTypeDisplayName;
} }
if (!inputData) { if (!inputViewModel) {
context = 'root'; context = 'root';
components = []; components = [];
this._componentMap.forEach(value => { this._componentMap.forEach(value => {
components.push(value.defintion); components.push(value.defintion);
}); });
type = this._input.objectTypeDisplayName; type = this._input.objectTypeDisplayName;
inputData = data; inputViewModel = viewModel;
} }
if (inputData) { if (inputViewModel) {
this._propertiesPane.show({ this._propertiesPane.show({
context: context, context: context,
type: type, type: type,
components: components, components: components,
data: inputData viewModel: inputViewModel
}); });
} }
} }
private async updateComponentValues(): Promise<void> { private async updateComponentValues(): Promise<void> {
const data = await this._input.getData(); const viewModel = await this._input.getViewModel();
// data[ScriptPropertyName] -- todo- set the script editor // data[ScriptPropertyName] -- todo- set the script editor
this._componentMap.forEach((value) => { this._componentMap.forEach((value) => {
this.setComponentValue(value.defintion, value.component, data); this.setComponentValue(value.defintion, value.component, viewModel);
}); });
await this.updatePropertiesPane(this._propertiesPane.context ?? 'root'); await this.updatePropertiesPane(this._propertiesPane.context ?? 'root');
} }
@@ -274,7 +274,7 @@ export class Designer extends Disposable implements IThemable {
await this.updateComponentValues(); await this.updateComponentValues();
if (edit.type === DesignerEditType.Add) { if (edit.type === DesignerEditType.Add) {
// Move focus to the first cell of the newly added row. // Move focus to the first cell of the newly added row.
const data = await this._input.getData(); const data = await this._input.getViewModel();
const propertyName = edit.property as string; const propertyName = edit.property as string;
const tableData = data[propertyName] as DesignerTableProperties; const tableData = data[propertyName] as DesignerTableProperties;
const table = this._componentMap.get(propertyName).component as Table<Slick.SlickData>; const table = this._componentMap.get(propertyName).component as Table<Slick.SlickData>;
@@ -287,21 +287,21 @@ export class Designer extends Disposable implements IThemable {
} }
private async applyEdit(edit: DesignerEdit): Promise<void> { private async applyEdit(edit: DesignerEdit): Promise<void> {
const data = await this._input.getData(); const viewModel = await this._input.getViewModel();
switch (edit.type) { switch (edit.type) {
case DesignerEditType.Update: case DesignerEditType.Update:
if (typeof edit.property === 'string') { if (typeof edit.property === 'string') {
// if the type of the property is string then the property is a top level property // if the type of the property is string then the property is a top level property
if (!data[edit.property]) { if (!viewModel[edit.property]) {
data[edit.property] = {}; viewModel[edit.property] = {};
} }
const componentData = data[edit.property]; const componentData = viewModel[edit.property];
const componentType = this._componentMap.get(edit.property).defintion.componentType; const componentType = this._componentMap.get(edit.property).defintion.componentType;
this.setComponentData(componentType, componentData, edit.value); this.setComponentData(componentType, componentData, edit.value);
} else { } else {
const columnPropertyName = edit.property.property; const columnPropertyName = edit.property.property;
const tableInfo = this._componentMap.get(edit.property.parentProperty).defintion.componentProperties as DesignerTableProperties; const tableInfo = this._componentMap.get(edit.property.parentProperty).defintion.componentProperties as DesignerTableProperties;
const tableProperties = data[edit.property.parentProperty] as DesignerTableProperties; const tableProperties = viewModel[edit.property.parentProperty] as DesignerTableProperties;
if (!tableProperties.data[edit.property.index][columnPropertyName]) { if (!tableProperties.data[edit.property.index][columnPropertyName]) {
tableProperties.data[edit.property.index][columnPropertyName] = {}; tableProperties.data[edit.property.index][columnPropertyName] = {};
} }
@@ -342,23 +342,23 @@ export class Designer extends Disposable implements IThemable {
}; };
} }
private setComponentValue(definition: DesignerDataPropertyInfo, component: DesignerUIComponent, data: DesignerData): void { private setComponentValue(definition: DesignerDataPropertyInfo, component: DesignerUIComponent, viewModel: DesignerViewModel): void {
// Skip the property if it is not in the data model // Skip the property if it is not in the data model
if (!data[definition.propertyName]) { if (!viewModel[definition.propertyName]) {
return; return;
} }
this._supressEditProcessing = true; this._supressEditProcessing = true;
switch (definition.componentType) { switch (definition.componentType) {
case 'input': case 'input':
const input = component as InputBox; const input = component as InputBox;
const inputData = data[definition.propertyName] as InputBoxProperties; const inputData = viewModel[definition.propertyName] as InputBoxProperties;
input.setEnabled(inputData.enabled ?? true); input.setEnabled(inputData.enabled ?? true);
input.value = inputData.value?.toString() ?? ''; input.value = inputData.value?.toString() ?? '';
break; break;
case 'table': case 'table':
const table = component as Table<Slick.SlickData>; const table = component as Table<Slick.SlickData>;
const tableDataView = table.getData() as TableDataView<Slick.SlickData>; const tableDataView = table.getData() as TableDataView<Slick.SlickData>;
const newData = (data[definition.propertyName] as DesignerTableProperties).data; const newData = (viewModel[definition.propertyName] as DesignerTableProperties).data;
let activeCell: Slick.Cell; let activeCell: Slick.Cell;
if (table.container.contains(document.activeElement)) { if (table.container.contains(document.activeElement)) {
// Note down the current active cell if the focus is currently in the table // Note down the current active cell if the focus is currently in the table
@@ -374,7 +374,7 @@ export class Designer extends Disposable implements IThemable {
break; break;
case 'checkbox': case 'checkbox':
const checkbox = component as Checkbox; const checkbox = component as Checkbox;
const checkboxData = data[definition.propertyName] as CheckBoxProperties; const checkboxData = viewModel[definition.propertyName] as CheckBoxProperties;
if (checkboxData.enabled === false) { if (checkboxData.enabled === false) {
checkbox.disable(); checkbox.disable();
} else { } else {
@@ -385,7 +385,7 @@ export class Designer extends Disposable implements IThemable {
case 'dropdown': case 'dropdown':
const dropdown = component as SelectBox; const dropdown = component as SelectBox;
const defaultDropdownData = definition.componentProperties as DropDownProperties; const defaultDropdownData = definition.componentProperties as DropDownProperties;
const dropdownData = data[definition.propertyName] as DropDownProperties; const dropdownData = viewModel[definition.propertyName] as DropDownProperties;
if (dropdownData.enabled === false) { if (dropdownData.enabled === false) {
dropdown.disable(); dropdown.disable();
} else { } else {
@@ -531,8 +531,8 @@ export class Designer extends Disposable implements IThemable {
isFontIcon: true isFontIcon: true
}); });
deleteRowColumn.onClick(async (e) => { deleteRowColumn.onClick(async (e) => {
const data = await this._input.getData(); const viewModel = await this._input.getViewModel();
(data[componentDefinition.propertyName] as DesignerTableProperties).data.splice(e.row, 1); (viewModel[componentDefinition.propertyName] as DesignerTableProperties).data.splice(e.row, 1);
await this.handleEdit({ await this.handleEdit({
type: DesignerEditType.Remove, type: DesignerEditType.Remove,
property: componentDefinition.propertyName, property: componentDefinition.propertyName,

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import { CreateComponentFunc, DesignerUIComponent, SetComponentValueFunc } from 'sql/base/browser/ui/designer/designer'; import { CreateComponentFunc, DesignerUIComponent, SetComponentValueFunc } from 'sql/base/browser/ui/designer/designer';
import { DesignerData, DesignerEditIdentifier, DesignerDataPropertyInfo, InputBoxProperties, NameProperty } from 'sql/base/browser/ui/designer/interfaces'; import { DesignerViewModel, DesignerEditIdentifier, DesignerDataPropertyInfo, InputBoxProperties, NameProperty } from 'sql/base/browser/ui/designer/interfaces';
import * as DOM from 'vs/base/browser/dom'; import * as DOM from 'vs/base/browser/dom';
import { equals } from 'vs/base/common/objects'; import { equals } from 'vs/base/common/objects';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
@@ -18,7 +18,7 @@ export interface ObjectInfo {
context: PropertiesPaneObjectContext; context: PropertiesPaneObjectContext;
type: string; type: string;
components: DesignerDataPropertyInfo[]; components: DesignerDataPropertyInfo[];
data: DesignerData; viewModel: DesignerViewModel;
} }
export class DesignerPropertiesPane { export class DesignerPropertiesPane {
@@ -73,13 +73,13 @@ export class DesignerPropertiesPane {
} }
}); });
} }
const name = (<InputBoxProperties>item.data[NameProperty])?.value ?? ''; const name = (<InputBoxProperties>item.viewModel[NameProperty])?.value ?? '';
this._titleElement.innerText = localize({ this._titleElement.innerText = localize({
key: 'tableDesigner.propertiesPaneTitleWithContext', key: 'tableDesigner.propertiesPaneTitleWithContext',
comment: ['{0} is the place holder for object type', '{1} is the place holder for object name'] comment: ['{0} is the place holder for object type', '{1} is the place holder for object name']
}, "Properties - {0} {1}", item.type, name); }, "Properties - {0} {1}", item.type, name);
this._componentMap.forEach((value) => { this._componentMap.forEach((value) => {
this._setComponentValue(value.defintion, value.component, item.data); this._setComponentValue(value.defintion, value.component, item.viewModel);
}); });
} }
} }

View File

@@ -22,9 +22,9 @@ export interface DesignerComponentInput {
getView(): Promise<DesignerView>; getView(): Promise<DesignerView>;
/** /**
* Gets the data. * Gets the view model.
*/ */
getData(): Promise<DesignerData>; getViewModel(): Promise<DesignerViewModel>;
/** /**
* Process the edit made in the designer. * Process the edit made in the designer.
@@ -68,7 +68,7 @@ export interface DesignerTab {
components: DesignerDataPropertyInfo[]; components: DesignerDataPropertyInfo[];
} }
export interface DesignerData { export interface DesignerViewModel {
[key: string]: InputBoxProperties | CheckBoxProperties | DropDownProperties | DesignerTableProperties; [key: string]: InputBoxProperties | CheckBoxProperties | DropDownProperties | DesignerTableProperties;
} }

View File

@@ -519,7 +519,7 @@ export class MainThreadDataProtocol extends Disposable implements MainThreadData
processTableEdit(table, data, edit): Thenable<azdata.designers.DesignerEditResult> { processTableEdit(table, data, edit): Thenable<azdata.designers.DesignerEditResult> {
return self._proxy.$processTableDesignerEdit(handle, table, data, edit); return self._proxy.$processTableDesignerEdit(handle, table, data, edit);
}, },
saveTable(tableInfo: azdata.designers.TableInfo, data: azdata.designers.DesignerData): Thenable<void> { saveTable(tableInfo: azdata.designers.TableInfo, data: azdata.designers.DesignerViewModel): Thenable<void> {
return self._proxy.$saveTable(handle, tableInfo, data); return self._proxy.$saveTable(handle, tableInfo, data);
} }
}); });

View File

@@ -896,11 +896,11 @@ export class ExtHostDataProtocol extends ExtHostDataProtocolShape {
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).getTableDesignerInfo(table); return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).getTableDesignerInfo(table);
} }
public override $processTableDesignerEdit(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerData, edit: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> { public override $processTableDesignerEdit(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerViewModel, edit: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> {
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).processTableEdit(table, data, edit); return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).processTableEdit(table, data, edit);
} }
public override $saveTable(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerData): Thenable<void> { public override $saveTable(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerViewModel): Thenable<void> {
return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).saveTable(table, data); return this._resolveProvider<azdata.designers.TableDesignerProvider>(handle).saveTable(table, data);
} }

View File

@@ -535,12 +535,12 @@ export abstract class ExtHostDataProtocolShape {
/** /**
* Process the table edit. * Process the table edit.
*/ */
$processTableDesignerEdit(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerData, edit: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> { throw ni(); } $processTableDesignerEdit(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerViewModel, edit: azdata.designers.DesignerEdit): Thenable<azdata.designers.DesignerEditResult> { throw ni(); }
/** /**
* Process the table edit. * Process the table edit.
*/ */
$saveTable(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerData): Thenable<void> { throw ni(); } $saveTable(handle, table: azdata.designers.TableInfo, data: azdata.designers.DesignerViewModel): Thenable<void> { throw ni(); }
/** /**
* Open a new instance of table designer. * Open a new instance of table designer.

View File

@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
import * as azdata from 'azdata'; import * as azdata from 'azdata';
import { DesignerData, DesignerEdit, DesignerEditResult, DesignerComponentInput, DesignerView, DesignerTab, DesignerDataPropertyInfo, DropDownProperties, DesignerTableProperties, DesignerState } from 'sql/base/browser/ui/designer/interfaces'; import { DesignerViewModel, DesignerEdit, DesignerEditResult, DesignerComponentInput, DesignerView, DesignerTab, DesignerDataPropertyInfo, DropDownProperties, DesignerTableProperties, DesignerState } from 'sql/base/browser/ui/designer/interfaces';
import { TableDesignerProvider } from 'sql/workbench/services/tableDesigner/common/interface'; import { TableDesignerProvider } from 'sql/workbench/services/tableDesigner/common/interface';
import { localize } from 'vs/nls'; import { localize } from 'vs/nls';
import { designers } from 'sql/workbench/api/common/sqlExtHostTypes'; import { designers } from 'sql/workbench/api/common/sqlExtHostTypes';
@@ -13,7 +13,7 @@ import { INotificationService, Severity } from 'vs/platform/notification/common/
export class TableDesignerComponentInput implements DesignerComponentInput { export class TableDesignerComponentInput implements DesignerComponentInput {
private _data: DesignerData; private _viewModel: DesignerViewModel;
private _view: DesignerView; private _view: DesignerView;
private _valid: boolean = true; private _valid: boolean = true;
private _dirty: boolean = false; private _dirty: boolean = false;
@@ -50,17 +50,17 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
return this._view; return this._view;
} }
async getData(): Promise<DesignerData> { async getViewModel(): Promise<DesignerViewModel> {
if (!this._data) { if (!this._viewModel) {
await this.initialize(); await this.initialize();
} }
return this._data; return this._viewModel;
} }
async processEdit(edit: DesignerEdit): Promise<DesignerEditResult> { async processEdit(edit: DesignerEdit): Promise<DesignerEditResult> {
const result = await this._provider.processTableEdit(this._tableInfo, this._data!, edit); const result = await this._provider.processTableEdit(this._tableInfo, this._viewModel!, edit);
if (result.isValid) { if (result.isValid) {
this._data = result.data; this._viewModel = result.viewModel;
} }
this.updateState(result.isValid, true, this.saving); this.updateState(result.isValid, true, this.saving);
return { return {
@@ -76,7 +76,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
}); });
try { try {
this.updateState(this.valid, this.dirty, true); this.updateState(this.valid, this.dirty, true);
await this._provider.saveTable(this._tableInfo, this._data); await this._provider.saveTable(this._tableInfo, this._viewModel);
this.updateState(true, false, false); this.updateState(true, false, false);
notificationHandle.updateMessage(localize('tableDesigner.savedChangeSuccess', "The changes have been successfully saved.")); notificationHandle.updateMessage(localize('tableDesigner.savedChangeSuccess', "The changes have been successfully saved."));
} catch (error) { } catch (error) {
@@ -106,7 +106,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
private async initialize(): Promise<void> { private async initialize(): Promise<void> {
const designerInfo = await this._provider.getTableDesignerInfo(this._tableInfo); const designerInfo = await this._provider.getTableDesignerInfo(this._tableInfo);
this._data = designerInfo.data; this._viewModel = designerInfo.viewModel;
this.setDefaultData(); this.setDefaultData();
const advancedTabComponents: DesignerDataPropertyInfo[] = [ const advancedTabComponents: DesignerDataPropertyInfo[] = [
@@ -180,8 +180,8 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
} }
]; ];
if (designerInfo.view.addtionalTableColumnProperties) { if (designerInfo.view.additionalTableColumnProperties) {
columnProperties.push(...designerInfo.view.addtionalTableColumnProperties); columnProperties.push(...designerInfo.view.additionalTableColumnProperties);
} }
const columnsTab = <DesignerTab>{ const columnsTab = <DesignerTab>{
@@ -208,7 +208,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
}; };
const tabs = [columnsTab, advancedTab]; const tabs = [columnsTab, advancedTab];
if (designerInfo.view.addtionalTabs) { if (designerInfo.view.additionalTabs) {
tabs.push(...tabs); tabs.push(...tabs);
} }
@@ -226,7 +226,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
} }
private setDefaultData(): void { private setDefaultData(): void {
const properties = Object.keys(this._data); const properties = Object.keys(this._viewModel);
this.setDefaultInputData(properties, designers.TableProperty.Name); this.setDefaultInputData(properties, designers.TableProperty.Name);
this.setDefaultInputData(properties, designers.TableProperty.Schema); this.setDefaultInputData(properties, designers.TableProperty.Schema);
this.setDefaultInputData(properties, designers.TableProperty.Description); this.setDefaultInputData(properties, designers.TableProperty.Description);
@@ -234,7 +234,7 @@ export class TableDesignerComponentInput implements DesignerComponentInput {
private setDefaultInputData(allProperties: string[], property: string): void { private setDefaultInputData(allProperties: string[], property: string): void {
if (allProperties.indexOf(property) === -1) { if (allProperties.indexOf(property) === -1) {
this._data[property] = {}; this._viewModel[property] = {};
} }
} }
} }