Skip to content
This repository has been archived by the owner on Jul 3, 2024. It is now read-only.

Commit

Permalink
Update #86byt93eq undo button hidden if coursenotes < 2
Browse files Browse the repository at this point in the history
  • Loading branch information
nihaalshaikh committed May 28, 2024
1 parent 9b51aa0 commit 4bde6bf
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion amd/build/coursenotes.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion amd/build/coursenotes.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions amd/src/coursenotes.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,11 @@ export const init = () => {
done: (response) => {
if (response.status) {
noteHistory = response.notes;
if (noteHistory.length > 0) {
if (response.note_count > 1) {
document.getElementById('undo-button').style.display = 'block';
} else {
document.getElementById('undo-button').style.display = 'none';
}
Log.log(response);
Log.log('Note history fetched successfully');
} else {
Log.log('Error fetching note history:', response.message);
Expand Down
3 changes: 2 additions & 1 deletion externallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public static function fetch_notes($courseid): array {
$notelist[] = $note->coursenote;
}

return ['status' => true, 'notes' => $notelist];
return ['status' => true, 'notes' => $notelist, 'note_count' => count($notelist)];
}

/**
Expand All @@ -162,6 +162,7 @@ public static function fetch_notes_returns(): external_single_structure {
'notes' => new external_multiple_structure(
new external_value(PARAM_TEXT, 'Course note')
),
'note_count' => new external_value(PARAM_INT, 'Number of course notes'),
]
);
}
Expand Down
2 changes: 1 addition & 1 deletion templates/block.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
</label>
<input type="submit" value="{{#savebutton}} {{savebutton}} {{/savebutton}}">
<button type="button" id="cancel-button">Cancel</button>
<button type="button" id="undo-button">Undo</button>
<button type="button" id="undo-button"style="display: none;">Undo</button>
</form>
</div>

0 comments on commit 4bde6bf

Please sign in to comment.