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": {
|
||||
"version": "12.2.10",
|
||||
"resolved": "https://registry.npmjs.org/@angular/animations/-/animations-12.2.10.tgz",
|
||||
|
@ -12,6 +12,7 @@
|
||||
"private": true,
|
||||
"dependencies": {
|
||||
"@angular-material-components/datetime-picker": "^6.0.3",
|
||||
"@angular-material-components/moment-adapter": "^6.0.0",
|
||||
"@angular/animations": "^12.2.10",
|
||||
"@angular/cdk": "^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 { InviteEditComponent } from './pages/invites/edit/invite.edit';
|
||||
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) {
|
||||
@ -82,7 +85,7 @@ export class XhrInterceptor implements HttpInterceptor {
|
||||
@NgModule({
|
||||
declarations: [
|
||||
AutofocusDirective,
|
||||
I18nPipe,I18nEmptyPipe,
|
||||
I18nPipe, I18nEmptyPipe,
|
||||
MomentPipe,
|
||||
MainComponent,
|
||||
AppComponent,
|
||||
@ -143,6 +146,28 @@ export class XhrInterceptor implements HttpInterceptor {
|
||||
service.injectI18n(i18n)
|
||||
return service;
|
||||
}, 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 ],
|
||||
})
|
||||
|
@ -45,6 +45,8 @@ import {MatTableModule} from '@angular/material/table';
|
||||
import {MatMomentDateModule} from '@angular/material-moment-adapter';
|
||||
import {FlexLayoutModule} from '@angular/flex-layout';
|
||||
|
||||
import { NgxMatMomentModule } from '@angular-material-components/moment-adapter';
|
||||
|
||||
import {
|
||||
NgxMatDatetimePickerModule,
|
||||
NgxMatNativeDateModule
|
||||
@ -93,6 +95,7 @@ import { NgxMatTimepickerModule } from 'ngx-mat-timepicker';
|
||||
MatTableModule,
|
||||
MatMomentDateModule,
|
||||
FlexLayoutModule,
|
||||
NgxMatMomentModule,
|
||||
NgxMatDatetimePickerModule,
|
||||
NgxMatNativeDateModule,
|
||||
NgxMatTimepickerModule
|
||||
|
@ -99,7 +99,6 @@ export class BorrowProvingResultDialog {
|
||||
constructor(
|
||||
@Inject(MAT_DIALOG_DATA) private data: any) {
|
||||
this.result = JSON.parse(JSON.stringify(data));
|
||||
console.log(this.result);
|
||||
}
|
||||
|
||||
}
|
@ -28,7 +28,7 @@
|
||||
</mat-select>
|
||||
</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}}">
|
||||
<mat-datepicker-toggle matSuffix [for]="afterPicker"></mat-datepicker-toggle>
|
||||
<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 { I18nService } from './../../../services/i18n.service';
|
||||
import { AuthService } from './../../../services/auth.service';
|
||||
import * as moment from 'moment';
|
||||
|
||||
@Component({
|
||||
selector: 'app-partey-timeslots',
|
||||
@ -74,7 +75,7 @@ export class ParteyTimeslotsComponent implements OnInit {
|
||||
this.ownerFormControl.setValue("");
|
||||
this.filter.type = "";
|
||||
this.typeFormControl.setValue("");
|
||||
this.filter.after = new Date().toUTCString();
|
||||
this.filter.after = moment.utc().format();
|
||||
this.afterFormControl.setValue(new Date());
|
||||
|
||||
this.searchFormControl.valueChanges.pipe(debounceTime(500)).subscribe(value => {
|
||||
@ -96,7 +97,7 @@ export class ParteyTimeslotsComponent implements OnInit {
|
||||
}, (error) => { })
|
||||
})
|
||||
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.timeslots = data;
|
||||
}, (error) => { })
|
||||
|
@ -1,31 +1,31 @@
|
||||
import {Component, OnInit, Inject, Input} from '@angular/core';
|
||||
import {Sort} from '@angular/material/sort';
|
||||
import {FormBuilder, FormGroup, Validators} from '@angular/forms';
|
||||
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
||||
import {ConfirmDialog} from '../confirm/confirm.component';
|
||||
import {I18nService} from '../../services/i18n.service';
|
||||
import {ProfileService} from '../../services/profile.service';
|
||||
import {ProfileFieldPgpBlob} from './binary/pgp/profilefield.pgp-blob';
|
||||
import { Component, OnInit, Inject, Input } from '@angular/core';
|
||||
import { Sort } from '@angular/material/sort';
|
||||
import { FormBuilder, FormGroup, Validators } from '@angular/forms';
|
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||||
import { ConfirmDialog } from '../confirm/confirm.component';
|
||||
import { I18nService } from '../../services/i18n.service';
|
||||
import { ProfileService } from '../../services/profile.service';
|
||||
import { ProfileFieldPgpBlob } from './binary/pgp/profilefield.pgp-blob';
|
||||
|
||||
@Component({
|
||||
selector: 'app-profilefields',
|
||||
templateUrl: './profilefields.component.html',
|
||||
styleUrls: ['./profilefields.component.scss']
|
||||
styleUrls: [ './profilefields.component.scss' ]
|
||||
})
|
||||
export class ProfileFieldsComponent implements OnInit {
|
||||
|
||||
@Input() username;
|
||||
@Input() edit;
|
||||
profileFieldColumns = ["name", "value"];
|
||||
profileFieldColumns = [ "name", "value" ];
|
||||
profileFields: Array<any> = [];
|
||||
datetimeformat: String;
|
||||
dateformat: 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 {
|
||||
if(this.edit) {
|
||||
if (this.edit) {
|
||||
this.profileFieldColumns.push("visibility");
|
||||
this.profileFieldColumns.push("edit");
|
||||
this.profileFieldColumns.push("delete");
|
||||
@ -40,7 +40,7 @@ export class ProfileFieldsComponent implements OnInit {
|
||||
|
||||
|
||||
update() {
|
||||
if(this.username) {
|
||||
if (this.username) {
|
||||
this.profileService.getForUser(this.username).subscribe((data: any) => {
|
||||
this.profileFields = data.profileFields;
|
||||
})
|
||||
@ -53,14 +53,14 @@ export class ProfileFieldsComponent implements OnInit {
|
||||
|
||||
sortData(sort: Sort) {
|
||||
const data = this.profileFields.slice();
|
||||
if(!sort.active || sort.direction === '') {
|
||||
if (!sort.active || sort.direction === '') {
|
||||
this.profileFields = data;
|
||||
return;
|
||||
}
|
||||
|
||||
this.profileFields = data.sort((a, b) => {
|
||||
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 'value': return this.compare(a.value, b.value, 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') {
|
||||
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);
|
||||
}
|
||||
@ -88,7 +88,7 @@ export class ProfileFieldsComponent implements OnInit {
|
||||
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if(result) {
|
||||
if (result) {
|
||||
this.profileService.createOrUpdate(result).subscribe();
|
||||
} else {
|
||||
profileField.name = resetProfileField.name;
|
||||
@ -105,13 +105,13 @@ export class ProfileFieldsComponent implements OnInit {
|
||||
const dialogRef = this.dialog.open(ConfirmDialog, {
|
||||
data: {
|
||||
'label': 'profileField.confirmDelete',
|
||||
'empty' : true,
|
||||
'args': ['profileField.name.' + profileField.name]
|
||||
'empty': true,
|
||||
'args': [ 'profileField.name.' + profileField.name ]
|
||||
}
|
||||
})
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if(result) {
|
||||
if (result) {
|
||||
this.profileService.delete(profileField.name).subscribe((result: any) => {
|
||||
this.update();
|
||||
})
|
||||
@ -121,12 +121,12 @@ export class ProfileFieldsComponent implements OnInit {
|
||||
|
||||
openCreate() {
|
||||
const dialogRef = this.dialog.open(ProfileFieldDialog, {
|
||||
data: {"type": "TEXT", "visibility": "PRIVATE"},
|
||||
data: { "type": "TEXT", "visibility": "PRIVATE" },
|
||||
minWidth: '400px'
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if(result) {
|
||||
if (result) {
|
||||
this.update();
|
||||
}
|
||||
});
|
||||
@ -145,15 +145,15 @@ export class ProfileFieldsComponent implements OnInit {
|
||||
@Component({
|
||||
selector: 'app-profilefield-dialog',
|
||||
templateUrl: 'profilefield.dialog.html',
|
||||
styleUrls: ['./profilefield.dialog.scss']
|
||||
styleUrls: [ './profilefield.dialog.scss' ]
|
||||
})
|
||||
export class ProfileFieldDialog {
|
||||
|
||||
form: FormGroup;
|
||||
profileField;
|
||||
|
||||
types = ["TEXT", "NUMBER", "DATE", "DATETIME", "URL", "EMAIL", "BOOL", "BLOB"];
|
||||
visibilities = ["PRIVATE", "PROTECTED", "PUBLIC"];
|
||||
types = [ "TEXT", "NUMBER", "DATE", "DATETIME", "URL", "EMAIL", "BOOL", "BLOB" ];
|
||||
visibilities = [ "PRIVATE", "PROTECTED", "PUBLIC" ];
|
||||
|
||||
constructor(
|
||||
private profileService: ProfileService,
|
||||
@ -166,17 +166,17 @@ export class ProfileFieldDialog {
|
||||
|
||||
ngOnInit() {
|
||||
this.form = this.formBuilder.group({
|
||||
name: ['', Validators.required],
|
||||
type: ['', Validators.required],
|
||||
value: [''],
|
||||
blob: [''],
|
||||
visibility: ['', Validators.required],
|
||||
index: ['']
|
||||
name: [ '', Validators.required ],
|
||||
type: [ '', Validators.required ],
|
||||
value: [ '' ],
|
||||
blob: [ '' ],
|
||||
visibility: [ '', Validators.required ],
|
||||
index: [ '' ]
|
||||
});
|
||||
}
|
||||
|
||||
booleanChange(profileField) {
|
||||
if(profileField.value == 'true') {
|
||||
if (profileField.value == 'true') {
|
||||
profileField.value = 'false';
|
||||
} else {
|
||||
profileField.value = 'true';
|
||||
@ -188,15 +188,15 @@ export class ProfileFieldDialog {
|
||||
this.profileService.createOrUpdate(profileField).subscribe((result: any) => {
|
||||
this.dialogRef.close(profileField);
|
||||
}, (error) => {
|
||||
if(error.status == 409) {
|
||||
if (error.status == 409) {
|
||||
let errors = {};
|
||||
for(let code of error.error) {
|
||||
errors[code.field] = errors[code.field] || {};
|
||||
errors[code.field][code.code] = true;
|
||||
for (let code of error.error) {
|
||||
errors[ code.field ] = errors[ code.field ] || {};
|
||||
errors[ code.field ][ code.code ] = true;
|
||||
}
|
||||
|
||||
for(let code in errors) {
|
||||
this.form.get(code).setErrors(errors[code]);
|
||||
for (let code in errors) {
|
||||
this.form.get(code).setErrors(errors[ code ]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -208,8 +208,7 @@ export class ProfileFieldDialog {
|
||||
});
|
||||
|
||||
dialogRef.afterClosed().subscribe(result => {
|
||||
if(result) {
|
||||
console.log(result, profileField);
|
||||
if (result) {
|
||||
profileField.blob = result;
|
||||
}
|
||||
});
|
||||
@ -222,7 +221,7 @@ export class ProfileFieldDialog {
|
||||
@Component({
|
||||
selector: 'app-profilefield-blob',
|
||||
templateUrl: 'profilefield.blob.html',
|
||||
styleUrls: ['./profilefield.blob.scss']
|
||||
styleUrls: [ './profilefield.blob.scss' ]
|
||||
})
|
||||
export class ProfileFieldBlob {
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user