From f7d8490e43d61dd99635b8cdb00582b07781cad0 Mon Sep 17 00:00:00 2001 From: "k.triantafyllou" Date: Wed, 19 Jul 2023 19:51:54 +0300 Subject: [PATCH] Stakeholder: Add projectUpdateDate. Input: Add date type. --- monitor/entities/stakeholder.ts | 1 + sharedComponents/input/input.component.ts | 60 +++++++++++++++++------ sharedComponents/input/input.module.ts | 10 +++- 3 files changed, 55 insertions(+), 16 deletions(-) diff --git a/monitor/entities/stakeholder.ts b/monitor/entities/stakeholder.ts index 2fece777..9284ad42 100644 --- a/monitor/entities/stakeholder.ts +++ b/monitor/entities/stakeholder.ts @@ -29,6 +29,7 @@ export class Stakeholder { visibility: Visibility; creationDate: Date = null; updateDate: Date; + projectUpdateDate: Date; /** @warning Use pipe in HTML or StringUtils.getLogoUrl in components */ logoUrl: string; isUpload: boolean = false; diff --git a/sharedComponents/input/input.component.ts b/sharedComponents/input/input.component.ts index 18036a87..64de88d8 100644 --- a/sharedComponents/input/input.component.ts +++ b/sharedComponents/input/input.component.ts @@ -23,6 +23,7 @@ import {properties} from "../../../../environments/environment"; import {ClickEvent} from "../../utils/click/click-outside-or-esc.directive"; import {LayoutService} from "../../dashboard/sharedComponents/sidebar/layout.service"; import {MobileDropdownComponent} from "../../utils/mobile-dropdown/mobile-dropdown.component"; +import {MatDatepicker} from "@angular/material/datepicker"; export type InputType = 'text' @@ -33,7 +34,8 @@ export type InputType = | 'textarea' | 'select' | 'chips' - | 'year-range'; + | 'year-range' + | 'date'; export interface Option { icon?: string, @@ -75,9 +77,9 @@ declare var UIkit;
-
@@ -90,8 +92,8 @@ declare var UIkit; [class.uk-text-truncate]="!focused"> - + @@ -163,8 +165,11 @@ declare var UIkit; maxlength="4" (click)="activeIndex = 1;$event.preventDefault()" [formControl]="getFormByName(yearRange.to.control)">
-
+
{{selectADate}}
+
{{formAsControl.getRawValue() | date: 'dd-MM-yyyy'}}
+ +
@@ -174,8 +179,10 @@ declare var UIkit; (click)="resetSearch($event)"> - @@ -188,15 +195,18 @@ declare var UIkit;
+
+ +
+ uk-dropdown="pos: bottom-justify; mode: none; boundary-align: true;" [attr.boundary]="'#' + id"> @@ -279,7 +289,9 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang /** Year Range Configuration */ @Input() yearRange: YearRange; public activeIndex: 0 | 1 | null = null; - + /** Date Configuration*/ + @Input() selectADate: string = 'Select a date'; + public selectedDate: Date; @Input() visibleRows: number = -1; @Input() extendEnter: () => void = null; @Output() focusEmitter: EventEmitter = new EventEmitter(); @@ -299,9 +311,11 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang private subscriptions: any[] = []; @ViewChild('inputBox') inputBox: ElementRef; @ViewChild('optionBox') optionBox: ElementRef; + @ViewChild('calendarBox') calendarBox: ElementRef; @ViewChild('mobileDropdown') mobileDropdown: MobileDropdownComponent; @ViewChild('searchInput') searchInput: ElementRef; @ViewChildren('chip') chips: QueryList; + @ViewChild('datepicker') datepicker: MatDatepicker; @Input() set placeholder(placeholder: string | Placeholder) { @@ -570,6 +584,9 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang let validator = this.formControl.validator({} as AbstractControl); this.required = (validator && validator.required); } + if(this.type === 'date') { + this.selectedDate = this.formAsControl.getRawValue()?new Date(this.formAsControl.getRawValue()):null; + } this.subscriptions.push(this.formControl.valueChanges.subscribe(value => { if (this.formControl.enabled) { if(this.type !== 'year-range') { @@ -589,6 +606,9 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang this.open(true); } } + if (this.type === 'date') { + this.selectedDate = value?new Date(value):null; + } } if ((this.value && value && this.value !== value) || (!this.value && value) || this.value && !value) { this.valueChange.emit(this.formControl.value); @@ -737,7 +757,7 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang this.searchInput.nativeElement.focus(); this.activeElement.next(this.chips.last); } - if (this.selectArrow) { + if (this.selectArrow || this.datepicker) { this.open(!this.opened); } else if (this.type !== 'autocomplete' || this.showOptionsOnEmpty || !this.formControl.value) { this.open(true); @@ -776,6 +796,13 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang UIkit.dropdown(this.optionBox.nativeElement).hide(); this.focused = false; } + } else if(this.calendarBox) { + if (this.opened) { + UIkit.dropdown(this.calendarBox.nativeElement).show(); + } else { + UIkit.dropdown(this.calendarBox.nativeElement).hide(); + this.focused = false; + } } else if(this.mobileDropdown) { if(this.opened) { this.mobileDropdown.open(); @@ -813,4 +840,9 @@ export class InputComponent implements OnInit, OnDestroy, AfterViewInit, OnChang } } } + + dateChanged(event: Date) { + this.focus(false); + this.formAsControl.setValue(event.getTime()); + } } diff --git a/sharedComponents/input/input.module.ts b/sharedComponents/input/input.module.ts index d332485a..fea6cc2c 100644 --- a/sharedComponents/input/input.module.ts +++ b/sharedComponents/input/input.module.ts @@ -1,10 +1,13 @@ import {NgModule} from '@angular/core'; import {InputComponent} from "./input.component"; -import {SharedModule} from "../../../openaireLibrary/shared/shared.module"; +import {SharedModule} from "../../shared/shared.module"; import {IconsModule} from "../../utils/icons/icons.module"; import {SafeHtmlPipeModule} from "../../utils/pipes/safeHTMLPipe.module"; import {ClickModule} from "../../utils/click/click.module"; import {MobileDropdownModule} from "../../utils/mobile-dropdown/mobile-dropdown.module"; +import {MatDatepickerModule} from "@angular/material/datepicker"; +import {MatNativeDateModule} from "@angular/material/core"; +import {MatInputModule} from "@angular/material/input"; @NgModule({ imports: [ @@ -12,7 +15,10 @@ import {MobileDropdownModule} from "../../utils/mobile-dropdown/mobile-dropdown. IconsModule, SafeHtmlPipeModule, ClickModule, - MobileDropdownModule + MobileDropdownModule, + MatDatepickerModule, + MatNativeDateModule, + MatInputModule ], exports: [ InputComponent