lotus_admin 1.4.3 → 1.5.1
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 +4 -4
- data/app/controllers/lotus_admin/resource_controller.rb +46 -10
- data/app/controllers/lotus_admin/users_controller.rb +8 -29
- data/app/helpers/lotus_admin/link_helpers.rb +30 -2
- data/app/views/lotus_admin/resource/_form.html.haml +16 -14
- data/app/views/lotus_admin/resource/edit.html.haml +2 -7
- data/app/views/lotus_admin/resource/index.html.haml +2 -6
- data/app/views/lotus_admin/resource/new.html.haml +1 -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/config/initializers/devise.rb +1 -1
- data/lib/lotus_admin/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 045cf584020f6a9ddb26bb32732a6c34d0a562d2691351fea2748acc07930140
|
4
|
+
data.tar.gz: 7cb526a8e6abc0d62357d47d394a4d83b8ac02ebd6c31c42b1b464e7872911c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fa06a04c853e7412efdc49d4f4f6b821cb8638dc962a485549881fbdb68ecd19a505ccb379405de262f2f3387186fdcfc8253daf0b23aebd3680d910c28da14c
|
7
|
+
data.tar.gz: 61f92a76cfeedbd9e1d0d1353961716207baa72d10a7fece3dacd65d6e239902d94d107ae4ef52b4b07f9b229b94e73a44d3db9ae292ca09057116f43ff2fdb9
|
@@ -15,34 +15,58 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
|
|
15
15
|
let(:resource_class) { self.class._resource_class }
|
16
16
|
let(:collection_path) { url_for(resource_class) }
|
17
17
|
|
18
|
-
def new
|
18
|
+
def new(&block)
|
19
19
|
self.resource = build_resource
|
20
20
|
|
21
21
|
authorize(resource) if using_pundit?
|
22
|
+
|
23
|
+
block.call if block.present?
|
22
24
|
end
|
23
25
|
|
24
|
-
def create
|
26
|
+
def create(&block)
|
25
27
|
self.resource = build_resource(permitted_params)
|
26
28
|
|
27
29
|
authorize(resource) if using_pundit?
|
28
30
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
31
|
+
respond_to do |format|
|
32
|
+
format.html
|
33
|
+
|
34
|
+
if block.present?
|
35
|
+
block.call
|
36
|
+
else
|
37
|
+
if resource.save
|
38
|
+
redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human } successfully"
|
39
|
+
else
|
40
|
+
render :new
|
41
|
+
end
|
42
|
+
end
|
33
43
|
end
|
34
44
|
end
|
35
45
|
|
36
|
-
def
|
46
|
+
def edit(&block)
|
37
47
|
authorize(resource) if using_pundit?
|
38
48
|
|
39
|
-
if
|
40
|
-
|
49
|
+
if block.present?
|
50
|
+
block.call
|
41
51
|
else
|
42
52
|
render :edit
|
43
53
|
end
|
44
54
|
end
|
45
55
|
|
56
|
+
def update(&block)
|
57
|
+
authorize(resource) if using_pundit?
|
58
|
+
|
59
|
+
if block.present?
|
60
|
+
block.call
|
61
|
+
else
|
62
|
+
if resource.update(permitted_params)
|
63
|
+
redirect_to after_update_redirect, notice: "Updated #{ resource_class.model_name.human } successfully"
|
64
|
+
else
|
65
|
+
render :edit
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
46
70
|
def index(&block)
|
47
71
|
authorize(resource_class) if using_pundit?
|
48
72
|
|
@@ -66,7 +90,7 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
|
|
66
90
|
flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
|
67
91
|
end
|
68
92
|
|
69
|
-
redirect_to
|
93
|
+
redirect_to after_destroy_redirect
|
70
94
|
end
|
71
95
|
|
72
96
|
private
|
@@ -82,4 +106,16 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
|
|
82
106
|
def set_view_paths
|
83
107
|
append_view_path("lotus_admin/resource/#{ action_name }")
|
84
108
|
end
|
109
|
+
|
110
|
+
def after_update_redirect
|
111
|
+
[lotus_admin, resource]
|
112
|
+
end
|
113
|
+
|
114
|
+
def after_create_redirect
|
115
|
+
after_update_redirect
|
116
|
+
end
|
117
|
+
|
118
|
+
def after_destroy_redirect
|
119
|
+
[lotus_admin, resource_class]
|
120
|
+
end
|
85
121
|
end
|
@@ -11,39 +11,18 @@ module LotusAdmin
|
|
11
11
|
filter :created_at
|
12
12
|
filter :last_sign_in_at
|
13
13
|
|
14
|
-
def new
|
15
|
-
self.resource = resource_class.new
|
16
|
-
end
|
17
|
-
|
18
14
|
def create
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
if resource.save
|
23
|
-
resource.send_invited_email_notification
|
15
|
+
super do
|
16
|
+
resource.password = Devise.friendly_token.first(8)
|
24
17
|
|
25
|
-
|
26
|
-
|
27
|
-
render :new
|
28
|
-
end
|
29
|
-
end
|
18
|
+
if resource.save
|
19
|
+
resource.send_invited_email_notification
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
render :edit
|
21
|
+
redirect_to after_create_redirect, notice: "Created new #{ resource_class.model_name.human }"
|
22
|
+
else
|
23
|
+
render :new
|
24
|
+
end
|
36
25
|
end
|
37
26
|
end
|
38
|
-
|
39
|
-
def destroy
|
40
|
-
if user.destroy
|
41
|
-
flash[:notice] = "#{ resource_class.model_name.human } has been removed"
|
42
|
-
else
|
43
|
-
flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
|
44
|
-
end
|
45
|
-
|
46
|
-
redirect_to [lotus_admin, resource_class]
|
47
|
-
end
|
48
27
|
end
|
49
28
|
end
|
@@ -1,13 +1,41 @@
|
|
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 view_resource_item(resource)
|
8
|
+
if policy(resource).show?
|
9
|
+
content_tag(:li) { view_link(resource) }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def new_resource_item(parent = nil)
|
14
|
+
if policy(resource_class).new?
|
15
|
+
content_tag(:li) { new_link(parent) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def edit_resource_item(resource)
|
20
|
+
if policy(resource).edit?
|
21
|
+
content_tag(:li) { edit_link(resource) }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy_resource_item(resource)
|
26
|
+
if policy(resource).destroy?
|
27
|
+
content_tag(:li) { destroy_link(resource) }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
3
31
|
def view_link(resource)
|
4
32
|
link_to lotus_admin.polymorphic_path(resource) do
|
5
33
|
content_tag(:i, nil, class: 'zmdi zmdi-eye')
|
6
34
|
end
|
7
35
|
end
|
8
36
|
|
9
|
-
def new_link
|
10
|
-
link_to lotus_admin.new_polymorphic_path(resource_class) do
|
37
|
+
def new_link(parent = nil)
|
38
|
+
link_to lotus_admin.new_polymorphic_path([parent, resource_class].compact) do
|
11
39
|
content_tag(:i, nil, class: 'zmdi zmdi-plus-circle')
|
12
40
|
end
|
13
41
|
end
|
@@ -1,15 +1,17 @@
|
|
1
|
-
|
2
|
-
.
|
3
|
-
|
4
|
-
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
.card
|
2
|
+
.card-body.card-padding
|
3
|
+
= material_form_for [lotus_admin, resource] do |f|
|
4
|
+
.form-inputs
|
5
|
+
- f.object.class.columns.each do |column|
|
6
|
+
- case column.type
|
7
|
+
- when :text
|
8
|
+
= f.input column.name, as: :text, input_html: { rows: 5 }
|
9
|
+
- else
|
10
|
+
- case column.name
|
11
|
+
- when /_at$/
|
12
|
+
- else
|
13
|
+
= f.input column.name
|
12
14
|
|
13
|
-
|
14
|
-
|
15
|
-
|
15
|
+
.form-actions
|
16
|
+
= material_form_submit(resource)
|
17
|
+
= material_form_cancel(lotus_admin.polymorphic_path(resource_class))
|
@@ -2,11 +2,6 @@
|
|
2
2
|
%h2= page_title!("Edit #{ resource_class.model_name.human }")
|
3
3
|
|
4
4
|
%ul.actions
|
5
|
-
|
5
|
+
= new_resource_item
|
6
6
|
|
7
|
-
|
8
|
-
.card-header
|
9
|
-
= t('.help', resource: resource_class.model_name.human)
|
10
|
-
|
11
|
-
.card-body.card-padding
|
12
|
-
= render 'form'
|
7
|
+
= render 'form'
|
@@ -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)
|
@@ -205,7 +205,7 @@ Devise.setup do |config|
|
|
205
205
|
# Time interval you can reset your password with a reset password key.
|
206
206
|
# Don't put a too small interval or your users won't have the time to
|
207
207
|
# change their passwords.
|
208
|
-
config.reset_password_within =
|
208
|
+
config.reset_password_within = 2.days
|
209
209
|
|
210
210
|
# When set to false, does not sign a user in automatically after their password is
|
211
211
|
# reset. Defaults to true, so a user is signed in automatically after a reset.
|
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.
|
4
|
+
version: 1.5.1
|
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-
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -453,6 +453,7 @@ files:
|
|
453
453
|
- app/views/lotus_admin/shared/_index.html.haml
|
454
454
|
- app/views/lotus_admin/shared/filters/_modal.html.haml
|
455
455
|
- app/views/lotus_admin/shared/filters/_results_banner.html.haml
|
456
|
+
- app/views/lotus_admin/shared/table/_actions.html.haml
|
456
457
|
- app/views/lotus_admin/user_mailer/invited.html.haml
|
457
458
|
- app/views/lotus_admin/user_mailer/invited.text.erb
|
458
459
|
- app/views/lotus_admin/users/_form.html.haml
|