Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
course-search-enroll-fe
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Scott Berg
course-search-enroll-fe
Commits
5cd71a9d
Commit
5cd71a9d
authored
6 years ago
by
Paulina Nogal
Browse files
Options
Downloads
Patches
Plain Diff
Additional messaging for user actions
parent
24e155e7
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/app/degree-planner/store/effects/plan.effects.ts
+42
-20
42 additions, 20 deletions
src/app/degree-planner/store/effects/plan.effects.ts
with
42 additions
and
20 deletions
src/app/degree-planner/store/effects/plan.effects.ts
+
42
−
20
View file @
5cd71a9d
...
...
@@ -59,7 +59,6 @@ export class DegreePlanEffects {
@
Effect
()
init$
=
this
.
actions$
.
pipe
(
ofType
(
ROOT_EFFECTS_INIT
),
// Load the list of degree plans and data used by all degree plans.
flatMap
(()
=>
{
const
activeTermCodes
=
this
.
api
...
...
@@ -72,7 +71,6 @@ export class DegreePlanEffects {
activeTermCodes
,
});
}),
// Load data specific to the primary degree plan.
flatMap
(({
allDegreePlans
,
subjects
,
activeTermCodes
})
=>
{
const
savedForLaterCourses
=
this
.
loadSavedForLaterCourses
(
subjects
);
...
...
@@ -93,7 +91,6 @@ export class DegreePlanEffects {
subjects
:
of
(
subjects
),
});
}),
map
(
payload
=>
{
const
allTerms
=
payload
.
visibleTerms
.
map
(
term
=>
term
.
termCode
);
const
currentIndex
=
allTerms
.
indexOf
(
payload
.
activeTermCodes
[
0
]);
...
...
@@ -105,12 +102,10 @@ export class DegreePlanEffects {
return
{
...
payload
,
expandedYears
};
}),
map
(
payload
=>
new
InitialLoadSuccess
({
...
INITIAL_DEGREE_PLANNER_STATE
,
...
payload
}),
),
catchError
(
error
=>
{
return
of
(
new
PlanError
({
...
...
@@ -125,9 +120,7 @@ export class DegreePlanEffects {
@
Effect
()
switch
$
=
this
.
actions$
.
pipe
(
ofType
<
SwitchPlan
>
(
PlanActionTypes
.
SwitchPlan
),
withLatestFrom
(
this
.
store$
.
select
(
getDegreePlannerState
)),
flatMap
(([
action
,
state
])
=>
{
const
visibleDegreePlan
=
state
.
allDegreePlans
.
find
(
plan
=>
{
return
plan
.
roadmapId
===
action
.
payload
.
newVisibleRoadmapId
;
...
...
@@ -145,15 +138,12 @@ export class DegreePlanEffects {
visibleTerms
,
});
}),
map
(
payload
=>
new
SwitchPlanSuccess
(
payload
)),
tap
(
state
=>
{
const
touchedPlan
=
state
.
payload
.
visibleDegreePlan
.
name
;
const
message
=
`Switched to
${
touchedPlan
}
`
;
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
}),
catchError
(
error
=>
{
return
of
(
new
PlanError
({
...
...
@@ -168,16 +158,13 @@ export class DegreePlanEffects {
@
Effect
()
MakePlanPrimary$
=
this
.
actions$
.
pipe
(
ofType
<
MakePlanPrimary
>
(
PlanActionTypes
.
MakePlanPrimary
),
withLatestFrom
(
this
.
store$
.
select
(
getDegreePlannerState
)),
filter
(([
_
,
state
])
=>
state
.
visibleDegreePlan
!==
undefined
),
// Get term data for the degree plan specified by the roadmap ID.
flatMap
(([
_action
,
state
])
=>
{
const
{
roadmapId
,
name
}
=
state
.
visibleDegreePlan
as
DegreePlan
;
return
this
.
api
.
updatePlan
(
roadmapId
,
name
,
true
);
}),
// // Wrap data in an Action for dispatch
map
(
response
=>
{
if
(
response
===
1
)
{
...
...
@@ -186,6 +173,19 @@ export class DegreePlanEffects {
return
new
MakePlanPrimaryFailure
();
}
}),
tap
(
state
=>
{
const
message
=
'
This plan has been set as the primary plan
'
;
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
}),
catchError
(
error
=>
{
return
of
(
new
PlanError
({
message
:
'
Unable to make this plan primary
'
,
duration
:
2000
,
error
,
}),
);
}),
);
@
Effect
()
...
...
@@ -206,7 +206,7 @@ export class DegreePlanEffects {
return
new
ChangePlanNameSuccess
({
roadmapId
,
newName
});
}),
tap
(()
=>
{
const
message
=
`Plan
name
has been
chang
ed to
${
newName
}
`
;
const
message
=
`Plan has been
renam
ed to
${
newName
}
`
;
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
}),
catchError
(()
=>
{
...
...
@@ -221,9 +221,22 @@ export class DegreePlanEffects {
ofType
<
CreatePlan
>
(
PlanActionTypes
.
CreatePlan
),
flatMap
(
action
=>
{
const
{
name
,
primary
}
=
action
.
payload
;
return
this
.
api
.
createDegreePlan
(
name
,
primary
)
.
pipe
(
map
(
newPlan
=>
new
CreatePlanSuccess
({
newPlan
})));
return
this
.
api
.
createDegreePlan
(
name
,
primary
).
pipe
(
map
(
newPlan
=>
new
CreatePlanSuccess
({
newPlan
})),
tap
(()
=>
{
const
message
=
`New plan has been created`
;
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
}),
catchError
(
error
=>
{
return
of
(
new
PlanError
({
message
:
'
Unable to create new plan
'
,
duration
:
2000
,
error
,
}),
);
}),
);
}),
);
...
...
@@ -232,9 +245,18 @@ export class DegreePlanEffects {
ofType
<
DeletePlan
>
(
PlanActionTypes
.
DeletePlan
),
flatMap
(
action
=>
{
const
{
roadmapId
}
=
action
.
payload
;
return
this
.
api
.
deleteDegreePlan
(
roadmapId
)
.
pipe
(
map
(()
=>
new
DeletePlanSuccess
({
roadmapId
})));
return
this
.
api
.
deleteDegreePlan
(
roadmapId
).
pipe
(
map
(()
=>
new
DeletePlanSuccess
({
roadmapId
})),
catchError
(
error
=>
{
return
of
(
new
PlanError
({
message
:
'
Unable to delete plan
'
,
duration
:
2000
,
error
,
}),
);
}),
);
}),
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment