Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adapt mobile code to ionic 7 #125

Merged
merged 2 commits into from
Jul 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/moodle-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
env:
DB: ${{ matrix.database }}
MOODLE_BRANCH: ${{ matrix.moodle-branch }}
MUSTACHE_IGNORE_NAMES: 'mobile_view_checklist.mustache'
MUSTACHE_IGNORE_NAMES: 'mobile_view_checklist_*.mustache'

- name: PHP Lint
if: ${{ always() }}
Expand Down
3 changes: 2 additions & 1 deletion classes/output/mobile.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public static function mobile_course_view($args) {
require_once($CFG->dirroot.'/mod/checklist/locallib.php');

$args = (object)$args;
$versionname = $args->appversioncode >= 44000 ? 'latest' : 'ionic5';
$cm = get_coursemodule_from_id('checklist', $args->cmid);

require_login($args->courseid, false, $cm, true, true);
Expand All @@ -51,7 +52,7 @@ public static function mobile_course_view($args) {
'templates' => [
[
'id' => 'main',
'html' => $OUTPUT->render_from_template('mod_checklist/mobile_view_checklist', $data),
'html' => $OUTPUT->render_from_template("mod_checklist/mobile_view_checklist_$versionname", $data),
],
],
'javascript' => file_get_contents($CFG->dirroot.'/mod/checklist/mobileapp/mobile.js'),
Expand Down
27 changes: 18 additions & 9 deletions styles_app.css
Original file line number Diff line number Diff line change
Expand Up @@ -31,34 +31,43 @@
.checklist-indent-10 {
--padding-start: 108px;
}
.checklist-colour-red ion-label .checklist-item-label {
.checklist-colour-red ion-label .checklist-item-label,
.checklist-colour-red ion-checkbox .checklist-item-label {
--color: #ca3120;
}
html.dark .checklist-colour-red ion-label .checklist-item-label {
html.dark .checklist-colour-red ion-label .checklist-item-label,
html.dark .checklist-colour-red ion-checkbox .checklist-item-label {
--color: #d55a4d;
}
.checklist-colour-orange ion-label .checklist-item-label {
.checklist-colour-orange ion-label .checklist-item-label,
.checklist-colour-orange ion-checkbox .checklist-item-label {
--color: #f98012;
}
.checklist-colour-green ion-label .checklist-item-label {
.checklist-colour-green ion-label .checklist-item-label,
.checklist-colour-green ion-checkbox .checklist-item-label {
--color: #357a32;
}
html.dark .checklist-colour-green ion-label .checklist-item-label {
html.dark .checklist-colour-green ion-label .checklist-item-label,
html.dark .checklist-colour-green ion-checkbox .checklist-item-label {
--color: #5d955b;
}
.checklist-colour-purple ion-label .checklist-item-label {
.checklist-colour-purple ion-label .checklist-item-label,
.checklist-colour-purple ion-checkbox .checklist-item-label {
--color: #c400f0;
}
html.dark .checklist-colour-purple ion-label .checklist-item-label {
html.dark .checklist-colour-purple ion-label .checklist-item-label,
html.dark .checklist-colour-purple ion-checkbox .checklist-item-label {
--color: #d61fff;
}
.checklist-item ion-label .checklist-item-label {
.checklist-item ion-label .checklist-item-label,
.checklist-item ion-checkbox .checklist-item-label {
display: flex;
flex-direction: row;
align-items: center;
font-size: 16px;
}
.checklist-item ion-label .checklist-item-label.item-heading {
.checklist-item ion-label .checklist-item-label.item-heading,
.checklist-item ion-checkbox .checklist-item-label.item-heading {
font-weight: bold;
}
.checklist-url-button {
Expand Down
146 changes: 146 additions & 0 deletions templates/mobile_view_checklist_latest.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
{{!
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/>.
}}
{{!
@template mod_checklist/mobile_view_checklist

Display the checklist activity in the mobile app

Context variables required for this template:
* intro, cmid, courseid, items

Example context (json):
{
"intro": "Description",
"cmid": 1,
"courseid": 1,
"showteachermark": false,
"showcheckbox": false,
"progress": 50,
"progressall": 50,
"showrequired": true,
"items": [
{
"itemid": 1,
"text": "Item text",
"indent": 1,
"colour": "red",
"duetime": 1704788067,
"showitemmark": true,
"showitemcheckbox": true,
"isoverdue": false,
"isheading": false,
"isoptional": false,
"checkedstudent": true,
"teachermarktext": "Teacher states that you have completed this",
"teachermarkimage": "SITEURL/theme/image.php...",
"url": "https://moodle.org/",
"disabled": false,
"comment": {
"commentby": 5,
"text": "Comment text",
"commentbyname": "Jeffery Sanders",
"commentbyurl": "SITEURL/user\/view.php..."
},
"studentcomment": {
"studentid": 6,
"text": "Comment text",
"studentname": "Barbara Gardner",
"studenturl": "SITEURL/user\/view.php..."
}
}
]
}
}}
{{=<% %>=}}
<div class="list-item-limited-width">
<core-course-module-info [module]="module" description="<% intro %>" component="mod_checklist" componentId="<% cmid %>"
[courseId]="courseId">
</core-course-module-info>

<%#showrequired%>
<ion-item>
<ion-label>
<p class="item-heading">{{'plugin.mod_checklist.percentcomplete'|translate}}:</p>
<core-progress-bar progress="<% progress %>"></core-progress-bar>
</ion-label>
</ion-item>
<%/showrequired%>
<ion-item>
<ion-label>
<p class="item-heading">{{'plugin.mod_checklist.percentcompleteall'|translate}}:</p>
<core-progress-bar progress="<% progressall %>"></core-progress-bar>
</ion-label>
</ion-item>


<ion-list>
<%#items%>
<!-- Template to render the content of an item. -->
<ng-template #itemTemplate<% itemid %>>
<p class="checklist-item-label <%#isheading%>item-heading<%/isheading%> <%#isoptional%>item-dimmed<%/isoptional%>">
<%#showitemmark%>
<img class="checklist-teachermark" src="<% teachermarkimage %>" alt="<% teachermarktext %>" core-external-content>
<%/showitemmark%>
<span><% text %></span>
<%#url%>
<ion-button fill="clear" href="<% url %>" core-link class="checklist-url-button" [showBrowserWarning]="false"
[attr.aria-label]="'plugin.mod_checklist.linktourl' | translate" >
<ion-icon name="fas-up-right-from-square" slot="icon-only" aria-hidden="true"></ion-icon>
</ion-button>
<%/url%>
</p>
<%#duetime%>
<p class="checklist-duetime text-<%^isoverdue%>success<%/isoverdue%><%#isoverdue%>danger<%/isoverdue%>">
<em>{{ <% duetime %> * 1000 | coreFormatDate:"core.strftimedate" }}</em>
</p>
<%/duetime%>
<%#comment%>
<p class="checklist-comment checklist-teachercomment">
<%#commentbyurl%>
<a href="<% commentbyurl %>" core-link [capture]="true"><% commentbyname %></a>:
<%/commentbyurl%>
<% text %>
</p>
<%/comment%>
<%#studentcomment%>
<p class="checklist-comment checklist-studentcomment">
<a href="<% studenturl %>" core-link [capture]="true"><% studentname %></a>:
<% text %>
</p>
<%/studentcomment%>
</ng-template>

<ion-item class="ion-text-wrap checklist-item checklist-indent-<% indent %> checklist-colour-<% colour %>">
<%^showitemcheckbox%>
<ion-label>
<ng-container *ngTemplateOutlet="itemTemplate<% itemid %>" />
</ion-label>
<%/showitemcheckbox%>
<%#showitemcheckbox%>
<ion-checkbox checked="<%#checkedstudent%>true<%/checkedstudent%><%^checkedstudent%>false<%/checkedstudent%>"
disabled="<%#disabled%>true<%/disabled%><%^disabled%>false<%/disabled%>"
(ionChange)="saveChanges(<% cmid %>, <% itemid %>, $event)">

<ng-container *ngTemplateOutlet="itemTemplate<% itemid %>" />

</ion-checkbox>
<%/showitemcheckbox%>
</ion-item>
<%/items%>
</ion-list>

</div>
Loading