From a212549f74bc366df7b01e5c65fcc935443c715d Mon Sep 17 00:00:00 2001 From: anubhajoshi Date: Thu, 17 Oct 2024 15:38:27 -0400 Subject: [PATCH] make change on flash error and disable modals --- app/assets/stylesheets/common/_icons.scss | 10 +++++----- app/controllers/criteria_controller.rb | 2 +- .../_criterion_editor.html.erb | 19 ++++++++++-------- app/views/criteria/_criteria_pane.html.erb | 2 +- app/views/criteria/index.html.erb | 6 ++++-- .../_criterion_editor.html.erb | 19 ++++++++++-------- .../_criterion_editor.html.erb | 20 +++++++++---------- .../_rubric_criterion_level.html.erb | 10 ++++------ .../_rubric_criterion_levels.html.erb | 2 +- 9 files changed, 48 insertions(+), 42 deletions(-) diff --git a/app/assets/stylesheets/common/_icons.scss b/app/assets/stylesheets/common/_icons.scss index 1dd39ca4e7..80a2c01e08 100644 --- a/app/assets/stylesheets/common/_icons.scss +++ b/app/assets/stylesheets/common/_icons.scss @@ -52,14 +52,14 @@ a[role='button'] > .fa-layers { color: $primary-one; } +.sorted-list:not(.sortable) .fa-grip-vertical { + display: none; +} + .sortable .fa-grip-vertical { color: $disabled-text; cursor: grab; float: left; height: 20px; margin-right: 1em; -} - -.sorted-list:not(.sortable) .fa-grip-vertical { - display: none; -} +} \ No newline at end of file diff --git a/app/controllers/criteria_controller.rb b/app/controllers/criteria_controller.rb index 480a5af496..459cb60c9c 100644 --- a/app/controllers/criteria_controller.rb +++ b/app/controllers/criteria_controller.rb @@ -50,7 +50,7 @@ def edit @criterion = record @assignment = @criterion.assignment if @assignment.released_marks.any? - flash_now(:error, t('criteria.errors.released_marks')) + flash_now(:notice, t('criteria.errors.released_marks')) end end diff --git a/app/views/checkbox_criteria/_criterion_editor.html.erb b/app/views/checkbox_criteria/_criterion_editor.html.erb index 2964e74c80..283254fa10 100644 --- a/app/views/checkbox_criteria/_criterion_editor.html.erb +++ b/app/views/checkbox_criteria/_criterion_editor.html.erb @@ -1,3 +1,5 @@ +<% marks_released = flash[:notice].present? %> +
<%= button_to t(:delete), course_criterion_path(@current_course, criterion), @@ -6,7 +8,8 @@ class: 'delete', form_class: 'display-inline-block', title: t('helpers.submit.delete', model: Criterion.model_name.human), - remote: true %> + remote: true, + disabled: marks_released %>

@@ -25,12 +28,12 @@
<%= f.label :name, Criterion.human_attribute_name(:name) %> - <%= f.text_field :name %> + <%= f.text_field :name, readonly: marks_released %> <%= f.label :max_mark, Criterion.human_attribute_name(:max_mark) %> - <%= f.number_field :max_mark, step: 0.1 %> + <%= f.number_field :max_mark, step: 0.1, readonly: marks_released %> <%= f.label :bonus, Criterion.human_attribute_name(:bonus) %> - <%= f.check_box :bonus %> + <%= f.check_box :bonus, { disabled: marks_released } %> <% if criterion.assignment.assignment_files.exists? %> <% selected_files = criterion.criteria_assignment_files_joins.map { |join| join.assignment_file } %> <%= f.label :assignment_files, AssignmentFile.model_name.human %> @@ -40,7 +43,7 @@ <% end %> <%= f.label :description, Criterion.human_attribute_name(:description) %>
- <%= f.text_area :description, rows: 6, cols: 50 %> + <%= f.text_area :description, rows: 6, cols: 50, readonly: marks_released %>

<%= t('criteria.description_hint') %>

@@ -48,12 +51,12 @@
<%= f.label :ta_visible, Criterion.human_attribute_name(:ta_visible) %> - <%= f.check_box :ta_visible %> + <%= f.check_box :ta_visible, { disabled: marks_released } %> <%= f.label :peer_visible, Criterion.human_attribute_name(:peer_visible) %> - <%= f.check_box :peer_visible %> + <%= f.check_box :peer_visible, { disabled: marks_released } %>
-

<%= f.submit t(:save), data: { disable_with: t('working') } %>

+

<%= f.submit t(:save), data: { disable_with: t('working') }, disabled: marks_released %>

<% end %> <% unless criterion.description.blank? %> diff --git a/app/views/criteria/_criteria_pane.html.erb b/app/views/criteria/_criteria_pane.html.erb index 696b85b642..d90d7dfb43 100644 --- a/app/views/criteria/_criteria_pane.html.erb +++ b/app/views/criteria/_criteria_pane.html.erb @@ -1,4 +1,4 @@ -<% marks_unreleased = @assignment.released_marks.blank? %> +<% marks_unreleased = flash[:notice].nil? %>
'>
diff --git a/app/views/criteria/index.html.erb b/app/views/criteria/index.html.erb index fafc0c3408..44634eb202 100644 --- a/app/views/criteria/index.html.erb +++ b/app/views/criteria/index.html.erb @@ -9,16 +9,18 @@ @assignment.parent_assignment.short_identifier + ' ' + PeerReview.model_name.human : @assignment.short_identifier) %> +<% marks_released = flash[:notice].present? %> + <% @heading_buttons = [ { link_text: t('criteria.new.button'), link_path: new_course_assignment_criterion_path(@current_course, @assignment), - html_options: { id: 'add-new-criterion', 'data-remote': 'true' } }, + html_options: { id: 'add-new-criterion', 'data-remote': 'true', class: (marks_released ? 'inactive' : '') } }, { link_text: t('download'), link_path: '#', html_options: { id: 'downloadModal' } }, { link_text: t('upload'), link_path: '#', - html_options: { id: 'uploadModal' } } + html_options: { id: 'uploadModal', class: (marks_released ? 'inactive' : '') } } ] %>
diff --git a/app/views/flexible_criteria/_criterion_editor.html.erb b/app/views/flexible_criteria/_criterion_editor.html.erb index 1cb2e122ae..3189689c3d 100644 --- a/app/views/flexible_criteria/_criterion_editor.html.erb +++ b/app/views/flexible_criteria/_criterion_editor.html.erb @@ -1,3 +1,5 @@ +<% marks_released = flash[:notice].present? %> +
<%= button_to t(:delete), course_criterion_path(@current_course, criterion), @@ -6,7 +8,8 @@ class: 'delete', form_class: 'display-inline-block', title: t('helpers.submit.delete', model: Criterion.model_name.human), - remote: true %> + remote: true, + disabled: marks_released %>

@@ -20,12 +23,12 @@
<%= f.label :name, Criterion.human_attribute_name(:name) %> - <%= f.text_field :name %> + <%= f.text_field :name, readonly: marks_released %> <%= f.label :max_mark, Criterion.human_attribute_name(:max_mark) %> - <%= f.number_field :max_mark, step: 0.1 %> + <%= f.number_field :max_mark, step: 0.1, readonly: marks_released %> <%= f.label :bonus, Criterion.human_attribute_name(:bonus) %> - <%= f.check_box :bonus %> + <%= f.check_box :bonus, { disabled: marks_released } %> <% if criterion.assignment.assignment_files.exists? %> <% selected_files = criterion.criteria_assignment_files_joins.map { |join| join.assignment_file } %> <%= f.label :assignment_files, AssignmentFile.model_name.human %> @@ -35,7 +38,7 @@ <% end %> <%= f.label :description, Criterion.human_attribute_name(:description) %>
- <%= f.text_area :description, rows: 6, cols: 50 %> + <%= f.text_area :description, rows: 6, cols: 50, readonly: marks_released %>

<%= t('criteria.description_hint') %>

@@ -44,13 +47,13 @@
<%= f.label :ta_visible, Criterion.human_attribute_name(:ta_visible) %> - <%= f.check_box :ta_visible %> + <%= f.check_box :ta_visible, { disabled: marks_released } %> <%= f.label :peer_visible, Criterion.human_attribute_name(:peer_visible) %> - <%= f.check_box :peer_visible %> + <%= f.check_box :peer_visible, { disabled: marks_released } %>
-

<%= f.submit t(:save), data: { disable_with: t('working') } %>

+

<%= f.submit t(:save), data: { disable_with: t('working') }, disabled: marks_released %>

<% end %> <% unless criterion.description.blank? %> diff --git a/app/views/rubric_criteria/_criterion_editor.html.erb b/app/views/rubric_criteria/_criterion_editor.html.erb index 7eb1112c7a..7936ad9e22 100644 --- a/app/views/rubric_criteria/_criterion_editor.html.erb +++ b/app/views/rubric_criteria/_criterion_editor.html.erb @@ -1,8 +1,8 @@
- <% released = !criterion.results_unreleased? %> + <% marks_released = flash[:notice].present? %> - <% if released %> + <% if marks_released %> <%= t('rubric_criteria.level.add') %> <% else %> <%= link_to t('rubric_criteria.level.add'), @@ -19,7 +19,7 @@ form_class: 'display-inline-block', title: t('helpers.submit.delete', model: Criterion.model_name.human), remote: true, - disabled: released + disabled: marks_released %>
@@ -36,16 +36,16 @@

"> <%= f.label :name, Criterion.human_attribute_name(:name) %> - <%= f.text_field :name, readonly: released %> + <%= f.text_field :name, readonly: marks_released %>

<%= f.label :max_mark, Criterion.human_attribute_name(:max_mark) %> - <%= f.number_field :max_mark, value: "#{criterion.max_mark}", step: 0.1, readonly: released %> + <%= f.number_field :max_mark, value: "#{criterion.max_mark}", step: 0.1, readonly: marks_released %>

<%= f.label :bonus, Criterion.human_attribute_name(:bonus) %> - <%= f.check_box :bonus, { disabled: released } %> + <%= f.check_box :bonus, { disabled: marks_released } %>

<% if criterion.assignment.assignment_files.exists? %> "> @@ -60,17 +60,17 @@
<%= f.label :ta_visible, Criterion.human_attribute_name(:ta_visible) %> - <%= f.check_box :ta_visible, { disabled: released } %> + <%= f.check_box :ta_visible, { disabled: marks_released } %> <%= f.label :peer_visible, Criterion.human_attribute_name(:peer_visible) %> - <%= f.check_box :peer_visible, { disabled: released } %> + <%= f.check_box :peer_visible, { disabled: marks_released } %>
-

<%= f.submit t(:save), data: { disable_with: t('working') }, disabled: released %>

+

<%= f.submit t(:save), data: { disable_with: t('working') }, disabled: marks_released %>

<%= render partial: 'rubric_criteria/rubric_criterion_levels', - locals: { criterion: criterion } %> + locals: { criterion: criterion, marks_released: marks_released } %>
<% end %> diff --git a/app/views/rubric_criteria/_rubric_criterion_level.html.erb b/app/views/rubric_criteria/_rubric_criterion_level.html.erb index ba811fd17d..49d151aa7e 100644 --- a/app/views/rubric_criteria/_rubric_criterion_level.html.erb +++ b/app/views/rubric_criteria/_rubric_criterion_level.html.erb @@ -3,25 +3,23 @@ %>
- <% released = !criterion.results_unreleased? %> -

<%= I18n.t("rubric_criteria.level.level_index", index: level_form.index.to_s) %> - <%= level_form.check_box :_destroy, { disabled: released } %> + <%= level_form.check_box :_destroy, { disabled: marks_released } %> <%= level_form.label :_destroy, I18n.t("rubric_criteria.level.delete.checkbox", index: level_form.index.to_s) %>

<%= level_form.label :name, Level.human_attribute_name(:name), class: 'required' %> - <%= level_form.text_field :name, required: true, readonly: released %> + <%= level_form.text_field :name, required: true, readonly: marks_released %> <%= level_form.label :mark, class: 'required' %> - <%= level_form.number_field :mark, step: 0.01, required: true, readonly: released %> + <%= level_form.number_field :mark, step: 0.01, required: true, readonly: marks_released %> <%= level_form.label :description, Level.human_attribute_name(:description), class: 'description' %> - <%= level_form.text_area :description, cols: 50, rows: 5, readonly: released %> + <%= level_form.text_area :description, cols: 50, rows: 5, readonly: marks_released %>
diff --git a/app/views/rubric_criteria/_rubric_criterion_levels.html.erb b/app/views/rubric_criteria/_rubric_criterion_levels.html.erb index e0fa526aae..30496b9e43 100644 --- a/app/views/rubric_criteria/_rubric_criterion_levels.html.erb +++ b/app/views/rubric_criteria/_rubric_criterion_levels.html.erb @@ -3,7 +3,7 @@ method: :patch, remote: true do |criterion_form| %> <%= criterion_form.fields_for :levels, criterion_form.object.levels.order(:mark) do |level_form| %> <%= render partial: 'rubric_criteria/rubric_criterion_level', - locals: { level_form: level_form, criterion: criterion } %> + locals: { level_form: level_form, marks_released: marks_released } %> <% end %> <% end %>