2020-07-22 15:45:56 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class MyModuleStatusFlowController < ApplicationController
|
2020-07-22 17:39:34 +08:00
|
|
|
before_action :load_my_module
|
|
|
|
before_action :check_view_permissions
|
|
|
|
|
2020-07-22 15:45:56 +08:00
|
|
|
def show
|
2020-09-25 16:14:57 +08:00
|
|
|
my_module_statuses = @my_module.my_module_status_flow
|
|
|
|
.my_module_statuses
|
|
|
|
.preload(:my_module_status_implications, next_status: :my_module_status_conditions)
|
|
|
|
.sort_by_position
|
2023-06-21 20:13:20 +08:00
|
|
|
render json: { html: render_to_string(partial: 'my_modules/modals/status_flow_modal_body',
|
2020-07-22 17:39:34 +08:00
|
|
|
locals: { my_module_statuses: my_module_statuses }) }
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def load_my_module
|
|
|
|
@my_module = MyModule.find_by(id: params[:my_module_id])
|
|
|
|
render_404 unless @my_module
|
|
|
|
end
|
|
|
|
|
|
|
|
def check_view_permissions
|
2021-09-22 17:28:32 +08:00
|
|
|
render_403 unless can_read_my_module?(@my_module)
|
2020-07-22 15:45:56 +08:00
|
|
|
end
|
|
|
|
end
|