Commit d572f8b8 by Waheed Ahmed

Added filters on dashboard.

ECOM-7649
parent d6d27cbb
...@@ -1415,6 +1415,35 @@ class DashboardTests(TestCase): ...@@ -1415,6 +1415,35 @@ class DashboardTests(TestCase):
site = Site.objects.first() site = Site.objects.first()
self.assertEqual(response.context['site_name'], site.name) self.assertEqual(response.context['site_name'], site.name)
def test_filters(self):
"""
Verify that filters available on dashboard.
"""
course_team_user = UserFactory()
course_run = self._create_course_assign_role(
CourseRunStateChoices.Review, self.user1, PublisherUserRole.ProjectCoordinator
)
factories.CourseUserRoleFactory(
course=course_run.course, role=PublisherUserRole.CourseTeam, user=course_team_user
)
course_run.course_run_state.owner_role = PublisherUserRole.CourseTeam
course_run.course_run_state.save()
response = self.client.get(self.page_url)
site = Site.objects.first()
self._assert_filter_counts(response, 'All', 3)
self._assert_filter_counts(response, 'With Course Team', 2)
self._assert_filter_counts(response, 'With {site_name}'.format(site_name=site.name), 1)
def _assert_filter_counts(self, response, expected_label, count):
"""
Assert label and course run count for filters.
"""
self.assertContains(response, expected_label, count=1)
expected_count = '<span class="filter-count">{count}</span>'.format(count=count)
self.assertContains(response, expected_count, count=1)
class ToggleEmailNotificationTests(TestCase): class ToggleEmailNotificationTests(TestCase):
""" Tests for `ToggleEmailNotification` view. """ """ Tests for `ToggleEmailNotification` view. """
......
...@@ -118,7 +118,14 @@ class Dashboard(mixins.LoginRequiredMixin, ListView): ...@@ -118,7 +118,14 @@ class Dashboard(mixins.LoginRequiredMixin, ListView):
context['is_project_coordinator'] = is_project_coordinator_user(self.request.user) context['is_project_coordinator'] = is_project_coordinator_user(self.request.user)
site = Site.objects.first() site = Site.objects.first()
context['site_name'] = 'edX' if 'edx' in site.name else site.name context['site_name'] = 'edX' if 'edx' in site.name.lower() else site.name
context['course_team_count'] = in_progress_course_runs.filter(
course_run_state__owner_role=PublisherUserRole.CourseTeam
).count()
context['internal_user_count'] = in_progress_course_runs.exclude(
course_run_state__owner_role=PublisherUserRole.CourseTeam
).count()
return context return context
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-08 22:45+0500\n" "POT-Creation-Date: 2017-04-10 13:14+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: apps/api/filters.py #: apps/api/filters.py
#, python-brace-format #, python-brace-format
...@@ -2508,6 +2508,7 @@ msgid "" ...@@ -2508,6 +2508,7 @@ msgid ""
msgstr "" msgstr ""
#: templates/publisher/course_run_detail/course_run_detail.html #: templates/publisher/course_run_detail/course_run_detail.html
#: templates/publisher/dashboard/_in_progress.html
msgid "All" msgid "All"
msgstr "" msgstr ""
...@@ -2592,6 +2593,18 @@ msgid "There are no in progress course runs." ...@@ -2592,6 +2593,18 @@ msgid "There are no in progress course runs."
msgstr "" msgstr ""
#: templates/publisher/dashboard/_in_progress.html #: templates/publisher/dashboard/_in_progress.html
msgid "Filter by"
msgstr ""
#: templates/publisher/dashboard/_in_progress.html
msgid "With Course Team"
msgstr ""
#: templates/publisher/dashboard/_in_progress.html
msgid "With"
msgstr ""
#: templates/publisher/dashboard/_in_progress.html
#: templates/publisher/dashboard/_published.html #: templates/publisher/dashboard/_published.html
msgid "Start" msgid "Start"
msgstr "" msgstr ""
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-08 22:45+0500\n" "POT-Creation-Date: 2017-04-10 13:14+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
#: static/js/catalogs-change-form.js #: static/js/catalogs-change-form.js
msgid "Preview" msgid "Preview"
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-08 22:45+0500\n" "POT-Creation-Date: 2017-04-10 13:14+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: apps/api/filters.py #: apps/api/filters.py
...@@ -2948,6 +2948,7 @@ msgstr "" ...@@ -2948,6 +2948,7 @@ msgstr ""
"Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#" "Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αмєт, ¢σηѕє¢тєтυя α#"
#: templates/publisher/course_run_detail/course_run_detail.html #: templates/publisher/course_run_detail/course_run_detail.html
#: templates/publisher/dashboard/_in_progress.html
msgid "All" msgid "All"
msgstr "Àll Ⱡ'σяєм#" msgstr "Àll Ⱡ'σяєм#"
...@@ -3051,6 +3052,18 @@ msgstr "" ...@@ -3051,6 +3052,18 @@ msgstr ""
"¢σηѕє¢тєтυ#" "¢σηѕє¢тєтυ#"
#: templates/publisher/dashboard/_in_progress.html #: templates/publisher/dashboard/_in_progress.html
msgid "Filter by"
msgstr "Fïltér ßý Ⱡ'σяєм ιρѕυм ∂σł#"
#: templates/publisher/dashboard/_in_progress.html
msgid "With Course Team"
msgstr "Wïth Çöürsé Téäm Ⱡ'σяєм ιρѕυм ∂σłσя ѕιт αм#"
#: templates/publisher/dashboard/_in_progress.html
msgid "With"
msgstr "Wïth Ⱡ'σяєм ι#"
#: templates/publisher/dashboard/_in_progress.html
#: templates/publisher/dashboard/_published.html #: templates/publisher/dashboard/_published.html
msgid "Start" msgid "Start"
msgstr "Stärt Ⱡ'σяєм ιρѕ#" msgstr "Stärt Ⱡ'σяєм ιρѕ#"
......
...@@ -7,14 +7,14 @@ msgid "" ...@@ -7,14 +7,14 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2017-04-08 22:45+0500\n" "POT-Creation-Date: 2017-04-10 13:14+0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
"Language: \n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Language: \n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
#: static/js/catalogs-change-form.js #: static/js/catalogs-change-form.js
......
...@@ -62,8 +62,31 @@ $(document).ready(function() { ...@@ -62,8 +62,31 @@ $(document).ready(function() {
"oLanguage": { "sEmptyTable": gettext("No course run previews are currently available.") } "oLanguage": { "sEmptyTable": gettext("No course run previews are currently available.") }
}); });
$('.data-table-in-progress').DataTable({ var inProgressTable = $('.data-table-in-progress').DataTable({
"autoWidth": false "autoWidth": false
}); });
$('.btn-filter').click( function (e) {
var searchValue = 'In Review|In Draft',
currentFilterColumn = $(this).data('filter-column'),
oldFilterColumn = $('.btn-filter.active').data('filter-column');
e.preventDefault();
$('.btn-filter').removeClass('active');
$(this).addClass('active');
if (currentFilterColumn == -1) {
applyCustomFilter(inProgressTable, oldFilterColumn, '');
} else {
if (oldFilterColumn != -1) {
// Clear previous filter if applied otherwise search will return no record.
applyCustomFilter(inProgressTable, oldFilterColumn, '');
}
applyCustomFilter(inProgressTable, currentFilterColumn, searchValue);
}
});
}); });
function applyCustomFilter(dataTable, columnIndex, value) {
dataTable.columns(columnIndex).search(value, true, false).draw();
}
...@@ -60,3 +60,40 @@ ...@@ -60,3 +60,40 @@
border-radius: 5px; border-radius: 5px;
margin-top: 10px; margin-top: 10px;
} }
$btn-filter-active-color: rgba(54, 54, 54, 1);
$btn-filter-color: rgba(228, 228, 228, 1);
.btn-filter {
@include margin-right(5px);
border-color: $btn-filter-color;
background: $btn-filter-color;
padding-bottom: 5px;
padding-top: 5px;
color: black;
.filter-count {
@include padding(1px, 6px, 1px, 6px);
@include margin-left(5px);
background: white;
border-radius: 4px;
color: black;
}
&:hover,
&.is-hovered,
&:focus,
&.is-focused {
border-color: $btn-filter-color;
background: $btn-filter-color;
color: black;
}
&.active,
&.is-pressed,
&.is-active {
border-color: $btn-filter-active-color;
background: $btn-filter-active-color;
color: white;
}
}
...@@ -14,5 +14,7 @@ ...@@ -14,5 +14,7 @@
margin-bottom: 20px; margin-bottom: 20px;
} }
.filters {
margin-bottom: 10px;
}
} }
...@@ -3,6 +3,18 @@ ...@@ -3,6 +3,18 @@
<p>{% trans "There are no in progress course runs." %}</p> <p>{% trans "There are no in progress course runs." %}</p>
{% else %} {% else %}
<table class="data-table-in-progress display" cellspacing="0" width="100%"> <table class="data-table-in-progress display" cellspacing="0" width="100%">
<div class="filters">
<strong>{% trans "Filter by" %}:</strong>
<button type="button" class="btn-neutral btn-small btn-filter active" data-filter-column="-1">{% trans "All" %}
<span class="filter-count">{{ in_progress_count }}</span>
</button>
<button type="button" class="btn-neutral btn-small btn-filter" data-filter-column="5">{% trans "With Course Team" %}
<span class="filter-count">{{ course_team_count }}</span>
</button>
<button type="button" class="btn-neutral btn-small btn-filter" data-filter-column="6">{% trans "With" %} {{ site_name }}
<span class="filter-count">{{ internal_user_count }}</span>
</button>
</div>
<thead> <thead>
<tr> <tr>
<th role="button"> <th role="button">
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment