UI: Notification request setting scheduler for later
This commit is contained in:
parent
8174a97926
commit
29c1c57413
@ -50,6 +50,23 @@
|
|||||||
requiredText="notification.targets-required"
|
requiredText="notification.targets-required"
|
||||||
[entityType]="entityType.NOTIFICATION_TARGET">
|
[entityType]="entityType.NOTIFICATION_TARGET">
|
||||||
</tb-entity-list>
|
</tb-entity-list>
|
||||||
|
<section formGroupName="additionalConfig" class="additional-config-group">
|
||||||
|
<mat-slide-toggle formControlName="enabled" class="toggle">
|
||||||
|
{{ 'notification.scheduler-later' | translate }}
|
||||||
|
</mat-slide-toggle>
|
||||||
|
<div *ngIf="notificationRequestForm.get('additionalConfig.enabled').value" fxLayout="column">
|
||||||
|
<tb-timezone-select userTimezoneByDefault
|
||||||
|
required
|
||||||
|
formControlName="timezone">
|
||||||
|
</tb-timezone-select>
|
||||||
|
<mat-form-field>
|
||||||
|
<mat-label translate>notification.time</mat-label>
|
||||||
|
<mat-datetimepicker-toggle [for]="startTimePicker" matPrefix></mat-datetimepicker-toggle>
|
||||||
|
<mat-datetimepicker #startTimePicker type="datetime" openOnFocus="true"></mat-datetimepicker>
|
||||||
|
<input required matInput fxFlex formControlName="time" [min]="minDate()" [matDatetimepicker]="startTimePicker">
|
||||||
|
</mat-form-field>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
</form>
|
</form>
|
||||||
</mat-step>
|
</mat-step>
|
||||||
<mat-step>
|
<mat-step>
|
||||||
|
|||||||
@ -19,6 +19,19 @@
|
|||||||
:host-context(.tb-fullscreen-dialog .mat-dialog-container) {
|
:host-context(.tb-fullscreen-dialog .mat-dialog-container) {
|
||||||
width: 640px;
|
width: 640px;
|
||||||
|
|
||||||
|
.additional-config-group {
|
||||||
|
padding: 16px 16px 4px;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
border: 1px solid rgba(0, 0, 0, 0.12);
|
||||||
|
border-radius: 6px;
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
|
||||||
|
.toggle {
|
||||||
|
margin-bottom: 12px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
.preview-group {
|
.preview-group {
|
||||||
padding: 16px;
|
padding: 16px;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
|
|||||||
@ -30,7 +30,8 @@ import { BreakpointObserver } from '@angular/cdk/layout';
|
|||||||
import { MatStepper } from '@angular/material/stepper';
|
import { MatStepper } from '@angular/material/stepper';
|
||||||
import { StepperOrientation, StepperSelectionEvent } from '@angular/cdk/stepper';
|
import { StepperOrientation, StepperSelectionEvent } from '@angular/cdk/stepper';
|
||||||
import { MediaBreakpoints } from '@shared/models/constants';
|
import { MediaBreakpoints } from '@shared/models/constants';
|
||||||
import { map } from 'rxjs/operators';
|
import { map, takeUntil } from 'rxjs/operators';
|
||||||
|
import { getCurrentTime } from '@shared/models/time/time.models';
|
||||||
|
|
||||||
export interface RequestNotificationDialogData {
|
export interface RequestNotificationDialogData {
|
||||||
request?: NotificationRequest;
|
request?: NotificationRequest;
|
||||||
@ -73,7 +74,24 @@ export class RequestNotificationDialogComponent extends
|
|||||||
|
|
||||||
this.notificationRequestForm = this.fb.group({
|
this.notificationRequestForm = this.fb.group({
|
||||||
templateId: [null, Validators.required],
|
templateId: [null, Validators.required],
|
||||||
targets: [null, Validators.required]
|
targets: [null, Validators.required],
|
||||||
|
additionalConfig: this.fb.group({
|
||||||
|
enabled: [false],
|
||||||
|
timezone: [{value: '', disabled: true}, Validators.required],
|
||||||
|
time: [{value: 0, disabled: true}, Validators.required]
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
this.notificationRequestForm.get('additionalConfig.enabled').valueChanges.pipe(
|
||||||
|
takeUntil(this.destroy$)
|
||||||
|
).subscribe(value => {
|
||||||
|
if (value) {
|
||||||
|
this.notificationRequestForm.get('additionalConfig.timezone').enable({emitEvent: false});
|
||||||
|
this.notificationRequestForm.get('additionalConfig.time').enable({emitEvent: false});
|
||||||
|
} else {
|
||||||
|
this.notificationRequestForm.get('additionalConfig.timezone').disable({emitEvent: false});
|
||||||
|
this.notificationRequestForm.get('additionalConfig.time').disable({emitEvent: false});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (data.isAdd) {
|
if (data.isAdd) {
|
||||||
@ -149,8 +167,14 @@ export class RequestNotificationDialogComponent extends
|
|||||||
}
|
}
|
||||||
|
|
||||||
private get notificationFormValue(): NotificationRequest {
|
private get notificationFormValue(): NotificationRequest {
|
||||||
const formValue: NotificationRequest = deepTrim(this.notificationRequestForm.value);
|
const formValue = deepTrim(this.notificationRequestForm.value);
|
||||||
formValue.additionalConfig = {sendingDelayInSec: 0};
|
let delay = 0;
|
||||||
|
if (formValue.additionalConfig.enabled) {
|
||||||
|
delay = (this.notificationRequestForm.value.additionalConfig.time.valueOf() - this.minDate().valueOf()) / 1000;
|
||||||
|
}
|
||||||
|
formValue.additionalConfig = {
|
||||||
|
sendingDelayInSec: delay > 0 ? delay : 0
|
||||||
|
};
|
||||||
return formValue;
|
return formValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,4 +189,8 @@ export class RequestNotificationDialogComponent extends
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
minDate(): Date {
|
||||||
|
return new Date(getCurrentTime(this.notificationRequestForm.get('additionalConfig.timezone').value).format('lll'));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2742,6 +2742,7 @@
|
|||||||
"review": "Review",
|
"review": "Review",
|
||||||
"rules": "Rules",
|
"rules": "Rules",
|
||||||
"platform-users": "Platform users",
|
"platform-users": "Platform users",
|
||||||
|
"scheduler-later": "Schedule for later",
|
||||||
"search-notification": "Search notification",
|
"search-notification": "Search notification",
|
||||||
"search-targets": "Search recipients",
|
"search-targets": "Search recipients",
|
||||||
"search-templates": "Search templates",
|
"search-templates": "Search templates",
|
||||||
@ -2789,6 +2790,7 @@
|
|||||||
},
|
},
|
||||||
"templates": "Templates",
|
"templates": "Templates",
|
||||||
"text": "Text",
|
"text": "Text",
|
||||||
|
"time": "Time",
|
||||||
"type": "Type",
|
"type": "Type",
|
||||||
"unread": "Unread",
|
"unread": "Unread",
|
||||||
"view-all": "View all",
|
"view-all": "View all",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user