Sha256: e8956b0adb5a0c87afcb41dc03f42cb26812fc5723d61d2acf0ad891538cf782

Contents?: true

Size: 1.18 KB

Versions: 28

Compression:

Stored size: 1.18 KB

Contents

module Workarea
  module Admin
    class SegmentsController < Admin::ApplicationController
      required_permissions :people

      before_action :find_segment, except: :index

      def index
        query = Search::AdminSegments.new(params)
        @search = SearchViewModel.new(query, view_model_options)
        @segments = SegmentViewModel.wrap(Segment.all, view_model_options)
      end

      def show
      end

      def edit
      end

      def update
        if @segment.update_attributes(params[:segment])
          flash[:success] = t('workarea.admin.segments.flash_messages.saved')
          redirect_to segment_path(@segment)
        else
          flash[:error] = @segment.errors.full_messages.to_sentence
          render :edit, status: :unprocessable_entity
        end
      end

      def insights
      end

      def destroy
        head :unprocessable_entity && return if @segment.life_cycle?

        @segment.destroy
        flash[:success] = t('workarea.admin.segments.flash_messages.removed')
        redirect_to segments_path
      end

      private

      def find_segment
        @segment = Admin::SegmentViewModel.new(Segment.find(params[:id]))
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.27 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.26 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.25 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.23 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.22 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.21 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.20 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.19 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.18 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.17 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.16 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.15 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.14 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.13 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.12 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.11 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.10 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.9 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.8 app/controllers/workarea/admin/segments_controller.rb
workarea-admin-3.5.7 app/controllers/workarea/admin/segments_controller.rb