itsf_backend 1.1.6 → 1.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dd4ebcdb087ecbe0d465e75228fe8d1b4f79d63d
4
- data.tar.gz: 543d6f1f8ca73ce81dcb3f9dd6d56bd8a086d8a8
3
+ metadata.gz: 0be05c7a7fd7f6d0fb8391a79bd47350b7d9ea00
4
+ data.tar.gz: 2ecc683d46c48fae5c150dd93a42d6a0c5d7a9b8
5
5
  SHA512:
6
- metadata.gz: 517f656d121ad0acd302814cc83355f067c29af784927385ef723497baa1eae6cdb2fe68d4bf0a1f92922ff37cfb482bfb8cad1224fe946b9c1f440f05081446
7
- data.tar.gz: 596ee97f86f70809e7bbc463655361a9e90032be8da25690de7c27ee68449b6e90b30c065691edbaa2ad0fbc16ed19396281bcdab5da29b6c862dd562e51145d
6
+ metadata.gz: fb484cf8858f22721a11804340796539a09189bfb7d8acaf5595c14e7aa108b56087d9ccd08192215517c6abc0f4d9cc9305efe78156c7fc8bbfc63d58bb88d8
7
+ data.tar.gz: dd9deebdf4828fcb22be500b5caeaa027027d8cf35b3088076cf4194f31da6c8a6505a4c369a59f84ef3de6f85cc022d2f785af446bf8ca8417f57bb2bd03b81
@@ -28,7 +28,7 @@ module Controller
28
28
  @resource = resource_class.new(permitted_params)
29
29
  authorize_action
30
30
  @resource.save
31
- respond_with @resource, location: collection_path
31
+ respond_with @resource, location: after_create_location
32
32
  end
33
33
 
34
34
  def show
@@ -47,18 +47,30 @@ module Controller
47
47
  @resource = load_resource
48
48
  authorize_action
49
49
  @resource.update_attributes(permitted_params)
50
- respond_with @resource, location: collection_path
50
+ respond_with @resource, location: after_update_location
51
51
  end
52
52
 
53
53
  def destroy
54
54
  @resource = load_resource
55
55
  authorize_action
56
56
  @resource.destroy
57
- respond_with @resource, location: collection_path
57
+ respond_with @resource, location: after_destroy_location
58
58
  end
59
59
 
60
60
  private
61
61
 
62
+ def after_create_location
63
+ collection_path
64
+ end
65
+
66
+ def after_destroy_location
67
+ collection_path
68
+ end
69
+
70
+ def after_update_location
71
+ collection_path
72
+ end
73
+
62
74
  def authorize_action
63
75
  action = action_name.to_sym
64
76
  case action
@@ -32,5 +32,19 @@ module Itsf::Backend
32
32
  def resource_class
33
33
  self.class.resource_class
34
34
  end
35
+
36
+ private
37
+
38
+ def after_create_location
39
+ return edit_resource_path(@resource) if params.has_key?(:commit_and_continue_with_edit)
40
+ return new_resource_path if params.has_key?(:commit_and_continue_with_new)
41
+ collection_path
42
+ end
43
+
44
+ def after_update_location
45
+ return edit_resource_path(@resource) if params.has_key?(:commit_and_continue_with_edit)
46
+ return new_resource_path if params.has_key?(:commit_and_continue_with_new)
47
+ collection_path
48
+ end
35
49
  end
36
50
  end
@@ -0,0 +1,21 @@
1
+ module Concerns
2
+ module Form
3
+ module AdditionalSubmitButtons
4
+ extend ActiveSupport::Concern
5
+
6
+ def submit_and_continue_with_edit *args
7
+ options = args.extract_options!
8
+ action = object.new_record? ? :create : :update
9
+ options.merge!(name: 'commit_and_continue_with_edit' ,value: I18n.t("helpers.submit.#{action}_and_continue_with_edit", resource_name: object.model_name.human))
10
+ submit(options)
11
+ end
12
+
13
+ def submit_and_continue_with_new *args
14
+ options = args.extract_options!
15
+ action = object.new_record? ? :create : :update
16
+ options.merge!(name: 'commit_and_continue_with_new' ,value: I18n.t("helpers.submit.#{action}_and_continue_with_new", resource_name: object.model_name.human))
17
+ submit(options)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -6,6 +6,8 @@
6
6
  = render partial: 'form_errors', locals: { resource: f.object }
7
7
  = render 'form', form: f
8
8
  = f.button :submit, class: 'btn btn-success'
9
+ = f.button :submit_and_continue_with_edit, class: 'btn btn-success'
10
+ = f.button :submit_and_continue_with_new, class: 'btn btn-success'
9
11
 
10
12
  .well.well-sm
11
13
  = link_to resource_path(@resource), class: 'btn btn-primary btn-responsive' do
@@ -6,6 +6,8 @@
6
6
  = render partial: 'form_errors', locals: { resource: f.object }
7
7
  = render 'form', form: f
8
8
  = f.button :submit, class: 'btn btn-success'
9
+ = f.button :submit_and_continue_with_edit, class: 'btn btn-success'
10
+ = f.button :submit_and_continue_with_new, class: 'btn btn-success'
9
11
  %div.panel-footer
10
12
 
11
13
  .well.well-sm
@@ -1,4 +1,7 @@
1
1
  require 'simple_form/form_builder'
2
2
 
3
3
  require 'concerns/form/ui_autocomplete'
4
- SimpleForm::FormBuilder.send(:include, Concerns::Form::UiAutocomplete)
4
+ SimpleForm::FormBuilder.send(:include, Concerns::Form::UiAutocomplete)
5
+
6
+ require 'concerns/form/additional_submit_buttons'
7
+ SimpleForm::FormBuilder.send(:include, Concerns::Form::AdditionalSubmitButtons)
@@ -37,7 +37,12 @@ de:
37
37
  notice: "%{resource_name} veröffentlicht."
38
38
  unpublished:
39
39
  notice: "%{resource_name} zurückgezogen."
40
-
40
+ helpers:
41
+ submit:
42
+ create_and_continue_with_edit: "%{resource_name} erstellen und weiter bearbeiten"
43
+ create_and_continue_with_new: "%{resource_name} erstellen und neu"
44
+ update_and_continue_with_edit: "%{resource_name} aktualisieren und weiter bearbeiten"
45
+ update_and_continue_with_new: "%{resource_name} aktualisieren und neu"
41
46
  itsf_backend: "Backend"
42
47
  itsf:
43
48
  backend:
@@ -1,5 +1,5 @@
1
1
  module Itsf
2
2
  module Backend
3
- VERSION = '1.1.6'
3
+ VERSION = '1.1.7'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: itsf_backend
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Roberto Vasquez Angel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-03-08 00:00:00.000000000 Z
11
+ date: 2016-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -520,6 +520,7 @@ files:
520
520
  - app/extensions/concerns/resource_row/published_extensions.rb
521
521
  - app/extensions/concerns/resource_row/timestamp_extensions.rb
522
522
  - app/extensions/concerns/simple_form_form_builder_extensions.rb
523
+ - app/forms/concerns/form/additional_submit_buttons.rb
523
524
  - app/forms/concerns/form/ui_autocomplete.rb
524
525
  - app/helpers/itsf/backend/application_helper.rb
525
526
  - app/inputs/fake_checkbox_input.rb