2022-07-26 19:52:40 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class LabelTemplatesController < ApplicationController
|
2022-07-27 16:10:32 +08:00
|
|
|
include InputSanitizeHelper
|
|
|
|
|
2022-07-26 19:52:40 +08:00
|
|
|
before_action :check_view_permissions
|
2022-07-27 16:10:32 +08:00
|
|
|
before_action :load_label_templates, only: %i(index datatable)
|
2022-07-26 19:52:40 +08:00
|
|
|
|
|
|
|
layout 'fluid'
|
|
|
|
|
|
|
|
def index; end
|
|
|
|
|
2022-07-27 16:10:32 +08:00
|
|
|
def datatable
|
|
|
|
respond_to do |format|
|
|
|
|
format.json do
|
|
|
|
render json: ::LabelTemplateDatatable.new(
|
|
|
|
view_context,
|
|
|
|
can_manage_label_templates?(current_team),
|
|
|
|
@label_templates
|
|
|
|
)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
render_404
|
|
|
|
end
|
|
|
|
|
2022-07-26 19:52:40 +08:00
|
|
|
private
|
|
|
|
|
|
|
|
def check_view_permissions
|
|
|
|
render_403 unless can_view_label_templates?(current_team)
|
|
|
|
end
|
2022-07-27 16:10:32 +08:00
|
|
|
|
|
|
|
def load_label_templates
|
|
|
|
@label_templates = LabelTemplate.where(team_id: current_team.id)
|
|
|
|
end
|
2022-07-26 19:52:40 +08:00
|
|
|
end
|