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

Replace jquery html calls by setHTMLExecuteScripts #4877

Merged
merged 1 commit into from
Aug 8, 2023
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
3 changes: 2 additions & 1 deletion app/javascript/packs/frame.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { Alert, Button, Collapse, Dropdown, Modal, Popover, Tab, Tooltip } from
const bootstrap = { Alert, Button, Collapse, Dropdown, Modal, Popover, Tab, Tooltip };
window.bootstrap = bootstrap;

import { initTooltips, ready } from "utilities.ts";
import { initTooltips, ready, setHTMLExecuteScripts } from "utilities.ts";
import { initClipboard } from "copy";
import { themeState } from "state/Theme";

Expand All @@ -22,6 +22,7 @@ const dodona = window.dodona || {};
dodona.initTooltips = initTooltips;
dodona.ready = ready;
dodona.setTheme = theme => themeState.selectedTheme = theme;
dodona.setHTMLExecuteScripts = setHTMLExecuteScripts;
window.dodona = dodona;

// Initialize clipboard.js
Expand Down
2 changes: 1 addition & 1 deletion app/views/activity_read_states/index.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#read-states-table-wrapper").html("<%= escape_javascript(render partial: 'read_states_table', locals: {read_states: @read_states, activity: @activity, course: @course, user: @user}) %>");
dodona.setHTMLExecuteScripts(document.querySelector("#read-states-table-wrapper"), "<%= escape_javascript(render partial: 'read_states_table', locals: {read_states: @read_states, activity: @activity, course: @course, user: @user}) %>");
2 changes: 1 addition & 1 deletion app/views/annotations/question_index.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#questions-table-wrapper").html("<%= escape_javascript(render partial: 'questions_table_with_pagination', locals: {questions: @questions}) %>");
dodona.setHTMLExecuteScripts(document.querySelector("#questions-table-wrapper"), "<%= escape_javascript(render partial: 'questions_table_with_pagination', locals: {questions: @questions}) %>");
2 changes: 1 addition & 1 deletion app/views/evaluations/add_users.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$("#users-table-wrapper").html("<%= escape_javascript(render partial: 'members_table', locals: {course_memberships: @course_memberships, confirm: false}) %>")
dodona.setHTMLExecuteScripts(document.querySelector("#users-table-wrapper"), "<%= escape_javascript(render partial: 'members_table', locals: {course_memberships: @course_memberships, confirm: false}) %>")
window.dodona.initTooltips();
window.dodona.initCheckboxes();
4 changes: 2 additions & 2 deletions app/views/evaluations/create.js.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
$("#info-panel .answer").text("<%= l @evaluation.deadline, format: :long %>");
$("#users-step-wrapper").html("<%= raw escape_javascript(render partial: 'add_users') %>");
dodona.setHTMLExecuteScripts(document.querySelector("#users-step-wrapper"), "<%= raw escape_javascript(render partial: 'add_users') %>");
window.dodona.initTooltips();
window.dodona.toUsersStep();
window.dodona.setEvaluationUrl("<%= evaluation_url(@evaluation) %>");
$("#items-step").html("<%= raw escape_javascript(render partial: 'score_items') %>");
dodona.setHTMLExecuteScripts(document.querySelector("#items-step"), "<%= raw escape_javascript(render partial: 'score_items') %>");
2 changes: 1 addition & 1 deletion app/views/evaluations/edit.js.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
$("#users-table-wrapper").html("<%= escape_javascript(render partial: 'members_table', locals: {course_memberships: @course_memberships, confirm: @should_confirm}) %>")
dodona.setHTMLExecuteScripts(document.querySelector("#users-table-wrapper"), "<%= escape_javascript(render partial: 'members_table', locals: {course_memberships: @course_memberships, confirm: @should_confirm}) %>")
window.dodona.initTooltips();
window.dodona.initCheckboxes();
4 changes: 2 additions & 2 deletions app/views/evaluations/show.js.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$("#evaluation-table-wrapper").html("<%= escape_javascript(render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>")
$("#evaluation-grade-table-wrapper").html("<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>")
dodona.setHTMLExecuteScripts(document.querySelector("#evaluation-table-wrapper"), "<%= escape_javascript(render 'evaluation_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>")
dodona.setHTMLExecuteScripts(document.querySelector("#evaluation-grade-table-wrapper"), "<%= escape_javascript(render 'evaluation_grade_table', feedbacks: @feedbacks, evaluation: @evaluation, users: @users) %>")
2 changes: 1 addition & 1 deletion app/views/events/index.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#events-table-wrapper").html("<%= escape_javascript(render partial: 'events/events_table', locals: {events: @events}) %>")
dodona.setHTMLExecuteScripts(document.querySelector("#events-table-wrapper"), "<%= escape_javascript(render partial: 'events/events_table', locals: {events: @events}) %>")
2 changes: 1 addition & 1 deletion app/views/feedbacks/edit.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#submissions-table-wrapper").html("<%= escape_javascript(render partial: 'submissions_table', locals: { submissions: @submissions }) %>")
dodona.setHTMLExecuteScripts(document.querySelector("#submissions-table-wrapper"), "<%= escape_javascript(render partial: 'submissions_table', locals: { submissions: @submissions }) %>")
2 changes: 1 addition & 1 deletion app/views/feedbacks/show.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#feedback-actions-holder").html("<%= escape_javascript(render partial: "feedbacks/feedback_actions") %>");
dodona.setHTMLExecuteScripts(document.querySelector("#feedback-actions-holder"), "<%= escape_javascript(render partial: "feedbacks/feedback_actions") %>");
2 changes: 1 addition & 1 deletion app/views/notifications/index.js.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
$(".notification-dropdown").html("<%= escape_javascript render(partial: 'notifications/small_notifications_table', locals: { notifications: @notifications }) %>");
dodona.setHTMLExecuteScripts(document.querySelector(".notification-dropdown"), "<%= escape_javascript render(partial: 'notifications/small_notifications_table', locals: { notifications: @notifications }) %>");
<% if @notifications.any? %>
document.getElementById("navbar-notifications").classList.remove("hidden");
<% end %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/rights_requests/approve.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#requests-table-wrapper").html("<%= escape_javascript(render partial: 'requests_table', locals: { requests: @requests }) %>");
dodona.setHTMLExecuteScripts(document.querySelector("#requests-table-wrapper"), "<%= escape_javascript(render partial: 'requests_table', locals: { requests: @requests }) %>");
2 changes: 1 addition & 1 deletion app/views/rights_requests/reject.js.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
$("#requests-table-wrapper").html("<%= escape_javascript(render partial: 'requests_table', locals: { requests: @requests }) %>");
dodona.setHTMLExecuteScripts(document.querySelector("#requests-table-wrapper"), "<%= escape_javascript(render partial: 'requests_table', locals: { requests: @requests }) %>");
2 changes: 1 addition & 1 deletion app/views/score_items/add_all.js.erb
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
$("#add-score-item-to-all").modal("hide");
$("#items-step").html("<%= raw escape_javascript(render partial: 'evaluations/score_items') %>");
dodona.setHTMLExecuteScripts(document.querySelector("#items-step"), "<%= raw escape_javascript(render partial: 'evaluations/score_items') %>");
6 changes: 3 additions & 3 deletions app/views/score_items/index.js.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
modal = $(".modal-<%= evaluation_exercise.id %>");
if (modal.is(":visible")) {
modal.on("hidden.bs.modal", () => {
$("#card-<%= evaluation_exercise.id %>").html("<%= escape_javascript(render 'score_items/exercise', evaluation_exercise: evaluation_exercise, new: new) %>");
dodona.setHTMLExecuteScripts(document.querySelector("#card-<%= evaluation_exercise.id %>"), "<%= escape_javascript(render 'score_items/exercise', evaluation_exercise: evaluation_exercise, new: new) %>");
}).modal("hide");
} else {
$("#card-<%= evaluation_exercise.id %>").html("<%= escape_javascript(render 'score_items/exercise', evaluation_exercise: evaluation_exercise, new: new) %>");
dodona.setHTMLExecuteScripts(document.querySelector("#card-<%= evaluation_exercise.id %>"), "<%= escape_javascript(render 'score_items/exercise', evaluation_exercise: evaluation_exercise, new: new) %>");
}
$(".summary-text").html("<%= t('score_items.new.summary_html', count: @evaluation.score_items.count, score: format_score(@evaluation.maximum_score)) %>");
dodona.setHTMLExecuteScripts(document.querySelector(".summary-text"), "<%= t('score_items.new.summary_html', count: @evaluation.score_items.count, score: format_score(@evaluation.maximum_score)) %>");