All files / src/fieldcontrols Date.ts

60% Statements 9/15
0% Branches 0/2
0% Functions 0/5
53.85% Lines 7/13
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 411x 1x   1x 1x 1x         1x                                       1x                    
import { computedFrom, autoinject, customAttribute } from 'aurelia-framework'
import { FieldBaseControl } from './FieldBaseControl';
import { FieldSettings } from 'sn-client-js';
import { LocaleService } from '../services';
import 'moment';
import * as moment from 'moment-timezone';
import { ValidationRules } from 'aurelia-validation';
 
@autoinject
@customAttribute('date-field')
export class Date extends FieldBaseControl<string, FieldSettings.DateTimeFieldSetting> {
 
    constructor(private localeService: LocaleService) {
        super();
    }
 
    
    get rules(): any {
        return super.rules;
    }
 
    get value(){
        return super.value;
    }
 
    set value(newValue){
        super.value = newValue && moment(newValue).format('YYYY-MM-DDT00:00:00') + 'Z';
    }
 
    @computedFrom('settings')
    get advancedOptions() {
        return {
            closeOnSelect: true,
            closeOnClear: true,
            selectYears: 50,
            showIcon: !this.readOnly,
            format: this.localeService.DateFormat,
        };
    };
 
}