Skip to content
Snippets Groups Projects
Commit 3fec3d81 authored by jvanboxtel@wisc.edu's avatar jvanboxtel@wisc.edu
Browse files

ROENROLL-1792

parent 5067dda7
No related branches found
No related tags found
No related merge requests found
Showing
with 123 additions and 19 deletions
......@@ -5,7 +5,16 @@ export enum UserPreferencesActionTypes {
UpdateUserPreferences = '[User Preferences] Update',
}
export enum NotificationActionTypes {
DismissAlert = '[UI] Dismiss alert',
}
export class UpdateUserPreferences implements Action {
public readonly type = UserPreferencesActionTypes.UpdateUserPreferences;
constructor(public payload: Partial<UserPreferences>) {}
}
export class DismissAlert implements Action {
public readonly type = NotificationActionTypes.DismissAlert;
constructor(public payload: { key: string }) {}
}
......@@ -13,3 +13,12 @@ export class DisclaimerAlert implements Alert {
constructor(public callback: Alert['callback']) {}
}
export class DarsDisclaimerAlert implements Alert {
public readonly key = 'disclaimerAlert';
public readonly title = 'This is a planning tool Dars.';
public readonly message =
'If you have questions about your plan or degree, please contact your advisor.';
constructor(public callback: Alert['callback']) {}
}
......@@ -3,4 +3,5 @@ export interface UserPreferences {
degreePlannerSelectedPlan?: number;
degreePlannerHasDismissedDisclaimer?: boolean;
degreePlannerHasDismissedIEWarning?: boolean;
darsHasDismissedDisclaimer?: boolean;
}
......@@ -20,6 +20,7 @@
<!-- Main DARS Content -->
<div id="dars-main">
<cse-alert-container></cse-alert-container>
<h2 class="mat-h1">Completed Audit Requests</h2>
<div id="dars-header-bar">
......
......@@ -7,6 +7,7 @@ import { DarsAuditComponent } from './audit/audit.component';
import { DarsMetadataTableComponent } from './metadata-table/metadata-table.component';
import { NewAuditOptionsComponent } from './dars-view/new-audit-options/new-audit-options.component';
import { MatStepperModule } from '@angular/material';
import { AlertContainerComponent } from '../shared/components/alert-container/alert-container.component';
@NgModule({
imports: [
......
import { DARSState } from '@app/dars/store/state';
import { Action } from '@ngrx/store';
import { AuditMetadata } from '../models/audit-metadata';
import { Audit } from '../models/audit';
......@@ -5,6 +6,7 @@ import { Audit } from '../models/audit';
export enum DarsActionTypes {
ErrorLoadingMetadata = '[DARS] Error Loading Metadata',
StartLoadingMetadata = '[DARS] Start Loading Metadata',
DoneLoadingMetadata = '[DARS] Done Loading Metadata',
ErrorLoadingAudit = '[DARS] Error Loading Audit',
AddAuditMetadata = '[DARS] Add Audit Metadata',
StartLoadingAudit = '[DARS] Start Loading Audit',
......@@ -21,6 +23,11 @@ export class StartLoadingMetadata implements Action {
public readonly type = DarsActionTypes.StartLoadingMetadata;
}
export class DoneLoadingMetadata implements Action {
public readonly type = DarsActionTypes.DoneLoadingMetadata;
constructor(public payload: DARSState) {}
}
export class ErrorLoadingAudit implements Action {
public readonly type = DarsActionTypes.ErrorLoadingAudit;
constructor(public payload: { message: string }) {}
......
import { visibleAudit } from './selectors';
import { UpdateUserPreferences } from './../../core/actions';
import { GlobalState } from '@app/core/state';
import { Store } from '@ngrx/store';
import { forkJoinWithKeys } from '@app/degree-planner/shared/utils';
import { Injectable } from '@angular/core';
import { Actions, Effect, ofType } from '@ngrx/effects';
import { DarsActionTypes } from '@app/dars/store/actions';
import * as darsActions from '@app/dars/store/actions';
import { flatMap, map, catchError } from 'rxjs/operators';
import { flatMap, map, catchError, switchMap } from 'rxjs/operators';
import { DarsApiService } from '../services/api.service';
import { of } from 'rxjs';
import { Alert, DarsDisclaimerAlert } from '@app/core/models/alert';
import { DegreePlannerApiService } from '@app/degree-planner/services/api.service';
import { INITIAL_DARS_STATE } from './state';
@Injectable()
export class DARSEffects {
constructor(private actions$: Actions, private api: DarsApiService) {}
constructor(
private actions$: Actions,
private api: DarsApiService,
private degreeAPI: DegreePlannerApiService,
private store$: Store<GlobalState>,
) {}
@Effect()
load$ = this.actions$.pipe(
ofType(DarsActionTypes.StartLoadingMetadata),
flatMap(() => this.api.getAudits()),
map(metadata => new darsActions.AddAuditMetadata({ metadata })),
catchError(() => {
return of(
new darsActions.ErrorLoadingMetadata({
message: 'Unable to load audit metadata. Please try again',
flatMap(() => {
return forkJoinWithKeys({
metadata: this.api.getAudits(),
userPreferences: this.degreeAPI.getUserPreferences(),
});
}),
flatMap(({ metadata, userPreferences }) => {
const alerts: Alert[] = [];
if (userPreferences.darsHasDismissedDisclaimer !== true) {
alerts.push(
new DarsDisclaimerAlert(() => {
this.store$.dispatch(
new UpdateUserPreferences({
darsHasDismissedDisclaimer: true,
}),
);
}),
);
}
return forkJoinWithKeys({
metadata: of(metadata),
visibleAudit: of({}),
alerts: of(alerts),
}).pipe(
switchMap(payload => {
return [
new darsActions.AddAuditMetadata({ metadata }),
new UpdateUserPreferences(userPreferences),
];
}),
);
}),
// catchError(() => {
// return of(
// new darsActions.ErrorLoadingMetadata({
// message: 'Unable to load audit metadata. Please try again',
// }),
// );
// }),
);
}
import { Alert } from './../../core/models/alert';
import { AuditMetadata } from '../models/audit-metadata';
import { Audit } from '../models/audit';
......@@ -11,9 +12,11 @@ export interface DARSState {
| { status: 'NotLoaded' }
| { status: 'Loading'; metadata: AuditMetadata }
| { status: 'Loaded'; metadata: AuditMetadata; audit: Audit };
alerts: Alert[];
}
export const INITIAL_DARS_STATE: DARSState = {
metadata: { status: 'Loading' },
visibleAudit: { status: 'NotLoaded' },
alerts: [],
};
......@@ -10,7 +10,7 @@ import { DragDropModule } from '@angular/cdk/drag-drop';
import { RemoveCourseConfirmDialogComponent } from './dialogs/remove-course-confirm-dialog/remove-course-confirm-dialog.component';
import { YearContainerComponent } from '@app/degree-planner/year-container/year-container.component';
import { CourseSearchComponent } from '@app/degree-planner/course-search/course-search.component';
import { AlertContainerComponent } from './alert-container/alert-container.component';
import { AlertContainerComponent } from '../shared/components/alert-container/alert-container.component';
import { EffectsModule } from '@ngrx/effects';
import { DegreePlanEffects } from './store/effects/plan.effects';
import { NoteEffects } from './store/effects/note.effects';
......@@ -38,7 +38,7 @@ import { ErrorEffects } from './store/effects/error.effects';
NotesDialogComponent,
RemoveCourseConfirmDialogComponent,
YearContainerComponent,
AlertContainerComponent,
// AlertContainerComponent,
CourseSearchComponent,
],
entryComponents: [NotesDialogComponent, RemoveCourseConfirmDialogComponent],
......
......@@ -16,7 +16,7 @@ export enum UIActionTypes {
OpenSidenav = '[UI] Open Sidenav',
CloseSidenav = '[UI] Close Sidenav',
DismissAlert = '[UI] Dismiss Disclaimer Alert',
// DismissAlert = '[UI] Dismiss Disclaimer Alert',
UpdateUserPreferences = '[UI] Update User Preferences',
......@@ -66,10 +66,10 @@ export class CloseSidenav implements Action {
public readonly type = UIActionTypes.CloseSidenav;
}
export class DismissAlert implements Action {
public readonly type = UIActionTypes.DismissAlert;
constructor(public payload: { key: string }) {}
}
// export class DismissAlert implements Action {
// public readonly type = UIActionTypes.DismissAlert;
// constructor(public payload: { key: string }) {}
// }
export class AddAcademicYear implements Action {
public readonly type = UIActionTypes.AddAcademicYear;
......
......@@ -6,6 +6,7 @@ import * as planActions from '@app/degree-planner/store/actions/plan.actions';
import * as courseActions from '@app/degree-planner/store/actions/course.actions';
import * as noteActions from '@app/degree-planner/store/actions/note.actions';
import * as uiActions from '@app/degree-planner/store/actions/ui.actions';
import * as globalActions from '@app/core/actions';
import { SavedForLaterCourse } from '@app/core/models/saved-for-later-course';
import { DegreePlan } from '@app/core/models/degree-plan';
import { Year, YearMapping } from '@app/core/models/year';
......@@ -41,7 +42,7 @@ type SupportedActions =
| planActions.DeletePlanSuccess
| uiActions.ExpandAcademicYear
| uiActions.CollapseAcademicYear
| uiActions.DismissAlert
| globalActions.DismissAlert
| uiActions.OpenCourseSearch
| uiActions.CloseCourseSearch
| uiActions.ToggleCourseSearch
......@@ -143,7 +144,7 @@ export function degreePlannerReducer(
return newState;
}
case uiActions.UIActionTypes.DismissAlert: {
case globalActions.NotificationActionTypes.DismissAlert: {
const keyToRemove = action.payload.key;
const newAlerts = state.alerts.filter(({ key }) => key !== keyToRemove);
return { ...state, alerts: newAlerts };
......
......@@ -4,7 +4,7 @@ import { GlobalState } from '@app/core/state';
import * as selectors from '@app/degree-planner/store/selectors';
import { Alert } from '@app/core/models/alert';
import { Observable } from 'rxjs';
import { DismissAlert } from '../store/actions/ui.actions';
import { DismissAlert } from '@app/core/actions';
@Component({
selector: 'cse-alert-container',
......
import { AlertContainerComponent } from './components/alert-container/alert-container.component';
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
......@@ -85,7 +86,13 @@ const directives = [ClickStopPropagationDirective];
@NgModule({
imports: [modules],
exports: [modules, pipes, directives, CourseDetailsComponent],
exports: [
modules,
pipes,
directives,
CourseDetailsComponent,
AlertContainerComponent,
],
entryComponents: [ConfirmDialogComponent, PromptDialogComponent],
declarations: [
pipes,
......@@ -97,6 +104,7 @@ const directives = [ClickStopPropagationDirective];
IE11WarningDialogComponent,
ConfirmDialogComponent,
PromptDialogComponent,
AlertContainerComponent,
],
})
export class SharedModule {}
[
{
"darsJobId": "abc123",
"darsAuditRunDate": "2019-02-04T20:41:31Z",
"sisEmplId": "string",
"darsInstitutionCode": "L&S",
"darsInstitutionCodeDescription": "Letters & Science, College of",
"darsDegreeProgramCode": "BA 916",
"darsStatusOfDegreeAuditRequest": "new",
"darsHonorsOptionCode": "Z",
"darsHonorsOptionDescription": "Omit Major, Include Liberal Arts",
"darsDegreeAuditReportId": 0,
"darsCatalogYearTerm": "20121",
"whichEnrolledCoursesIncluded": "previous",
"degreePlannerPlanName": "string"
}
]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment