Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-analytics-dashboard
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-analytics-dashboard
Commits
afe731cd
Commit
afe731cd
authored
Apr 26, 2016
by
Daniel Friedman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Respond to code review feedback
parent
e6cca75b
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
61 additions
and
7 deletions
+61
-7
analytics_dashboard/static/apps/learners/app/views/root.js
+12
-1
analytics_dashboard/static/apps/learners/app/views/spec/root-spec.js
+7
-0
analytics_dashboard/static/apps/learners/roster/views/filter.js
+13
-6
analytics_dashboard/static/apps/learners/roster/views/spec/roster-spec.js
+29
-0
No files found.
analytics_dashboard/static/apps/learners/app/views/root.js
View file @
afe731cd
...
@@ -15,31 +15,42 @@ define(function (require) {
...
@@ -15,31 +15,42 @@ define(function (require) {
LearnersRootView
=
Marionette
.
LayoutView
.
extend
({
LearnersRootView
=
Marionette
.
LayoutView
.
extend
({
template
:
_
.
template
(
rootTemplate
),
template
:
_
.
template
(
rootTemplate
),
regions
:
{
regions
:
{
error
:
'.learners-error-region'
,
error
:
'.learners-error-region'
,
header
:
'.learners-header-region'
,
header
:
'.learners-header-region'
,
main
:
'.learners-main-region'
main
:
'.learners-main-region'
},
},
childEvents
:
{
childEvents
:
{
appError
:
'onAppError'
,
appError
:
'onAppError'
,
clearError
:
'onClearError'
clearError
:
'onClearError'
,
setFocusToTop
:
'onSetFocusToTop'
},
},
initialize
:
function
(
options
)
{
initialize
:
function
(
options
)
{
this
.
options
=
options
||
{};
this
.
options
=
options
||
{};
},
},
onRender
:
function
()
{
onRender
:
function
()
{
this
.
showChildView
(
'header'
,
new
HeaderView
({
this
.
showChildView
(
'header'
,
new
HeaderView
({
model
:
this
.
options
.
pageModel
model
:
this
.
options
.
pageModel
}));
}));
},
},
onAppError
:
function
(
childView
,
errorMessage
)
{
onAppError
:
function
(
childView
,
errorMessage
)
{
this
.
showChildView
(
'error'
,
new
AlertView
({
this
.
showChildView
(
'error'
,
new
AlertView
({
alertType
:
'error'
,
alertType
:
'error'
,
title
:
errorMessage
title
:
errorMessage
}));
}));
},
},
onClearError
:
function
()
{
onClearError
:
function
()
{
this
.
getRegion
(
'error'
).
empty
();
this
.
getRegion
(
'error'
).
empty
();
},
onSetFocusToTop
:
function
()
{
this
.
$
(
'#learner-app-focusable'
).
focus
();
}
}
});
});
...
...
analytics_dashboard/static/apps/learners/app/views/spec/root-spec.js
View file @
afe731cd
...
@@ -40,5 +40,12 @@ define(function (require) {
...
@@ -40,5 +40,12 @@ define(function (require) {
this
.
rootView
.
triggerMethod
(
'clearError'
,
'This is the error copy'
);
this
.
rootView
.
triggerMethod
(
'clearError'
,
'This is the error copy'
);
expect
(
this
.
rootView
.
$
(
'.learners-error-region'
)).
not
.
toHaveText
(
'This is the error copy'
);
expect
(
this
.
rootView
.
$
(
'.learners-error-region'
)).
not
.
toHaveText
(
'This is the error copy'
);
});
});
it
(
'sets focus on setFocusToTop events'
,
function
()
{
var
childView
=
new
Marionette
.
View
();
this
.
rootView
.
showChildView
(
'main'
,
childView
);
childView
.
triggerMethod
(
'setFocusToTop'
);
expect
(
this
.
rootView
.
$
(
'#learner-app-focusable'
)).
toBeFocused
();
});
});
});
});
});
analytics_dashboard/static/apps/learners/roster/views/filter.js
View file @
afe731cd
...
@@ -51,10 +51,11 @@ define(function (require) {
...
@@ -51,10 +51,11 @@ define(function (require) {
templateHelpers
:
function
()
{
templateHelpers
:
function
()
{
// 'filterValues' is an array of objects, each having a 'name' key
// 'filterValues' is an array of objects, each having a 'name' key
// and a 'displayName' key. 'name' is the canonical name for the
// and a 'displayName' key. 'name' is the name of the filter value
// filter, while 'displayName' is the user-facing representation of
// (e.g. the cohort name when filtering by cohort), while
// the filter which combines the filter with the number of users
// 'displayName' is the user-facing representation of the filter
// belonging to it.
// which combines the filter with the number of users belonging to
// it.
var
catchAllFilterValue
,
var
catchAllFilterValue
,
filterValues
,
filterValues
,
selectedFilterValue
;
selectedFilterValue
;
...
@@ -65,12 +66,18 @@ define(function (require) {
...
@@ -65,12 +66,18 @@ define(function (require) {
numLearners
=
filterPair
[
1
];
numLearners
=
filterPair
[
1
];
return
{
return
{
name
:
name
,
name
:
name
,
displayName
:
_
.
template
(
'<%= name %> (<%= numLearners %>)'
)({
displayName
:
_
.
template
(
// jshint ignore:start
// Translators: 'name' here refers to the name of the filter, while 'numLearners' refers to the number of learners belonging to that filter.
gettext
(
'<%= name %> (<%= numLearners %>)'
)
// jshint ignore:end
)({
name
:
name
,
name
:
name
,
numLearners
:
Utils
.
localizeNumber
(
numLearners
,
0
)
numLearners
:
Utils
.
localizeNumber
(
numLearners
,
0
)
})
})
};
};
})
})
.
sortBy
(
'name'
)
.
value
();
.
value
();
if
(
filterValues
.
length
)
{
if
(
filterValues
.
length
)
{
...
@@ -109,7 +116,7 @@ define(function (require) {
...
@@ -109,7 +116,7 @@ define(function (require) {
$
(
event
.
currentTarget
).
find
(
'option:selected'
).
val
()
$
(
event
.
currentTarget
).
find
(
'option:selected'
).
val
()
);
);
this
.
collection
.
refresh
();
this
.
collection
.
refresh
();
$
(
'#learner-app-focusable'
).
focus
(
);
this
.
triggerMethod
(
'setFocusToTop'
);
}
}
});
});
...
...
analytics_dashboard/static/apps/learners/roster/views/spec/roster-spec.js
View file @
afe731cd
...
@@ -507,6 +507,34 @@ define(function (require) {
...
@@ -507,6 +507,34 @@ define(function (require) {
expect
(
$
(
'option[value="'
+
filterValue
+
'"]'
)).
toBeSelected
();
expect
(
$
(
'option[value="'
+
filterValue
+
'"]'
)).
toBeSelected
();
};
};
it
(
'renders filters in alphabetical order'
,
function
()
{
var
options
,
rosterView
;
rosterView
=
getRosterView
({
courseMetadata
:
{
cohorts
:
{
zebra
:
1
,
antelope
:
2
}
}});
options
=
rosterView
.
$
(
'.learners-filter option'
);
expect
(
options
[
1
]).
toHaveText
(
'antelope (2)'
);
expect
(
options
[
2
]).
toHaveText
(
'zebra (1)'
);
});
it
(
'sets focus after executing a filter'
,
function
()
{
var
rosterView
,
spy
,
cohortFilterView
;
rosterView
=
getRosterView
({
courseMetadata
:
{
cohorts
:
{
mudskipper
:
1
}}});
spy
=
{
onFocusTriggered
:
function
()
{}};
cohortFilterView
=
rosterView
.
controls
.
currentView
.
cohortFilter
.
currentView
;
spyOn
(
cohortFilterView
,
'triggerMethod'
);
expectCanFilterBy
(
'cohort'
,
'mudskipper'
);
expect
(
cohortFilterView
.
triggerMethod
).
toHaveBeenCalledWith
(
'setFocusToTop'
);
});
SpecHelpers
.
withConfiguration
({
SpecHelpers
.
withConfiguration
({
'by cohort'
:
[
'by cohort'
:
[
'cohort'
,
// filter field name
'cohort'
,
// filter field name
...
@@ -560,6 +588,7 @@ define(function (require) {
...
@@ -560,6 +588,7 @@ define(function (require) {
_
.
chain
(
this
.
filterOptions
)
_
.
chain
(
this
.
filterOptions
)
.
pairs
()
.
pairs
()
.
sortBy
(
0
)
// we expect the filter options to appear in alphabetical order
.
zip
(
_
.
rest
(
selectOptions
))
.
zip
(
_
.
rest
(
selectOptions
))
.
each
(
function
(
filterAndSelectOption
)
{
.
each
(
function
(
filterAndSelectOption
)
{
var
filterOption
=
filterAndSelectOption
[
0
],
var
filterOption
=
filterAndSelectOption
[
0
],
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment