ng2-easyform
Version:
angular2 angular4 ng2
1,530 lines (1,491 loc) • 68.8 kB
JavaScript
import { Injectable, Directive, Input, Optional, Host, Inject, NgModule, Component, HostListener, ViewChild, ViewContainerRef, ComponentFactoryResolver, ElementRef } from '@angular/core';
import { FormBuilder, FormControl, FormGroup, Validators, FormGroupDirective, NgControl, ControlContainer, FormsModule, ReactiveFormsModule } from '@angular/forms';
import { DateAdapter, MAT_DATE_LOCALE, MAT_DATE_FORMATS, MatDatepickerModule, MatInputModule, MatSelectModule, MatCheckboxModule, MatRadioModule, ErrorStateMatcher } from '@angular/material';
import * as _moment from 'moment';
import _moment__default, { unix } from 'moment';
import { CommonModule } from '@angular/common';
import 'rxjs';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { Bootstrap3GridModule } from 'ng2-bootstrap3-grid';
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class QueryOperate {
/**
* @param {?} name
* @param {?} operate
* @param {?} advanced
*/
constructor(name, operate, advanced) {
this.advanced = false;
this.name = name;
this.advanced = advanced;
this.operate = operate;
}
}
QueryOperate.nomal = new QueryOperate("nomal", "nomal", false);
QueryOperate.eq = new QueryOperate("eq", "=", true);
QueryOperate.cn = new QueryOperate("cn", "LIKE", true);
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
* @template T
*/
class FieldBase {
/**
* @param {?} options
*/
constructor(options) {
// debugger
this.value = options.value;
this.id = options.id;
this.selector = options.selector || this.controlType; //文本框等基础表单元素可以让 controlType 等于selector
this.key = options.key || '';
this.label = options.label || '';
this.span = options.span == null ? 6 : options.span;
this.required = !!options.required;
this.order = options.order == null ? 1 : options.order;
this.controlType = options.controlType || '';
this.validator = options.validator;
this.asyncValidator = options.asyncValidator;
this.labelOffset = options.labelOffset == null ? 75 : options.labelOffset;
this.labelSpan = options.labelSpan == null ? 3 : options.labelSpan;
this.isObject = options.isObject == null ? false : options.isObject;
this.disabled = options.disabled == null ? false : options.disabled;
this.hidden = options.hidden == null ? false : options.hidden;
this.statusChange = options.statusChange;
this.valueChange = options.valueChange;
this.op = options.op || QueryOperate.nomal;
this.params = options.params;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
*/
class FieldGroup extends FieldBase {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.controlType = "group";
this.groupName = options.groupName;
this.fields = options.fields || [];
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class FieldArray {
/**
* @param {?} options
*/
constructor(options) {
this.arrayName = options.arrayName;
this.groups = options.groups || [];
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class FieldControlService {
/**
* @param {?} fb
*/
constructor(fb) {
this.fb = fb;
}
/**
* @param {?} fields
* @return {?}
*/
toFormGroup(fields) {
let /** @type {?} */ group = {};
fields.forEach(field => {
if (field instanceof FieldArray) {
const /** @type {?} */ arraygroups = new Array();
for (let /** @type {?} */ fieldGroup in field.groups) {
let /** @type {?} */ fieldGroupArray = [fieldGroup];
arraygroups.push(this.toFormGroup(fieldGroupArray));
}
group[field.arrayName] = this.fb.array(arraygroups);
}
else if (field instanceof FieldGroup) {
group[field.key] = this.toFormGroup(field.fields);
}
else if (field instanceof FieldBase) {
var /** @type {?} */ validators = [];
var /** @type {?} */ asyncValidators = [];
if (field.required) {
validators.push(Validators.required);
}
if (field.validator) {
validators.push(field.validator);
}
if (field.asyncValidator) {
asyncValidators.push(field.asyncValidator);
}
if (validators.length > 0 && asyncValidators.length > 0) {
group[field.key] = new FormControl({ value: field.value, disabled: field.disabled } || '', validators, asyncValidators);
}
else if (validators.length > 0) {
group[field.key] = new FormControl({ value: field.value, disabled: field.disabled } || '', validators);
}
else if (asyncValidators.length > 0) {
group[field.key] = new FormControl({ value: field.value, disabled: field.disabled } || '', null, asyncValidators);
}
else {
group[field.key] = new FormControl({ value: field.value, disabled: field.disabled } || '');
}
}
});
return new FormGroup(group);
}
}
FieldControlService.decorators = [
{ type: Injectable },
];
/** @nocollapse */
FieldControlService.ctorParameters = () => [
{ type: FormBuilder, },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class FormstatusWrap extends FormGroupDirective {
}
FormstatusWrap.decorators = [
{ type: Directive, args: [{
selector: "999"
},] },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class DisableControlDirective {
/**
* @param {?} ngControl
* @param {?} controlContainer
*/
constructor(ngControl, controlContainer) {
// debugger
this.ngControl = ngControl;
this.controlContainer = controlContainer;
}
/**
* @param {?} condition
* @return {?}
*/
set disableControl(condition) {
setTimeout(() => {
const /** @type {?} */ action = condition ? 'disable' : 'enable';
if (this.ngControl) {
this.ngControl.control[action]();
}
if (this.controlContainer) {
this.controlContainer.control[action]();
}
});
}
}
DisableControlDirective.decorators = [
{ type: Directive, args: [{
selector: '[disableControl]'
},] },
];
/** @nocollapse */
DisableControlDirective.ctorParameters = () => [
{ type: NgControl, decorators: [{ type: Optional }, { type: Host },] },
{ type: ControlContainer, decorators: [{ type: Optional }, { type: Host },] },
];
DisableControlDirective.propDecorators = {
"disableControl": [{ type: Input },],
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class RequiredControlDirective {
/**
* @param {?} ngControl
* @param {?} controlContainer
*/
constructor(ngControl, controlContainer) {
// debugger
this.ngControl = ngControl;
this.controlContainer = controlContainer;
}
/**
* @param {?} condition
* @return {?}
*/
set requiredControl(condition) {
setTimeout(() => {
const /** @type {?} */ action = condition ? 'disable' : 'enable';
debugger;
if (this.ngControl) {
this.ngControl.control[action]();
}
if (this.controlContainer) {
this.controlContainer.control[action]();
}
});
}
}
RequiredControlDirective.decorators = [
{ type: Directive, args: [{
selector: '[requiredControl]'
},] },
];
/** @nocollapse */
RequiredControlDirective.ctorParameters = () => [
{ type: NgControl, decorators: [{ type: Optional }, { type: Host },] },
{ type: ControlContainer, decorators: [{ type: Optional }, { type: Host },] },
];
RequiredControlDirective.propDecorators = {
"requiredControl": [{ type: Input },],
};
/*! *****************************************************************************
Copyright (c) Microsoft Corporation. All rights reserved.
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
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
MERCHANTABLITY OR NON-INFRINGEMENT.
See the Apache Version 2.0 License for specific language governing permissions
and limitations under the License.
***************************************************************************** */
/* global Reflect, Promise */
var extendStatics = Object.setPrototypeOf ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
function __extends(d, b) {
extendStatics(d, b);
function __() { this.constructor = d; }
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
}
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */ moment = _moment__default || _moment;
/**
* Creates an array and fills it with values.
* @template T
* @param {?} length
* @param {?} valueFunction
* @return {?}
*/
function range(length, valueFunction) {
var /** @type {?} */ valuesArray = Array(length);
for (var /** @type {?} */ i = 0; i < length; i++) {
valuesArray[i] = valueFunction(i);
}
return valuesArray;
}
/**
* Adapts Moment.js Dates for use with Angular Material.
*/
var MomentDateAdapter = /** @class */ (function (_super) {
__extends(MomentDateAdapter, _super);
function MomentDateAdapter(dateLocale) {
var _this = _super.call(this) || this;
_this.setLocale(dateLocale || moment.locale());
return _this;
}
/**
* @param {?} locale
* @return {?}
*/
MomentDateAdapter.prototype.setLocale = /**
* @param {?} locale
* @return {?}
*/
function (locale) {
var _this = this;
_super.prototype.setLocale.call(this, locale);
var /** @type {?} */ momentLocaleData = moment.localeData(locale);
this._localeData = {
firstDayOfWeek: momentLocaleData.firstDayOfWeek(),
longMonths: momentLocaleData.months(),
shortMonths: momentLocaleData.monthsShort(),
dates: range(31, function (i) { return _this.createDate(2017, 0, i + 1).format('D'); }),
longDaysOfWeek: momentLocaleData.weekdays(),
shortDaysOfWeek: momentLocaleData.weekdaysShort(),
narrowDaysOfWeek: momentLocaleData.weekdaysMin(),
};
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.getYear = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).year();
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.getMonth = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).month();
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.getDate = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).date();
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.getDayOfWeek = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).day();
};
/**
* @param {?} style
* @return {?}
*/
MomentDateAdapter.prototype.getMonthNames = /**
* @param {?} style
* @return {?}
*/
function (style) {
// Moment.js doesn't support narrow month names, so we just use short if narrow is requested.
return style == 'long' ? this._localeData.longMonths : this._localeData.shortMonths;
};
/**
* @return {?}
*/
MomentDateAdapter.prototype.getDateNames = /**
* @return {?}
*/
function () {
return this._localeData.dates;
};
/**
* @param {?} style
* @return {?}
*/
MomentDateAdapter.prototype.getDayOfWeekNames = /**
* @param {?} style
* @return {?}
*/
function (style) {
if (style == 'long') {
return this._localeData.longDaysOfWeek;
}
if (style == 'short') {
return this._localeData.shortDaysOfWeek;
}
return this._localeData.narrowDaysOfWeek;
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.getYearName = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).format('YYYY');
};
/**
* @return {?}
*/
MomentDateAdapter.prototype.getFirstDayOfWeek = /**
* @return {?}
*/
function () {
return this._localeData.firstDayOfWeek;
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.getNumDaysInMonth = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).daysInMonth();
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.clone = /**
* @param {?} date
* @return {?}
*/
function (date) {
return date.clone().locale(this.locale);
};
/**
* @param {?} year
* @param {?} month
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.createDate = /**
* @param {?} year
* @param {?} month
* @param {?} date
* @return {?}
*/
function (year, month, date) {
// Moment.js will create an invalid date if any of the components are out of bounds, but we
// explicitly check each case so we can throw more descriptive errors.
if (month < 0 || month > 11) {
throw Error("Invalid month index \"" + month + "\". Month index has to be between 0 and 11.");
}
if (date < 1) {
throw Error("Invalid date \"" + date + "\". Date has to be greater than 0.");
}
var /** @type {?} */ result = moment({ year: year, month: month, date: date }).locale(this.locale);
// If the result isn't valid, the date must have been out of bounds for this month.
if (!result.isValid()) {
throw Error("Invalid date \"" + date + "\" for month with index \"" + month + "\".");
}
return result;
};
/**
* @return {?}
*/
MomentDateAdapter.prototype.today = /**
* @return {?}
*/
function () {
return moment().locale(this.locale);
};
/**
* @param {?} value
* @param {?} parseFormat
* @return {?}
*/
MomentDateAdapter.prototype.parse = /**
* @param {?} value
* @param {?} parseFormat
* @return {?}
*/
function (value, parseFormat) {
if (value && typeof value == 'string') {
return moment(value, parseFormat, this.locale);
}
return value ? moment(value).locale(this.locale) : null;
};
/**
* @param {?} date
* @param {?} displayFormat
* @return {?}
*/
MomentDateAdapter.prototype.format = /**
* @param {?} date
* @param {?} displayFormat
* @return {?}
*/
function (date, displayFormat) {
date = this.clone(date);
if (!this.isValid(date)) {
throw Error('MomentDateAdapter: Cannot format invalid date.');
}
return date.format(displayFormat);
};
/**
* @param {?} date
* @param {?} years
* @return {?}
*/
MomentDateAdapter.prototype.addCalendarYears = /**
* @param {?} date
* @param {?} years
* @return {?}
*/
function (date, years) {
return this.clone(date).add({ years: years });
};
/**
* @param {?} date
* @param {?} months
* @return {?}
*/
MomentDateAdapter.prototype.addCalendarMonths = /**
* @param {?} date
* @param {?} months
* @return {?}
*/
function (date, months) {
return this.clone(date).add({ months: months });
};
/**
* @param {?} date
* @param {?} days
* @return {?}
*/
MomentDateAdapter.prototype.addCalendarDays = /**
* @param {?} date
* @param {?} days
* @return {?}
*/
function (date, days) {
return this.clone(date).add({ days: days });
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.toIso8601 = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).format();
};
/**
* Returns the given value if given a valid Moment or null. Deserializes valid ISO 8601 strings
* (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty
* string into null. Returns an invalid date for all other values.
*/
/**
* Returns the given value if given a valid Moment or null. Deserializes valid ISO 8601 strings
* (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty
* string into null. Returns an invalid date for all other values.
* @param {?} value
* @return {?}
*/
MomentDateAdapter.prototype.deserialize = /**
* Returns the given value if given a valid Moment or null. Deserializes valid ISO 8601 strings
* (https://www.ietf.org/rfc/rfc3339.txt) and valid Date objects into valid Moments and empty
* string into null. Returns an invalid date for all other values.
* @param {?} value
* @return {?}
*/
function (value) {
var /** @type {?} */ date;
if (value instanceof Date) {
date = moment(value);
}
if (typeof value === 'string') {
if (!value) {
return null;
}
date = moment(value, moment.ISO_8601).locale(this.locale);
}
if (date && this.isValid(date)) {
return date;
}
return _super.prototype.deserialize.call(this, value);
};
/**
* @param {?} obj
* @return {?}
*/
MomentDateAdapter.prototype.isDateInstance = /**
* @param {?} obj
* @return {?}
*/
function (obj) {
return moment.isMoment(obj);
};
/**
* @param {?} date
* @return {?}
*/
MomentDateAdapter.prototype.isValid = /**
* @param {?} date
* @return {?}
*/
function (date) {
return this.clone(date).isValid();
};
/**
* @return {?}
*/
MomentDateAdapter.prototype.invalid = /**
* @return {?}
*/
function () {
return moment.invalid();
};
MomentDateAdapter.decorators = [
{ type: Injectable },
];
/** @nocollapse */
MomentDateAdapter.ctorParameters = function () { return [
{ type: undefined, decorators: [{ type: Optional }, { type: Inject, args: [MAT_DATE_LOCALE,] },] },
]; };
return MomentDateAdapter;
}(DateAdapter));
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
var /** @type {?} */ MAT_MOMENT_DATE_FORMATS = {
parse: {
dateInput: 'l',
},
display: {
dateInput: 'l',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
};
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class EfDateAdapter extends MomentDateAdapter {
/**
* @param {?} value
* @param {?} parseFormat
* @return {?}
*/
parse(value, parseFormat) {
return super.parse(value, parseFormat);
}
/**
* @param {?} value
* @return {?}
*/
deserialize(value) {
if (value && typeof value == 'string'
&& (value.length == 13 || value.length == 10) && parseInt(value)) {
return unix(parseInt(value));
}
else if (value && typeof value == 'number') {
if (value / 1000000000 > 1000) {
return unix(value / 1000);
}
else {
return unix(value);
}
}
else {
return super.deserialize(value);
}
}
}
EfDateAdapter.decorators = [
{ type: Injectable },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
let /** @type {?} */ uilist = new Array();
let /** @type {?} */ uimap = new Map();
let /** @type {?} */ uimap1 = new Map();
/**
* @param {?} options
* @return {?}
*/
function UIComponent(options) {
//
if (!options["name"]) {
let /** @type {?} */ l = options.component.name.length;
// options["name"] = options.component.name.substr(0, l - 9)
options.name = options.component.name;
}
uilist.push(options);
uimap.set(options.selector, options.component);
uimap1.set(options.selector, options);
// console.log("uicomponent: selector", options.selector);
// console.log("uicomponent: component", options.component);
return function ({ constructor: Function }) {
};
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
*/
class EfDictdataService {
/**
* @param {?} http
*/
constructor(http) {
this.http = http;
}
/**
* @param {?} error
* @return {?}
*/
handleError(error) {
console.error('An error occurred', error);
return Promise.reject(error.message || error);
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @template T
*/
class InputField extends FieldBase {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.minLength = options.minLength;
this.maxLength = options.maxLength;
this.pattern = options.pattern;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
/**
* @abstract
*/
class OptionsField extends FieldBase {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.options = [];
this.options = options['options'] || [];
this.optionsUrl = options['optionsUrl'] || undefined;
this.optionsOb = options['optionsOb'] || undefined;
this.dictName = options['dictName'] || undefined;
this.optionId = options['optionId'] || "key";
this.optionName = options['optionName'] || "value";
this.multiple = options.multiple || false;
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class EasyFormCoreModule {
/**
* @return {?}
*/
static forRoot() {
return {
ngModule: EasyFormCoreModule,
providers: [
FieldControlService,
{ provide: DateAdapter, useClass: EfDateAdapter },
{ provide: MAT_DATE_FORMATS, useValue: MAT_MOMENT_DATE_FORMATS }
],
};
}
}
EasyFormCoreModule.decorators = [
{ type: NgModule, args: [{
imports: [
CommonModule,
],
exports: [
DisableControlDirective,
RequiredControlDirective,
],
declarations: [
FormstatusWrap,
DisableControlDirective,
RequiredControlDirective,
],
providers: [
FieldControlService,
],
entryComponents: [],
},] },
];
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class MdDatepickerField extends FieldBase {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.selector = 'ef-md-datepicker';
}
}
var __decorate$1 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$1 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let MdDatepickerComponent = MdDatepickerComponent_1 = class MdDatepickerComponent {
constructor() {
this.span = 12;
this.touchUi = false;
}
/**
* @return {?}
*/
ngOnInit() {
this.formControl = this.form.get(this.field.key);
this.span = this.field.span == undefined ? 4 : this.field.span;
this.label = this.field.label;
this.eNfxFlex = "calc(" + (this.span / 12) * 100 + "% - 15px)";
// this.eNfxFlexXs = "calc(100% - 15px)"
this.eNfxFlexXs = "100%";
this.formControl.valueChanges.subscribe(value => {
// this
// debugger
});
}
/**
* @return {?}
*/
patchValueToView() {
// this.model = this.controll.value
}
/**
* @param {?} width
* @return {?}
*/
onResize(width) {
if (width < 720) {
this.touchUi = true;
}
else {
this.touchUi = false;
}
}
};
MdDatepickerComponent.decorators = [
{ type: Component, args: [{
selector: 'ef-md-datepicker',
template: `
<mat-form-field [bsCol.sm]="span" [bsCol.xs]="12">
<input matInput [matDatepicker]="myDatepicker" [placeholder]="label" [formControl]="formControl" [disableControl]="field.disabled">
<mat-datepicker-toggle matSuffix [for]="myDatepicker"></mat-datepicker-toggle>
<mat-datepicker [touchUi]="touchUi" #myDatepicker></mat-datepicker>
<mat-error *ngIf="formControl.hasError('matDatepickerParse');else elseBlock">
<strong>时间格式不正确</strong>
</mat-error>
<ng-template #elseBlock>
<mat-error *ngIf="formControl.hasError('required')">
<strong>必填项</strong>
</mat-error>
</ng-template>
</mat-form-field>
`
},] },
];
/** @nocollapse */
MdDatepickerComponent.ctorParameters = () => [];
MdDatepickerComponent.propDecorators = {
"field": [{ type: Input },],
"form": [{ type: Input },],
"onResize": [{ type: HostListener, args: ['window:resize', ['$event.target.innerWidth'],] },],
};
MdDatepickerComponent = MdDatepickerComponent_1 = __decorate$1([
UIComponent({
selector: 'ef-md-datepicker',
component: MdDatepickerComponent_1,
field: MdDatepickerField,
name: "日期选择"
}),
__metadata$1("design:paramtypes", [])
], MdDatepickerComponent);
var MdDatepickerComponent_1;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class MdTextinputField extends InputField {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.selector = 'ef-md-input';
this["type"] = options["type"] || 'text';
}
}
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class FormUtils {
/**
* @param {?} field
* @param {?} status
* @param {?} errors
* @param {?} errorsKeys
* @return {?}
*/
static doFormFieldInputStatusChanges(field, status, errors, errorsKeys) {
if (errors == null) {
errorsKeys.length = 0;
return;
}
FormUtils.doErrors(errors, errorsKeys);
if (field.statusChange instanceof Function) {
field.statusChange(status);
}
}
/**
* @param {?} errors
* @param {?} errorsKeys
* @return {?}
*/
static doErrors(errors, errorsKeys) {
errorsKeys.length = 0;
for (let /** @type {?} */ p in errors) {
if (p != "required") {
errorsKeys.push(p);
}
}
return errorsKeys;
}
}
var __decorate$2 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$2 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let MdInputComponent = MdInputComponent_1 = class MdInputComponent {
constructor() {
this.span = 12;
this.errors = {};
this.errorsKeys = [];
}
/**
* @return {?}
*/
ngOnInit() {
this.fieldControl = this.form.get(this.field.key);
this.span = this.field.span == undefined ? 4 : this.field.span;
this.label = this.field.label;
// this.eNfxFlex = "calc(" + (this.span / 12) * 100 + "% - 15px)"
// this.eNfxFlexXs = "calc(100% - 15px)"
// this.eNfxFlexXs = "100%"
// debugger
this.fieldControl.statusChanges.subscribe(data => {
this.errors = this.fieldControl.errors;
FormUtils.doFormFieldInputStatusChanges(this.field, data, this.errors, this.errorsKeys);
});
this.fieldControl.valueChanges.subscribe(data => {
// debugger
if (this.field.valueChange instanceof Function) {
this.field.valueChange(data);
}
});
}
/**
* @return {?}
*/
ngAfterViewInit() {
}
/**
* @param {?} changes
* @return {?}
*/
ngOnChanges(changes) {
// debugger
this.fieldControl;
for (let /** @type {?} */ propName in changes) {
let /** @type {?} */ chng = changes[propName];
let /** @type {?} */ cur = JSON.stringify(chng.currentValue);
let /** @type {?} */ prev = JSON.stringify(chng.previousValue);
}
}
};
MdInputComponent.decorators = [
{ type: Component, args: [{
selector: 'ef-md-input',
template: `
<mat-form-field
[bsCol.sm]="span"
[bsCol.xs]="12"
[hideRequiredMarker]="false"
[hidden]="this.field.hidden">
<input matInput
[type]="field.type || field.params.inputType "
[placeholder]="label"
[formControl]="fieldControl"
[disableControl]="field.disabled"
>
<mat-error *ngIf="fieldControl.hasError('required')">
<strong>必填项</strong>
</mat-error>
<mat-error *ngFor="let key of this.errorsKeys">
<strong>{{this.errors[key]}}</strong>
</mat-error>
</mat-form-field>
`
},] },
];
/** @nocollapse */
MdInputComponent.ctorParameters = () => [];
MdInputComponent.propDecorators = {
"field": [{ type: Input },],
"form": [{ type: Input },],
};
MdInputComponent = MdInputComponent_1 = __decorate$2([
UIComponent({
selector: 'ef-md-input',
component: MdInputComponent_1,
field: MdTextinputField,
name: "文本框"
}),
__metadata$2("design:paramtypes", [])
], MdInputComponent);
var MdInputComponent_1;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class MdTextareaField extends InputField {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.selector = 'ef-md-textarea';
this["type"] = 'textarea';
}
}
var __decorate$3 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$3 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let MdTextareaComponent = MdTextareaComponent_1 = class MdTextareaComponent {
constructor() {
this.span = 12;
this.errors = {};
this.errorsKeys = [];
}
/**
* @return {?}
*/
ngOnInit() {
this.fieldControl = this.form.get(this.field.key);
this.span = this.field.span == undefined ? 4 : this.field.span;
this.lable = this.field.label;
// this.eNfxFlex = "calc(" + (this.span / 12) * 100 + "% - 15px)"
// this.eNfxFlexXs = "calc(100% - 15px)"
// this.eNfxFlexXs = "100%"
// debugger
this.fieldControl.statusChanges.subscribe(data => {
this.errors = this.fieldControl.errors;
FormUtils.doFormFieldInputStatusChanges(this.field, data, this.errors, this.errorsKeys);
});
}
};
MdTextareaComponent.decorators = [
{ type: Component, args: [{
selector: 'ef-md-textarea',
template: `
<mat-form-field [bsCol.sm]="span" [bsCol.xs]="12" [hidden]="this.field.hidden">
<textarea matInput [type]="field.type || field.params.inputType" [placeholder]="lable" [formControl]="fieldControl"
[disableControl]="field.disabled">
</textarea>
<mat-error *ngIf="fieldControl.hasError('required')">
<strong>必填项</strong>
</mat-error>
<mat-error *ngFor="let key of this.errorsKeys">
<strong>{{this.errors[key]}}</strong>
</mat-error>
</mat-form-field>
`
},] },
];
/** @nocollapse */
MdTextareaComponent.ctorParameters = () => [];
MdTextareaComponent.propDecorators = {
"field": [{ type: Input },],
"form": [{ type: Input },],
};
MdTextareaComponent = MdTextareaComponent_1 = __decorate$3([
UIComponent({
selector: 'ef-md-textarea',
component: MdTextareaComponent_1,
field: MdTextareaField,
name: "文本域"
}),
__metadata$3("design:paramtypes", [])
], MdTextareaComponent);
var MdTextareaComponent_1;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class MdCheckboxField extends FieldBase {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.selector = 'ef-md-checkbox';
}
}
var __decorate$4 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$4 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let MdCheckBoxComponent = MdCheckBoxComponent_1 = class MdCheckBoxComponent {
constructor() {
this.span = 12;
this.checked = false;
this.indeterminate = false;
this.labelPosition = 'after';
}
/**
* @return {?}
*/
ngOnInit() {
this.formControl = this.form.get(this.field.key);
this.span = this.field.span == undefined ? 4 : this.field.span;
this.label = this.field.label;
this.eNfxFlex = "calc(" + (this.span / 12) * 100 + "% - 15px)";
// this.eNfxFlexXs = "calc(100% - 15px)"
this.eNfxFlexXs = "100%";
}
};
MdCheckBoxComponent.decorators = [
{ type: Component, args: [{
selector: 'ef-md-checkbox',
template: `
<mat-checkbox
class="example-margin"
[checked]="checked"
[indeterminate]="indeterminate"
[labelPosition]="labelPosition"
[formControl]="formControl"
[disableControl]="field.disabled"
[hidden]="this.field.hidden"
[bsCol.sm]="span" [bsCol.xs]="12"
style="padding-top: 20px;padding-bottom: 15px; min-height: 65.5px;">
{{label}}
</mat-checkbox>
`
},] },
];
/** @nocollapse */
MdCheckBoxComponent.ctorParameters = () => [];
MdCheckBoxComponent.propDecorators = {
"field": [{ type: Input },],
"form": [{ type: Input },],
};
MdCheckBoxComponent = MdCheckBoxComponent_1 = __decorate$4([
UIComponent({
selector: 'ef-md-checkbox',
component: MdCheckBoxComponent_1,
field: MdCheckboxField,
name: "CheckBox"
}),
__metadata$4("design:paramtypes", [])
], MdCheckBoxComponent);
var MdCheckBoxComponent_1;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class MdRadioGroupField extends OptionsField {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.noneOption = true;
this.selector = 'ef-md-radios';
this.noneOption = options.noneOption == undefined ? true : options.noneOption;
}
}
var __decorate$5 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$5 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let MdRadioGroupComponent = MdRadioGroupComponent_1 = class MdRadioGroupComponent {
/**
* @param {?} efDictdataService
*/
constructor(efDictdataService) {
this.efDictdataService = efDictdataService;
this.isEasyForm = true;
this.key = 'dropdowninput';
this.label = '';
this.span = 4;
this.offset = 0;
this.hidden = false;
this.disabled = false;
this.options = [];
this.optionId = 'key';
this.optionName = 'value';
this.multiple = false;
this.noneOption = true;
}
/**
* @return {?}
*/
ngOnInit() {
if (this.isEasyForm) {
this.label = this.field.label;
this.key = this.field.key;
this.field._view = this;
this.controll = this.field._control = this.form.get(this.field.key);
this.controll.statusChanges.subscribe(data => {
if (this.field.statusChange instanceof Function) {
this.field.statusChange(data);
}
});
this.controll.valueChanges.subscribe(data => {
if (this.field.valueChange instanceof Function) {
this.field.valueChange(data);
}
});
this.span = this.field.span == undefined ? 4 : this.field.span;
this.noneOption = this.field.noneOption;
// this.dictName = this.field.dictName || (this.field.params.primaryField ? this.field.params.primaryField.dictName : undefined)
this.dictName = this.field.dictName;
this.optionId = this.field.optionId;
this.optionName = this.field.optionName;
if (this.field.options == undefined
|| this.field.options.length == 0) {
if (this.field.optionsOb) {
this.field.optionsOb.subscribe(data => this.options = data);
}
else if (this.dictName) {
this.efDictdataService.getDictDataObserable(this.dictName).subscribe(data => this.options = data);
this.optionId = 'dictdataName';
this.optionName = 'dictdataValue';
}
}
else {
if (!(this.field.options instanceof Array)) {
this.optionId = 'key';
this.optionName = 'value';
setTimeout(() => {
this.options = this.transform(this.field.options);
});
}
else {
this.options = this.field.options;
}
}
}
else {
if (this.options.length == 0 && this.optionsOb) {
this.optionsOb.subscribe(data => this.options = data);
}
}
}
/**
* @param {?} value
* @return {?}
*/
transform(value) {
let /** @type {?} */ keys = [];
for (let /** @type {?} */ key in value) {
keys.push({ key: key, value: value[key] });
}
return keys;
}
};
MdRadioGroupComponent.decorators = [
{ type: Component, args: [{
selector: 'ef-md-radios',
template: `
<mat-radio-group [bsCol.sm]="span" [bsCol.xs]="12" [formControl]="controll" [disableControl]="field.disabled">
<mat-radio-button *ngFor="let option of options" [value]="option[optionId]">
{{ option[optionName] }}
</mat-radio-button>
</mat-radio-group>
`
},] },
];
/** @nocollapse */
MdRadioGroupComponent.ctorParameters = () => [
{ type: EfDictdataService, },
];
MdRadioGroupComponent.propDecorators = {
"isEasyForm": [{ type: Input },],
"key": [{ type: Input },],
"label": [{ type: Input },],
"span": [{ type: Input },],
"offset": [{ type: Input },],
"hidden": [{ type: Input },],
"disabled": [{ type: Input },],
"optionsOb": [{ type: Input },],
"options": [{ type: Input },],
"optionId": [{ type: Input },],
"optionName": [{ type: Input },],
"multiple": [{ type: Input },],
"noneOption": [{ type: Input },],
"field": [{ type: Input },],
"form": [{ type: Input },],
"model": [{ type: Input },],
};
MdRadioGroupComponent = MdRadioGroupComponent_1 = __decorate$5([
UIComponent({
selector: 'ef-md-radios',
component: MdRadioGroupComponent_1,
field: MdRadioGroupField,
name: "RadiosGroup"
}),
__metadata$5("design:paramtypes", [EfDictdataService])
], MdRadioGroupComponent);
var MdRadioGroupComponent_1;
/**
* @fileoverview added by tsickle
* @suppress {checkTypes} checked by tsc
*/
class MdSelectField extends OptionsField {
/**
* @param {?} options
*/
constructor(options) {
super(options);
this.noneOption = true;
this.selector = 'ef-md-select'; //MD select
this.noneOption = options.noneOption == undefined ? true : options.noneOption;
}
}
var __decorate$6 = (undefined && undefined.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __metadata$6 = (undefined && undefined.__metadata) || function (k, v) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
};
let MdSelectComponent = MdSelectComponent_1 = class MdSelectComponent {
/**
* @param {?} http
* @param {?} efDictdataService
*/
constructor(http, efDictdataService) {
this.http = http;
this.efDictdataService = efDictdataService;
this.isEasyForm = true;
this.key = 'dropdowninput';
this.label = '';
this.span = 4;
this.offset = 0;
this.hidden = false;
this.disabled = false;
this.options = [];
this.optionId = 'key';
this.optionName = 'value';
this.multiple = false;
this.noneOption = true;
this.classExpression = {};
}
/**
* @return {?}
*/
ngOnInit() {
// debugger
if (this.isEasyForm) {
this.label = this.field.label;
this.key = this.field.key;
this.field._view = this;
this.controll = this.field._control = this.form.get(this.field.key);
this.span = this.field.span == undefined ? 4 : this.field.span;
this.eNfxFlex = "calc(" + (this.span / 12) * 100 + "% - 15px)";
// this.eNfxFlexXs = "calc(100% - 15px)"
this.eNfxFlexXs = "100%";
this.multiple = MdSelectComponent_1.isMutipleField(this.field);
this.noneOption = this.field.noneOption;
// this.dictName = this.field.dictName || (this.field.params.primaryField ? this.field.params.primaryField.dictName : undefined)
this.dictName = this.field.dictName;
this.patchValueToView();
this.controll.valueChanges.forEach((data) => {
this.patchValueToView();
});
this.optionId = this.field.optionId;
this.optionName = this.field.optionName;
if (this.field.options == undefined
|| this.field.options.length == 0) {
if (this.field.optionsOb) {
this.field.optionsOb.subscribe(data => this.options = data);
}
else if (this.dictName) {
this.getDictDataObserable(this.dictName).subscribe(data => this.options = data);
this.optionId = 'dictdataName';
this.optionName = 'dictdataValue';
}
}
else {
this.options = this.field.options;
}
}
else {
if (this.options.length == 0 && this.optionsOb) {
this.optionsOb.subscribe(data => this.options = data);
}
}
this.classExpression = {
'form-group': true,
};
if (this.isEasyForm) {
this.classExpression["col-sm-" + this.span] = true;
this.classExpression["col-md-offset-" + this.offset] = this.offset == 0 ? false :