mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-17 02:51:36 -05:00
Feature/form improvements (#1707)
* adding more options for form * added form requied and info for item
This commit is contained in:
@@ -3,6 +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 'vs/css!./formLayout';
|
import 'vs/css!./formLayout';
|
||||||
|
import 'vs/css!sql/media/icons/common-icons';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver,
|
Component, Input, Inject, ChangeDetectorRef, forwardRef, ComponentFactoryResolver,
|
||||||
@@ -25,6 +26,9 @@ export interface TitledFormItemLayout {
|
|||||||
horizontal: boolean;
|
horizontal: boolean;
|
||||||
componentWidth?: number | string;
|
componentWidth?: number | string;
|
||||||
componentHeight?: number | string;
|
componentHeight?: number | string;
|
||||||
|
titleFontSize?: number;
|
||||||
|
required?: boolean;
|
||||||
|
info?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormLayout {
|
export interface FormLayout {
|
||||||
@@ -37,12 +41,15 @@ class FormItem {
|
|||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
template: `
|
template: `
|
||||||
<div #container *ngIf="items" class="form-table" [style.width]="getFormWidth()" [style.height]="getFormHeight()">
|
<div #container *ngIf="items" class="form-table" [style.padding]="getFormPadding()" [style.width]="getFormWidth()" [style.height]="getFormHeight()">
|
||||||
<ng-container *ngFor="let item of items">
|
<ng-container *ngFor="let item of items">
|
||||||
<div class="form-row" *ngIf="isFormComponent(item)" [style.height]="getRowHeight(item)">
|
<div class="form-row" *ngIf="isFormComponent(item)" [style.height]="getRowHeight(item)">
|
||||||
|
|
||||||
<ng-container *ngIf="isHorizontal(item)">
|
<ng-container *ngIf="isHorizontal(item)">
|
||||||
<div class="form-cell">{{getItemTitle(item)}}</div>
|
<div class="form-cell" [style.font-size]="getItemTitleFontSize(item)">
|
||||||
|
{{getItemTitle(item)}}<span class="form-required" *ngIf="isItemRequired(item)">*</span>
|
||||||
|
<span class="icon info" *ngIf="itemHasInfo(item)" [title]="getItemInfo(item)"></span>
|
||||||
|
</div>
|
||||||
<div class="form-cell">
|
<div class="form-cell">
|
||||||
<div class="form-component-container">
|
<div class="form-component-container">
|
||||||
<div [style.width]="getComponentWidth(item)" [ngClass]="{'form-input-flex': !getComponentWidth(item)}">
|
<div [style.width]="getComponentWidth(item)" [ngClass]="{'form-input-flex': !getComponentWidth(item)}">
|
||||||
@@ -59,7 +66,10 @@ class FormItem {
|
|||||||
</div>
|
</div>
|
||||||
</ng-container>
|
</ng-container>
|
||||||
<div class="form-vertical-container" *ngIf="isVertical(item)" [style.height]="getRowHeight(item)">
|
<div class="form-vertical-container" *ngIf="isVertical(item)" [style.height]="getRowHeight(item)">
|
||||||
<div class="form-item-row">{{getItemTitle(item)}}</div>
|
<div class="form-item-row" [style.font-size]="getItemTitleFontSize(item)">
|
||||||
|
{{getItemTitle(item)}}<span class="form-required" *ngIf="isItemRequired(item)">*</span>
|
||||||
|
<span class="icon info" *ngIf="itemHasInfo(item)" [title]="getItemInfo(item)"></span>
|
||||||
|
</div>
|
||||||
<div class="form-item-row" [style.width]="getComponentWidth(item)" [style.height]="getRowHeight(item)">
|
<div class="form-item-row" [style.width]="getComponentWidth(item)" [style.height]="getRowHeight(item)">
|
||||||
<model-component-wrapper [descriptor]="item.descriptor" [modelStore]="modelStore" [style.width]="getComponentWidth(item)" [style.height]="getRowHeight(item)">
|
<model-component-wrapper [descriptor]="item.descriptor" [modelStore]="modelStore" [style.width]="getComponentWidth(item)" [style.height]="getRowHeight(item)">
|
||||||
</model-component-wrapper>
|
</model-component-wrapper>
|
||||||
@@ -121,6 +131,10 @@ export default class FormContainer extends ContainerBase<FormItemLayout> impleme
|
|||||||
return this.convertSize(this._formLayout && this._formLayout.width, '');
|
return this.convertSize(this._formLayout && this._formLayout.width, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getFormPadding(): string {
|
||||||
|
return this._formLayout && this._formLayout.padding ? this._formLayout.padding : '10px 30px 0px 30px';
|
||||||
|
}
|
||||||
|
|
||||||
private getFormHeight(): string {
|
private getFormHeight(): string {
|
||||||
return this.convertSize(this._formLayout && this._formLayout.height, '');
|
return this.convertSize(this._formLayout && this._formLayout.height, '');
|
||||||
}
|
}
|
||||||
@@ -135,11 +149,32 @@ export default class FormContainer extends ContainerBase<FormItemLayout> impleme
|
|||||||
return (itemConfig && itemConfig.componentHeight) ? this.convertSize(itemConfig.componentHeight, '') : '';
|
return (itemConfig && itemConfig.componentHeight) ? this.convertSize(itemConfig.componentHeight, '') : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private isItemRequired(item: FormItem): boolean {
|
||||||
|
let itemConfig = item.config;
|
||||||
|
return itemConfig && itemConfig.required;
|
||||||
|
}
|
||||||
|
|
||||||
|
private getItemInfo(item: FormItem): string {
|
||||||
|
let itemConfig = item.config;
|
||||||
|
return itemConfig && itemConfig.info;
|
||||||
|
}
|
||||||
|
|
||||||
|
private itemHasInfo(item: FormItem): boolean {
|
||||||
|
let itemConfig = item.config;
|
||||||
|
return itemConfig && itemConfig.info !== undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private getItemTitle(item: FormItem): string {
|
private getItemTitle(item: FormItem): string {
|
||||||
let itemConfig = item.config;
|
let itemConfig = item.config;
|
||||||
return itemConfig ? itemConfig.title : '';
|
return itemConfig ? itemConfig.title : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private getItemTitleFontSize(item: FormItem): string {
|
||||||
|
let itemConfig = item.config;
|
||||||
|
return itemConfig && itemConfig.titleFontSize ? this.convertSize(itemConfig.titleFontSize, '11px') : '11px';
|
||||||
|
}
|
||||||
|
|
||||||
private getActionComponents(item: FormItem): FormItem[] {
|
private getActionComponents(item: FormItem): FormItem[] {
|
||||||
let items = this.items;
|
let items = this.items;
|
||||||
let itemConfig = item.config;
|
let itemConfig = item.config;
|
||||||
|
|||||||
@@ -37,6 +37,11 @@
|
|||||||
flex: 1;
|
flex: 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.form-required {
|
||||||
|
color: red;
|
||||||
|
padding-left: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
.form-component-actions {
|
.form-component-actions {
|
||||||
padding-left: 5px;
|
padding-left: 5px;
|
||||||
}
|
}
|
||||||
|
|||||||
4
src/sql/sqlops.proposed.d.ts
vendored
4
src/sql/sqlops.proposed.d.ts
vendored
@@ -239,11 +239,15 @@ declare module 'sqlops' {
|
|||||||
horizontal?: boolean;
|
horizontal?: boolean;
|
||||||
componentWidth?: number | string;
|
componentWidth?: number | string;
|
||||||
componentHeight?: number | string;
|
componentHeight?: number | string;
|
||||||
|
titleFontSize?: number;
|
||||||
|
required?: boolean;
|
||||||
|
info?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FormLayout {
|
export interface FormLayout {
|
||||||
width?: number | string;
|
width?: number | string;
|
||||||
height?: number | string;
|
height?: number | string;
|
||||||
|
padding?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupLayout {
|
export interface GroupLayout {
|
||||||
|
|||||||
@@ -255,6 +255,9 @@ class FormContainerBuilder extends ContainerBuilderImpl<sqlops.FormContainer, sq
|
|||||||
|
|
||||||
private convertToItemConfig(formComponent: sqlops.FormComponent, itemLayout?: sqlops.FormItemLayout): InternalItemConfig {
|
private convertToItemConfig(formComponent: sqlops.FormComponent, itemLayout?: sqlops.FormItemLayout): InternalItemConfig {
|
||||||
let componentWrapper = formComponent.component as ComponentWrapper;
|
let componentWrapper = formComponent.component as ComponentWrapper;
|
||||||
|
if (itemLayout && itemLayout.required && componentWrapper) {
|
||||||
|
componentWrapper.required = true;
|
||||||
|
}
|
||||||
let actions: string[] = undefined;
|
let actions: string[] = undefined;
|
||||||
if (formComponent.actions) {
|
if (formComponent.actions) {
|
||||||
actions = formComponent.actions.map(action => {
|
actions = formComponent.actions.map(action => {
|
||||||
@@ -400,6 +403,13 @@ class ComponentWrapper implements sqlops.Component {
|
|||||||
this.setProperty('width', v);
|
this.setProperty('width', v);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public get required(): boolean {
|
||||||
|
return this.properties['required'];
|
||||||
|
}
|
||||||
|
public set required(v: boolean) {
|
||||||
|
this.setProperty('required', v);
|
||||||
|
}
|
||||||
|
|
||||||
public toComponentShape(): IComponentShape {
|
public toComponentShape(): IComponentShape {
|
||||||
return <IComponentShape>{
|
return <IComponentShape>{
|
||||||
id: this.id,
|
id: this.id,
|
||||||
|
|||||||
Reference in New Issue
Block a user