wobapphelpers 3.1.1 → 4.0.0
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 +5 -5
- data/LICENSE +1 -1
- data/README.md +10 -4
- data/app/assets/config/manifest.js +3 -0
- data/config/locales/de.yml +11 -6
- data/config/locales/en.yml +9 -4
- data/lib/wobapphelpers/breadcrumbs/action_controller.rb +0 -5
- data/lib/wobapphelpers/breadcrumbs/breadcrumbs_helper.rb +5 -10
- data/lib/wobapphelpers/helpers/action_view_helper.rb +40 -27
- data/lib/wobapphelpers/helpers/icon_helper.rb +2 -2
- data/lib/wobapphelpers/version.rb +2 -2
- data/test/breadcrumbs/breadcrumb_helper_test.rb +3 -3
- data/test/helpers/action_view_helper_test.rb +3 -4
- data/test/helpers/can_view_helper_test.rb +0 -1
- data/test/helpers/form_legend_test.rb +2 -2
- data/test/helpers/icon_helper_test.rb +4 -5
- data/test/helpers/show_edit_delete_link_helper_test.rb +0 -1
- data/test/integration/helper_delivery_test.rb +1 -1
- data/test/tmp/config/initializers/wobapphelpers.rb +18 -0
- metadata +23 -23
- data/test/tmp/lib/templates/rails/scaffold_controller/controller.rb +0 -66
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 12c301fa73d2bc6e7ed490e0c4705e97fe958cecadab3cd603bb00c6bc9f43e0
|
4
|
+
data.tar.gz: b2c5d81eb33f8f8cca05c2a51e5c835394db40a31f04304ecb4db9a0ac8712c8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5761d19b7170a14b1e870b938773dedc4eae005ff3a4be9d59f90e85c1d5b15263319b9b8610ac6035ed43aeb85f034ba00de04f335f093a6e433c45ef8950eb
|
7
|
+
data.tar.gz: d3799fb2cb12d6706491f8e1e323bdb762f4f891201d65fe3c3a587a175b922a95769a7d4b6cc4a13f61122126a9171dadaf10d418d1503c1c83f0d1fd2e97f0
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -1,16 +1,22 @@
|
|
1
1
|
wobapphelpers
|
2
2
|
=============
|
3
3
|
|
4
|
-
|
4
|
+
This is the ''master'' branch, for use with rails >= 5.2.
|
5
|
+
|
6
|
+
BREAKING CHANGE between 3-0 -> master: please reinstall wobapphelpers locales with:
|
7
|
+
|
8
|
+
* rails g wobapphelpers:install
|
5
9
|
|
6
|
-
|
10
|
+
|
11
|
+
Rails helpers and more shared between common wob rails applications. Depends on twitter bootstrap.
|
7
12
|
|
8
13
|
Requirements
|
9
14
|
------------
|
10
15
|
|
11
16
|
| branch | rails | ruby | bootstrap | icons |
|
12
17
|
|------------|-------|--------|-----------|-------------|
|
13
|
-
| master | 5.
|
18
|
+
| master | 5.2 | >= 2.3 | v4 | fontawesome |
|
19
|
+
| 3-0-stable | 5.1 | >= 2.3 | v4 | fontawesome |
|
14
20
|
| 2-0-stable | 5.0 | >= 2.2 | v3 | glyphicons |
|
15
21
|
| 1-0-stable | 4.2 | >= 2.0 | v3 | glyphicons |
|
16
22
|
|
@@ -149,7 +155,7 @@ other variable names you have to use :add_breadcrumbs_for, i.e.
|
|
149
155
|
Licence
|
150
156
|
-------
|
151
157
|
|
152
|
-
Wobapphelpers Copyright (C) 2014-
|
158
|
+
Wobapphelpers Copyright (C) 2014-2019 Wolfgang Barth
|
153
159
|
|
154
160
|
MIT License, see [LICENSE](LICENSE)
|
155
161
|
|
data/config/locales/de.yml
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
de:
|
2
2
|
wobapphelpers:
|
3
3
|
helpers:
|
4
|
-
back:
|
5
|
-
cancel:
|
6
|
-
|
7
|
-
new: "%{
|
8
|
-
|
9
|
-
|
4
|
+
back: Zurück
|
5
|
+
cancel: Abbrechen
|
6
|
+
actions:
|
7
|
+
new: "%{model} erstellen"
|
8
|
+
create: "%{model} erstellen"
|
9
|
+
show: "%{model} anzeigen"
|
10
|
+
edit: "%{model} bearbeiten"
|
11
|
+
copy: "%{model} kopieren"
|
12
|
+
update: "%{model} bearbeiten"
|
13
|
+
destroy: "%{model} löschen"
|
14
|
+
destroy_confirm: "Der Datensatz kann nicht wieder hergestellt werden!"
|
data/config/locales/en.yml
CHANGED
@@ -3,7 +3,12 @@ en:
|
|
3
3
|
helpers:
|
4
4
|
back: Back
|
5
5
|
cancel: Cancel
|
6
|
-
|
7
|
-
new: "create %{
|
8
|
-
|
9
|
-
|
6
|
+
actions:
|
7
|
+
new: "create %{model}"
|
8
|
+
create: "create %{model}"
|
9
|
+
show: "show %{model}"
|
10
|
+
edit: "update %{model}"
|
11
|
+
update: "update %{model}"
|
12
|
+
copy: "copy %{model}"
|
13
|
+
destroy: "destroy %{model}"
|
14
|
+
destroy_confirm: "record would be finally destroyed, no recovery possible!"
|
@@ -3,11 +3,6 @@ module Wobapphelpers
|
|
3
3
|
module ActionController
|
4
4
|
def add_breadcrumb(name, url)
|
5
5
|
breadcrumbs ||= (session[:breadcrumbs] || [] )
|
6
|
-
if params[:bci]
|
7
|
-
# this a back link of an existing breadcrumb entry,
|
8
|
-
# shorten the list
|
9
|
-
breadcrumbs = breadcrumbs.first(params[:bci].to_i)
|
10
|
-
end
|
11
6
|
if breadcrumbs.size == 0 || url != breadcrumbs.last[1]
|
12
7
|
breadcrumbs << [name, url]
|
13
8
|
end
|
@@ -5,21 +5,16 @@ module Wobapphelpers
|
|
5
5
|
return if Wobapphelpers.breadcrumb_controller_blacklist.include?(controller.controller_path)
|
6
6
|
return if session[:breadcrumbs].nil? || session[:breadcrumbs].size == 0
|
7
7
|
track = ""
|
8
|
-
session[:breadcrumbs].
|
9
|
-
track += "> #{
|
8
|
+
session[:breadcrumbs].each do |b|
|
9
|
+
track += "> #{set_breadcrumb(b[0], b[1])} "
|
10
10
|
end
|
11
11
|
%Q[<div id="breadcrumbs" class="visible-desktop">#{track}</div>].html_safe
|
12
12
|
end
|
13
13
|
|
14
|
-
def
|
14
|
+
def set_breadcrumb(name, url, options = {})
|
15
|
+
options.symbolize_keys!
|
15
16
|
uri = URI.parse(url)
|
16
|
-
|
17
|
-
if query =~ /bci=(\d+)/
|
18
|
-
uri.query.gsub!(/bci=(\d+)/, "bci=#{idx}")
|
19
|
-
else
|
20
|
-
uri.query = query + "&bci=#{idx}"
|
21
|
-
end
|
22
|
-
link_to name, uri.to_s.gsub('?&','?'), :class => html_class
|
17
|
+
link_to name, uri.to_s, options
|
23
18
|
end
|
24
19
|
end
|
25
20
|
end
|
@@ -19,11 +19,9 @@ module Wobapphelpers
|
|
19
19
|
mypoly, obj = get_parts(poly)
|
20
20
|
if _can?(:create, obj)
|
21
21
|
options.symbolize_keys!
|
22
|
-
link_to obj
|
23
|
-
new_polymorphic_path(mypoly),
|
24
|
-
|
25
|
-
title: options.fetch(:title, title(obj) + " hinzufügen"),
|
26
|
-
class: options.fetch(:class, 'btn btn-secondary')
|
22
|
+
link_to title(obj, :new),
|
23
|
+
new_polymorphic_path(mypoly),
|
24
|
+
default_options(obj, :new).merge(options)
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -31,10 +29,8 @@ module Wobapphelpers
|
|
31
29
|
mypoly, obj = get_parts(poly)
|
32
30
|
if _can?(:read, obj)
|
33
31
|
options.symbolize_keys!
|
34
|
-
link_to icon_show, polymorphic_path(mypoly),
|
35
|
-
|
36
|
-
title: options.fetch(:title, title(obj) + " anzeigen"),
|
37
|
-
class: options.fetch(:class, 'btn btn-secondary')
|
32
|
+
link_to icon_show, polymorphic_path(mypoly),
|
33
|
+
default_options(obj, :show).merge(options)
|
38
34
|
end
|
39
35
|
end
|
40
36
|
|
@@ -42,10 +38,8 @@ module Wobapphelpers
|
|
42
38
|
mypoly, obj = get_parts(poly)
|
43
39
|
if _can?(:edit, obj)
|
44
40
|
options.symbolize_keys!
|
45
|
-
link_to icon_edit, edit_polymorphic_path(mypoly),
|
46
|
-
|
47
|
-
title: options.fetch(:title, title(obj) + " bearbeiten"),
|
48
|
-
class: options.fetch(:class, 'btn btn-secondary')
|
41
|
+
link_to icon_edit, edit_polymorphic_path(mypoly),
|
42
|
+
default_options(obj, :edit).merge(options)
|
49
43
|
end
|
50
44
|
end
|
51
45
|
|
@@ -53,15 +47,11 @@ module Wobapphelpers
|
|
53
47
|
mypoly, obj = get_parts(poly)
|
54
48
|
if _can?(:destroy, obj)
|
55
49
|
options.symbolize_keys!
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
}.merge(verify),
|
62
|
-
method: :delete,
|
63
|
-
title: options.fetch(:title, title(obj) + " löschen"),
|
64
|
-
class: options.fetch(:class, 'btn btn-danger')
|
50
|
+
options = delete_options(obj).merge(options)
|
51
|
+
if options[:data][:confirm].blank?
|
52
|
+
options[:data][:confirm] = confirm_message(obj)
|
53
|
+
end
|
54
|
+
link_to icon_delete, mypoly, options
|
65
55
|
end
|
66
56
|
end
|
67
57
|
|
@@ -76,7 +66,7 @@ module Wobapphelpers
|
|
76
66
|
idx = session[:breadcrumbs].size - 2
|
77
67
|
title = bc[0]
|
78
68
|
goto = bc[1]
|
79
|
-
|
69
|
+
set_breadcrumb(label, goto, class: 'btn btn-secondary')
|
80
70
|
else
|
81
71
|
link_to label, url_for(:back), :class => 'btn btn-secondary'
|
82
72
|
end
|
@@ -134,13 +124,14 @@ module Wobapphelpers
|
|
134
124
|
end
|
135
125
|
end
|
136
126
|
|
137
|
-
def title(obj)
|
127
|
+
def title(obj, action)
|
138
128
|
if obj.kind_of? Class
|
139
129
|
model = obj
|
140
130
|
else
|
141
131
|
model = obj.class
|
142
132
|
end
|
143
|
-
t(
|
133
|
+
t(action.to_s, scope: "wobapphelpers.actions".to_sym,
|
134
|
+
model: t('activerecord.models.' + model.model_name.i18n_key.to_s))
|
144
135
|
end
|
145
136
|
|
146
137
|
def controlleraction
|
@@ -148,8 +139,8 @@ module Wobapphelpers
|
|
148
139
|
namespace = controller.controller_path
|
149
140
|
resource_name = t("activerecord.models.#{namespace.singularize}")
|
150
141
|
search_for = [namespace, action].join(".").to_sym
|
151
|
-
t(search_for, scope: "wobapphelpers.
|
152
|
-
default: action.to_sym,
|
142
|
+
t(search_for, scope: "wobapphelpers.actions".to_sym,
|
143
|
+
default: action.to_sym, model: resource_name)
|
153
144
|
end
|
154
145
|
|
155
146
|
def _can?(action, obj)
|
@@ -165,6 +156,28 @@ module Wobapphelpers
|
|
165
156
|
model
|
166
157
|
end
|
167
158
|
end
|
159
|
+
|
160
|
+
def default_options(obj, action)
|
161
|
+
{
|
162
|
+
title: title(obj, action),
|
163
|
+
remote: false,
|
164
|
+
class: 'btn btn-secondary',
|
165
|
+
}
|
166
|
+
end
|
167
|
+
|
168
|
+
def delete_options(obj)
|
169
|
+
{
|
170
|
+
title: title(obj, :destroy),
|
171
|
+
remote: false,
|
172
|
+
class: 'btn btn-danger',
|
173
|
+
data: {},
|
174
|
+
method: :delete,
|
175
|
+
}
|
176
|
+
end
|
177
|
+
|
178
|
+
def confirm_message(obj)
|
179
|
+
"#{title(obj, :destroy)}?\n" + t('wobapphelpers.actions.destroy_confirm')
|
180
|
+
end
|
168
181
|
end
|
169
182
|
end
|
170
183
|
end
|
@@ -11,7 +11,7 @@ module Wobapphelpers
|
|
11
11
|
delete: 'trash',
|
12
12
|
document: 'file',
|
13
13
|
download: 'download',
|
14
|
-
edit: 'pencil',
|
14
|
+
edit: 'pencil-alt',
|
15
15
|
help: 'question',
|
16
16
|
info: 'info',
|
17
17
|
left: 'arrow-left',
|
@@ -26,7 +26,7 @@ module Wobapphelpers
|
|
26
26
|
}
|
27
27
|
|
28
28
|
def icon(what)
|
29
|
-
raw(%Q[<i class="
|
29
|
+
raw(%Q[<i class="fas fa-#{what} fa-fw" aria-hidden="true"></i>])
|
30
30
|
end
|
31
31
|
|
32
32
|
PREDEFINED_ICONS.each do |key,value|
|
@@ -10,8 +10,8 @@ class BreadcrumbHelperHelperTest < ActionDispatch::IntegrationTest
|
|
10
10
|
get home_path
|
11
11
|
get posts_path
|
12
12
|
assert_select "div#breadcrumbs" do
|
13
|
-
assert_select "[href='/home
|
14
|
-
assert_select "[href='/posts
|
13
|
+
assert_select "[href='/home']", title: "Home"
|
14
|
+
assert_select "[href='/posts']", title: "Postings"
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -22,7 +22,7 @@ class BreadcrumbHelperHelperTest < ActionDispatch::IntegrationTest
|
|
22
22
|
get home_path, headers: {'HTTP_REFERER' => 'http://example.org'}
|
23
23
|
get posts_path
|
24
24
|
assert_select "[class=?]", "btn btn-secondary" do
|
25
|
-
assert_select "[href='/home
|
25
|
+
assert_select "[href='/home']", text: /.*Zurück/
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
@@ -1,5 +1,4 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'sass'
|
3
2
|
require 'jquery-rails'
|
4
3
|
require 'shoulda-context'
|
5
4
|
|
@@ -28,12 +27,12 @@ class ActionViewHelperTest < ActionDispatch::IntegrationTest
|
|
28
27
|
"No back button found"
|
29
28
|
end
|
30
29
|
|
31
|
-
should "cancel_button renders i with class
|
30
|
+
should "cancel_button renders i with class fas" do
|
32
31
|
visit new_post_path
|
33
|
-
assert page.has_text?('
|
32
|
+
assert page.has_text?('Posting erstellen')
|
34
33
|
within('form') do
|
35
34
|
assert page.has_link?('Abbrechen'), "button submit not found"
|
36
|
-
assert find('a.btn.btn-secondary i.
|
35
|
+
assert find('a.btn.btn-secondary i.fas.fa-trash'),
|
37
36
|
"button cancel not found"
|
38
37
|
end
|
39
38
|
end
|
@@ -12,7 +12,7 @@ class FormLegendTest < ActionController::TestCase
|
|
12
12
|
get :new
|
13
13
|
assert_select "div.row" do
|
14
14
|
assert_select "div" do
|
15
|
-
assert_select "legend", text: "
|
15
|
+
assert_select "legend", text: "Posting erstellen"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
@@ -21,7 +21,7 @@ class FormLegendTest < ActionController::TestCase
|
|
21
21
|
get :edit, params: { id: @p1 }
|
22
22
|
assert_select "div.row" do
|
23
23
|
assert_select "div" do
|
24
|
-
assert_select "legend", text: "
|
24
|
+
assert_select "legend", text: "Posting bearbeiten"
|
25
25
|
end
|
26
26
|
end
|
27
27
|
end
|
@@ -1,21 +1,20 @@
|
|
1
1
|
require 'test_helper'
|
2
|
-
require 'sass'
|
3
2
|
|
4
3
|
class IconHelperTest < ActionView::TestCase
|
5
4
|
include Wobapphelpers::Helpers::IconHelper
|
6
5
|
|
7
|
-
test "icon() renders i with class
|
6
|
+
test "icon() renders i with class fas" do
|
8
7
|
render plain: icon('search')
|
9
8
|
|
10
|
-
assert_select 'i.
|
11
|
-
assert_select 'i.
|
9
|
+
assert_select 'i.fas.fa-search.fa-fw', 1
|
10
|
+
assert_select 'i.fas.fa-quark', 0
|
12
11
|
end
|
13
12
|
|
14
13
|
Wobapphelpers::Helpers::IconHelper::PREDEFINED_ICONS.each do |key,value|
|
15
14
|
test "icon_#{key} renders i with class fa-#{value}" do
|
16
15
|
render plain: send("icon_#{key}")
|
17
16
|
|
18
|
-
assert_select "i.
|
17
|
+
assert_select "i.fas.fa-#{value}", 1
|
19
18
|
end
|
20
19
|
end
|
21
20
|
end
|
@@ -11,7 +11,7 @@ class HelperDeliveryTest < ActionDispatch::IntegrationTest
|
|
11
11
|
get home_path
|
12
12
|
assert_response :success
|
13
13
|
Wobapphelpers::Helpers::IconHelper::PREDEFINED_ICONS.each do |key,value|
|
14
|
-
assert_match "<i class=\"
|
14
|
+
assert_match "<i class=\"fas fa-#{value} fa-fw\" aria-hidden=\"true\"></i>", response.body
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
Wobapphelpers.setup do |config|
|
2
|
+
#
|
3
|
+
# exclude some controllers from breadcrumbs
|
4
|
+
# the given string must match controller.controller_name
|
5
|
+
#
|
6
|
+
# example:
|
7
|
+
# config.breadcrumb_controller_blacklist = ["user_sessions"]
|
8
|
+
# default:
|
9
|
+
# config.breadcrumb_controller_blacklist = []
|
10
|
+
#
|
11
|
+
# show action links only if has ability to execute the action
|
12
|
+
# * :none : always present action links
|
13
|
+
# * :cancan1 : for cancancan '~>1.7.0' or cancan '~>1.6.0'
|
14
|
+
# * :cancan2 : for cancan '~>2.0.0', untested
|
15
|
+
#
|
16
|
+
# default:
|
17
|
+
# config.cancan = :none
|
18
|
+
end
|
metadata
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wobapphelpers
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wolfgang Barth
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-11-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: sassc-rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
@@ -26,32 +26,18 @@ dependencies:
|
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rails
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '5.0'
|
34
|
-
type: :runtime
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - "~>"
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '5.0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: sassc-rails
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
46
32
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
33
|
+
version: '5.0'
|
48
34
|
type: :runtime
|
49
35
|
prerelease: false
|
50
36
|
version_requirements: !ruby/object:Gem::Requirement
|
51
37
|
requirements:
|
52
38
|
- - ">="
|
53
39
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
40
|
+
version: '5.0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: coffee-rails
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -114,6 +100,20 @@ dependencies:
|
|
114
100
|
- - "<="
|
115
101
|
- !ruby/object:Gem::Version
|
116
102
|
version: '6'
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: responders
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - ">="
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
type: :runtime
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - ">="
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0'
|
117
117
|
- !ruby/object:Gem::Dependency
|
118
118
|
name: sqlite3
|
119
119
|
requirement: !ruby/object:Gem::Requirement
|
@@ -292,6 +292,7 @@ files:
|
|
292
292
|
- LICENSE
|
293
293
|
- README.md
|
294
294
|
- Rakefile
|
295
|
+
- app/assets/config/manifest.js
|
295
296
|
- app/assets/stylesheets/wobapphelpers/breadcrumbs.scss
|
296
297
|
- config/locales/de.yml
|
297
298
|
- config/locales/en.yml
|
@@ -363,7 +364,7 @@ files:
|
|
363
364
|
- test/integration/helper_delivery_test.rb
|
364
365
|
- test/responders/flash_test.rb
|
365
366
|
- test/test_helper.rb
|
366
|
-
- test/tmp/
|
367
|
+
- test/tmp/config/initializers/wobapphelpers.rb
|
367
368
|
- test/translate_test.rb
|
368
369
|
- test/wobapphelpers_test.rb
|
369
370
|
homepage: http://github.com/swobspace/wobapphelpers
|
@@ -385,13 +386,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
385
386
|
- !ruby/object:Gem::Version
|
386
387
|
version: '0'
|
387
388
|
requirements: []
|
388
|
-
|
389
|
-
rubygems_version: 2.6.14.1
|
389
|
+
rubygems_version: 3.0.3
|
390
390
|
signing_key:
|
391
391
|
specification_version: 4
|
392
392
|
summary: Rails helpers and more shared between wob's rails applications
|
393
393
|
test_files:
|
394
|
-
- test/tmp/
|
394
|
+
- test/tmp/config/initializers/wobapphelpers.rb
|
395
395
|
- test/wobapphelpers_test.rb
|
396
396
|
- test/helpers/can_view_helper_test.rb
|
397
397
|
- test/helpers/action_view_helper_test.rb
|
@@ -1,66 +0,0 @@
|
|
1
|
-
<% if namespaced? -%>
|
2
|
-
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
-
|
4
|
-
<% end -%>
|
5
|
-
<% module_namespacing do -%>
|
6
|
-
class <%= controller_class_name %>Controller < ApplicationController
|
7
|
-
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
8
|
-
before_action :add_breadcrumb_show, only: [:show]
|
9
|
-
|
10
|
-
# GET <%= route_url %>
|
11
|
-
def index
|
12
|
-
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
13
|
-
respond_with(@<%= plural_table_name %>)
|
14
|
-
end
|
15
|
-
|
16
|
-
# GET <%= route_url %>/1
|
17
|
-
def show
|
18
|
-
respond_with(@<%= singular_table_name %>)
|
19
|
-
end
|
20
|
-
|
21
|
-
# GET <%= route_url %>/new
|
22
|
-
def new
|
23
|
-
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
24
|
-
respond_with(@<%= singular_table_name %>)
|
25
|
-
end
|
26
|
-
|
27
|
-
# GET <%= route_url %>/1/edit
|
28
|
-
def edit
|
29
|
-
end
|
30
|
-
|
31
|
-
# POST <%= route_url %>
|
32
|
-
def create
|
33
|
-
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
34
|
-
|
35
|
-
@<%= orm_instance.save %>
|
36
|
-
respond_with(@<%= singular_table_name %>)
|
37
|
-
end
|
38
|
-
|
39
|
-
# PATCH/PUT <%= route_url %>/1
|
40
|
-
def update
|
41
|
-
@<%= orm_instance.update("#{singular_table_name}_params") %>
|
42
|
-
respond_with(@<%= singular_table_name %>)
|
43
|
-
end
|
44
|
-
|
45
|
-
# DELETE <%= route_url %>/1
|
46
|
-
def destroy
|
47
|
-
@<%= orm_instance.destroy %>
|
48
|
-
respond_with(@<%= singular_table_name %>)
|
49
|
-
end
|
50
|
-
|
51
|
-
private
|
52
|
-
# Use callbacks to share common setup or constraints between actions.
|
53
|
-
def set_<%= singular_table_name %>
|
54
|
-
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
55
|
-
end
|
56
|
-
|
57
|
-
# Only allow a trusted parameter "white list" through.
|
58
|
-
def <%= "#{singular_table_name}_params" %>
|
59
|
-
<%- if attributes_names.empty? -%>
|
60
|
-
params[:<%= singular_table_name %>]
|
61
|
-
<%- else -%>
|
62
|
-
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
63
|
-
<%- end -%>
|
64
|
-
end
|
65
|
-
end
|
66
|
-
<% end -%>
|