You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
mohemmhmg/Mohem/src/app/uI-elements/time.input.ts

66 lines
3.2 KiB
TypeScript

import { UiElement } from './ui-element';
// import { TranslatorService } from '../hmg-common/services/translator/translator.service';
export class TimeInput extends UiElement {
// public direction: string;
constructor(
private label: string,
private elementId: string,
private value: any,
private containerId: string,
private disabled: string,
private hidden: string,
private required: string) {
super(elementId, containerId, '');
// this.direction = TranslatorService.getCurrentLanguageName();
this.createElement(this.getTemplate());
}
formatDate() {
const date = new Date();
this.value = date.getHours() + ':' + date.getMinutes() + ':' + date.getSeconds();
}
public getTemplate() {
let requiredClass = '';
let disaledClass = '';
// tslint:disable-next-line: triple-equals
if (this.required == 'Y') {
requiredClass = 'requiredClass';
}
// tslint:disable-next-line: max-line-length
if (this.disabled === 'N') { this.disabled = 'disabled'; disaledClass = 'disabled'; } else { this.disabled = ''; disaledClass = ''; }
if (this.hidden === 'N') { this.hidden = 'display:none;'; } else { this.hidden = ''; }
if (this.value === 'currentTime') {
this.formatDate();
}
const template =
'<div class=\'custom-text-area-element\' style=\'' + this.hidden + '\'>' +
' <label class=\'daynamicForm-Label ' + requiredClass + '\' id=\'title\' >' + this.label + '</label>' +
// tslint:disable-next-line: max-line-length
// " <input class='daynamicForm-DateTime' type='time' id='" + this.elementId + "' value='" + this.value + "' "+this.disabled+" />"+
// tslint:disable-next-line: max-line-length
' <div class=\'daynamicForm-DateTime ' + disaledClass + '\' id=\'' + this.elementId + '\' data-dtvalue=\'' + this.value + '\' ' + this.disabled + '>' + this.value + '</div>' +
'</div>';
// "<ion-item>" +
// " <ion-label style='font-size: medium !important;' id='title' >" + this.label + "</ion-label>" +
// tslint:disable-next-line: max-line-length
// // " <div class='daynamicForm-DateTime " + disaledClass + "' id='" + this.elementId + "' data-dtvalue='" + this.value + "' " + this.disabled + ">" + this.value + "</div>" +
// tslint:disable-next-line: max-line-length
// "<ion-datetime displayFormat='hh:mm' value='" + this.value + "' id='" + this.elementId + "' " + this.disabled + "></ion-datetime>" +
// tslint:disable-next-line: max-line-length
// // " <input class='daynamicForm-DateTime' type='text' id='" + this.elementId + "' value='" + this.value + "' "+this.disabled+" (click)='showDateTimePicker()'/>"+
// // " <input class='daynamicForm-DateTime' type='date' id='" + this.elementId + "' value='" + dateValue+ "' "+this.disabled+" />"+
// tslint:disable-next-line: max-line-length
// // " <input class='daynamicForm-DateTime' type='time' id='" + this.elementId + "Time' value='" + timeValue + "' "+this.disabled+" />"+
// "</ion-item>"
return template;
}
}