2020-06-07 08:28:05 +00:00
|
|
|
class Api::V1::Accounts::LabelsController < Api::V1::Accounts::BaseController
|
2020-06-07 05:47:13 +00:00
|
|
|
before_action :current_account
|
|
|
|
before_action :fetch_label, except: [:index, :create]
|
|
|
|
before_action :check_authorization
|
|
|
|
|
2020-03-09 17:57:10 +00:00
|
|
|
def index
|
2020-06-07 08:28:05 +00:00
|
|
|
@labels = policy_scope(Current.account.labels)
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def show; end
|
|
|
|
|
|
|
|
def create
|
2020-06-07 08:28:05 +00:00
|
|
|
@label = Current.account.labels.create!(permitted_params)
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2020-06-25 18:05:16 +00:00
|
|
|
@label.update!(permitted_params)
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
2022-03-24 07:58:25 +00:00
|
|
|
@label.destroy!
|
2020-06-07 05:47:13 +00:00
|
|
|
head :ok
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def fetch_label
|
2020-06-07 08:28:05 +00:00
|
|
|
@label = Current.account.labels.find(params[:id])
|
2020-06-07 05:47:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def permitted_params
|
|
|
|
params.require(:label).permit(:title, :description, :color, :show_on_sidebar)
|
2020-02-02 10:59:18 +00:00
|
|
|
end
|
2019-08-14 09:48:44 +00:00
|
|
|
end
|