-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #38 from codeplaysoftware/add-update-digest
Add What's New/Digest Functionality & Storage Updates
- Loading branch information
Showing
43 changed files
with
1,759 additions
and
250 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/app/pages/changed/change-start-date-popup/change-start-date.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<header> | ||
<div> | ||
<span class="material-symbols-outlined popup-icon">event</span> | ||
<h1>Set Start Date</h1> | ||
|
||
@if (noLastVisit()) { | ||
<h2>You've not been here before.</h2> | ||
} | ||
|
||
<h2>Please set a start date that we can use to determine what has changed.</h2> | ||
</div> | ||
</header> | ||
|
||
<main> | ||
<article> | ||
<div> | ||
<input type="date" | ||
value="{{ startDate() | date: 'yyyy-MM-dd' }}" | ||
(change)="onDateChanged($event)" /> | ||
</div> | ||
@if (errorMessage(); as message) { | ||
<div class="error" [innerHTML]="message"></div> | ||
} | ||
</article> | ||
<footer> | ||
<a class="button centered cancel" (click)="onClose()"> | ||
<span class="material-symbols-outlined">close</span> Close | ||
</a> | ||
</footer> | ||
</main> |
37 changes: 37 additions & 0 deletions
37
src/app/pages/changed/change-start-date-popup/change-start-date.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
:host { | ||
@media screen and (min-width: 800px) { | ||
width: 100vw !important; | ||
} | ||
|
||
header { | ||
h2 { | ||
font-weight: normal; | ||
opacity: .7; | ||
} | ||
|
||
div { | ||
text-align: center; | ||
} | ||
} | ||
|
||
input { | ||
display: block; | ||
width: 100%; | ||
padding: 1.5rem; | ||
border: var(--border-default); | ||
border-radius: var(--border-radius); | ||
background-color: transparent; | ||
color: var(--text-color); | ||
font-family: inherit; | ||
font-size: 1.2rem; | ||
} | ||
|
||
.error { | ||
background-color: #ffd2d2; | ||
padding: 2rem; | ||
text-align: center; | ||
color: red; | ||
margin-top: 1rem; | ||
border-radius: var(--border-radius); | ||
} | ||
} |
106 changes: 106 additions & 0 deletions
106
src/app/pages/changed/change-start-date-popup/change-start-date.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* | ||
* Copyright (C) Codeplay Software Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { ChangeDetectionStrategy, Component, Inject, signal, Signal, WritableSignal } from '@angular/core'; | ||
import { DatePipe, NgOptimizedImage } from '@angular/common'; | ||
import { PopupReference } from '../../../shared/components/popup/popup.service'; | ||
|
||
@Component({ | ||
selector: 'st-change-start-date', | ||
standalone: true, | ||
templateUrl: './change-start-date.component.html', | ||
imports: [ | ||
NgOptimizedImage, | ||
DatePipe | ||
], | ||
styleUrls: [ | ||
'../../../shared/components/popup/layouts/large-top-header.scss', | ||
'./change-start-date.component.scss' | ||
], | ||
changeDetection: ChangeDetectionStrategy.OnPush | ||
}) | ||
export class ChangeStartDateComponent { | ||
protected readonly noLastVisit: Signal<boolean>; | ||
protected readonly errorMessage: WritableSignal<string> = signal(''); | ||
protected readonly startDate: Signal<Date>; | ||
|
||
/** | ||
* Constructor. | ||
* @param popupReference | ||
*/ | ||
constructor( | ||
@Inject('POPUP_DATA') protected popupReference: PopupReference, | ||
) { | ||
if (this.popupReference.data) { | ||
this.noLastVisit = signal(false); | ||
this.startDate = signal(new Date(this.popupReference.data)); | ||
} else { | ||
this.noLastVisit = signal(true); | ||
|
||
const dateDateTime = new Date(); | ||
dateDateTime.setMonth(dateDateTime.getMonth() - 5); | ||
dateDateTime.setDate(1); | ||
|
||
// Set a default date, just in case we can't load one successfully | ||
this.startDate = signal(dateDateTime); | ||
} | ||
} | ||
|
||
/** | ||
* Called when the date selector changes. | ||
* @param event | ||
*/ | ||
onDateChanged(event: any) { | ||
const selectedDate: any = new Date(event.target.value); | ||
const currentDate = new Date(); | ||
|
||
if (isNaN(selectedDate)) { | ||
this.errorMessage.set('Please ensure that the date is in a correct format.'); | ||
return; | ||
} | ||
|
||
if (ChangeStartDateComponent.monthDifference(selectedDate, currentDate) > 6) { | ||
this.errorMessage.set('You cannot pick a date that is more than six months from the current date.'); | ||
return; | ||
} | ||
|
||
if (selectedDate > currentDate) { | ||
this.errorMessage.set('You cannot set a date that is in the future, please choose an earlier date.'); | ||
return; | ||
} | ||
|
||
this.popupReference.close(selectedDate); | ||
} | ||
|
||
/** | ||
* Called when the user clicks on the cancel button. | ||
*/ | ||
onClose() { | ||
this.popupReference.close(this.startDate()); | ||
} | ||
|
||
/** | ||
* Calculate the month difference between two dates. | ||
* @param dateFrom | ||
* @param dateTo | ||
*/ | ||
public static monthDifference(dateFrom: Date, dateTo: Date): number { | ||
return dateTo.getMonth() - dateFrom.getMonth() + | ||
(12 * (dateTo.getFullYear() - dateFrom.getFullYear())) | ||
} | ||
} |
Oops, something went wrong.