mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-31 09:37:15 +01:00
Removed Libs inside date and datepicker
This commit is contained in:
@@ -5,13 +5,13 @@ import { ApplicationService } from '@core/application';
|
||||
import { BreadcrumbService } from '@core/breadcrumb';
|
||||
import { CrmCustomerService } from '@domain/crm';
|
||||
import { CustomerDTO } from '@swagger/crm';
|
||||
import { UiValidators } from '@ui/common';
|
||||
import { UiModalService } from '@ui/modal';
|
||||
import { AddressSelectionModalService } from '../modals/address-selection-modal/address-selection-modal.service';
|
||||
import { CustomerCreateComponentBase } from './customer-create.component';
|
||||
import { validateEmail } from '../validators/email-validator';
|
||||
import { Subscription } from 'rxjs';
|
||||
import { CheckoutService } from '@domain/checkout';
|
||||
import { UiValidators } from '@ui/common';
|
||||
|
||||
@Component({
|
||||
selector: 'page-customer-create-branch',
|
||||
|
||||
@@ -54,7 +54,6 @@ import { AppStoreModule } from './app-store.module';
|
||||
import { ModalDialogueModule } from './core/overlay/component';
|
||||
import { AppModalModule } from './app-modal.module';
|
||||
import { OverlaysModule } from './core/overlay/overlays.module';
|
||||
import { DateAdapter, NativeDateAdapter } from '@isa-ui/core/date';
|
||||
import { CoreBreadcrumbModule } from '@core/breadcrumb';
|
||||
import { CoreApplicationModule, ProcessService } from '@core/application';
|
||||
import { UiModalModule } from '@ui/modal';
|
||||
@@ -64,6 +63,7 @@ import { CartRefactImp } from './refact-imp/cart.refact-imp';
|
||||
import { CheckoutService } from '@domain/checkout';
|
||||
import { CheckoutRefactImp } from './refact-imp/checkout.refact-imp';
|
||||
import { CDN_PRODUCT_PICTURES } from './tokens';
|
||||
import { DateAdapter, NativeDateAdapter } from '@ui/common';
|
||||
registerLocaleData(localeDe, localeDeExtra);
|
||||
registerLocaleData(localeDe, 'de', localeDeExtra);
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Component, ChangeDetectionStrategy, Input, Output, EventEmitter } from '@angular/core';
|
||||
import { OrderDetailsCardInput } from './order-details-card-input';
|
||||
import { KeyValueDTOOfStringAndString, OrderItemProcessingStatusValue } from '@swagger/oms';
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
import { ShelfOrderDetailsService } from '../../services';
|
||||
import { DateAdapter } from '@ui/common';
|
||||
|
||||
@Component({
|
||||
selector: 'app-shelf-order-details-card',
|
||||
|
||||
@@ -2,10 +2,10 @@ import { NgModule } from '@angular/core';
|
||||
|
||||
import { ShelfOrderDetailsCardComponent } from './order-details-card.component';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { UiDatepickerModule } from '@isa-ui/datepicker';
|
||||
import { IconModule } from '@libs/ui';
|
||||
import { UiDropdownModule } from '@isa-ui/dropdown';
|
||||
import { ShelfPipesModule } from '../../pipes';
|
||||
import { UiDatepickerModule } from '@ui/datepicker';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, UiDatepickerModule, IconModule, ShelfPipesModule, UiDropdownModule],
|
||||
|
||||
@@ -9,14 +9,6 @@
|
||||
.container {
|
||||
overflow: scroll;
|
||||
max-height: 800px;
|
||||
|
||||
@include mq-tablet-landscape() {
|
||||
max-height: 300px;
|
||||
}
|
||||
|
||||
@include mq-desktop() {
|
||||
max-height: 300px;
|
||||
}
|
||||
}
|
||||
|
||||
.main-container {
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
// start:ng42.barrel
|
||||
export * from './month-names';
|
||||
// end:ng42.barrel
|
||||
@@ -1,14 +0,0 @@
|
||||
export const MONTH_NAMES = {
|
||||
0: 'Januar',
|
||||
1: 'Februar',
|
||||
2: 'März',
|
||||
3: 'April',
|
||||
4: 'Mai',
|
||||
5: 'Juni',
|
||||
6: 'Juli',
|
||||
7: 'August',
|
||||
8: 'September',
|
||||
9: 'Oktober',
|
||||
10: 'November',
|
||||
11: 'Dezember',
|
||||
};
|
||||
@@ -1,56 +0,0 @@
|
||||
import { isNullOrUndefined } from 'util';
|
||||
|
||||
export abstract class DateAdapter<TDate> {
|
||||
abstract getYear(date: TDate): number;
|
||||
|
||||
abstract getMonth(date: TDate): number;
|
||||
|
||||
abstract getDate(date: TDate): number;
|
||||
|
||||
abstract getYearName(date: TDate): string;
|
||||
|
||||
abstract getMonthName(date: TDate): string;
|
||||
|
||||
abstract getDateName(date: TDate): string;
|
||||
|
||||
abstract addCalendarMonths(date: TDate, months: number): TDate;
|
||||
|
||||
abstract addCalendarDays(date: TDate, days: number): TDate;
|
||||
|
||||
abstract createDate(year: number, month: number, date: number): TDate;
|
||||
|
||||
abstract today(): TDate;
|
||||
|
||||
abstract isValid(date: TDate): boolean;
|
||||
|
||||
abstract getFirstDateOfWeek(date: TDate): TDate;
|
||||
|
||||
abstract getLastDateOfWeek(date: TDate): TDate;
|
||||
|
||||
abstract getFirstDateOfMonth(date: TDate): TDate;
|
||||
|
||||
abstract getLastDateOfMonth(date: TDate): TDate;
|
||||
|
||||
abstract getDifferenceInDays(first: TDate, second: TDate): number;
|
||||
|
||||
abstract getDayOfWeek(date: TDate): number;
|
||||
|
||||
compareDate(first: TDate, second: TDate) {
|
||||
if (isNullOrUndefined(first) || isNullOrUndefined(second)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return (
|
||||
this.getYear(first) - this.getYear(second) ||
|
||||
this.getMonth(first) - this.getMonth(second) ||
|
||||
this.getDate(first) - this.getDate(second)
|
||||
);
|
||||
}
|
||||
|
||||
compareYearAndMonth(first: TDate, second: TDate) {
|
||||
if (isNullOrUndefined(first) || isNullOrUndefined(second)) {
|
||||
return null;
|
||||
}
|
||||
return this.getYear(first) - this.getYear(second) || this.getMonth(first) - this.getMonth(second);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// start:ng42.barrel
|
||||
export * from './date.adapter';
|
||||
export * from './native-date.adapter';
|
||||
export * from './constants';
|
||||
// end:ng42.barrel
|
||||
@@ -1,78 +0,0 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { DateAdapter } from './date.adapter';
|
||||
import { MONTH_NAMES } from './constants';
|
||||
|
||||
@Injectable()
|
||||
export class NativeDateAdapter extends DateAdapter<Date> {
|
||||
getYear(date: Date): number {
|
||||
return date.getFullYear();
|
||||
}
|
||||
getMonth(date: Date): number {
|
||||
return date.getMonth();
|
||||
}
|
||||
getDate(date: Date): number {
|
||||
return date.getDate();
|
||||
}
|
||||
getYearName(date: Date): string {
|
||||
return this.getYear(date).toString();
|
||||
}
|
||||
getMonthName(date: Date): string {
|
||||
return MONTH_NAMES[this.getMonth(date)];
|
||||
}
|
||||
getDateName(date: Date): string {
|
||||
return this.getDate(date).toString();
|
||||
}
|
||||
addCalendarMonths(date: Date, months: number): Date {
|
||||
return this.createDate(this.getYear(date), this.getMonth(date) + months, this.getDate(date));
|
||||
}
|
||||
addCalendarDays(date: Date, days: number): Date {
|
||||
return this.createDate(this.getYear(date), this.getMonth(date), this.getDate(date) + days);
|
||||
}
|
||||
|
||||
getFirstDateOfWeek(date: Date): Date {
|
||||
const clone = new Date(date);
|
||||
const day = clone.getDay();
|
||||
const diff = clone.getDate() - day + (day === 0 ? -6 : 1); // Start of Week = Monday
|
||||
return new Date(clone.setDate(diff));
|
||||
}
|
||||
|
||||
getLastDateOfWeek(date: Date): Date {
|
||||
const clone = new Date(date);
|
||||
const day = clone.getDay();
|
||||
const diff = clone.getDate() - day + (day === 0 ? 0 : 7); // End of Week = Sunday
|
||||
return new Date(clone.setDate(diff));
|
||||
}
|
||||
|
||||
getFirstDateOfMonth(date: Date) {
|
||||
return this.createDate(this.getYear(date), this.getMonth(date), 1);
|
||||
}
|
||||
|
||||
getLastDateOfMonth(date: Date) {
|
||||
return this.createDate(this.getYear(date), this.getMonth(date) + 1, 0);
|
||||
}
|
||||
|
||||
getDifferenceInDays(first: Date, second: Date) {
|
||||
return (first.getTime() - second.getTime()) / (1000 * 3600 * 24);
|
||||
}
|
||||
|
||||
getDayOfWeek(date: Date) {
|
||||
return date.getDay();
|
||||
}
|
||||
|
||||
createDate(year: number, month: number, date: number): Date {
|
||||
const result = new Date(year, month, date);
|
||||
// abbreviations for 19xx.
|
||||
if (year >= 0 && year < 100) {
|
||||
result.setFullYear(this.getYear(result) - 1900);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
today(): Date {
|
||||
return new Date();
|
||||
}
|
||||
|
||||
isValid(date: Date): boolean {
|
||||
return date instanceof Date && !isNaN(date.getDate());
|
||||
}
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
M
|
||||
</th>
|
||||
<th>
|
||||
D
|
||||
</th>
|
||||
<th>
|
||||
M
|
||||
</th>
|
||||
<th>
|
||||
D
|
||||
</th>
|
||||
<th>
|
||||
F
|
||||
</th>
|
||||
<th>
|
||||
S
|
||||
</th>
|
||||
<th>
|
||||
S
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr *ngFor="let week of dates$ | async" class="row">
|
||||
<td *ngFor="let date of week" class="cell" [appUiDatepickerCell]="date">
|
||||
{{ date | getCellName }}
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -1,40 +0,0 @@
|
||||
@import 'variables';
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
font-size: 16px;
|
||||
margin-top: 14px;
|
||||
margin-bottom: 14px;
|
||||
}
|
||||
|
||||
th {
|
||||
color: $datepicker-table-header-color;
|
||||
}
|
||||
|
||||
.cell {
|
||||
text-align: center;
|
||||
vertical-align: middle;
|
||||
width: 41px;
|
||||
height: 41px;
|
||||
}
|
||||
|
||||
.cell-is-today {
|
||||
border: 1px dashed $datepicker-selected-cell-bg-color;
|
||||
border-radius: 50%;
|
||||
font-weight: 700;
|
||||
}
|
||||
|
||||
.cell-not-in-range,
|
||||
.cell-is-disabled-day-of-week {
|
||||
color: $datepicker-cell-not-in-range-color;
|
||||
}
|
||||
|
||||
.cell-not-in-displayed-month {
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.cell-selected {
|
||||
background-color: $datepicker-selected-cell-bg-color;
|
||||
border-radius: 22px;
|
||||
font-weight: 700;
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Datepicker } from '@isa-ui/datepicker/datepicker';
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
import { map } from 'rxjs/operators';
|
||||
@Component({
|
||||
selector: 'app-ui-datepicker-body',
|
||||
templateUrl: 'body.component.html',
|
||||
styleUrls: ['body.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class UiDatepickerBodyComponent<TDate> implements OnInit {
|
||||
selected$ = this.datepicker.selected$;
|
||||
displayed$ = this.datepicker.displayed$;
|
||||
min$ = this.datepicker.min$;
|
||||
max$ = this.datepicker.max$;
|
||||
|
||||
dates$ = this.datepicker.displayed$.pipe(map((date) => this.getDateCellsForDate(date)));
|
||||
|
||||
constructor(private datepicker: Datepicker<TDate>, private dateAdapter: DateAdapter<TDate>) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
getDateCellsForDate(date: TDate): TDate[][] {
|
||||
const firstDateOfMonth = this.dateAdapter.getFirstDateOfMonth(date);
|
||||
const firstCalendarDate = this.dateAdapter.getFirstDateOfWeek(firstDateOfMonth);
|
||||
const lastDateOfMonth = this.dateAdapter.getLastDateOfMonth(date);
|
||||
const lastCalendarDate = this.dateAdapter.getLastDateOfWeek(lastDateOfMonth);
|
||||
|
||||
const dates: TDate[][] = [];
|
||||
|
||||
const days = this.dateAdapter.getDifferenceInDays(lastCalendarDate, firstCalendarDate);
|
||||
|
||||
for (let day = 0; day <= days; day++) {
|
||||
if (day % 7 === 0) {
|
||||
dates.push([]);
|
||||
}
|
||||
|
||||
const current = this.dateAdapter.addCalendarDays(firstCalendarDate, day);
|
||||
dates[dates.length - 1].push(current);
|
||||
}
|
||||
|
||||
return dates;
|
||||
}
|
||||
|
||||
selectDate(date: TDate) {
|
||||
this.datepicker.setSelected(date);
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
import { Directive, Input, HostBinding, OnDestroy, OnInit, HostListener } from '@angular/core';
|
||||
import { Datepicker } from '@isa-ui/datepicker/datepicker';
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
import { Subscription, ReplaySubject, combineLatest, BehaviorSubject } from 'rxjs';
|
||||
|
||||
@Directive({ selector: '[appUiDatepickerCell]' })
|
||||
export class UiDatepickerCellDirective<TDate> implements OnInit, OnDestroy {
|
||||
dateSubject = new BehaviorSubject<TDate>(undefined);
|
||||
|
||||
@Input('appUiDatepickerCell')
|
||||
set date(value: TDate) {
|
||||
this.dateSubject.next(value);
|
||||
}
|
||||
get date() {
|
||||
return this.dateSubject.value;
|
||||
}
|
||||
|
||||
@HostBinding('class.cell-in-displayed-month')
|
||||
inDisplayedMonth: boolean;
|
||||
|
||||
@HostBinding('class.cell-not-in-displayed-month')
|
||||
notInDisplayedMonth: boolean;
|
||||
|
||||
@HostBinding('class.cell-selected')
|
||||
selected: boolean;
|
||||
|
||||
@HostBinding('class.cell-in-range')
|
||||
inRange: boolean;
|
||||
|
||||
@HostBinding('class.cell-not-in-range')
|
||||
notInRange: boolean;
|
||||
|
||||
@HostBinding('class.cell-is-today')
|
||||
isToday: boolean;
|
||||
|
||||
@HostBinding('class.cell-is-disabled-day-of-week')
|
||||
isDisabledDayOfWeek: boolean;
|
||||
|
||||
private subscription = new Subscription();
|
||||
|
||||
constructor(private datepicker: Datepicker<TDate>, private dateAdapter: DateAdapter<TDate>) {}
|
||||
|
||||
ngOnInit(): void {
|
||||
this.initDisplayed$();
|
||||
this.initSelected$();
|
||||
this.initRange$();
|
||||
this.initToday$();
|
||||
this.initDisabledDayOfWeek$();
|
||||
}
|
||||
|
||||
initDisplayed$() {
|
||||
const sub = combineLatest([this.dateSubject, this.datepicker.displayed$]).subscribe(([date, displayed]) => {
|
||||
this.inDisplayedMonth = this.dateAdapter.compareYearAndMonth(date, displayed) === 0;
|
||||
this.notInDisplayedMonth = !this.inDisplayedMonth;
|
||||
});
|
||||
|
||||
this.subscription.add(sub);
|
||||
}
|
||||
|
||||
initSelected$() {
|
||||
const sub = combineLatest([this.dateSubject, this.datepicker.selected$]).subscribe(([date, selected]) => {
|
||||
this.selected = this.dateAdapter.compareDate(date, selected) === 0;
|
||||
});
|
||||
|
||||
this.subscription.add(sub);
|
||||
}
|
||||
|
||||
initRange$() {
|
||||
const sub = combineLatest([this.dateSubject, this.datepicker.min$, this.datepicker.max$]).subscribe(([date, min, max]) => {
|
||||
const minInRange = !!min ? this.dateAdapter.compareDate(date, min) > 0 : true;
|
||||
const maxInRange = !!max ? this.dateAdapter.compareDate(max, date) > 0 : true;
|
||||
|
||||
this.inRange = minInRange && maxInRange;
|
||||
this.notInRange = !this.inRange;
|
||||
});
|
||||
|
||||
this.subscription.add(sub);
|
||||
}
|
||||
|
||||
initToday$() {
|
||||
const sub = this.dateSubject.subscribe((date) => {
|
||||
this.isToday = this.dateAdapter.compareDate(date, this.dateAdapter.today()) === 0;
|
||||
});
|
||||
this.subscription.add(sub);
|
||||
}
|
||||
|
||||
initDisabledDayOfWeek$() {
|
||||
const sub = combineLatest([this.dateSubject, this.datepicker.disabledDaysOfWeek$]).subscribe(([date, disabledDayOfWeek]) => {
|
||||
this.isDisabledDayOfWeek = disabledDayOfWeek && disabledDayOfWeek.includes(this.dateAdapter.getDayOfWeek(date));
|
||||
});
|
||||
|
||||
this.subscription.add(sub);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscription.unsubscribe();
|
||||
this.dateSubject.complete();
|
||||
}
|
||||
|
||||
@HostListener('click')
|
||||
select() {
|
||||
if (this.inRange && this.inDisplayedMonth && !this.isDisabledDayOfWeek) {
|
||||
this.datepicker.setSelected(this.date);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
import { Pipe, PipeTransform } from '@angular/core';
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
|
||||
@Pipe({
|
||||
name: 'getCellName',
|
||||
})
|
||||
export class GetCellNamePipe implements PipeTransform {
|
||||
constructor(private dateAdapter: DateAdapter<any>) {}
|
||||
|
||||
transform(value: any, ...args: any[]): any {
|
||||
return this.dateAdapter.getDateName(value);
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
// start:ng42.barrel
|
||||
export * from './body.component';
|
||||
export * from './cell.directive';
|
||||
export * from './get-cell-name.pipe';
|
||||
// end:ng42.barrel
|
||||
@@ -1,12 +0,0 @@
|
||||
<div class="dp" *ngIf="opened" [class.left-0]="left" [class.right-0]="right">
|
||||
<div class="dp-body isa-card isa-border-radius-3">
|
||||
<app-ui-datepicker-header></app-ui-datepicker-header>
|
||||
<div class="hr"></div>
|
||||
<app-ui-datepicker-body></app-ui-datepicker-body>
|
||||
<div class="isa-text-center isa-mb-10">
|
||||
<button class="isa-btn isa-btn-primary isa-btn-pill isa-py-15 isa-px-25" (click)="save.emit(selected)">
|
||||
Speichern
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,53 +0,0 @@
|
||||
@import 'variables';
|
||||
:host {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 100%;
|
||||
z-index: 10;
|
||||
}
|
||||
|
||||
.hr {
|
||||
height: 1px;
|
||||
background-color: $datepicker-header-body-divider-color;
|
||||
margin-left: -18px;
|
||||
margin-right: -18px;
|
||||
}
|
||||
|
||||
.dp {
|
||||
position: absolute;
|
||||
border-radius: 3px;
|
||||
|
||||
top: 1.1rem;
|
||||
width: 350px;
|
||||
}
|
||||
|
||||
.dp-body {
|
||||
box-shadow: 0px 0px 15px rgba(0, 0, 0, 0.3);
|
||||
}
|
||||
|
||||
.dp-body::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
top: -10px;
|
||||
transform: rotate(45deg);
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
background-color: #ffffff;
|
||||
box-shadow: -5px -5px 5px rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
|
||||
.left-0 {
|
||||
left: 0;
|
||||
|
||||
.dp-body::after {
|
||||
left: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.right-0 {
|
||||
right: 0;
|
||||
|
||||
.dp-body::after {
|
||||
right: 11px;
|
||||
}
|
||||
}
|
||||
@@ -1,77 +0,0 @@
|
||||
import { Component, ChangeDetectionStrategy, OnInit, forwardRef, OnDestroy, ChangeDetectorRef, Input, HostBinding } from '@angular/core';
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
import { Datepicker } from './datepicker';
|
||||
import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ui-datepicker',
|
||||
templateUrl: 'datepicker.component.html',
|
||||
styleUrls: ['datepicker.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
providers: [
|
||||
{ provide: Datepicker, useExisting: forwardRef(() => UiDatepickerComponent) },
|
||||
{ provide: NG_VALUE_ACCESSOR, useExisting: forwardRef(() => UiDatepickerComponent), multi: true },
|
||||
],
|
||||
exportAs: 'uiDatepicker',
|
||||
})
|
||||
export class UiDatepickerComponent<TDate = any> extends Datepicker<TDate> implements ControlValueAccessor, OnInit, OnDestroy {
|
||||
@Input()
|
||||
@HostBinding('style.right')
|
||||
right: string;
|
||||
|
||||
@Input()
|
||||
@HostBinding('style.left')
|
||||
left: string;
|
||||
|
||||
opened = false;
|
||||
|
||||
private subscription = new Subscription();
|
||||
|
||||
onChange = (date: TDate) => {};
|
||||
|
||||
onTouched = () => {};
|
||||
|
||||
constructor(dateAdapter: DateAdapter<TDate>, private cdr: ChangeDetectorRef) {
|
||||
super(dateAdapter);
|
||||
const sub = this.selectedChange.subscribe((date) => {
|
||||
this.onChange(date);
|
||||
this.onTouched();
|
||||
});
|
||||
this.subscription.add(sub);
|
||||
}
|
||||
|
||||
ngOnInit(): void {}
|
||||
|
||||
ngOnDestroy() {
|
||||
this.subscription.unsubscribe();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
writeValue(obj: TDate): void {
|
||||
this.setSelected(obj, { emit: false });
|
||||
}
|
||||
|
||||
registerOnChange(fn: any): void {
|
||||
this.onChange = fn;
|
||||
}
|
||||
|
||||
registerOnTouched(fn: any): void {
|
||||
this.onTouched = fn;
|
||||
}
|
||||
|
||||
setDisabledState?(isDisabled: boolean): void {}
|
||||
|
||||
open() {
|
||||
this.opened = true;
|
||||
}
|
||||
|
||||
close() {
|
||||
this.opened = false;
|
||||
}
|
||||
|
||||
toggle() {
|
||||
this.opened = !this.opened;
|
||||
this.cdr.markForCheck();
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { NgModule } from '@angular/core';
|
||||
|
||||
import { UiDatepickerComponent } from './datepicker.component';
|
||||
import { CommonModule } from '@angular/common';
|
||||
import { UiDatepickerBodyComponent, UiDatepickerCellDirective, GetCellNamePipe } from './body';
|
||||
import { UiDatepickerHeaderComponent } from './header';
|
||||
import { IconModule } from '@libs/ui';
|
||||
|
||||
@NgModule({
|
||||
imports: [CommonModule, IconModule],
|
||||
exports: [UiDatepickerComponent],
|
||||
declarations: [UiDatepickerComponent, UiDatepickerBodyComponent, UiDatepickerHeaderComponent, UiDatepickerCellDirective, GetCellNamePipe],
|
||||
providers: [],
|
||||
})
|
||||
export class UiDatepickerModule {}
|
||||
@@ -1,142 +0,0 @@
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
import { EventEmitter, Input, Output, Directive } from '@angular/core';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
interface SetPropertyOptions {
|
||||
emit: boolean;
|
||||
}
|
||||
|
||||
@Directive()
|
||||
export abstract class Datepicker<TDate> {
|
||||
@Input()
|
||||
get selected() {
|
||||
return this.selectedSubject.value;
|
||||
}
|
||||
set selected(val: TDate) {
|
||||
this.setSelected(val, { emit: false });
|
||||
}
|
||||
@Output()
|
||||
selectedChange = new EventEmitter<TDate>();
|
||||
|
||||
@Output()
|
||||
save = new EventEmitter<TDate>();
|
||||
|
||||
@Input()
|
||||
get displayed() {
|
||||
return this.displayedSubject.value;
|
||||
}
|
||||
set displayed(val: TDate) {
|
||||
this.setDisplayed(val, { emit: false });
|
||||
}
|
||||
@Output()
|
||||
displayedChange = new EventEmitter<TDate>();
|
||||
|
||||
@Input()
|
||||
get min() {
|
||||
return this.displayedSubject.value;
|
||||
}
|
||||
set min(val: TDate) {
|
||||
this.setMin(val);
|
||||
}
|
||||
@Input()
|
||||
get max() {
|
||||
return this.displayedSubject.value;
|
||||
}
|
||||
set max(val: TDate) {
|
||||
this.setMax(val);
|
||||
}
|
||||
|
||||
@Input()
|
||||
get disabledDaysOfWeek() {
|
||||
return this.disableDayOfWeekSubject.value;
|
||||
}
|
||||
set disabledDaysOfWeek(value: number[]) {
|
||||
// 0 = Sunday, 1 = Monday, ... 6 = Saturday
|
||||
this.disableDayOfWeekSubject.next(value);
|
||||
}
|
||||
|
||||
protected selectedSubject = new BehaviorSubject<TDate>(undefined);
|
||||
protected displayedSubject = new BehaviorSubject<TDate>(this.dateAdapter.today());
|
||||
protected minSubject = new BehaviorSubject<TDate>(undefined);
|
||||
protected maxSubject = new BehaviorSubject<TDate>(undefined);
|
||||
protected disableDayOfWeekSubject = new BehaviorSubject<number[]>(undefined);
|
||||
|
||||
get selected$() {
|
||||
return this.selectedSubject.asObservable();
|
||||
}
|
||||
get displayed$() {
|
||||
return this.displayedSubject.asObservable();
|
||||
}
|
||||
get min$() {
|
||||
return this.minSubject.asObservable();
|
||||
}
|
||||
get max$() {
|
||||
return this.maxSubject.asObservable();
|
||||
}
|
||||
get disabledDaysOfWeek$() {
|
||||
return this.disableDayOfWeekSubject.asObservable();
|
||||
}
|
||||
|
||||
constructor(private dateAdapter: DateAdapter<TDate>) {}
|
||||
|
||||
nextMonth() {
|
||||
this.setDisplayed(this.dateAdapter.addCalendarMonths(this.displayed, 1));
|
||||
}
|
||||
|
||||
previousMonth() {
|
||||
this.setDisplayed(this.dateAdapter.addCalendarMonths(this.displayed, -1));
|
||||
}
|
||||
|
||||
setSelected(date: TDate, { emit: emitChanged }: SetPropertyOptions = { emit: true }) {
|
||||
if (!this.dateAdapter.isValid(date)) {
|
||||
this.selectedSubject.next(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dateAdapter.compareDate(this.selected, date) !== 0) {
|
||||
this.selectedSubject.next(date);
|
||||
if (emitChanged) {
|
||||
this.selectedChange.emit(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setDisplayed(date: TDate, { emit: emitChanged }: SetPropertyOptions = { emit: true }) {
|
||||
if (!this.dateAdapter.isValid(date)) {
|
||||
this.displayedSubject.next(undefined);
|
||||
return;
|
||||
}
|
||||
|
||||
if (this.dateAdapter.compareDate(this.displayed, date) !== 0) {
|
||||
this.displayedSubject.next(date);
|
||||
if (emitChanged) {
|
||||
this.displayedChange.emit(date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setMin(date: TDate) {
|
||||
if (!!!date && !this.dateAdapter.isValid(date)) {
|
||||
throw new Error('Date is not Valid.');
|
||||
}
|
||||
|
||||
this.minSubject.next(date);
|
||||
}
|
||||
|
||||
setMax(date: TDate) {
|
||||
if (!!!date && !this.dateAdapter.isValid(date)) {
|
||||
throw new Error('Date is not Valid.');
|
||||
}
|
||||
|
||||
this.maxSubject.next(date);
|
||||
}
|
||||
|
||||
onDestroy() {
|
||||
this.selectedSubject.complete();
|
||||
this.displayedSubject.complete();
|
||||
this.selectedChange.complete();
|
||||
this.displayedChange.complete();
|
||||
this.maxSubject.complete();
|
||||
this.minSubject.complete();
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
export interface DisplayDate {
|
||||
year: number;
|
||||
month: number;
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
// start:ng42.barrel
|
||||
export * from './display-date';
|
||||
// end:ng42.barrel
|
||||
@@ -1,13 +0,0 @@
|
||||
<div class="isa-flex isa-align-items-center isa-justify-content-space-between">
|
||||
<button class="isa-btn" (click)="previous()">
|
||||
<span class="icon arrow-left">
|
||||
<lib-icon name="Arrow_left" height="22px"></lib-icon>
|
||||
</span>
|
||||
</button>
|
||||
<strong> {{ monthName$ | async }} {{ yearName$ | async }} </strong>
|
||||
<button class="isa-btn" (click)="next()">
|
||||
<span class="icon arrow-right">
|
||||
<lib-icon name="Arrow_right"></lib-icon>
|
||||
</span>
|
||||
</button>
|
||||
</div>
|
||||
@@ -1,14 +0,0 @@
|
||||
:host {
|
||||
display: block;
|
||||
margin-left: -18px;
|
||||
margin-right: -18px;
|
||||
margin-top: -18px;
|
||||
}
|
||||
|
||||
.isa-btn {
|
||||
padding: 18px;
|
||||
}
|
||||
|
||||
lib-icon {
|
||||
display: flex;
|
||||
}
|
||||
@@ -1,28 +0,0 @@
|
||||
import { Component, OnInit, ChangeDetectionStrategy } from '@angular/core';
|
||||
import { Datepicker } from '../datepicker';
|
||||
import { DateAdapter } from '@isa-ui/core/date';
|
||||
import { map } from 'rxjs/operators';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ui-datepicker-header',
|
||||
templateUrl: 'header.component.html',
|
||||
styleUrls: ['header.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class UiDatepickerHeaderComponent<TDate> implements OnInit {
|
||||
monthName$ = this.datepicker.displayed$.pipe(map((date) => this.dateAdapter.getMonthName(date)));
|
||||
|
||||
yearName$ = this.datepicker.displayed$.pipe(map((date) => this.dateAdapter.getYearName(date)));
|
||||
|
||||
constructor(private datepicker: Datepicker<TDate>, private dateAdapter: DateAdapter<TDate>) {}
|
||||
|
||||
ngOnInit() {}
|
||||
|
||||
next() {
|
||||
this.datepicker.nextMonth();
|
||||
}
|
||||
|
||||
previous() {
|
||||
this.datepicker.previousMonth();
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
// start:ng42.barrel
|
||||
export * from './header.component';
|
||||
// end:ng42.barrel
|
||||
@@ -1,8 +0,0 @@
|
||||
// start:ng42.barrel
|
||||
export * from './datepicker.component';
|
||||
export * from './datepicker.module';
|
||||
export * from './datepicker';
|
||||
export * from './body';
|
||||
export * from './defs';
|
||||
export * from './header';
|
||||
// end:ng42.barrel
|
||||
@@ -34,7 +34,7 @@
|
||||
"rootUrl": "https://isa.paragon-systems.de/print/v1"
|
||||
},
|
||||
"eis": {
|
||||
"rootUrl": "https://filialinformationsystem-integration.paragon-systems.de/eiswebapi/v1"
|
||||
"rootUrl": "https://filialinformationsystem.paragon-systems.de/eiswebapi/v1"
|
||||
}
|
||||
},
|
||||
"remissionModuleOptions": {
|
||||
|
||||
Reference in New Issue
Block a user