2018-09-14 05:42:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2015-09-03 12:50:23 +00:00
|
|
|
class Admin::LabelsController < Admin::ApplicationController
|
|
|
|
before_action :set_label, only: [:show, :edit, :update, :destroy]
|
|
|
|
|
2021-10-27 15:13:41 +00:00
|
|
|
feature_category :team_planning
|
2022-05-13 15:07:43 +00:00
|
|
|
urgency :low
|
2020-10-05 21:08:47 +00:00
|
|
|
|
2015-09-03 12:50:23 +00:00
|
|
|
def index
|
2016-03-19 21:37:54 +00:00
|
|
|
@labels = Label.templates.page(params[:page])
|
2015-09-03 12:50:23 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@label = Label.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
2017-03-29 11:45:15 +00:00
|
|
|
@label = Labels::CreateService.new(label_params).execute(template: true)
|
2015-09-03 12:50:23 +00:00
|
|
|
|
2017-03-29 11:45:15 +00:00
|
|
|
if @label.persisted?
|
2019-03-21 13:31:05 +00:00
|
|
|
redirect_to admin_labels_url, notice: _("Label was created")
|
2015-09-03 12:50:23 +00:00
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2017-03-29 11:45:15 +00:00
|
|
|
@label = Labels::UpdateService.new(label_params).execute(@label)
|
|
|
|
|
|
|
|
if @label.valid?
|
2019-03-21 13:31:05 +00:00
|
|
|
redirect_to admin_labels_path, notice: _('Label was successfully updated.')
|
2015-09-03 12:50:23 +00:00
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@label.destroy
|
|
|
|
@labels = Label.templates
|
|
|
|
|
|
|
|
respond_to do |format|
|
|
|
|
format.html do
|
2019-11-17 12:06:19 +00:00
|
|
|
redirect_to admin_labels_path, status: :found, notice: _('Label was removed')
|
2015-09-03 12:50:23 +00:00
|
|
|
end
|
2021-05-19 06:10:37 +00:00
|
|
|
format.js { head :ok }
|
2015-09-03 12:50:23 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_label
|
|
|
|
@label = Label.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def label_params
|
2016-02-17 13:52:12 +00:00
|
|
|
params[:label].permit(:title, :description, :color)
|
2015-09-03 12:50:23 +00:00
|
|
|
end
|
|
|
|
end
|