Class: Naf::ApplicationSchedulesController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Naf::ApplicationSchedulesController
- Defined in:
- app/controllers/naf/application_schedules_controller.rb
Instance Method Summary collapse
- #check_application_run_group_name ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #edit ⇒ Object
- #index ⇒ Object
- #new ⇒ Object
- #set_application_run_group_name ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#check_application_run_group_name ⇒ Object
79 80 81 82 83 84 85 86 87 88 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 79 def check_application_run_group_name case @application_schedule.application_run_group_name when @application_schedule.application.command @run_group_name_type = 'command' when nil, '' @run_group_name_type = 'not set' else @run_group_name_type = 'custom' end end |
#create ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 41 def create @application_schedule = Naf::ApplicationSchedule.new(params[:application_schedule]) check_application_run_group_name set_application_run_group_name if @application_schedule.save redirect_to(@application_schedule.application, notice: "Application Schedule was successfully created.") else render action: :new end end |
#destroy ⇒ Object
72 73 74 75 76 77 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 72 def destroy @application_schedule = ::Naf::ApplicationSchedule.find(params[:id]) @application_schedule.destroy flash[:notice] = 'Application Schedule was successfully deleted.' redirect_to action: :index end |
#edit ⇒ Object
52 53 54 55 56 57 58 59 60 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 52 def edit @application_schedule = ::Naf::ApplicationSchedule.find(params[:id]) check_application_run_group_name if @application_schedule.application_schedule_prerequisites.blank? @application_schedule.application_schedule_prerequisites.build else @show_prerequisite = true end end |
#index ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 6 def index respond_to do |format| format.html format.json do set_page application_schedules = [] application_schedule = [] @total_records = Naf::ApplicationSchedule.count(:all) Logical::Naf::ApplicationSchedule.search(params).map(&:to_hash).map do |hash| hash.map do |key, value| value = '' if value.nil? application_schedule << value end application_schedules << application_schedule application_schedule = [] end @total_display_records = application_schedules.count @application_schedules = application_schedules.paginate(page: @page, per_page: @rows_per_page) render layout: 'naf/layouts/jquery_datatables' end end end |
#new ⇒ Object
37 38 39 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 37 def new @application_schedule = Naf::ApplicationSchedule.new(application_id: params[:application_id]) end |
#set_application_run_group_name ⇒ Object
90 91 92 93 94 95 96 97 98 99 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 90 def set_application_run_group_name run_group_name_type = params[:run_group_name_type] case run_group_name_type when 'command' params[:application_schedule][:application_run_group_name] = ::Naf::Application.find_by_id(params[:application_schedule][:application_id]).command when 'not set' params[:application_schedule][:application_run_group_name] = nil end end |
#show ⇒ Object
32 33 34 35 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 32 def show schedule = ::Naf::ApplicationSchedule.find(params[:id]) @application_schedule = ::Logical::Naf::ApplicationSchedule.new(schedule) end |
#update ⇒ Object
62 63 64 65 66 67 68 69 70 |
# File 'app/controllers/naf/application_schedules_controller.rb', line 62 def update @application_schedule = ::Naf::ApplicationSchedule.find(params[:id]) set_application_run_group_name if @application_schedule.update_attributes(params[:application_schedule]) redirect_to(@application_schedule, notice: "Application Schedule was successfully updated.") else render action: :edit end end |