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



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

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

#indexObject



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

def index
  @process_templates = ProcessTemplateDecorator
                       .decorate_collection(process_templates_collection)

  respond_with(@process_templates)
end

#newObject



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

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



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

def upload
  uploaded = params[:import_file]

  json = JSON.parse(uploaded.read)

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

  redirect_to process_templates_path
end