Skip to content

Commit

Permalink
make change on flash error and disable modals
Browse files Browse the repository at this point in the history
  • Loading branch information
anubhajoshi01 committed Oct 17, 2024
1 parent 6eb79f0 commit a212549
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 42 deletions.
10 changes: 5 additions & 5 deletions app/assets/stylesheets/common/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion app/controllers/criteria_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 11 additions & 8 deletions app/views/checkbox_criteria/_criterion_editor.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% marks_released = flash[:notice].present? %>

<div class='float-right'>
<%= button_to t(:delete),
course_criterion_path(@current_course, criterion),
Expand All @@ -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 %>
</div>

<h2>
Expand All @@ -25,12 +28,12 @@

<div class='inline-labels'>
<%= 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 %>
Expand All @@ -40,20 +43,20 @@
<% end %>
<%= f.label :description, Criterion.human_attribute_name(:description) %>
<div>
<%= f.text_area :description, rows: 6, cols: 50 %>
<%= f.text_area :description, rows: 6, cols: 50, readonly: marks_released %>
<p><%= t('criteria.description_hint') %></p>
</div>
</div>
<h4><%= t('criteria.visibility') %></h4>
<div class='inline-labels'>
<%= 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 } %>
</div>
<p><%= f.submit t(:save), data: { disable_with: t('working') } %></p>
<p><%= f.submit t(:save), data: { disable_with: t('working') }, disabled: marks_released %></p>
<% end %>
<% unless criterion.description.blank? %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/criteria/_criteria_pane.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<% marks_unreleased = @assignment.released_marks.blank? %>
<% marks_unreleased = flash[:notice].nil? %>

<div class='listings sorted-list <%= 'sortable' if marks_unreleased %>'>
<header>
Expand Down
6 changes: 4 additions & 2 deletions app/views/criteria/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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' : '') } }
] %>

<div class='wrapper'>
Expand Down
19 changes: 11 additions & 8 deletions app/views/flexible_criteria/_criterion_editor.html.erb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<% marks_released = flash[:notice].present? %>

<div class='float-right'>
<%= button_to t(:delete),
course_criterion_path(@current_course, criterion),
Expand All @@ -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 %>
</div>

<h2>
Expand All @@ -20,12 +23,12 @@

<div class='inline-labels'>
<%= 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 %>
Expand All @@ -35,7 +38,7 @@
<% end %>
<%= f.label :description, Criterion.human_attribute_name(:description) %>
<div>
<%= f.text_area :description, rows: 6, cols: 50 %>
<%= f.text_area :description, rows: 6, cols: 50, readonly: marks_released %>
<p><%= t('criteria.description_hint') %></p>
</div>
</div>
Expand All @@ -44,13 +47,13 @@
<div class='inline-labels'>
<%= 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 } %>
</div>

<p><%= f.submit t(:save), data: { disable_with: t('working') } %></p>
<p><%= f.submit t(:save), data: { disable_with: t('working') }, disabled: marks_released %></p>
<% end %>
<% unless criterion.description.blank? %>
Expand Down
20 changes: 10 additions & 10 deletions app/views/rubric_criteria/_criterion_editor.html.erb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<div class='float-right'>

<% released = !criterion.results_unreleased? %>
<% marks_released = flash[:notice].present? %>
<% if released %>
<% if marks_released %>
<span class="button disabled"><%= t('rubric_criteria.level.add') %></span>
<% else %>
<%= link_to t('rubric_criteria.level.add'),
Expand All @@ -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
%>
</div>

Expand All @@ -36,16 +36,16 @@
<div class='main_rubric_criteria_edit'>
<p id="<%= "criterion_inputs_#{criterion.id}" %>">
<%= f.label :name, Criterion.human_attribute_name(:name) %>
<%= f.text_field :name, readonly: released %>
<%= f.text_field :name, readonly: marks_released %>
</p>
<p>
<%= 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 %>
</p>
<p>
<%= f.label :bonus,
Criterion.human_attribute_name(:bonus) %>
<%= f.check_box :bonus, { disabled: released } %>
<%= f.check_box :bonus, { disabled: marks_released } %>
</p>
<% if criterion.assignment.assignment_files.exists? %>
<span id="<%= "criterion_inputs_#{criterion.id}" %>">
Expand All @@ -60,17 +60,17 @@
<div class='inline-labels'>
<%= 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 } %>
</div>
<p><%= f.submit t(:save), data: { disable_with: t('working') }, disabled: released %></p>
<p><%= f.submit t(:save), data: { disable_with: t('working') }, disabled: marks_released %></p>
</div>

<div id='rubric-criteria-levels' class='rubric-criteria-levels'>
<%= render partial: 'rubric_criteria/rubric_criterion_levels',
locals: { criterion: criterion } %>
locals: { criterion: criterion, marks_released: marks_released } %>
</div>

<% end %>
10 changes: 4 additions & 6 deletions app/views/rubric_criteria/_rubric_criterion_level.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,23 @@
%>
<div class='level'>

<% released = !criterion.results_unreleased? %>

<h4 class='rubric_level_header'>
<span id="display_name">
<%= I18n.t("rubric_criteria.level.level_index", index: level_form.index.to_s) %>
</span>
<span class="float-right destroy_checkbox">
<%= 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) %>
</span>
</h4>
<div class="inline-labels">
<%= 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 %>
</div>
</div>
<!--<br>-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
</div>

0 comments on commit a212549

Please sign in to comment.