Part of MDL-55611 epic.
root.one(CustomEvents.events.activate, SELECTORS.PAGE_LINK, function(e, data) {
var page = $(e.target).closest(SELECTORS.PAGE_LINK);
var activePage = root.find(SELECTORS.ACTIVE_PAGE_LINK);
- var isSamePage = page.is(activatePage);
+ var isSamePage = page.is(activePage);
if (!isSamePage) {
root.find(SELECTORS.PAGE_LINK).removeClass('active');
return $this->content;
}
- $renderable = new \block_myoverview\output\course_summary();
-
+ $renderable = new \block_myoverview\output\main();
$renderer = $this->page->get_renderer('block_myoverview');
$this->content = new stdClass();
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Class containing data for courses view in the myoverview block.
+ *
+ * @package block_myoverview
+ * @copyright 2017 Ryan Wyllie <ryan@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace block_myoverview\output;
+defined('MOODLE_INTERNAL') || die();
+
+use renderable;
+use renderer_base;
+use templatable;
+/**
+ * Class containing data for courses view in the myoverview block.
+ *
+ * @copyright 2017 Simey Lameze <simey@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class courses_view implements renderable, templatable {
+
+ /**
+ * Export this data so it can be used as the context for a mustache template.
+ *
+ * @param \renderer_base $output
+ * @return stdClass
+ */
+ public function export_for_template(renderer_base $output) {
+ return [
+ 'past' => [
+ 'pagingbar' => [
+ 'first' => [
+ 'number' => 1,
+ 'page' => '«',
+ 'url' => '#',
+ ],
+ 'last' => [
+ 'number' => 3,
+ 'page' => '»',
+ 'url' => '#',
+ ],
+ 'pages' => [
+ [
+ 'number' => 1,
+ 'page' => 1,
+ 'url' => '#',
+ 'active' => true,
+ ],
+ [
+ 'number' => 2,
+ 'page' => 2,
+ 'url' => '#',
+ ],
+ [
+ 'number' => 3,
+ 'page' => 3,
+ 'url' => '#',
+ ],
+ ]
+ ],
+ ],
+ 'inprogress' => [
+ 'pagingbar' => [
+ 'first' => [
+ 'number' => 1,
+ 'page' => '«',
+ 'url' => '#',
+ ],
+ 'last' => [
+ 'number' => 3,
+ 'page' => '»',
+ 'url' => '#',
+ ],
+ 'pages' => [
+ [
+ 'number' => 1,
+ 'page' => 1,
+ 'url' => '#',
+ 'active' => true,
+ ],
+ [
+ 'number' => 2,
+ 'page' => 2,
+ 'url' => '#',
+ ],
+ [
+ 'number' => 3,
+ 'page' => 3,
+ 'url' => '#',
+ ],
+ ]
+ ],
+ ],
+ 'future' => [
+ 'pagingbar' => [
+ 'first' => [
+ 'number' => 1,
+ 'page' => '«',
+ 'url' => '#',
+ ],
+ 'last' => [
+ 'number' => 3,
+ 'page' => '»',
+ 'url' => '#',
+ ],
+ 'pages' => [
+ [
+ 'number' => 1,
+ 'page' => 1,
+ 'url' => '#',
+ 'active' => true,
+ ],
+ [
+ 'number' => 2,
+ 'page' => 2,
+ 'url' => '#',
+ ],
+ [
+ 'number' => 3,
+ 'page' => 3,
+ 'url' => '#',
+ ],
+ ]
+ ],
+ ],
+ ];
+ }
+}
--- /dev/null
+<?php
+// This file is part of Moodle - http://moodle.org/
+//
+// Moodle is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// Moodle is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
+
+/**
+ * Class containing data for my overview block.
+ *
+ * @package block_myoverview
+ * @copyright 2017 Ryan Wyllie <ryan@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+namespace block_myoverview\output;
+defined('MOODLE_INTERNAL') || die();
+
+use renderable;
+use renderer_base;
+use templatable;
+/**
+ * Class containing data for my overview block.
+ *
+ * @copyright 2017 Simey Lameze <simey@moodle.com>
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+class main implements renderable, templatable {
+
+ /**
+ * Export this data so it can be used as the context for a mustache template.
+ *
+ * @param \renderer_base $output
+ * @return stdClass
+ */
+ public function export_for_template(renderer_base $output) {
+ $coursesummary = new course_summary();
+ $coursesview = new courses_view();
+
+ return [
+ 'courses' => $coursesummary->export_for_template($output),
+ 'coursesview' => $coursesview->export_for_template($output),
+ ];
+ }
+}
/**
* Return the main content for the block overview.
*
- * @param course_summary $coursesummary Course summary.
+ * @param main $main The main renderable
* @return string HTML string
*/
- public function render_course_summary(course_summary $coursesummary) {
- return $this->render_from_template('block_myoverview/main', ['courses' => $coursesummary->export_for_template($this)]);
+ public function render_main(main $main) {
+ return $this->render_from_template('block_myoverview/main', $main->export_for_template($this));
}
}
</div>
<div class="tab-content">
<div class="tab-pane active fade in" id="myoverview_courses_view_in_progress">
- {{< block_myoverview/courses-view-by-status }}
- {{$status}}1{{/status}}
- {{/ block_myoverview/courses-view-by-status }}
+ {{#inprogress}}
+ {{< block_myoverview/courses-view-by-status }}
+ {{$status}}1{{/status}}
+ {{/ block_myoverview/courses-view-by-status }}
+ {{/inprogress}}
</div>
<div class="tab-pane fade" id="myoverview_courses_view_future">
- {{> block_myoverview/courses-view-future }}
+ {{#future}}
+ {{< block_myoverview/courses-view-by-status }}
+ {{$status}}2{{/status}}
+ {{/ block_myoverview/courses-view-by-status }}
+ {{/future}}
</div>
<div class="tab-pane fade" id="myoverview_courses_view_past">
- {{> block_myoverview/courses-view-past }}
+ {{#past}}
+ {{< block_myoverview/courses-view-by-status }}
+ {{$status}}0{{/status}}
+ {{/ block_myoverview/courses-view-by-status }}
+ {{/past}}
</div>
</div>
</div>
{{> block_myoverview/timeline-view }}
</div>
<div role="tabpanel" class="tab-pane fade" id="myoverview_courses_view">
- {{> block_myoverview/courses-view }}
+ {{#coursesview}}
+ {{> block_myoverview/courses-view }}
+ {{/coursesview}}
</div>
</div>
</div>
data-page-number="{{number}}"
data-region="page-link">
{{$item-content}}
- {{page}}
+ {{{page}}}
{{#active}}
<span class="sr-only">{{#str}}currentinparentheses, theme_boost{{/str}}</span>
{{/active}}
{
}
}}
+{{#pagingbar}}
<nav aria-label="{{label}}"
id="{{$id}}paging-bar-{{uniqid}}{{/id}}"
data-region="paging-bar">
PagingBar.registerEventListeners(root);
});
{{/js}}
+{{/pagingbar}}