mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-31 17:38:48 +00:00
* mdl2 transition part form 1 * hyperlink * radio buttons * label * people component * [ADF-852] moved textarea to new angular material * number widget * change error multiline * [ADF-852] added md desgin for dropdown * [ADF-852] removed unused css file * functional widget * error dropdown * [ADF-852] - changed to new md date * remove md-date-time-picker dependency in ng2-alfresco-from * [ADF-852] conversion dynamic table phase 1 * container widget * remove test unused * validation change * [ADF-852] convert dynamic table phase 2 * [ADF-852] improving style and fixing bugs * move custom style for form in form.scss * error footer refactor * fix models and test * [ADF-852]- fixed minor twitch on dynamic table * align fields and fix tests dropdown * disabling button in readonly clean mdl form start process form * align dropdown * [ADF-1048] Upload widget can manage multiple files. (#2134) * [ADF-1048] improving upload widget * [ADF-1048] added ability to upload multiple file on upload widget * [ADF-1048] added multiple upload elements on upload widget * [ADF-1048] - show all the files on the completed form * [ADF-1048] fixed wrong selecion on displya upload * [ADF-1048] removed fdescribe from upload widget * date validation and custom moment data adapter * move content widget in the widget folder * add style fields and theming * color primary radio and checkbox * fix amount widget and colors * change ViewEncapsulation and fix date style button issue * empty form customization 1736 * focus label style * [ADF-224] fix the rendering of custom stencils when form is opened in readonly state. (#2161) * [ADF-224] Fixed rendering of custom stencil in readonly mode * [ADF-224] improved variable name * test fix * container filter in form model creation * show display value correctly * fix change date and test * fix date editor and add some test coverage for date * style minor issue * fix new unused local import rule * fix test date * strict date check * fix analytics failing test * restore null as default in model * unify model diagrams and analytics
84 lines
2.8 KiB
TypeScript
84 lines
2.8 KiB
TypeScript
/*!
|
|
* @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.
|
|
*/
|
|
|
|
/* tslint:disable:component-selector */
|
|
|
|
/* tslint:disable::no-access-missing-member */
|
|
import { Component, ElementRef, Input, OnInit } from '@angular/core';
|
|
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
|
import { ParameterValueModel, ReportParameterDetailsModel } from 'ng2-activiti-diagrams';
|
|
import { NumberWidgetComponent } from './../number/number.widget';
|
|
|
|
@Component({
|
|
selector: 'duration-widget',
|
|
templateUrl: './duration.widget.html',
|
|
styleUrls: ['./duration.widget.css']
|
|
})
|
|
export class DurationWidgetComponent extends NumberWidgetComponent implements OnInit {
|
|
|
|
@Input()
|
|
field: any;
|
|
|
|
@Input('group')
|
|
public formGroup: FormGroup;
|
|
|
|
@Input('controllerName')
|
|
public controllerName: string;
|
|
|
|
@Input()
|
|
required: boolean = false;
|
|
|
|
duration: ReportParameterDetailsModel;
|
|
currentValue: number;
|
|
|
|
public selectionGroup: FormGroup;
|
|
|
|
constructor(public elementRef: ElementRef) {
|
|
super(elementRef);
|
|
}
|
|
|
|
ngOnInit() {
|
|
let timeType = new FormControl();
|
|
this.formGroup.addControl('timeType', timeType);
|
|
|
|
if (this.required) {
|
|
this.formGroup.get(this.controllerName).setValidators(Validators.required);
|
|
}
|
|
if (this.field.value === null) {
|
|
this.field.value = 0;
|
|
}
|
|
|
|
let paramOptions: ParameterValueModel[] = [];
|
|
paramOptions.push(new ParameterValueModel({id: '1', name: 'Seconds'}));
|
|
paramOptions.push(new ParameterValueModel({id: '60', name: 'Minutes'}));
|
|
paramOptions.push(new ParameterValueModel({id: '3600', name: 'Hours'}));
|
|
paramOptions.push(new ParameterValueModel({id: '86400', name: 'Days', selected: true}));
|
|
|
|
this.duration = new ReportParameterDetailsModel({id: 'duration', name: 'duration', options: paramOptions});
|
|
this.duration.value = paramOptions[0].id;
|
|
}
|
|
|
|
public calculateDuration() {
|
|
if (this.field && this.duration.value ) {
|
|
this.currentValue = parseInt(this.field.value, 10) * parseInt(this.duration.value, 10);
|
|
this.formGroup.get(this.controllerName).setValue(this.currentValue);
|
|
this.fieldChanged.emit({value: this.currentValue});
|
|
}
|
|
}
|
|
|
|
}
|