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
ea4cba1f
Commit
ea4cba1f
authored
6 years ago
by
Scott Berg
Browse files
Options
Downloads
Patches
Plain Diff
ROENROLL-1399
parent
72f9e7a9
No related branches found
No related tags found
No related merge requests found
Pipeline
#34124
passed
6 years ago
Stage: build
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/degree-planner/services/api.service.ts
+17
-0
17 additions, 0 deletions
src/app/degree-planner/services/api.service.ts
src/app/degree-planner/store/effects/plan.effects.ts
+43
-2
43 additions, 2 deletions
src/app/degree-planner/store/effects/plan.effects.ts
with
60 additions
and
2 deletions
src/app/degree-planner/services/api.service.ts
+
17
−
0
View file @
ea4cba1f
...
...
@@ -266,6 +266,23 @@ export class DegreePlannerApiService {
);
}
public
getUserPreferences
():
Observable
<
{
[
key
:
string
]:
any
}
>
{
return
this
.
http
.
get
(
`
${
environment
.
apiPlannerUrl
}
/preferences`
,
HTTP_OPTIONS
,
);
}
public
updateUserPreferences
(
payload
:
{
[
key
:
string
]:
any
;
}):
Observable
<
{
[
key
:
string
]:
any
}
>
{
return
this
.
http
.
post
(
`
${
environment
.
apiPlannerUrl
}
/preferences`
,
payload
,
HTTP_OPTIONS
,
);
}
/**
* Helper function for building API endpoint URLs
*/
...
...
This diff is collapsed.
Click to expand it.
src/app/degree-planner/store/effects/plan.effects.ts
+
43
−
2
View file @
ea4cba1f
...
...
@@ -76,13 +76,25 @@ export class DegreePlanEffects {
subjects
:
this
.
api
.
getAllSubjects
(),
subjectDescriptions
:
this
.
api
.
getAllSubjectDescriptions
(),
activeTermCodes
,
userPreferences
:
this
.
api
.
getUserPreferences
(),
});
}),
// Load data specific to the primary degree plan.
flatMap
(
({
allDegreePlans
,
subjects
,
subjectDescriptions
,
activeTermCodes
})
=>
{
({
allDegreePlans
,
subjects
,
subjectDescriptions
,
activeTermCodes
,
userPreferences
,
})
=>
{
const
savedForLaterCourses
=
this
.
loadSavedForLaterCourses
(
subjects
);
const
visibleDegreePlan
=
pickPrimaryDegreePlan
(
allDegreePlans
);
const
visibleDegreePlan
=
userPreferences
.
degreePlannerSelectedPlan
?
pickDegreePlanById
(
userPreferences
.
degreePlannerSelectedPlan
,
allDegreePlans
,
)
:
pickPrimaryDegreePlan
(
allDegreePlans
);
const
visibleYears
=
loadPlanYears
(
this
.
api
,
visibleDegreePlan
.
roadmapId
,
...
...
@@ -166,6 +178,9 @@ export class DegreePlanEffects {
const
touchedPlan
=
state
.
payload
.
visibleDegreePlan
.
name
;
const
message
=
`Switched to
${
touchedPlan
}
`
;
this
.
snackBar
.
open
(
message
,
undefined
,
{});
// Get the users current preferences and update the selected roadmapId
this
.
updateSelectedPlan
(
state
.
payload
.
visibleDegreePlan
.
roadmapId
);
}),
catchError
(
error
=>
{
return
of
(
...
...
@@ -261,6 +276,7 @@ export class DegreePlanEffects {
});
}),
map
(({
newPlan
,
newYears
})
=>
{
this
.
updateSelectedPlan
(
newPlan
.
roadmapId
);
return
new
CreatePlanSuccess
({
newPlan
,
newYears
});
}),
tap
(()
=>
{
...
...
@@ -312,6 +328,23 @@ export class DegreePlanEffects {
}),
);
}
private
updateSelectedPlan
(
roadmapId
:
number
)
{
// Get the users current preferences and update the selected roadmapId
this
.
api
.
getUserPreferences
()
.
toPromise
()
.
then
(
prefs
=>
{
this
.
api
.
updateUserPreferences
({
...
prefs
,
degreePlannerSelectedPlan
:
roadmapId
,
})
.
toPromise
();
// We have to .toPromise this to actually fire the API call
});
}
}
type
SimpleMap
=
{
[
name
:
string
]:
any
};
...
...
@@ -461,3 +494,11 @@ const pickPrimaryDegreePlan = (plans: DegreePlan[]): DegreePlan => {
const
primary
=
plans
.
find
(
plan
=>
plan
.
primary
);
return
primary
?
primary
:
plans
[
0
];
};
const
pickDegreePlanById
=
(
roadmapId
:
number
,
plans
:
DegreePlan
[],
):
DegreePlan
=>
{
const
plan
=
plans
.
find
(
plan
=>
plan
.
roadmapId
===
roadmapId
);
return
plan
?
plan
:
plans
[
0
];
};
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