#440 Dropdown widget stub, base widget component

This commit is contained in:
Denys Vuika
2016-07-25 12:54:36 +01:00
parent 0b03f2077c
commit b0b7a7130c
9 changed files with 101 additions and 69 deletions

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Component, Input, AfterViewInit } from '@angular/core';
import { FormFieldModel } from './../widget.model';
import { Component } from '@angular/core';
import { WidgetComponent } from './../widget.component';
declare let __moduleName: string;
declare var componentHandler;
@@ -26,20 +26,6 @@ declare var componentHandler;
selector: 'checkbox-widget',
templateUrl: './checkbox.widget.html'
})
export class CheckboxWidget implements AfterViewInit {
@Input()
field: FormFieldModel;
hasField() {
return this.field ? true : false;
}
ngAfterViewInit() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
export class CheckboxWidget extends WidgetComponent {
}

View File

@@ -15,6 +15,9 @@
<div *ngSwitchCase="'boolean'">
<checkbox-widget [field]="field"></checkbox-widget>
</div>
<div *ngSwitchCase="'dropdown'">
<dropdown-widget [field]="field"></dropdown-widget>
</div>
<div *ngSwitchDefault>
<span>UNKNOWN WIDGET TYPE: {{field.type}}</span>
</div>

View File

@@ -22,6 +22,7 @@ import { TextWidget } from './../text/text.widget';
import { NumberWidget } from './../number/number.widget';
import { CheckboxWidget } from './../checkbox/checkbox.widget';
import { MultilineTextWidget } from './../multiline-text/multiline-text.widget';
import { DropdownWidget } from './../dropdown/dropdown.widget';
declare let __moduleName: string;
declare var componentHandler;
@@ -30,7 +31,13 @@ declare var componentHandler;
moduleId: __moduleName,
selector: 'container-widget',
templateUrl: './container.widget.html',
directives: [TextWidget, NumberWidget, CheckboxWidget, MultilineTextWidget]
directives: [
TextWidget,
NumberWidget,
CheckboxWidget,
MultilineTextWidget,
DropdownWidget
]
})
export class ContainerWidget implements AfterViewInit {

View File

@@ -0,0 +1,4 @@
<select>
<option value="1">One</option>
<option value="2">Two</option>
</select>

View File

@@ -0,0 +1,31 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Component } from '@angular/core';
import { WidgetComponent } from './../widget.component';
declare let __moduleName: string;
declare var componentHandler;
@Component({
moduleId: __moduleName,
selector: 'dropdown-widget',
templateUrl: './dropdown.widget.html'
})
export class DropdownWidget extends WidgetComponent {
}

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Component, Input, AfterViewInit } from '@angular/core';
import { FormFieldModel } from './../widget.model';
import { Component } from '@angular/core';
import { WidgetComponent } from './../widget.component';
declare let __moduleName: string;
declare var componentHandler;
@@ -27,20 +27,6 @@ declare var componentHandler;
templateUrl: './multiline-text.widget.html',
styleUrls: ['./multiline-text.widget.css']
})
export class MultilineTextWidget implements AfterViewInit {
@Input()
field: FormFieldModel;
hasField() {
return this.field ? true : false;
}
ngAfterViewInit() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
export class MultilineTextWidget extends WidgetComponent {
}

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Component, Input, AfterViewInit } from '@angular/core';
import { FormFieldModel } from './../widget.model';
import { Component } from '@angular/core';
import { WidgetComponent } from './../widget.component';
declare let __moduleName: string;
declare var componentHandler;
@@ -27,20 +27,6 @@ declare var componentHandler;
templateUrl: './number.widget.html',
styleUrls: ['./number.widget.css']
})
export class NumberWidget implements AfterViewInit {
@Input()
field: FormFieldModel;
hasField() {
return this.field ? true : false;
}
ngAfterViewInit() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
export class NumberWidget extends WidgetComponent {
}

View File

@@ -15,8 +15,8 @@
* limitations under the License.
*/
import { Component, Input, AfterViewInit } from '@angular/core';
import { FormFieldModel } from './../widget.model';
import { Component } from '@angular/core';
import { WidgetComponent } from './../widget.component';
declare let __moduleName: string;
declare var componentHandler;
@@ -27,20 +27,6 @@ declare var componentHandler;
templateUrl: './text.widget.html',
styleUrls: ['./text.widget.css']
})
export class TextWidget implements AfterViewInit {
@Input()
field: FormFieldModel;
hasField() {
return this.field ? true : false;
}
ngAfterViewInit() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
export class TextWidget extends WidgetComponent {
}

View File

@@ -0,0 +1,43 @@
/*!
* @license
* Copyright 2016 Alfresco Software, Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Input, AfterViewInit } from '@angular/core';
import { FormFieldModel } from './widget.model';
declare let __moduleName: string;
declare var componentHandler;
/**
* Base widget component.
*/
export class WidgetComponent implements AfterViewInit {
@Input()
field: FormFieldModel;
hasField() {
return this.field ? true : false;
}
ngAfterViewInit() {
// workaround for MDL issues with dynamic components
if (componentHandler) {
componentHandler.upgradeAllRegistered();
}
}
}