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 {
...
@@ -59,7 +59,6 @@ export class DegreePlanEffects {
@
Effect
()
@
Effect
()
init$
=
this
.
actions$
.
pipe
(
init$
=
this
.
actions$
.
pipe
(
ofType
(
ROOT_EFFECTS_INIT
),
ofType
(
ROOT_EFFECTS_INIT
),
// Load the list of degree plans and data used by all degree plans.
// Load the list of degree plans and data used by all degree plans.
flatMap
(()
=>
{
flatMap
(()
=>
{
const
activeTermCodes
=
this
.
api
const
activeTermCodes
=
this
.
api
...
@@ -72,7 +71,6 @@ export class DegreePlanEffects {
...
@@ -72,7 +71,6 @@ export class DegreePlanEffects {
activeTermCodes
,
activeTermCodes
,
});
});
}),
}),
// Load data specific to the primary degree plan.
// Load data specific to the primary degree plan.
flatMap
(({
allDegreePlans
,
subjects
,
activeTermCodes
})
=>
{
flatMap
(({
allDegreePlans
,
subjects
,
activeTermCodes
})
=>
{
const
savedForLaterCourses
=
this
.
loadSavedForLaterCourses
(
subjects
);
const
savedForLaterCourses
=
this
.
loadSavedForLaterCourses
(
subjects
);
...
@@ -93,7 +91,6 @@ export class DegreePlanEffects {
...
@@ -93,7 +91,6 @@ export class DegreePlanEffects {
subjects
:
of
(
subjects
),
subjects
:
of
(
subjects
),
});
});
}),
}),
map
(
payload
=>
{
map
(
payload
=>
{
const
allTerms
=
payload
.
visibleTerms
.
map
(
term
=>
term
.
termCode
);
const
allTerms
=
payload
.
visibleTerms
.
map
(
term
=>
term
.
termCode
);
const
currentIndex
=
allTerms
.
indexOf
(
payload
.
activeTermCodes
[
0
]);
const
currentIndex
=
allTerms
.
indexOf
(
payload
.
activeTermCodes
[
0
]);
...
@@ -105,12 +102,10 @@ export class DegreePlanEffects {
...
@@ -105,12 +102,10 @@ export class DegreePlanEffects {
return
{
...
payload
,
expandedYears
};
return
{
...
payload
,
expandedYears
};
}),
}),
map
(
map
(
payload
=>
payload
=>
new
InitialLoadSuccess
({
...
INITIAL_DEGREE_PLANNER_STATE
,
...
payload
}),
new
InitialLoadSuccess
({
...
INITIAL_DEGREE_PLANNER_STATE
,
...
payload
}),
),
),
catchError
(
error
=>
{
catchError
(
error
=>
{
return
of
(
return
of
(
new
PlanError
({
new
PlanError
({
...
@@ -125,9 +120,7 @@ export class DegreePlanEffects {
...
@@ -125,9 +120,7 @@ export class DegreePlanEffects {
@
Effect
()
@
Effect
()
switch
$
=
this
.
actions$
.
pipe
(
switch
$
=
this
.
actions$
.
pipe
(
ofType
<
SwitchPlan
>
(
PlanActionTypes
.
SwitchPlan
),
ofType
<
SwitchPlan
>
(
PlanActionTypes
.
SwitchPlan
),
withLatestFrom
(
this
.
store$
.
select
(
getDegreePlannerState
)),
withLatestFrom
(
this
.
store$
.
select
(
getDegreePlannerState
)),
flatMap
(([
action
,
state
])
=>
{
flatMap
(([
action
,
state
])
=>
{
const
visibleDegreePlan
=
state
.
allDegreePlans
.
find
(
plan
=>
{
const
visibleDegreePlan
=
state
.
allDegreePlans
.
find
(
plan
=>
{
return
plan
.
roadmapId
===
action
.
payload
.
newVisibleRoadmapId
;
return
plan
.
roadmapId
===
action
.
payload
.
newVisibleRoadmapId
;
...
@@ -145,15 +138,12 @@ export class DegreePlanEffects {
...
@@ -145,15 +138,12 @@ export class DegreePlanEffects {
visibleTerms
,
visibleTerms
,
});
});
}),
}),
map
(
payload
=>
new
SwitchPlanSuccess
(
payload
)),
map
(
payload
=>
new
SwitchPlanSuccess
(
payload
)),
tap
(
state
=>
{
tap
(
state
=>
{
const
touchedPlan
=
state
.
payload
.
visibleDegreePlan
.
name
;
const
touchedPlan
=
state
.
payload
.
visibleDegreePlan
.
name
;
const
message
=
`Switched to
${
touchedPlan
}
`
;
const
message
=
`Switched to
${
touchedPlan
}
`
;
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
}),
}),
catchError
(
error
=>
{
catchError
(
error
=>
{
return
of
(
return
of
(
new
PlanError
({
new
PlanError
({
...
@@ -168,16 +158,13 @@ export class DegreePlanEffects {
...
@@ -168,16 +158,13 @@ export class DegreePlanEffects {
@
Effect
()
@
Effect
()
MakePlanPrimary$
=
this
.
actions$
.
pipe
(
MakePlanPrimary$
=
this
.
actions$
.
pipe
(
ofType
<
MakePlanPrimary
>
(
PlanActionTypes
.
MakePlanPrimary
),
ofType
<
MakePlanPrimary
>
(
PlanActionTypes
.
MakePlanPrimary
),
withLatestFrom
(
this
.
store$
.
select
(
getDegreePlannerState
)),
withLatestFrom
(
this
.
store$
.
select
(
getDegreePlannerState
)),
filter
(([
_
,
state
])
=>
state
.
visibleDegreePlan
!==
undefined
),
filter
(([
_
,
state
])
=>
state
.
visibleDegreePlan
!==
undefined
),
// Get term data for the degree plan specified by the roadmap ID.
// Get term data for the degree plan specified by the roadmap ID.
flatMap
(([
_action
,
state
])
=>
{
flatMap
(([
_action
,
state
])
=>
{
const
{
roadmapId
,
name
}
=
state
.
visibleDegreePlan
as
DegreePlan
;
const
{
roadmapId
,
name
}
=
state
.
visibleDegreePlan
as
DegreePlan
;
return
this
.
api
.
updatePlan
(
roadmapId
,
name
,
true
);
return
this
.
api
.
updatePlan
(
roadmapId
,
name
,
true
);
}),
}),
// // Wrap data in an Action for dispatch
// // Wrap data in an Action for dispatch
map
(
response
=>
{
map
(
response
=>
{
if
(
response
===
1
)
{
if
(
response
===
1
)
{
...
@@ -186,6 +173,19 @@ export class DegreePlanEffects {
...
@@ -186,6 +173,19 @@ export class DegreePlanEffects {
return
new
MakePlanPrimaryFailure
();
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
()
@
Effect
()
...
@@ -206,7 +206,7 @@ export class DegreePlanEffects {
...
@@ -206,7 +206,7 @@ export class DegreePlanEffects {
return
new
ChangePlanNameSuccess
({
roadmapId
,
newName
});
return
new
ChangePlanNameSuccess
({
roadmapId
,
newName
});
}),
}),
tap
(()
=>
{
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
});
this
.
snackBar
.
open
(
message
,
undefined
,
{
duration
:
2000
});
}),
}),
catchError
(()
=>
{
catchError
(()
=>
{
...
@@ -221,9 +221,22 @@ export class DegreePlanEffects {
...
@@ -221,9 +221,22 @@ export class DegreePlanEffects {
ofType
<
CreatePlan
>
(
PlanActionTypes
.
CreatePlan
),
ofType
<
CreatePlan
>
(
PlanActionTypes
.
CreatePlan
),
flatMap
(
action
=>
{
flatMap
(
action
=>
{
const
{
name
,
primary
}
=
action
.
payload
;
const
{
name
,
primary
}
=
action
.
payload
;
return
this
.
api
return
this
.
api
.
createDegreePlan
(
name
,
primary
).
pipe
(
.
createDegreePlan
(
name
,
primary
)
map
(
newPlan
=>
new
CreatePlanSuccess
({
newPlan
})),
.
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 {
...
@@ -232,9 +245,18 @@ export class DegreePlanEffects {
ofType
<
DeletePlan
>
(
PlanActionTypes
.
DeletePlan
),
ofType
<
DeletePlan
>
(
PlanActionTypes
.
DeletePlan
),
flatMap
(
action
=>
{
flatMap
(
action
=>
{
const
{
roadmapId
}
=
action
.
payload
;
const
{
roadmapId
}
=
action
.
payload
;
return
this
.
api
return
this
.
api
.
deleteDegreePlan
(
roadmapId
).
pipe
(
.
deleteDegreePlan
(
roadmapId
)
map
(()
=>
new
DeletePlanSuccess
({
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