mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
#473 basic hyperlink widget
This commit is contained in:
@@ -31,6 +31,9 @@
|
||||
<div *ngSwitchCase="'dropdown'">
|
||||
<dropdown-widget [field]="field"></dropdown-widget>
|
||||
</div>
|
||||
<div *ngSwitchCase="'hyperlink'">
|
||||
<hyperlink-widget [field]="field"></hyperlink-widget>
|
||||
</div>
|
||||
<div *ngSwitchDefault>
|
||||
<span>UNKNOWN WIDGET TYPE: {{field.type}}</span>
|
||||
</div>
|
||||
|
@@ -24,6 +24,7 @@ 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';
|
||||
import { HyperlinkWidget } from './../hyperlink/hyperlink.widget';
|
||||
|
||||
declare let __moduleName: string;
|
||||
declare var componentHandler;
|
||||
@@ -39,7 +40,8 @@ declare var componentHandler;
|
||||
NumberWidget,
|
||||
CheckboxWidget,
|
||||
MultilineTextWidget,
|
||||
DropdownWidget
|
||||
DropdownWidget,
|
||||
HyperlinkWidget
|
||||
]
|
||||
})
|
||||
export class ContainerWidget implements AfterViewInit {
|
||||
|
@@ -0,0 +1 @@
|
||||
.hyperlink-widget {}
|
@@ -0,0 +1,3 @@
|
||||
<div class="hyperlink-widget">
|
||||
<a [href]="linkUrl" target="_blank" rel="nofollow">{{linkText}}</a>
|
||||
</div>
|
@@ -0,0 +1,49 @@
|
||||
/*!
|
||||
* @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: 'hyperlink-widget',
|
||||
templateUrl: './hyperlink.widget.html',
|
||||
styleUrls: ['./hyperlink.widget.css']
|
||||
})
|
||||
export class HyperlinkWidget extends WidgetComponent {
|
||||
|
||||
get linkUrl(): string {
|
||||
let url = '#';
|
||||
|
||||
if (this.field && this.field.hyperlinkUrl) {
|
||||
url = this.field.hyperlinkUrl;
|
||||
if (!/^https?:\/\//i.test(url)) {
|
||||
url = 'http://' + url;
|
||||
}
|
||||
}
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
get linkText() {
|
||||
return this.field.displayText || this.field.hyperlinkUrl;
|
||||
}
|
||||
|
||||
}
|
@@ -23,3 +23,5 @@ export * from './text/text.widget';
|
||||
export * from './number/number.widget';
|
||||
export * from './checkbox/checkbox.widget';
|
||||
export * from './multiline-text/multiline-text.widget';
|
||||
export * from './dropdown/dropdown.widget';
|
||||
export * from './hyperlink/hyperlink.widget';
|
||||
|
@@ -26,6 +26,7 @@ export class FormFieldTypes {
|
||||
static CONTAINER: string = 'container';
|
||||
static GROUP: string = 'group';
|
||||
static DROPDOWN: string = 'dropdown';
|
||||
static HYPERLINK: string = 'hyperlink';
|
||||
}
|
||||
|
||||
export class FormWidgetModel {
|
||||
@@ -74,6 +75,8 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
className: string;
|
||||
optionType: string;
|
||||
params: FormFieldMetadata = {};
|
||||
hyperlinkUrl: string;
|
||||
displayText: string;
|
||||
|
||||
get value(): any {
|
||||
return this._value;
|
||||
@@ -106,6 +109,8 @@ export class FormFieldModel extends FormWidgetModel {
|
||||
this.className = json.className;
|
||||
this.optionType = json.optionType;
|
||||
this.params = <FormFieldMetadata> json.params || {};
|
||||
this.hyperlinkUrl = json.hyperlinkUrl;
|
||||
this.displayText = json.displayText;
|
||||
|
||||
this._value = this.parseValue(json);
|
||||
this.updateForm();
|
||||
|
Reference in New Issue
Block a user