Merge branch 'MDL-64855-37_block_myoverview_course_category_display' of https://githu...
authorDavid Monllaó <davidm@moodle.com>
Mon, 15 Apr 2019 05:50:45 +0000 (07:50 +0200)
committerDavid Monllaó <davidm@moodle.com>
Mon, 15 Apr 2019 05:50:45 +0000 (07:50 +0200)
1  2 
blocks/myoverview/amd/build/view.min.js
blocks/myoverview/amd/src/view.js
blocks/myoverview/templates/view-list.mustache
blocks/myoverview/templates/view-summary.mustache

index 661f018,3ce966a..90bf195
Binary files differ
@@@ -90,7 -90,8 +90,8 @@@ function
          return {
              display: courseRegion.attr('data-display'),
              grouping: courseRegion.attr('data-grouping'),
-             sort: courseRegion.attr('data-sort')
+             sort: courseRegion.attr('data-sort'),
+             displaycategories: courseRegion.attr('data-displaycategories'),
          };
      };
  
              currentTemplate = TEMPLATES.COURSES_SUMMARY;
          }
  
+         // Delete the course category if it is not to be displayed
+         if (filters.displaycategories != 'on') {
+             coursesData.courses = coursesData.courses.map(function(course) {
+                 delete course.coursecategory;
+                 return course;
+             });
+         }
          if (coursesData.courses.length) {
              return Templates.render(currentTemplate, {
-                 courses: coursesData.courses
+                 courses: coursesData.courses,
              });
          } else {
              var nocoursesimg = root.find(Selectors.courseView.region).attr('data-nocoursesimg');
                          }
  
                          // Set the last page to either the current or next page
 -                        if (loadedPages[currentPage].courses.length < pageData.limit) {
 +                        if (loadedPages[currentPage].courses.length < pageData.limit || !remainingCourses.length) {
                              lastPage = currentPage;
                              actions.allItemsLoaded(currentPage);
                          } else if (loadedPages[currentPage + 1] != undefined
          data-region="course-content"
          data-course-id="{{{id}}}">
          <div class="row-fluid">
 -            <div class="{{#hasprogress}}col-md-6 span6{{/hasprogress}}{{^hasprogress}}col-md-11 span11{{/hasprogress}} d-flex align-items-center">
 +            <div class="{{#hasprogress}}col-md-6{{/hasprogress}}{{^hasprogress}}col-md-11 col-md-11{{/hasprogress}} d-flex align-items-center">
                  <a href="{{viewurl}}" class="coursename">
                      <div class="text-muted muted d-flex" style="flex-flow:wrap;">
                          <span class="sr-only">
                              {{#str}}aria:coursecategory, core_course{{/str}}
                          </span>
-                         <div>{{{coursecategory}}}</div>
+                         {{#displaycategories}}
+                             <div>{{{coursecategory}}}</div>
+                         {{/displaycategories}}
                          {{#showshortname}}
                          <div class="pl-1 pr-1">|</div>
                          <span class="sr-only">
                  </a>
              </div>
              {{#hasprogress}}
 -            <div class="col-md-5 span5 pt-1">
 +            <div class="col-md-5 pt-1">
                  {{> block_myoverview/progress-bar}}
              </div>
              {{/hasprogress}}
 -            <div class="col-md-1 span1 p-0 d-flex">
 +            <div class="col-md-1 p-0 d-flex">
                  {{> block_myoverview/course-action-menu }}
              </div>
          </div>
  }}
  <div role="list">
  {{#courses}}
 -    <div class="course-summaryitem m-b-1 p-2" role="listitem"
 +    <div class="course-summaryitem mb-1 p-2" role="listitem"
          data-region="course-content"
          data-course-id="{{{id}}}">
          <div class="d-flex">
              <a href="{{viewurl}}" tabindex="-1">
 -                <div class="summaryimage rounded-circle m-r-1" style='background-image: url("{{{courseimage}}}");'>
 +                <div class="summaryimage rounded-circle mr-1" style='background-image: url("{{{courseimage}}}");'>
                      <span class="sr-only">{{#str}}aria:courseimage, core_course{{/str}}</span>
                  </div>
              </a>
@@@ -54,7 -54,9 +54,9 @@@
                              <span class="sr-only">
                                  {{#str}}aria:coursecategory, core_course{{/str}}
                              </span>
-                             <div>{{{coursecategory}}}</div>
+                             {{#displaycategories}}
+                                 <div>{{{coursecategory}}}</div>
+                             {{/displaycategories}}
                              {{#showshortname}}
                              <div class="pl-1 pr-1">|</div>
                              <span class="sr-only">