lotus_admin 1.5.0 → 1.5.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/lotus_admin/datepickers.js.coffee +3 -4
- data/app/controllers/lotus_admin/resource_controller.rb +19 -5
- data/app/controllers/lotus_admin/users_controller.rb +1 -1
- data/app/helpers/lotus_admin/link_helpers.rb +35 -3
- data/app/inputs/currency_input.rb +22 -0
- data/app/inputs/date_time_input.rb +28 -0
- data/app/views/lotus_admin/resource/edit.html.haml +1 -1
- data/app/views/lotus_admin/resource/index.html.haml +2 -6
- data/app/views/lotus_admin/resource/show.html.haml +3 -3
- data/app/views/lotus_admin/shared/table/_actions.html.haml +5 -0
- data/app/views/lotus_admin/users/edit.html.haml +1 -1
- data/app/views/lotus_admin/users/index.html.haml +4 -4
- data/app/views/lotus_admin/users/show.html.haml +2 -2
- data/lib/lotus_admin/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7e57539d667b82f3e4212841eb753c5ad31c65c7c3e67ebb38660032f56c1a4e
|
4
|
+
data.tar.gz: 965da47c55f3f89e867fc4baa338013c49b896712db2eb1b146869dba1f0aa95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae1f254edaa96c81589c526b955d2f099768a69b68999ddd8155b1e0f414cbf72f266ea3922765add1059c3a340f2fa26ade8e978871c2f6717f8b8be5621dae
|
7
|
+
data.tar.gz: 27e4aef7ba354a1c039eb6bc4aef087e8477aef3ab6d537b147f26f9ece1a90a55568da42b4152ad927bf658092aaea95537e115fb55471b2fac3e256f279dcf
|
@@ -12,14 +12,13 @@ $ ->
|
|
12
12
|
}
|
13
13
|
|
14
14
|
setup_datepickers = (container)->
|
15
|
-
container.find('.input-group.date
|
15
|
+
container.find('.input-group.date').datetimepicker
|
16
16
|
format: 'YYYY-MM-DD',
|
17
17
|
icons: icons
|
18
18
|
|
19
|
-
container.find('.input-group.datetime
|
19
|
+
container.find('.input-group.datetime').datetimepicker
|
20
20
|
format: 'YYYY-MM-DD hh:mm a',
|
21
|
-
icons: icons
|
22
|
-
debug: true
|
21
|
+
icons: icons
|
23
22
|
|
24
23
|
# On page load
|
25
24
|
setup_datepickers($('body'))
|
@@ -32,7 +32,7 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
|
|
32
32
|
format.html
|
33
33
|
|
34
34
|
if block.present?
|
35
|
-
block.call
|
35
|
+
block.call(format)
|
36
36
|
else
|
37
37
|
if resource.save
|
38
38
|
redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human } successfully"
|
@@ -43,16 +43,30 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
def
|
46
|
+
def edit(&block)
|
47
47
|
authorize(resource) if using_pundit?
|
48
48
|
|
49
49
|
if block.present?
|
50
50
|
block.call
|
51
51
|
else
|
52
|
-
|
53
|
-
|
52
|
+
render :edit
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def update(&block)
|
57
|
+
authorize(resource) if using_pundit?
|
58
|
+
|
59
|
+
respond_to do |format|
|
60
|
+
format.html
|
61
|
+
|
62
|
+
if block.present?
|
63
|
+
block.call(format)
|
54
64
|
else
|
55
|
-
|
65
|
+
if resource.update(permitted_params)
|
66
|
+
redirect_to after_update_redirect, notice: "Updated #{ resource_class.model_name.human } successfully"
|
67
|
+
else
|
68
|
+
render :edit
|
69
|
+
end
|
56
70
|
end
|
57
71
|
end
|
58
72
|
end
|
@@ -1,7 +1,39 @@
|
|
1
1
|
module LotusAdmin
|
2
2
|
module LinkHelpers
|
3
|
+
def default_table_actions_column(resource)
|
4
|
+
render 'lotus_admin/shared/table/actions', resource: resource
|
5
|
+
end
|
6
|
+
|
7
|
+
def undecorated(resource)
|
8
|
+
resource.try(:object).presence || resource
|
9
|
+
end
|
10
|
+
|
11
|
+
def view_resource_item(resource)
|
12
|
+
if policy(resource).show?
|
13
|
+
content_tag(:li) { view_link(resource) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def new_resource_item(parent = nil)
|
18
|
+
if policy(resource_class).new?
|
19
|
+
content_tag(:li) { new_link(parent) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def edit_resource_item(resource)
|
24
|
+
if policy(resource).edit?
|
25
|
+
content_tag(:li) { edit_link(resource) }
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def destroy_resource_item(resource)
|
30
|
+
if policy(resource).destroy?
|
31
|
+
content_tag(:li) { destroy_link(resource) }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
3
35
|
def view_link(resource)
|
4
|
-
link_to lotus_admin.polymorphic_path(resource) do
|
36
|
+
link_to lotus_admin.polymorphic_path(undecorated(resource)) do
|
5
37
|
content_tag(:i, nil, class: 'zmdi zmdi-eye')
|
6
38
|
end
|
7
39
|
end
|
@@ -13,13 +45,13 @@ module LotusAdmin
|
|
13
45
|
end
|
14
46
|
|
15
47
|
def edit_link(resource)
|
16
|
-
link_to lotus_admin.edit_polymorphic_path(resource) do
|
48
|
+
link_to lotus_admin.edit_polymorphic_path(undecorated(resource)) do
|
17
49
|
content_tag(:i, nil, class: 'zmdi zmdi-edit')
|
18
50
|
end
|
19
51
|
end
|
20
52
|
|
21
53
|
def destroy_link(resource)
|
22
|
-
link_to lotus_admin.polymorphic_path(resource), data: { method: :delete, confirm: "Are you sure you want to remove this #{ resource.model_name.human }?" } do
|
54
|
+
link_to lotus_admin.polymorphic_path(undecorated(resource)), data: { method: :delete, confirm: "Are you sure you want to remove this #{ resource.model_name.human }?" } do
|
23
55
|
content_tag(:i, nil, class: 'zmdi zmdi-delete')
|
24
56
|
end
|
25
57
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class CurrencyInput < SimpleForm::Inputs::Base
|
2
|
+
def input(wrapper_options)
|
3
|
+
currency = options.delete(:currency) || default_currency
|
4
|
+
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
|
5
|
+
|
6
|
+
content_tag(:div, input_group(currency, merged_input_options), class: "input-group")
|
7
|
+
end
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def input_group(currency, merged_input_options)
|
12
|
+
"#{currency_addon(currency)} #{@builder.text_field(attribute_name, merged_input_options)}".html_safe
|
13
|
+
end
|
14
|
+
|
15
|
+
def currency_addon(currency)
|
16
|
+
content_tag(:span, currency, class: "input-group-addon")
|
17
|
+
end
|
18
|
+
|
19
|
+
def default_currency
|
20
|
+
"$"
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class DateTimeInput < SimpleForm::Inputs::Base
|
2
|
+
def input(wrapper_options)
|
3
|
+
merged_input_options = merge_wrapper_options(input_html_options, wrapper_options)
|
4
|
+
|
5
|
+
content_tag(:div, input_group(merged_input_options), class: "input-group datetime")
|
6
|
+
end
|
7
|
+
|
8
|
+
private
|
9
|
+
|
10
|
+
def input_group(merged_input_options)
|
11
|
+
"#{calendar_addon} #{@builder.text_field(attribute_name, merged_input_options)}".html_safe
|
12
|
+
end
|
13
|
+
|
14
|
+
def calendar_addon
|
15
|
+
content_tag(:span, calendar_icon, class: "input-group-addon")
|
16
|
+
end
|
17
|
+
|
18
|
+
def calendar_icon
|
19
|
+
@builder.template.fa_icon(:calendar)
|
20
|
+
end
|
21
|
+
|
22
|
+
def input_html_options
|
23
|
+
super.merge({
|
24
|
+
class: 'datetime',
|
25
|
+
value: @builder.object.public_send(attribute_name)&.strftime('%Y-%m-%d %l:%M %P')
|
26
|
+
})
|
27
|
+
end
|
28
|
+
end
|
@@ -1,5 +1,5 @@
|
|
1
1
|
- content_for :action_items do
|
2
|
-
|
2
|
+
= new_resource_item
|
3
3
|
|
4
4
|
= render_index do
|
5
5
|
.table-responsive
|
@@ -12,8 +12,4 @@
|
|
12
12
|
- collection.each do |resource|
|
13
13
|
%tr
|
14
14
|
%td= link_to resource.id, [lotus_admin, resource]
|
15
|
-
|
16
|
-
%ul.actions
|
17
|
-
%li= view_link(resource)
|
18
|
-
%li= edit_link(resource)
|
19
|
-
%li= destroy_link(resource)
|
15
|
+
= default_table_actions_column(resource)
|
@@ -2,9 +2,9 @@
|
|
2
2
|
%h2= page_title!("#{ resource_class.model_name.human } Details")
|
3
3
|
|
4
4
|
%ul.actions
|
5
|
-
|
6
|
-
|
7
|
-
|
5
|
+
= edit_resource_item(resource)
|
6
|
+
= destroy_resource_item(resource)
|
7
|
+
= new_resource_item
|
8
8
|
|
9
9
|
.card
|
10
10
|
.card-header
|
@@ -1,5 +1,5 @@
|
|
1
1
|
- content_for :action_items do
|
2
|
-
|
2
|
+
= new_resource_item
|
3
3
|
|
4
4
|
= render_index do
|
5
5
|
.table-responsive
|
@@ -20,6 +20,6 @@
|
|
20
20
|
%td= user.email
|
21
21
|
%td.actions-col
|
22
22
|
%ul.actions
|
23
|
-
|
24
|
-
|
25
|
-
|
23
|
+
= view_resource_item(user)
|
24
|
+
= edit_resource_item(user)
|
25
|
+
= destroy_resource_item(user)
|
data/lib/lotus_admin/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lotus_admin
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Millsaps-Brewer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-06-
|
11
|
+
date: 2020-06-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -405,7 +405,9 @@ files:
|
|
405
405
|
- app/helpers/lotus_admin/panel_helpers.rb
|
406
406
|
- app/helpers/lotus_admin/render_helpers.rb
|
407
407
|
- app/helpers/lotus_admin/sidebar_helpers.rb
|
408
|
+
- app/inputs/currency_input.rb
|
408
409
|
- app/inputs/date_picker_input.rb
|
410
|
+
- app/inputs/date_time_input.rb
|
409
411
|
- app/jobs/lotus_admin/application_job.rb
|
410
412
|
- app/mailers/lotus_admin/application_mailer.rb
|
411
413
|
- app/mailers/lotus_admin/user_mailer.rb
|
@@ -453,6 +455,7 @@ files:
|
|
453
455
|
- app/views/lotus_admin/shared/_index.html.haml
|
454
456
|
- app/views/lotus_admin/shared/filters/_modal.html.haml
|
455
457
|
- app/views/lotus_admin/shared/filters/_results_banner.html.haml
|
458
|
+
- app/views/lotus_admin/shared/table/_actions.html.haml
|
456
459
|
- app/views/lotus_admin/user_mailer/invited.html.haml
|
457
460
|
- app/views/lotus_admin/user_mailer/invited.text.erb
|
458
461
|
- app/views/lotus_admin/users/_form.html.haml
|