wobapphelpers 3.1.1 → 4.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +1 -1
- data/README.md +12 -5
- data/app/assets/config/manifest.js +3 -0
- data/config/locales/de.yml +11 -6
- data/config/locales/en.yml +9 -4
- data/lib/generators/templates/erb/scaffold/_form.html.erb +12 -20
- data/lib/generators/templates/erb/scaffold/index.html.erb +43 -24
- data/lib/generators/templates/erb/scaffold/show.html.erb +20 -13
- data/lib/wobapphelpers/breadcrumbs/action_controller.rb +0 -5
- data/lib/wobapphelpers/breadcrumbs/breadcrumbs_helper.rb +5 -10
- data/lib/wobapphelpers/helpers.rb +2 -0
- data/lib/wobapphelpers/helpers/action_view_helper.rb +40 -27
- data/lib/wobapphelpers/helpers/icon_helper.rb +3 -2
- data/lib/wobapphelpers/helpers/polymorphic_helper.rb +51 -0
- data/lib/wobapphelpers/version.rb +2 -2
- data/test/breadcrumbs/breadcrumb_helper_test.rb +3 -3
- data/test/dummy/app/controllers/application_controller.rb +1 -1
- data/test/dummy/config/application.rb +0 -2
- data/test/dummy/config/boot.rb +2 -4
- data/test/dummy/config/environment.rb +1 -1
- data/test/dummy/config/environments/development.rb +50 -11
- data/test/dummy/config/environments/production.rb +64 -27
- data/test/dummy/config/environments/test.rb +28 -14
- data/test/dummy/config/initializers/application_controller_renderer.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +4 -3
- data/test/dummy/config/initializers/content_security_policy.rb +28 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -1
- data/test/dummy/config/initializers/filter_parameter_logging.rb +3 -1
- data/test/dummy/config/initializers/new_framework_defaults_6_1.rb +63 -0
- data/test/dummy/config/initializers/permissions_policy.rb +11 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +2 -2
- data/test/dummy/config/puma.rb +43 -0
- data/test/dummy/db/migrate/20201224095623_add_service_name_to_active_storage_blobs.active_storage.rb +18 -0
- data/test/dummy/db/migrate/20201224095624_create_active_storage_variant_records.active_storage.rb +12 -0
- 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
- metadata +36 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b461d0fd48b611986501332be4b0867efd73430b40a7ad2ca8093c459e917d76
|
4
|
+
data.tar.gz: 642ee767f5d72db56976c34a53f27a152108dde5f41846b4851891d7e81238a0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c763a9d9103fbfc9f5bd378b7738319a59d8532036d003bb4ffc694f0d285cda136f83187121cafebc5b3fc4aad2459647db84e35f623ad48c9a0e40453ebfad
|
7
|
+
data.tar.gz: 1914eb04aec1dc9237fecaf44360eded2cab93d53bb19947fcc78cd156e8b30ed052947da52557bebd66d5999312bc450327fc935aea6ae9fa90437e5aac75fc
|
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:
|
5
7
|
|
6
|
-
|
8
|
+
* rails g wobapphelpers:install
|
9
|
+
|
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
|
|
@@ -19,9 +25,10 @@ Requirements
|
|
19
25
|
Installation
|
20
26
|
------------
|
21
27
|
|
28
|
+
gem 'wobapphelpers', github: 'swobspace/wobapphelpers', branch: "master"
|
29
|
+
gem 'wobapphelpers', github: 'swobspace/wobapphelpers', branch: "3-0-stable"
|
22
30
|
gem 'wobapphelpers', github: 'swobspace/wobapphelpers', branch: "2-0-stable"
|
23
31
|
gem 'wobapphelpers', github: 'swobspace/wobapphelpers', branch: "1-0-stable"
|
24
|
-
gem 'wobapphelpers', github: 'swobspace/wobapphelpers', branch: "master"
|
25
32
|
|
26
33
|
Generators
|
27
34
|
----------
|
@@ -149,7 +156,7 @@ other variable names you have to use :add_breadcrumbs_for, i.e.
|
|
149
156
|
Licence
|
150
157
|
-------
|
151
158
|
|
152
|
-
Wobapphelpers Copyright (C) 2014-
|
159
|
+
Wobapphelpers Copyright (C) 2014-2021 Wolfgang Barth
|
153
160
|
|
154
161
|
MIT License, see [LICENSE](LICENSE)
|
155
162
|
|
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!"
|
@@ -1,26 +1,18 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
wrapper_mappings: {
|
5
|
-
check_boxes: :horizontal_radio_and_checkboxes,
|
6
|
-
radio_buttons: :horizontal_radio_and_checkboxes,
|
7
|
-
file: :horizontal_file_input,
|
8
|
-
boolean: :horizontal_boolean
|
9
|
-
}) do |f| %>
|
1
|
+
<div class="container">
|
2
|
+
<%%= simple_form_for(@<%= singular_table_name %>,
|
3
|
+
html: { class: 'form-horizontal card' }) do |f| %>
|
10
4
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
<div class="form-inputs">
|
15
|
-
<%- attributes.each do |attribute| -%>
|
16
|
-
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %><% (attribute.field_type == :date_select) ? ', as: :string' : '' %>
|
17
|
-
%>
|
18
|
-
<%- end -%>
|
5
|
+
<div class="card-header">
|
6
|
+
<%%= form_legend %>
|
19
7
|
</div>
|
8
|
+
<div class="card-body">
|
9
|
+
<%- attributes.each do |attribute| -%>
|
10
|
+
<%%= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %><% (attribute.field_type == :date_select) ? ', as: :string' : '' %>
|
11
|
+
%>
|
12
|
+
<%- end -%>
|
20
13
|
|
21
|
-
<div class="col-sm-9 col-sm-offset-3">
|
22
14
|
<%%= f.button :submit, class: 'btn btn-primary' %>
|
23
15
|
<%%= cancel_button %>
|
24
16
|
</div>
|
25
|
-
|
26
|
-
|
17
|
+
<%% end %>
|
18
|
+
</div>
|
@@ -1,30 +1,49 @@
|
|
1
|
-
|
1
|
+
<%% content_for :head do %>
|
2
|
+
<meta name="turbolinks-cache-control" content="no-cache">
|
3
|
+
<%% end %>
|
2
4
|
|
3
|
-
<
|
4
|
-
<thead>
|
5
|
-
<tr>
|
6
|
-
<% attributes.each do |attribute| -%>
|
7
|
-
<th><%%= t('attributes.<%= attribute.name %>') %></th>
|
8
|
-
<% end -%>
|
9
|
-
<th></th>
|
10
|
-
</tr>
|
11
|
-
</thead>
|
12
|
-
<tbody>
|
5
|
+
<h1><%%= t('controller.<%= plural_table_name %>') %></h1>
|
13
6
|
|
14
|
-
|
15
|
-
<%%=
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
7
|
+
<div data-controller="datatables">
|
8
|
+
<%%= content_tag :table, role: :datatable,
|
9
|
+
id: "<%= plural_table_name + "_table" %>",
|
10
|
+
class: "table table-bordered table-responsive-xl",
|
11
|
+
data: {
|
12
|
+
'datatables-target': 'datatable',
|
13
|
+
order: [[0, 'desc']].to_json
|
14
|
+
} do %>
|
15
|
+
<thead>
|
16
|
+
<tr class="search">
|
17
|
+
<% attributes.each do |attribute| -%>
|
18
|
+
<th><%%= t('attributes.<%= attribute.name %>') %></th>
|
19
|
+
<% end -%>
|
20
|
+
<th class="nosort"><%%= t('daisy.action') %></th>
|
21
|
+
</tr>
|
22
|
+
</thead>
|
23
|
+
<tfoot>
|
24
|
+
<tr>
|
25
|
+
<% attributes.each do |attribute| -%>
|
26
|
+
<th></th>
|
27
|
+
<% end -%>
|
28
|
+
<th></th>
|
29
|
+
</tr>
|
30
|
+
</tfoot>
|
31
|
+
<tbody>
|
32
|
+
<%% @<%= plural_table_name %>.each do |<%= singular_table_name %>| %>
|
33
|
+
<%%= content_tag_for(:tr, <%= singular_table_name %>) do %>
|
34
|
+
<% attributes.each do |attribute| -%>
|
35
|
+
<td><%%= <%= singular_table_name %>.<%= attribute.name %> %></td>
|
36
|
+
<% end -%>
|
37
|
+
<td class="text-nowrap">
|
38
|
+
<%%= show_link <%= singular_table_name %> %>
|
39
|
+
<%%= edit_link <%= singular_table_name %> %>
|
40
|
+
<%%= delete_link <%= singular_table_name %> %>
|
41
|
+
</td>
|
42
|
+
<%% end %>
|
43
|
+
<%% end %>
|
44
|
+
</tbody>
|
24
45
|
<%% end %>
|
25
|
-
|
26
|
-
</tbody>
|
27
|
-
</table>
|
46
|
+
</div>
|
28
47
|
|
29
48
|
<br />
|
30
49
|
|
@@ -1,15 +1,22 @@
|
|
1
|
-
<
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
<%
|
8
|
-
|
1
|
+
<div class="card">
|
2
|
+
<div class="card-header">
|
3
|
+
<h4><%%= t('activerecord.models.<%= singular_table_name %>') %></h4>
|
4
|
+
</div>
|
5
|
+
<div class="card-body">
|
6
|
+
<table class="table table-bordered table-hover autowidth">
|
7
|
+
<% attributes.each do |attribute| %>
|
8
|
+
<tr>
|
9
|
+
<th><%%= t('attributes.<%= attribute.name %>')%>:</th>
|
10
|
+
<td><%%= @<%= singular_table_name %>.<%= attribute.name %> %></td>
|
11
|
+
</tr>
|
12
|
+
<% end -%>
|
13
|
+
</table>
|
9
14
|
|
10
|
-
<div role="toolbar">
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
+
<div role="toolbar">
|
16
|
+
<%%= back_link %>
|
17
|
+
<%%= edit_link(@<%= singular_table_name %>) %>
|
18
|
+
<%%= delete_link(@<%= singular_table_name %>) %>
|
19
|
+
<%%= new_link <%= class_name %> %>
|
20
|
+
</div>
|
21
|
+
</div>
|
15
22
|
</div>
|
@@ -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
|
@@ -2,11 +2,13 @@ module Wobapphelpers
|
|
2
2
|
module Helpers
|
3
3
|
autoload :IconHelper, 'wobapphelpers/helpers/icon_helper.rb'
|
4
4
|
autoload :ActionViewHelper, 'wobapphelpers/helpers/action_view_helper.rb'
|
5
|
+
autoload :PolymorphicHelper, 'wobapphelpers/helpers/polymorphic_helper.rb'
|
5
6
|
|
6
7
|
# one module to rule all
|
7
8
|
module All
|
8
9
|
include IconHelper
|
9
10
|
include ActionViewHelper
|
11
|
+
# PolymorphicHelper must be explicit included
|
10
12
|
end
|
11
13
|
end
|
12
14
|
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
|