Skip to content

Commit

Permalink
wip - no form control instance attached...
Browse files Browse the repository at this point in the history
  • Loading branch information
vktrrdk committed Sep 11, 2024
1 parent a07116e commit 7996a86
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 50 deletions.
20 changes: 10 additions & 10 deletions src/app/facility_manager/newsmanagement/facility-news.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
export class FacilityNews {
id;
title: string;
posted_at: string;
text: string;
motd: string;
tags: string[];
facility: number;
valid_till: Date;
is_current_motd: boolean;
id
title: string
posted_at: string
text: string
motd: string
tags: string[]
facility: number
expire_at: Date
is_current_motd: boolean

constructor(news?: Partial<FacilityNews>) {
Object.assign(this, news);
Object.assign(this, news)
}
}
71 changes: 35 additions & 36 deletions src/app/facility_manager/newsmanagement/news-manager.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ <h5>Please select the facilities to load news from:</h5>
<br />
In case you also want to send the news as a mail to the users of your facility, please use the mail function
on the <a href="#/facility-manager/facilityProjects">Facility Overview page.</a>
<hr />
When not setting a specific expiry date for this news, the news will be removed from the facility news
section of the de.NBI Cloud website after <strong>one year</strong>.
</c-alert>
</div>
</div>
Expand All @@ -56,7 +59,7 @@ <h5>Please select the facilities to load news from:</h5>
style="cursor: pointer"
(click)="setCurrentNews(news)"
[ngStyle]="{
'border-color': news.id === selectedFacilityNews.id ? '#005aa9' : '#c8ced3'
'border-color': news.id === selectedFacilityNews.id ? '#005aa9' : '#c8ced3',
}"
>
<div
Expand Down Expand Up @@ -100,9 +103,9 @@ <h5>Please select the facilities to load news from:</h5>
</div>
<div class="row">
<div class="text-truncate col" data-toggle="tooltip" *ngIf="news?.motd" data-placement="auto">
<strong>Valid Till: </strong>
<span *ngIf="news?.valid_till">{{ news.valid_till | date: 'YYYY-MM-dd' }}</span>
<span *ngIf="!news?.valid_till">not set</span>
<strong>Expires at: </strong>
<span *ngIf="news?.expire_at">{{ news.expire_at | date: 'YYYY-MM-dd' }}</span>
<span *ngIf="!news?.expire_at">not set</span>
</div>
</div>
<br />
Expand Down Expand Up @@ -162,8 +165,7 @@ <h5>Please select the facilities to load news from:</h5>
id="news_text"
formControlName="text"
name="news_text"
placeholder="e.g. Dear cloud users,
we are happy to inform..."
placeholder="e.g. Dear cloud users, we are happy to inform..."
[class.is-invalid]="
selectedNewsForm.controls['text'].invalid &&
(selectedNewsForm.controls['text'].dirty || selectedNewsForm.controls['text'].touched)
Expand Down Expand Up @@ -203,6 +205,33 @@ <h5>Please select the facilities to load news from:</h5>
</div>
</div>

<div class="form-group my-3">
<label class="col-form-label" for="expire_at">Expiry data</label>
<input
id="expire_at"
type="text"
name="expire_at"
class="form-control"
bsDatepicker
#dp="bsDatepicker"
[bsConfig]="{
adaptivePosition: true,
minDate: today,
dateInputFormat: 'YYYY-MM-DD',
containerClass: 'theme-dark-blue',
}"
formControlName="expire_at"
/>
<button
class="btn input-group-append input-group-text"
(click)="dp.show()"
[attr.aria-expanded]="dp.isOpen"
type="button"
>
<i class="fa fa-clock"></i>
</button>
</div>

<div class="form-group">
<label class="form-check-label" for="facility_news_tags_input">Tags</label>
<ng-select
Expand Down Expand Up @@ -259,36 +288,6 @@ <h5>Please select the facilities to load news from:</h5>
>
</div>
</div>
<div class="form-row my-4" *ngIf="this.motdChecked">
<div class="col-6 my-2">Set Expiry date for MOTD</div>
<div class="input-group col-4">
<div class="input-group-prepend">
<span class="input-group-text">valid till</span>
</div>
<input
type="text"
name="valid_till"
class="form-control"
bsDatepicker
#dp="bsDatepicker"
[bsConfig]="{
adaptivePosition: true,
minDate: today,
dateInputFormat: 'YYYY-MM-DD',
containerClass: 'theme-dark-blue'
}"
formControlName="valid_till"
/>
<button
class="btn input-group-append input-group-text"
(click)="dp.show()"
[attr.aria-expanded]="dp.isOpen"
type="button"
>
<i class="fa fa-clock"></i>
</button>
</div>
</div>
</ng-container>
</div>
<br />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export class NewsManagerComponent implements OnInit, OnDestroy {
title: new UntypedFormControl({ value: this.newFacilityNews.title, disabled: false }, Validators.required),
text: new UntypedFormControl({ value: this.newFacilityNews.text, disabled: false }, Validators.required),
motd: new UntypedFormControl({ value: this.newFacilityNews.motd, disabled: false }),
valid_till: new UntypedFormControl({ value: this.newFacilityNews.valid_till, disabled: false }),
expire_at: new UntypedFormControl({ value: this.newFacilityNews.expire_at, disabled: false }),
entered_tags: new UntypedFormControl({ value: this.newFacilityNews.tags, disabled: false })
})

Expand Down Expand Up @@ -112,7 +112,7 @@ export class NewsManagerComponent implements OnInit, OnDestroy {
news.title = this.selectedNewsForm.controls['title'].value
news.text = this.selectedNewsForm.controls['text'].value
news.motd = this.selectedNewsForm.controls['motd'].value
news.valid_till = this.selectedNewsForm.controls['valid_till'].value
news.expire_at = this.selectedNewsForm.controls['expire_at'].value
news.facility = this.facilityToPost
news.tags = this.selectedFacilityNews.tags
if (document.getElementById(`news_select_${this.facilityToPost}_motd`)['checked']) {
Expand Down Expand Up @@ -164,7 +164,7 @@ export class NewsManagerComponent implements OnInit, OnDestroy {
news.title = this.selectedNewsForm.controls['title'].value
news.text = this.selectedNewsForm.controls['text'].value
news.motd = this.selectedNewsForm.controls['motd'].value
news.valid_till = this.selectedNewsForm.controls['valid_till'].value
news.expire_at = this.selectedNewsForm.controls['expire_at'].value
news.facility = this.facilityToPost
news.tags = this.selectedFacilityNews.tags
if (document.getElementById(`news_select_${this.facilityToPost}_motd`)['checked']) {
Expand Down Expand Up @@ -337,7 +337,7 @@ export class NewsManagerComponent implements OnInit, OnDestroy {
text: new UntypedFormControl({ value: this.selectedFacilityNews.text, disabled: false }, Validators.required),
motd: new UntypedFormControl({ value: this.selectedFacilityNews.motd, disabled: false }),
tag: new UntypedFormControl({ value: this.selectedFacilityNews.tags, disabled: false }),
valid_till: new UntypedFormControl({ value: this.selectedFacilityNews.valid_till, disabled: false }),
expire_at: new UntypedFormControl({ value: this.selectedFacilityNews.expire_at, disabled: false }),
entered_tags: new UntypedFormControl({ value: this.selectedFacilityNews.tags, disabled: false })
})
this.subscription.add(
Expand Down

0 comments on commit 7996a86

Please sign in to comment.