Skip to content

Commit

Permalink
Changed the instance status toggle icon
Browse files Browse the repository at this point in the history
  • Loading branch information
prasanna-lmsace committed Sep 26, 2023
1 parent 898150f commit 2e931ad
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 42 deletions.
11 changes: 11 additions & 0 deletions automation/instances/list.php
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,18 @@
})
});
}
// Make the status toggle check and uncheck on click on status update toggle.
var form = document.querySelectorAll(".pulse-instance-status-switch");
form.forEach((switche) => {
switche.addEventListener("click", function(e) {
var form = e.currentTarget.querySelector("input[type=checkbox]");
form.click();
})
});
})');

}

// Finish page output.
Expand Down
15 changes: 9 additions & 6 deletions classes/automation/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -308,9 +308,9 @@ public static function get_templates_tablehelps() {

$templatehelp = [
'help1' => implode(',', array_column($actions, 'icon')),
'help2' => get_string('automationwelcomemsg', 'pulse'),
'help2' => get_string('automation_title', 'pulse'),
'help3' => implode(',', array_column($actions, 'badge')),
'help4' => '<h5 class="template-reference">'.get_string('automationreferencedemo', 'pulse').'</h5>',
'help4' => '<h5 class="template-reference">'.get_string('automation_reference', 'pulse').'</h5>',
'help5' => $OUTPUT->pix_icon('t/edit', \get_string('edit')),
'help6' => $OUTPUT->pix_icon('t/hide', \get_string('hide')),
'help7' => \html_writer::tag('div', '<input type="checkbox" class="custom-control-input" checked>
Expand Down Expand Up @@ -351,13 +351,16 @@ public static function get_instance_tablehelps() {

$templatehelp = [
'help1' => implode(',', array_column($actions, 'icon')),
'help2' => get_string('automationwelcomemsg', 'pulse'),
'help2' => get_string('automationinstance_title', 'pulse'),
'help3' => implode(',', array_column($actions, 'badge')),
'help4' => '<h5 class="template-reference">'.get_string('automationreferencedemo', 'pulse').'</h5>',
'help4' => '<h5 class="template-reference">'.get_string('automationinstance_reference', 'pulse').'</h5>',
'help5' => $OUTPUT->pix_icon('t/edit', \get_string('edit')),
'help6' => $OUTPUT->pix_icon('t/copy', \get_string('copy')),
'help7' => $OUTPUT->pix_icon('i/calendar', \get_string('copy')),
'help8' => $OUTPUT->pix_icon('t/hide', \get_string('hide')),
'help7' => $OUTPUT->pix_icon('i/calendar', \get_string('instancereport', 'pulse')),
'help8' => \html_writer::tag('div', '<input type="checkbox" class="custom-control-input" checked>
<span class="custom-control-label"></span>', ['class' => "custom-control custom-switch"]),
'help9' => $OUTPUT->pix_icon('t/delete', \get_string('delete')),

];

$table = new \html_table();
Expand Down
44 changes: 9 additions & 35 deletions classes/table/auto_instances.php
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,15 @@ public function col_actions($row) {
);

// Show/Hide.
if ($row->status) {
$actions[] = array(
'url' => new \moodle_url($listurl, array('action' => 'disable')),
'icon' => new \pix_icon('t/hide', \get_string('hide')),
'attributes' => array('data-action' => 'hide', 'class' => 'action-hide')
);
} else {
$actions[] = array(
'url' => new \moodle_url($listurl, array('action' => 'enable')),
'icon' => new \pix_icon('t/show', \get_string('show')),
'attributes' => array('data-action' => 'show', 'class' => 'action-show')
);
}
$checked = ($row->status) ? ['checked' => 'checked'] : [];
$checkbox = html_writer::div(
html_writer::empty_tag('input',
['type' => 'checkbox', 'class' => 'custom-control-input'] + $checked
) . html_writer::tag('span', '', ['class' => 'custom-control-label']),
'custom-control custom-switch'
);
$statusurl = new \moodle_url($listurl, array('action' => ($row->status) ? 'disable' : 'enable'));
$actions[] = html_writer::link($statusurl->out(false), $checkbox, ['class' => 'pulse-instance-status-switch']);

// Delete.
$actions[] = array(
Expand All @@ -245,26 +241,4 @@ public function col_actions($row) {
return html_writer::span(join('', $actionshtml), 'menu-item-actions item-actions mr-0');
}

/**
* Create a navbar switch for toggling editing mode.
*
* @param stdclass $row
* @return string Html containing the edit switch
*/
public function edit_switch($row) {
global $PAGE, $OUTPUT;

if ($PAGE->user_allowed_editing()) {

$temp = (object) [
'legacyseturl' => (new moodle_url('/mod/pulse/automation/templates/list.php',
['id' => $row->id, 'sesskey' => sesskey()]))->out(false),
'pagecontextid' => $PAGE->context->id,
'pageurl' => $PAGE->url,
'sesskey' => sesskey(),
'checked' => $row->status
];
return $OUTPUT->render_from_template('pulse/status_switch', $temp);
}
}
}
6 changes: 5 additions & 1 deletion lang/en/pulse.php
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@

// ...Automation templates table instruction help texts.
$string['instruction'] = 'Instructions';
$string['automationwelcomemsg'] = '<b> Welcome message </b>';
$string['automation_title'] = '<b> Template title </b>';
$string['automation_reference'] = 'TEMPLATE_REFERENCE';
$string['automationreferencedemo'] = 'WELCOME_MESSAGE';
$string['automationtemplate_help1'] = 'The icon represents the enabled action(s) in the automation (template). the following actions are available: "Notification", "Assignment". "Membership", "Skills",';
$string['automationtemplate_help2'] = 'The title of the automation <b>template</b>. This should be a generic explanation about what the template is for. It can be changed inline by clicking on the pencil icon.';
Expand All @@ -359,6 +360,8 @@
$string['automationtemplate_help8'] = 'How many automation instances are using the template? The number in brackets indicates the number of disabled instances.';

// ...Automation instance table instruction help texts.
$string['automationinstance_title'] = ' <b> Instance title </b>';
$string['automationinstance_reference'] = 'INSTANCE_REFERENCE';
$string['automationinstance_help1'] = 'The icon represents the enabled action(s) in the automation (template). the following actions are available: "Notification", "Assignment". "Membership", "Skills",';
$string['automationinstance_help2'] = 'The title of the automation <b>instance</b>. This should be a generic explanation about what the template is for. It can be changed inline by clicking on the pencil icon.';
$string['automationinstance_help3'] = 'The pills provide additional improtant information about the automation instance. In this case, it explains that it\'s a notification.';
Expand All @@ -367,6 +370,7 @@
$string['automationinstance_help6'] = 'Duplicate the automation';
$string['automationinstance_help7'] = 'Open the automation queue (in the report builder), which provides information about all the automations that ran.';
$string['automationinstance_help8'] = 'Use this toggle to turn on or off the automation instance locally. This will override the status of the template, i.e. even if the template is turned off, it can be enabled.';
$string['automationinstance_help9'] = 'Click on this icon to delete the automation instance.';

// Pulse automation template profile navigation link.
$string['pulsetemplink'] = "Pulse Automation Template";
Expand Down
36 changes: 36 additions & 0 deletions templates/automation_tabs.mustache
Original file line number Diff line number Diff line change
@@ -1,3 +1,39 @@
{{!
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_pulse/automation_tabs
This template renders the tabs in the pulse automation instance / templates pages
Example context (json):
{
"tabs": [{
"name": "pulse-general",
"title": "General",
"active": "active"
},
{
"name": "pulse-general",
"title": "General"
}
]
}
}}
<ul class="nav nav-tabs mb-3" id="automation-tabs" role="tablist">
{{#tabs}}
<li class="nav-item">
Expand Down

0 comments on commit 2e931ad

Please sign in to comment.