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



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

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

#destroyObject



52
53
54
55
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 52

def destroy
  @process_template.destroy
  redirect_to process_templates_url
end

#exportObject



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

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

#indexObject



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

def index
  @process_templates = ProcessTemplateDecorator.
      decorate_collection(process_templates_collection)

  respond_with(@process_templates)
end

#newObject



36
37
38
39
# File 'app/controllers/rails_workflow/process_templates_controller.rb', line 36

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

#updateObject



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

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

#uploadObject



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

def upload
  uploaded = params[:import_file]

  json = JSON.parse(uploaded.read)

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

  redirect_to process_templates_path
end