Class: RailsWorkflow::ProcessTemplatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/rails_workflow/process_templates_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



38
39
40
41
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 38

def create
  @process_template = ProcessTemplate.create(permitted_params)
  redirect_to process_template_operation_templates_path(@process_template)
end

#destroyObject



48
49
50
51
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 48

def destroy
  @process_template.destroy
  redirect_to process_templates_url
end

#exportObject



24
25
26
27
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 24

def export
  template = ProcessTemplate.find(params[:id])
  send_data render_to_string(json: template, serializer: ProcessTemplateSerializer), filename: "#{template.title}.json"
end

#indexObject



29
30
31
32
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 29

def index
  @process_templates = ProcessTemplateDecorator
                       .decorate_collection(process_templates_collection)
end

#newObject



34
35
36
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 34

def new
  @process_template = ProcessTemplate.new(permitted_params).decorate
end

#updateObject



43
44
45
46
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 43

def update
  @process_template.update(permitted_params)
  redirect_to process_template_url(@process_template)
end

#uploadObject



13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 13

def upload
  uploaded = params[:import_file]

  json = JSON.parse(uploaded.read)

  importer = RailsWorkflow::ProcessImporter.new(json)
  importer.process

  redirect_to process_templates_path
end