fixed locale dates
This commit is contained in:
parent
01f399e547
commit
f3a7017320
8
package-lock.json
generated
8
package-lock.json
generated
@ -257,6 +257,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@angular-material-components/moment-adapter": {
|
||||||
|
"version": "6.0.0",
|
||||||
|
"resolved": "https://registry.npmjs.org/@angular-material-components/moment-adapter/-/moment-adapter-6.0.0.tgz",
|
||||||
|
"integrity": "sha512-YnUfaaYIsK1xeN3D84RGc500ieh7BrgSK1DNh3abneeKGTS9es9FJPkqK3JW9P+8460YQ4hxrMMeerGLG30C5A==",
|
||||||
|
"requires": {
|
||||||
|
"tslib": "^2.1.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"@angular/animations": {
|
"@angular/animations": {
|
||||||
"version": "12.2.10",
|
"version": "12.2.10",
|
||||||
"resolved": "https://registry.npmjs.org/@angular/animations/-/animations-12.2.10.tgz",
|
"resolved": "https://registry.npmjs.org/@angular/animations/-/animations-12.2.10.tgz",
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@angular-material-components/datetime-picker": "^6.0.3",
|
"@angular-material-components/datetime-picker": "^6.0.3",
|
||||||
|
"@angular-material-components/moment-adapter": "^6.0.0",
|
||||||
"@angular/animations": "^12.2.10",
|
"@angular/animations": "^12.2.10",
|
||||||
"@angular/cdk": "^12.2.10",
|
"@angular/cdk": "^12.2.10",
|
||||||
"@angular/common": "^12.2.10",
|
"@angular/common": "^12.2.10",
|
||||||
|
@ -62,6 +62,9 @@ import { DurationpickerComponent } from './ui/durationpicker/durationpicker.comp
|
|||||||
import { InviteCodeComponent } from './pages/invites/code/code.component';
|
import { InviteCodeComponent } from './pages/invites/code/code.component';
|
||||||
import { InviteEditComponent } from './pages/invites/edit/invite.edit';
|
import { InviteEditComponent } from './pages/invites/edit/invite.edit';
|
||||||
import { MatPaginatorIntl } from '@angular/material/paginator';
|
import { MatPaginatorIntl } from '@angular/material/paginator';
|
||||||
|
import { NgxMatDateAdapter, NGX_MAT_DATE_FORMATS } from '@angular-material-components/datetime-picker';
|
||||||
|
import { MAT_DATE_LOCALE } from '@angular/material/core';
|
||||||
|
import { NgxMatMomentAdapter } from '@angular-material-components/moment-adapter';
|
||||||
|
|
||||||
|
|
||||||
export function init_app(i18n: I18nService) {
|
export function init_app(i18n: I18nService) {
|
||||||
@ -82,7 +85,7 @@ export class XhrInterceptor implements HttpInterceptor {
|
|||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [
|
declarations: [
|
||||||
AutofocusDirective,
|
AutofocusDirective,
|
||||||
I18nPipe,I18nEmptyPipe,
|
I18nPipe, I18nEmptyPipe,
|
||||||
MomentPipe,
|
MomentPipe,
|
||||||
MainComponent,
|
MainComponent,
|
||||||
AppComponent,
|
AppComponent,
|
||||||
@ -143,6 +146,28 @@ export class XhrInterceptor implements HttpInterceptor {
|
|||||||
service.injectI18n(i18n)
|
service.injectI18n(i18n)
|
||||||
return service;
|
return service;
|
||||||
}, deps: [ I18nService ]
|
}, deps: [ I18nService ]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
provide: NgxMatDateAdapter,
|
||||||
|
useClass: NgxMatMomentAdapter,
|
||||||
|
useFactory: (i18n: I18nService) => {
|
||||||
|
return new NgxMatMomentAdapter(i18n.getLocale());
|
||||||
|
}, deps: [ I18nService ]
|
||||||
|
}, {
|
||||||
|
provide: NGX_MAT_DATE_FORMATS, useFactory: (i18n: I18nService) => {
|
||||||
|
const datetimeformat = i18n.get('format.datetime', []);
|
||||||
|
return {
|
||||||
|
parse: {
|
||||||
|
dateInput: "l, LTS"
|
||||||
|
},
|
||||||
|
display: {
|
||||||
|
dateInput: datetimeformat,
|
||||||
|
monthYearLabel: "MMM YYYY",
|
||||||
|
dateA11yLabel: "LL",
|
||||||
|
monthYearA11yLabel: "MMMM YYYY"
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}, deps: [ I18nService ]
|
||||||
} ],
|
} ],
|
||||||
bootstrap: [ AppComponent ],
|
bootstrap: [ AppComponent ],
|
||||||
})
|
})
|
||||||
|
@ -45,6 +45,8 @@ import {MatTableModule} from '@angular/material/table';
|
|||||||
import {MatMomentDateModule} from '@angular/material-moment-adapter';
|
import {MatMomentDateModule} from '@angular/material-moment-adapter';
|
||||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||||
|
|
||||||
|
import { NgxMatMomentModule } from '@angular-material-components/moment-adapter';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
NgxMatDatetimePickerModule,
|
NgxMatDatetimePickerModule,
|
||||||
NgxMatNativeDateModule
|
NgxMatNativeDateModule
|
||||||
@ -93,6 +95,7 @@ import { NgxMatTimepickerModule } from 'ngx-mat-timepicker';
|
|||||||
MatTableModule,
|
MatTableModule,
|
||||||
MatMomentDateModule,
|
MatMomentDateModule,
|
||||||
FlexLayoutModule,
|
FlexLayoutModule,
|
||||||
|
NgxMatMomentModule,
|
||||||
NgxMatDatetimePickerModule,
|
NgxMatDatetimePickerModule,
|
||||||
NgxMatNativeDateModule,
|
NgxMatNativeDateModule,
|
||||||
NgxMatTimepickerModule
|
NgxMatTimepickerModule
|
||||||
|
@ -99,7 +99,6 @@ export class BorrowProvingResultDialog {
|
|||||||
constructor(
|
constructor(
|
||||||
@Inject(MAT_DIALOG_DATA) private data: any) {
|
@Inject(MAT_DIALOG_DATA) private data: any) {
|
||||||
this.result = JSON.parse(JSON.stringify(data));
|
this.result = JSON.parse(JSON.stringify(data));
|
||||||
console.log(this.result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -28,7 +28,7 @@
|
|||||||
</mat-select>
|
</mat-select>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput [ngxMatDatetimePicker]="afterPicker" [formControl]="afterFormControl"
|
<input matInput [ngxMatDatetimePicker]="afterPicker" readonly [formControl]="afterFormControl"
|
||||||
placeholder="{{'partey.timeslots.filter.after' | i18n}}">
|
placeholder="{{'partey.timeslots.filter.after' | i18n}}">
|
||||||
<mat-datepicker-toggle matSuffix [for]="afterPicker"></mat-datepicker-toggle>
|
<mat-datepicker-toggle matSuffix [for]="afterPicker"></mat-datepicker-toggle>
|
||||||
<ngx-mat-datetime-picker #afterPicker></ngx-mat-datetime-picker>
|
<ngx-mat-datetime-picker #afterPicker></ngx-mat-datetime-picker>
|
||||||
|
@ -13,6 +13,7 @@ import { ParteyTimeslotsService } from '../../../services/partey.service';
|
|||||||
import { ConfirmDialog } from '../../../ui/confirm/confirm.component';
|
import { ConfirmDialog } from '../../../ui/confirm/confirm.component';
|
||||||
import { I18nService } from './../../../services/i18n.service';
|
import { I18nService } from './../../../services/i18n.service';
|
||||||
import { AuthService } from './../../../services/auth.service';
|
import { AuthService } from './../../../services/auth.service';
|
||||||
|
import * as moment from 'moment';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-partey-timeslots',
|
selector: 'app-partey-timeslots',
|
||||||
@ -74,7 +75,7 @@ export class ParteyTimeslotsComponent implements OnInit {
|
|||||||
this.ownerFormControl.setValue("");
|
this.ownerFormControl.setValue("");
|
||||||
this.filter.type = "";
|
this.filter.type = "";
|
||||||
this.typeFormControl.setValue("");
|
this.typeFormControl.setValue("");
|
||||||
this.filter.after = new Date().toUTCString();
|
this.filter.after = moment.utc().format();
|
||||||
this.afterFormControl.setValue(new Date());
|
this.afterFormControl.setValue(new Date());
|
||||||
|
|
||||||
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
|
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
|
||||||
@ -96,7 +97,7 @@ export class ParteyTimeslotsComponent implements OnInit {
|
|||||||
}, (error) => { })
|
}, (error) => { })
|
||||||
})
|
})
|
||||||
this.afterFormControl.valueChanges.subscribe((value: Date) => {
|
this.afterFormControl.valueChanges.subscribe((value: Date) => {
|
||||||
this.filter.after = value && value.toUTCString() || undefined;
|
this.filter.after = value && moment.utc(value).format() || undefined;
|
||||||
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
|
this.parteyTimeslotsService.get(this.page.page, this.page.size, this.page.sort, this.page.desc, this.filter).subscribe((data: any) => {
|
||||||
this.timeslots = data;
|
this.timeslots = data;
|
||||||
}, (error) => { })
|
}, (error) => { })
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
import {Component, OnInit, Inject, Input} from '@angular/core';
|
import { Component, OnInit, Inject, Input } from '@angular/core';
|
||||||
import {Sort} from '@angular/material/sort';
|
import { Sort } from '@angular/material/sort';
|
||||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||||
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||||
import {ConfirmDialog} from '../confirm/confirm.component';
|
import { ConfirmDialog } from '../confirm/confirm.component';
|
||||||
import {I18nService} from '../../services/i18n.service';
|
import { I18nService } from '../../services/i18n.service';
|
||||||
import {ProfileService} from '../../services/profile.service';
|
import { ProfileService } from '../../services/profile.service';
|
||||||
import {ProfileFieldPgpBlob} from './binary/pgp/profilefield.pgp-blob';
|
import { ProfileFieldPgpBlob } from './binary/pgp/profilefield.pgp-blob';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-profilefields',
|
selector: 'app-profilefields',
|
||||||
templateUrl: './profilefields.component.html',
|
templateUrl: './profilefields.component.html',
|
||||||
styleUrls: ['./profilefields.component.scss']
|
styleUrls: [ './profilefields.component.scss' ]
|
||||||
})
|
})
|
||||||
export class ProfileFieldsComponent implements OnInit {
|
export class ProfileFieldsComponent implements OnInit {
|
||||||
|
|
||||||
@Input() username;
|
@Input() username;
|
||||||
@Input() edit;
|
@Input() edit;
|
||||||
profileFieldColumns = ["name", "value"];
|
profileFieldColumns = [ "name", "value" ];
|
||||||
profileFields: Array<any> = [];
|
profileFields: Array<any> = [];
|
||||||
datetimeformat: String;
|
datetimeformat: String;
|
||||||
dateformat: String;
|
dateformat: String;
|
||||||
timeformat: String;
|
timeformat: String;
|
||||||
|
|
||||||
constructor(private i18n: I18nService, private profileService: ProfileService, public dialog: MatDialog) {}
|
constructor(private i18n: I18nService, private profileService: ProfileService, public dialog: MatDialog) { }
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
if(this.edit) {
|
if (this.edit) {
|
||||||
this.profileFieldColumns.push("visibility");
|
this.profileFieldColumns.push("visibility");
|
||||||
this.profileFieldColumns.push("edit");
|
this.profileFieldColumns.push("edit");
|
||||||
this.profileFieldColumns.push("delete");
|
this.profileFieldColumns.push("delete");
|
||||||
@ -40,7 +40,7 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
update() {
|
update() {
|
||||||
if(this.username) {
|
if (this.username) {
|
||||||
this.profileService.getForUser(this.username).subscribe((data: any) => {
|
this.profileService.getForUser(this.username).subscribe((data: any) => {
|
||||||
this.profileFields = data.profileFields;
|
this.profileFields = data.profileFields;
|
||||||
})
|
})
|
||||||
@ -53,14 +53,14 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
|
|
||||||
sortData(sort: Sort) {
|
sortData(sort: Sort) {
|
||||||
const data = this.profileFields.slice();
|
const data = this.profileFields.slice();
|
||||||
if(!sort.active || sort.direction === '') {
|
if (!sort.active || sort.direction === '') {
|
||||||
this.profileFields = data;
|
this.profileFields = data;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.profileFields = data.sort((a, b) => {
|
this.profileFields = data.sort((a, b) => {
|
||||||
const isAsc = sort.direction === 'asc';
|
const isAsc = sort.direction === 'asc';
|
||||||
switch(sort.active) {
|
switch (sort.active) {
|
||||||
case 'name': return this.compare(this.i18n.getEmpty('profileField.name.' + a.name, []), this.i18n.getEmpty('profileField.name.' + b.name, []), isAsc);
|
case 'name': return this.compare(this.i18n.getEmpty('profileField.name.' + a.name, []), this.i18n.getEmpty('profileField.name.' + b.name, []), isAsc);
|
||||||
case 'value': return this.compare(a.value, b.value, isAsc);
|
case 'value': return this.compare(a.value, b.value, isAsc);
|
||||||
case 'index': return this.compare(a.index, b.index, isAsc);
|
case 'index': return this.compare(a.index, b.index, isAsc);
|
||||||
@ -70,9 +70,9 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
compare(a: number | string , b: number | string , isAsc: boolean) {
|
compare(a: number | string, b: number | string, isAsc: boolean) {
|
||||||
if (typeof a === 'string' && typeof b === 'string') {
|
if (typeof a === 'string' && typeof b === 'string') {
|
||||||
return a.localeCompare(b,undefined, { sensitivity: 'accent' } ) * (isAsc ? 1 : -1);
|
return a.localeCompare(b, undefined, { sensitivity: 'accent' }) * (isAsc ? 1 : -1);
|
||||||
}
|
}
|
||||||
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
return (a < b ? -1 : 1) * (isAsc ? 1 : -1);
|
||||||
}
|
}
|
||||||
@ -88,7 +88,7 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
|
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe(result => {
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
if(result) {
|
if (result) {
|
||||||
this.profileService.createOrUpdate(result).subscribe();
|
this.profileService.createOrUpdate(result).subscribe();
|
||||||
} else {
|
} else {
|
||||||
profileField.name = resetProfileField.name;
|
profileField.name = resetProfileField.name;
|
||||||
@ -105,13 +105,13 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||||
data: {
|
data: {
|
||||||
'label': 'profileField.confirmDelete',
|
'label': 'profileField.confirmDelete',
|
||||||
'empty' : true,
|
'empty': true,
|
||||||
'args': ['profileField.name.' + profileField.name]
|
'args': [ 'profileField.name.' + profileField.name ]
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe(result => {
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
if(result) {
|
if (result) {
|
||||||
this.profileService.delete(profileField.name).subscribe((result: any) => {
|
this.profileService.delete(profileField.name).subscribe((result: any) => {
|
||||||
this.update();
|
this.update();
|
||||||
})
|
})
|
||||||
@ -121,12 +121,12 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
|
|
||||||
openCreate() {
|
openCreate() {
|
||||||
const dialogRef = this.dialog.open(ProfileFieldDialog, {
|
const dialogRef = this.dialog.open(ProfileFieldDialog, {
|
||||||
data: {"type": "TEXT", "visibility": "PRIVATE"},
|
data: { "type": "TEXT", "visibility": "PRIVATE" },
|
||||||
minWidth: '400px'
|
minWidth: '400px'
|
||||||
});
|
});
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe(result => {
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
if(result) {
|
if (result) {
|
||||||
this.update();
|
this.update();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -145,15 +145,15 @@ export class ProfileFieldsComponent implements OnInit {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-profilefield-dialog',
|
selector: 'app-profilefield-dialog',
|
||||||
templateUrl: 'profilefield.dialog.html',
|
templateUrl: 'profilefield.dialog.html',
|
||||||
styleUrls: ['./profilefield.dialog.scss']
|
styleUrls: [ './profilefield.dialog.scss' ]
|
||||||
})
|
})
|
||||||
export class ProfileFieldDialog {
|
export class ProfileFieldDialog {
|
||||||
|
|
||||||
form: FormGroup;
|
form: FormGroup;
|
||||||
profileField;
|
profileField;
|
||||||
|
|
||||||
types = ["TEXT", "NUMBER", "DATE", "DATETIME", "URL", "EMAIL", "BOOL", "BLOB"];
|
types = [ "TEXT", "NUMBER", "DATE", "DATETIME", "URL", "EMAIL", "BOOL", "BLOB" ];
|
||||||
visibilities = ["PRIVATE", "PROTECTED", "PUBLIC"];
|
visibilities = [ "PRIVATE", "PROTECTED", "PUBLIC" ];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private profileService: ProfileService,
|
private profileService: ProfileService,
|
||||||
@ -166,17 +166,17 @@ export class ProfileFieldDialog {
|
|||||||
|
|
||||||
ngOnInit() {
|
ngOnInit() {
|
||||||
this.form = this.formBuilder.group({
|
this.form = this.formBuilder.group({
|
||||||
name: ['', Validators.required],
|
name: [ '', Validators.required ],
|
||||||
type: ['', Validators.required],
|
type: [ '', Validators.required ],
|
||||||
value: [''],
|
value: [ '' ],
|
||||||
blob: [''],
|
blob: [ '' ],
|
||||||
visibility: ['', Validators.required],
|
visibility: [ '', Validators.required ],
|
||||||
index: ['']
|
index: [ '' ]
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
booleanChange(profileField) {
|
booleanChange(profileField) {
|
||||||
if(profileField.value == 'true') {
|
if (profileField.value == 'true') {
|
||||||
profileField.value = 'false';
|
profileField.value = 'false';
|
||||||
} else {
|
} else {
|
||||||
profileField.value = 'true';
|
profileField.value = 'true';
|
||||||
@ -188,15 +188,15 @@ export class ProfileFieldDialog {
|
|||||||
this.profileService.createOrUpdate(profileField).subscribe((result: any) => {
|
this.profileService.createOrUpdate(profileField).subscribe((result: any) => {
|
||||||
this.dialogRef.close(profileField);
|
this.dialogRef.close(profileField);
|
||||||
}, (error) => {
|
}, (error) => {
|
||||||
if(error.status == 409) {
|
if (error.status == 409) {
|
||||||
let errors = {};
|
let errors = {};
|
||||||
for(let code of error.error) {
|
for (let code of error.error) {
|
||||||
errors[code.field] = errors[code.field] || {};
|
errors[ code.field ] = errors[ code.field ] || {};
|
||||||
errors[code.field][code.code] = true;
|
errors[ code.field ][ code.code ] = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(let code in errors) {
|
for (let code in errors) {
|
||||||
this.form.get(code).setErrors(errors[code]);
|
this.form.get(code).setErrors(errors[ code ]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -208,8 +208,7 @@ export class ProfileFieldDialog {
|
|||||||
});
|
});
|
||||||
|
|
||||||
dialogRef.afterClosed().subscribe(result => {
|
dialogRef.afterClosed().subscribe(result => {
|
||||||
if(result) {
|
if (result) {
|
||||||
console.log(result, profileField);
|
|
||||||
profileField.blob = result;
|
profileField.blob = result;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -222,7 +221,7 @@ export class ProfileFieldDialog {
|
|||||||
@Component({
|
@Component({
|
||||||
selector: 'app-profilefield-blob',
|
selector: 'app-profilefield-blob',
|
||||||
templateUrl: 'profilefield.blob.html',
|
templateUrl: 'profilefield.blob.html',
|
||||||
styleUrls: ['./profilefield.blob.scss']
|
styleUrls: [ './profilefield.blob.scss' ]
|
||||||
})
|
})
|
||||||
export class ProfileFieldBlob {
|
export class ProfileFieldBlob {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user