Skip to content

Commit d1dd6df

Browse files
committed
MOBILE-2008 courses: Sort courses using sortorder field
1 parent 08b6294 commit d1dd6df

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-3
lines changed

www/core/components/courses/controllers/coursecategories.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ angular.module('mm.core.courses')
2121
* @ngdoc controller
2222
* @name mmCourseCategoriesCtrl
2323
*/
24-
.controller('mmCourseCategoriesCtrl', function($scope, $stateParams, $mmCourses, $mmUtil, $q, $state, $mmSite) {
24+
.controller('mmCourseCategoriesCtrl', function($scope, $stateParams, $mmCourses, $mmUtil, $q, $mmSite) {
2525

2626
var categoryId = $stateParams.categoryid || 0;
2727

www/core/components/courses/services/courses.js

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,25 @@ angular.module('mm.core.courses')
307307
};
308308

309309
return site.read('core_course_get_courses_by_field', data, preSets).then(function(courses) {
310-
return courses.courses || $q.reject();
310+
if (courses.courses) {
311+
// Courses will be sorted using sortorder if avalaible.
312+
return courses.courses.sort(function(a, b) {
313+
if (typeof a.sortorder == "undefined" && typeof b.sortorder == "undefined") {
314+
return b.id - a.id;
315+
}
316+
317+
if (typeof a.sortorder == "undefined") {
318+
return 1;
319+
}
320+
321+
if (typeof b.sortorder == "undefined") {
322+
return -1;
323+
}
324+
325+
return b.sortorder - a.sortorder;
326+
});
327+
}
328+
return $q.reject();
311329
});
312330
});
313331
};

www/core/components/courses/templates/courselistitem.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<a class="item item-icon-left item-button-right item-text-wrap" ui-sref="site.mm_viewresult({course: course})" title="{{course.fullname}}">
1+
<a class="item item-icon-left item-button-right item-text-wrap" ui-sref="site.mm_viewresult({course: course})" ng-class="{'item-disabled': course.visible == 0}" title="{{course.fullname}}">
22
<i class="icon ion-ionic"></i>
33
<h2><mm-format-text watch="true">{{course.fullname}}</mm-format-text></h2>
44
<div class="buttons buttons-small">

www/core/scss/styles.scss

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ p.item-text-wrap {
265265
.item.item-disabled,
266266
.platform-android .item.item-disabled {
267267
color: $item-disabled-color;
268+
h2 {
269+
color: $item-disabled-color;
270+
}
268271
}
269272

270273
// Avoid adding too much padding.

0 commit comments

Comments
 (0)