-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/libs/web/src/controls/text-input/text-input.component.scss b/libs/web/src/controls/text-input/text-input.component.scss
deleted file mode 100644
index 1e344827..00000000
--- a/libs/web/src/controls/text-input/text-input.component.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-.text-input {
-
-}
\ No newline at end of file
diff --git a/libs/web/src/controls/text-input/text-input.component.ts b/libs/web/src/controls/text-input/text-input.component.ts
index d36b9ad0..ff292ac9 100644
--- a/libs/web/src/controls/text-input/text-input.component.ts
+++ b/libs/web/src/controls/text-input/text-input.component.ts
@@ -1,26 +1,23 @@
import { Component, ElementRef, EventEmitter, Injector, Input, Output, ViewChild } from '@angular/core';
-import * as moment from 'moment/moment';
-import { BsDatepickerConfig } from 'ngx-bootstrap/datepicker';
+import { ChangeDetectorRef } from '@angular/core';
+import * as lodashImported from 'lodash'; const _ = lodashImported;
+import * as momentImported from 'moment'; const moment = momentImported;
+import { getLocale } from 'ngx-bootstrap/bs-moment/locale/locales.service';
+import { BsLocaleService } from 'ngx-bootstrap/datepicker';
import { TooltipDirective } from 'ngx-bootstrap/tooltip';
import createNumberMask from 'text-mask-addons/dist/createNumberMask';
import emailMask from 'text-mask-addons/dist/emailMask';
import { BaseComponent } from './../../base/base-component/base-component.component';
import { TextInputConfig } from './text-input.config';
-import { DatePickerComponent } from 'ngx-bootstrap/datepicker';
-import { ChangeDetectorRef } from '@angular/core';
@Component({
selector: 'text-input',
- templateUrl: './text-input.component.html',
- styleUrls: ['./text-input.component.scss'],
- // changeDetection: ChangeDetectionStrategy.OnPush
+ templateUrl: './text-input.component.html'
})
export class TextInputComponent extends BaseComponent {
- @ViewChild('picker')
- picker: DatePickerComponent;
@ViewChild('inputElement')
inputElement: ElementRef;
@ViewChild('tooltip')
@@ -65,34 +62,35 @@ export class TextInputComponent extends BaseComponent {
@Input()
isNativeDateInput?: boolean;
@Input()
- startingDay: number;
-
- config: TextInputConfig;
+ bsDatepickerConfig: any;
private _dateValue: any;
+ private _config: TextInputConfig;
+ private _localeService: BsLocaleService;
constructor(
public injector: Injector,
- public changeDetectorRef: ChangeDetectorRef,
+ public changeDetectorRef: ChangeDetectorRef
) {
super(injector);
- this.config = injector.get(TextInputConfig);
+ this._config = injector.get(TextInputConfig);
+ this._localeService = injector.get(BsLocaleService);
}
afterCreate() {
if (this.isNativeDateInput === undefined) {
- this.isNativeDateInput = this.config.isNativeDateInput;
+ this.isNativeDateInput = this._config.isNativeDateInput;
}
if (this.tooltipEnable === undefined) {
- this.tooltipEnable = this.config.errorInTooltip;
+ this.tooltipEnable = this._config.errorInTooltip;
}
if (this.maxlength === undefined) {
- this.maxlength = this.config.maxlength;
+ this.maxlength = this._config.maxlength;
}
if (this.step === undefined) {
- this.step = this.config.step;
+ this.step = this._config.step;
}
- if (this.startingDay === undefined) {
- this.startingDay = this.config.startingDay;
+ if (this.bsDatepickerConfig === undefined) {
+ this.bsDatepickerConfig = this._config.bsDatepickerConfig;
}
this.translateService.onLangChange.subscribe(
(langData: any) => {
@@ -101,13 +99,8 @@ export class TextInputComponent extends BaseComponent {
);
}
initLang(lang: string) {
- this.bsDatepickerConfig = { locale: lang };
- if (this.picker) {
- this.picker.config.locale = lang;
- this.picker.config.showWeeks = false;
- this.picker.config.startingDay = this.startingDay;
- this.picker.configureOptions();
- }
+ this._localeService.use(lang);
+ moment.locale(lang);
}
init() {
if (this.type === undefined) {
@@ -122,17 +115,13 @@ export class TextInputComponent extends BaseComponent {
this.mask.mask = emailMask;
}
if (this.type === 'currency') {
- const numberMask = createNumberMask(this.config.currencyMask);
+ const numberMask = createNumberMask(this._config.currencyMask);
this.type = 'text';
this.mask.mask = numberMask;
}
if (this.type === 'phone') {
this.type = 'text';
- this.mask = this.config.phoneMask;
- }
- if (this.type === 'date' && !this.isNativeDateInput) {
- this.mask = this.config.dateMask;
- this.dateInputChange(this.value);
+ this.mask = this._config.phoneMask;
}
}
super.init();
@@ -140,6 +129,9 @@ export class TextInputComponent extends BaseComponent {
this.initLang(this.app.component.currentLanguage);
}
get dateValue() {
+ if (this._dateValue === undefined) {
+ this.setDateValueFromString(this.value);
+ }
return this._dateValue;
}
set dateValue(value: any) {
@@ -148,23 +140,44 @@ export class TextInputComponent extends BaseComponent {
this.value = this.getStringFromDateValue();
}
}
- dateInputChange(value: any) {
- if (value.target && value.target.value) {
- this.value = value.target.value;
- } else {
- this.value = value;
- }
- this.setDateValueFromString(this.value);
- if (!this._dateValue || this._dateValue.toString() === 'Invalid Date') {
- this._dateValue = new Date();
- }
+ get inputDateFormat(): any {
+ const locale: any = getLocale(this._localeService.currentLocale);
+ return locale._longDateFormat && locale._longDateFormat.L ? locale._longDateFormat.L : this._config.nativeInputDateFormat;
+ }
+ get inputDateMask(): any {
+ const inputDateFormat = this.inputDateFormat;
+ const inline = inputDateFormat.replace(new RegExp('DD', 'ig'), 'D').replace(new RegExp('MM', 'ig'), 'M').replace(new RegExp('YYYY', 'ig'), 'Y');
+ let mask: any[] = [];
+ inline.split('').forEach((ch: string) => {
+ switch (ch) {
+ case 'D': {
+ mask = _.concat(mask, this._config.dateMask.day);
+ break;
+ }
+ case 'M': {
+ mask = _.concat(mask, this._config.dateMask.month);
+ break;
+ }
+ case 'Y': {
+ mask = _.concat(mask, this._config.dateMask.year);
+ break;
+ }
+ default: {
+ mask = _.concat(mask, [ch]);
+ break;
+ }
+ }
+ });
+ return {
+ mask: mask
+ };
}
get value() {
if (this.hardValue !== null) {
return this.hardValue;
}
if (this.type === 'date' && !this.isNativeDateInput) {
- return moment(moment(this.model, this.config.nativeInputDateFormat).toDate()).format(this.config.inputDateFormat);
+ return moment(moment(this.model, this._config.nativeInputDateFormat).toDate()).format(this.inputDateFormat);
}
return this.model;
}
@@ -175,7 +188,7 @@ export class TextInputComponent extends BaseComponent {
this.tooltipText = '';
}
if (this.type === 'date' && !this.isNativeDateInput) {
- newValue = moment(moment(value, this.config.inputDateFormat).toDate()).format(this.config.nativeInputDateFormat);
+ newValue = moment(moment(value, this.inputDateFormat).toDate()).format(this._config.nativeInputDateFormat);
}
if (newValue === 'Invalid date' && !this.model) {
newValue = this.model;
@@ -192,7 +205,7 @@ export class TextInputComponent extends BaseComponent {
let value: string;
value = '';
try {
- value = moment(this._dateValue).format(this.config.inputDateFormat);
+ value = moment(this._dateValue).format(this.inputDateFormat);
} catch (err) {
value = '';
}
@@ -203,7 +216,7 @@ export class TextInputComponent extends BaseComponent {
}
setDateValueFromString(value: any) {
try {
- value = moment(value, this.config.inputDateFormat).toDate();
+ value = moment(value, this.inputDateFormat).toDate();
} catch (err) {
value = null;
}
diff --git a/libs/web/src/controls/text-input/text-input.config.ts b/libs/web/src/controls/text-input/text-input.config.ts
index db726afe..38bc0ec4 100644
--- a/libs/web/src/controls/text-input/text-input.config.ts
+++ b/libs/web/src/controls/text-input/text-input.config.ts
@@ -2,10 +2,10 @@ import { Injectable } from '@angular/core';
@Injectable()
export class TextInputConfig {
- isNativeDateInput = false;
errorInTooltip = true;
maxlength = 250;
step = 'any';
+ // masks
currencyMask = {
prefix: '',
decimalLimit: 4,
@@ -16,13 +16,19 @@ export class TextInputConfig {
prefix: '',
thousandsSeparatorSymbol: ' '
};
- nativeInputDateFormat = 'YYYY-MM-DD';
- inputDateFormat = 'DD.MM.YYYY';
phoneMask = {
mask: ['+', /\d/, '(', /[1-9]/, /\d/, /\d/, ')', ' ', /\d/, /\d/, /\d/, '-', /\d/, /\d/, /\d/, /\d/]
};
+ // date
+ nativeInputDateFormat = 'YYYY-MM-DD';
+ isNativeDateInput = false;
+ bsDatepickerConfig = {
+ containerClass: 'theme-green',
+ showWeekNumbers: false
+ };
dateMask = {
- mask: [/[0-3]/, /[0-9]/, '.', /[0,1]/, /[0-9]/, '.', /[1-2]/, /[0,9]/, /[0-9]/, /[0-9]/]
+ day: [/[0-3]/, /[0-9]/],
+ month: [/[0,1]/, /[0-9]/],
+ year: [/[1-2]/, /[0,9]/, /[0-9]/, /[0-9]/]
};
- startingDay = 1;
}
diff --git a/libs/web/src/controls/text-input/text-input.module.ts b/libs/web/src/controls/text-input/text-input.module.ts
index 776c0f10..e5e03e91 100644
--- a/libs/web/src/controls/text-input/text-input.module.ts
+++ b/libs/web/src/controls/text-input/text-input.module.ts
@@ -1,7 +1,7 @@
import { ModuleWithProviders, NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { TextMaskModule } from 'angular2-text-mask';
-import { DatepickerModule } from 'ngx-bootstrap/datepicker';
+import { BsDatepickerModule } from 'ngx-bootstrap/datepicker';
import { TooltipModule } from 'ngx-bootstrap/tooltip';
import { PipesModule } from '../../pipes/pipes.module';
@@ -10,7 +10,7 @@ import { TextInputComponent } from './text-input.component';
@NgModule({
imports: [
- FormsModule, SharedModule.forRoot(), DatepickerModule.forRoot(),
+ FormsModule, SharedModule.forRoot(), BsDatepickerModule.forRoot(),
PipesModule.forRoot(), TextMaskModule, TooltipModule.forRoot()
],
declarations: [TextInputComponent],
diff --git a/libs/web/src/frames/error-frame/error-frame.component.scss b/libs/web/src/frames/error-frame/error-frame.component.scss
deleted file mode 100644
index 909c9cde..00000000
--- a/libs/web/src/frames/error-frame/error-frame.component.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-.error-frame {
-
-}
\ No newline at end of file
diff --git a/libs/web/src/frames/error-frame/error-frame.component.ts b/libs/web/src/frames/error-frame/error-frame.component.ts
index 4d0cd9e8..94997c94 100644
--- a/libs/web/src/frames/error-frame/error-frame.component.ts
+++ b/libs/web/src/frames/error-frame/error-frame.component.ts
@@ -4,8 +4,7 @@ import { BaseComponent } from '../../base/base-component/base-component.componen
@Component({
selector: 'error-frame',
- templateUrl: './error-frame.component.html',
- styleUrls: ['./error-frame.component.scss']
+ templateUrl: './error-frame.component.html'
})
export class ErrorFrameComponent extends BaseComponent {
diff --git a/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.scss b/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.scss
deleted file mode 100644
index a4712d37..00000000
--- a/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.scss
+++ /dev/null
@@ -1,2 +0,0 @@
-.content-type-modal {
-}
diff --git a/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.ts b/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.ts
index f2a6e751..679a33b8 100644
--- a/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.ts
+++ b/libs/web/src/grids/content-types-grid/content-type-modal/content-type-modal.component.ts
@@ -9,8 +9,7 @@ import { TextInputComponent } from './../../../controls/text-input/text-input.co
@Component({
selector: 'content-type-modal',
- templateUrl: './content-type-modal.component.html',
- styleUrls: ['./content-type-modal.component.scss']
+ templateUrl: './content-type-modal.component.html'
})
export class ContentTypeModalComponent extends BaseResourceModalComponent {
diff --git a/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.html b/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.html
index 63921cd4..936b3779 100644
--- a/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.html
+++ b/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.html
@@ -1,17 +1,20 @@
\ No newline at end of file
diff --git a/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.scss b/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.scss
deleted file mode 100644
index 0d556540..00000000
--- a/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.scss
+++ /dev/null
@@ -1,3 +0,0 @@
-.content-type-select-input {
-
-}
diff --git a/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.ts b/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.ts
index 85a25ea3..0175a115 100644
--- a/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.ts
+++ b/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.ts
@@ -1,5 +1,3 @@
-import { takeUntil } from 'rxjs/operators';
-
import { Component, ComponentFactoryResolver, EventEmitter, Injector, Input, Output, ViewChild } from '@angular/core';
import { ContentTypesService, translate } from '@rucken/core';
import { ContentType } from '@rucken/core';
@@ -13,7 +11,6 @@ import { ContentTypesListModalComponent } from './../content-types-list-modal/co
@Component({
selector: 'content-type-select-input',
templateUrl: './content-type-select-input.component.html',
- styleUrls: ['./content-type-select-input.component.scss'],
entryComponents: [ContentTypesListModalComponent]
})
@@ -31,6 +28,7 @@ export class ContentTypeSelectInputComponent extends BaseResourceSelectInputComp
@Output()
modelChange: EventEmitter
= new EventEmitter();
+ loadAll = false;
items: any[] | ContentType[];
cachedResourcesService: ContentTypesService;
@@ -44,13 +42,6 @@ export class ContentTypeSelectInputComponent extends BaseResourceSelectInputComp
this.contentTypesService = injector.get(ContentTypesService);
this.cachedResourcesService = this.contentTypesService.createCache();
}
- changeInputValue(value: string) {
- const filter: any = {};
- if (this.cachedResourcesService) {
- this.cachedResourcesService.ignoreCache = true;
- this.cachedResourcesService.loadAll(value, filter);
- }
- }
onLookup() {
const itemModal: ContentTypesListModalComponent =
this.app.modals(this.resolver).create(ContentTypesListModalComponent);
@@ -76,8 +67,3 @@ export class ContentTypeSelectInputComponent extends BaseResourceSelectInputComp
return '';
}
}
-
-
-
-// WEBPACK FOOTER //
-// C:/Projects/open-sources/@rucken/core/libs/web/src/grids/content-types-grid/content-type-select-input/content-type-select-input.component.ts
diff --git a/libs/web/src/grids/content-types-grid/content-types-grid.component.html b/libs/web/src/grids/content-types-grid/content-types-grid.component.html
index 16633b70..ca04c8bc 100644
--- a/libs/web/src/grids/content-types-grid/content-types-grid.component.html
+++ b/libs/web/src/grids/content-types-grid/content-types-grid.component.html
@@ -1,5 +1,5 @@
-
-