mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-11-08 07:21:03 +08:00
Merge pull request #7126 from wandji20/wb-SCI-10198
Replace task flow buttons partial after successful change of task status [SCI-10198]
This commit is contained in:
commit
c1161ce9eb
3 changed files with 89 additions and 80 deletions
|
|
@ -44,7 +44,7 @@
|
|||
data: { my_module: { status_id: item.data('state-id') } },
|
||||
success: function(result) {
|
||||
animateSpinner(null, false);
|
||||
location.reload();
|
||||
$('.task-sharing-and-flows .status-flow-container').replaceWith(result.html);
|
||||
},
|
||||
error: function(e) {
|
||||
animateSpinner(null, false);
|
||||
|
|
|
|||
|
|
@ -348,7 +348,14 @@ class MyModulesController < ApplicationController
|
|||
log_activity(:change_status_on_task_flow, @my_module, my_module_status_old: old_status_id,
|
||||
my_module_status_new: @my_module.my_module_status.id)
|
||||
|
||||
render json: { status: :changed }
|
||||
render json: {
|
||||
status: :changed,
|
||||
html: render_to_string(
|
||||
partial: 'my_modules/status_flow/task_flow_button',
|
||||
locals: { my_module: @my_module },
|
||||
formats: :html
|
||||
)
|
||||
}
|
||||
else
|
||||
render json: { errors: @my_module.errors.messages.values.flatten.join('\n') }, status: :unprocessable_entity
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,82 +1,84 @@
|
|||
<% status = my_module.my_module_status %>
|
||||
<div class="status-label">
|
||||
<div class="status-title"><%= t('my_module_statuses.dropdown.status_label') %></div>
|
||||
<div class="status-note">
|
||||
<% if my_module.last_transition_error %>
|
||||
<div class="status-transition-error">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
<% case my_module.last_transition_error["type"] %>
|
||||
<% when "repository_snapshot" %>
|
||||
<%= t(
|
||||
"my_modules.status_error.repository_snapshot",
|
||||
repository: Repository.find(my_module.last_transition_error["repository_id"]).name
|
||||
) %>
|
||||
<% else %>
|
||||
<%= t("my_modules.status_error.general") %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-buttons">
|
||||
<div class="dropdown sci-dropdown status-flow-dropdown"
|
||||
data-status-changing="<%= my_module.status_changing %>"
|
||||
data-status-check-url="<%= status_state_my_module_path(my_module) %>">
|
||||
<button class="btn btn-secondary dropdown-toggle
|
||||
<%= 'disabled' if my_module.status_changing || my_module.archived_branch? %>
|
||||
<%= 'status-light' if status.light_color? %>"
|
||||
type="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="true"
|
||||
style="<%= "background-color: #{status.color}" %>;">
|
||||
<span>
|
||||
<% if my_module.status_changing %>
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<span><%= t('my_module_statuses.dropdown.status_transitioning_label') %></span>
|
||||
<% end %>
|
||||
<%= status.name %>
|
||||
</span>
|
||||
<span class="sn-icon sn-icon-down"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right" aria-labelledby="dropdownTaskFlow" id="dropdownTaskFlowList" data-link-url="<%= update_state_my_module_url(my_module) %>">
|
||||
<% if can_update_my_module_status?(@my_module) %>
|
||||
<% unless status.initial_status? %>
|
||||
<% previous_s = status.previous_status %>
|
||||
<% previous_s_errors = previous_s.conditions_errors(my_module) %>
|
||||
<li data-state-id="<%= previous_s.id %>" id="previousStatusSelector" class="<%= 'disabled' if previous_s_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 <%= 'status-light' if previous_s.light_color? %>"
|
||||
style="<%= "background-color: #{previous_s.color}" %>"><%= previous_s.name %></div>
|
||||
</div>
|
||||
</li>
|
||||
<span class="error-message"><% previous_s_errors.each do |error| %>
|
||||
<%= error %><br>
|
||||
<% end %></span>
|
||||
<% end %>
|
||||
|
||||
<% unless status.final_status? %>
|
||||
<% next_s = status.next_status %>
|
||||
<% next_s_errors = next_s.conditions_errors(my_module) %>
|
||||
<li data-state-id="<%= next_s.id %>" id="nextStatusSelector" class="<%= 'disabled' if next_s_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>
|
||||
<span class="error-message" data-errors-for="next-status"><% next_s_errors.each do |error| %>
|
||||
<%= error %><br>
|
||||
<% end %></span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="error-message permission-error"><%= t('my_module_statuses.dropdown.no_permission_label') %></span>
|
||||
<div class='status-flow-container flex items-center gap-2'>
|
||||
<div class="status-label">
|
||||
<div class="status-title"><%= t('my_module_statuses.dropdown.status_label') %></div>
|
||||
<div class="status-note">
|
||||
<% if my_module.last_transition_error %>
|
||||
<div class="status-transition-error">
|
||||
<i class="fas fa-exclamation-triangle"></i>
|
||||
<% case my_module.last_transition_error["type"] %>
|
||||
<% when "repository_snapshot" %>
|
||||
<%= t(
|
||||
"my_modules.status_error.repository_snapshot",
|
||||
repository: Repository.find(my_module.last_transition_error["repository_id"]).name
|
||||
) %>
|
||||
<% else %>
|
||||
<%= t("my_modules.status_error.general") %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<li id="viewTaskFlow">
|
||||
<%= t('my_module_statuses.dropdown.view_flow_label') %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="status-buttons">
|
||||
<div class="dropdown sci-dropdown status-flow-dropdown"
|
||||
data-status-changing="<%= my_module.status_changing %>"
|
||||
data-status-check-url="<%= status_state_my_module_path(my_module) %>">
|
||||
<button class="btn btn-secondary dropdown-toggle
|
||||
<%= 'disabled' if my_module.status_changing || my_module.archived_branch? %>
|
||||
<%= 'status-light' if status.light_color? %>"
|
||||
type="button"
|
||||
data-toggle="dropdown"
|
||||
aria-haspopup="true"
|
||||
aria-expanded="true"
|
||||
style="<%= "background-color: #{status.color}" %>;">
|
||||
<span>
|
||||
<% if my_module.status_changing %>
|
||||
<i class="fas fa-spinner fa-spin"></i>
|
||||
<span><%= t('my_module_statuses.dropdown.status_transitioning_label') %></span>
|
||||
<% end %>
|
||||
<%= status.name %>
|
||||
</span>
|
||||
<span class="sn-icon sn-icon-down"></span>
|
||||
</button>
|
||||
<ul class="dropdown-menu pull-right" aria-labelledby="dropdownTaskFlow" id="dropdownTaskFlowList" data-link-url="<%= update_state_my_module_url(my_module) %>">
|
||||
<% if can_update_my_module_status?(@my_module) %>
|
||||
<% unless status.initial_status? %>
|
||||
<% previous_s = status.previous_status %>
|
||||
<% previous_s_errors = previous_s.conditions_errors(my_module) %>
|
||||
<li data-state-id="<%= previous_s.id %>" id="previousStatusSelector" class="<%= 'disabled' if previous_s_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 <%= 'status-light' if previous_s.light_color? %>"
|
||||
style="<%= "background-color: #{previous_s.color}" %>"><%= previous_s.name %></div>
|
||||
</div>
|
||||
</li>
|
||||
<span class="error-message"><% previous_s_errors.each do |error| %>
|
||||
<%= error %><br>
|
||||
<% end %></span>
|
||||
<% end %>
|
||||
|
||||
<% unless status.final_status? %>
|
||||
<% next_s = status.next_status %>
|
||||
<% next_s_errors = next_s.conditions_errors(my_module) %>
|
||||
<li data-state-id="<%= next_s.id %>" id="nextStatusSelector" class="<%= 'disabled' if next_s_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>
|
||||
<span class="error-message" data-errors-for="next-status"><% next_s_errors.each do |error| %>
|
||||
<%= error %><br>
|
||||
<% end %></span>
|
||||
<% end %>
|
||||
<% else %>
|
||||
<span class="error-message permission-error"><%= t('my_module_statuses.dropdown.no_permission_label') %></span>
|
||||
<% end %>
|
||||
<li id="viewTaskFlow">
|
||||
<%= t('my_module_statuses.dropdown.view_flow_label') %>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue