mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-03-04 19:53:19 +08:00
Disable button when condition not fullfield
This commit is contained in:
parent
3d2aaed791
commit
18426b90be
3 changed files with 39 additions and 24 deletions
|
@ -21,7 +21,7 @@
|
|||
&.open .dropdown-menu{
|
||||
align-items: center;
|
||||
display: grid;
|
||||
grid-template-columns: max-content min-content minmax(0, auto);
|
||||
grid-template-columns: minmax(0, auto) 12px minmax(0, auto);
|
||||
padding: .5em 0;
|
||||
|
||||
li {
|
||||
|
@ -36,6 +36,14 @@
|
|||
&:hover > *{
|
||||
background: $color-concrete;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
pointer-events: none;
|
||||
|
||||
.status-name {
|
||||
background: $color-alto !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.fa-long-arrow-alt-right {
|
||||
|
@ -64,7 +72,8 @@
|
|||
@include font-small;
|
||||
color: $color-silver-chalice;
|
||||
grid-column: span 3;
|
||||
padding: .5em 1em;
|
||||
line-height: 1em;
|
||||
padding: 0em 1em .5em;
|
||||
}
|
||||
|
||||
#viewTaskFlow {
|
||||
|
|
|
@ -48,6 +48,8 @@ class MyModuleStatus < ApplicationRecord
|
|||
end
|
||||
|
||||
def conditions_fulfilled?(my_module)
|
||||
my_module.errors.clear
|
||||
|
||||
my_module_status_conditions.each do |condition|
|
||||
condition.call(my_module)
|
||||
end
|
||||
|
|
|
@ -13,32 +13,36 @@
|
|||
<ul class="dropdown-menu" aria-labelledby="dropdownTaskFlow" id="dropdownTaskFlowList" data-link-url="<%= update_state_my_module_url(my_module) %>">
|
||||
<% unless status.initial_status? %>
|
||||
<% previous_s = status.previous_status %>
|
||||
<% if previous_s.conditions_fulfilled?(my_module) %>
|
||||
<li data-state-id="<%= previous_s.id %>">
|
||||
<% previous_s.conditions_fulfilled?(my_module) %>
|
||||
<li data-state-id="<%= previous_s.id %>" class="<%= 'disabled' if my_module.errors.any? %>">
|
||||
<span><%= t('my_module_statuses.dropdown.return_label') %></span>
|
||||
<i class="fas fa-long-arrow-alt-right"></i>
|
||||
<div class=" status-container">
|
||||
<div class="status-name" style="<%= "background-color: #{previous_s.color}" %>"><%= previous_s.name %></div>
|
||||
</div>
|
||||
</li>
|
||||
<% else %>
|
||||
<span class="error-message"><%= my_module.errors.messages&.values&.join(' ') %></span>
|
||||
<span class="error-message">
|
||||
<% my_module.errors.messages&.values&.flatten&.each do |error| %>
|
||||
<%= error %><br>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
|
||||
<% unless status.final_status? %>
|
||||
<% next_s = status.next_status %>
|
||||
<% if next_s.conditions_fulfilled?(my_module) %>
|
||||
<li data-state-id="<%= next_s.id %>">
|
||||
<% next_s.conditions_fulfilled?(my_module) %>
|
||||
<li data-state-id="<%= next_s.id %>" class="<%= 'disabled' if my_module.errors.any? %>">
|
||||
<span><%= t('my_module_statuses.dropdown.move_label') %></span>
|
||||
<i class="fas fa-long-arrow-alt-right"></i>
|
||||
<div class="status-container">
|
||||
<div class="status-name" style="<%= "background-color: #{next_s.color}" %>"><%= next_s.name %></div>
|
||||
</div>
|
||||
</li>
|
||||
<% else %>
|
||||
<span class="error-message"><%= my_module.errors.messages&.values&.join(' ') %></span>
|
||||
<span class="error-message">
|
||||
<% my_module.errors.messages&.values&.flatten&.each do |error| %>
|
||||
<%= error %><br>
|
||||
<% end %>
|
||||
</span>
|
||||
<% end %>
|
||||
<li id="viewTaskFlow">
|
||||
<%= t('my_module_statuses.dropdown.view_flow_label') %>
|
||||
|
|
Loading…
Reference in a new issue