lotus_admin 1.5.1 → 1.5.6

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
  SHA256:
3
- metadata.gz: 045cf584020f6a9ddb26bb32732a6c34d0a562d2691351fea2748acc07930140
4
- data.tar.gz: 7cb526a8e6abc0d62357d47d394a4d83b8ac02ebd6c31c42b1b464e7872911c0
3
+ metadata.gz: 9722e072421aa225525f1705c81d9c2fe9e99d62855019955eb1426b3f59f502
4
+ data.tar.gz: 73d6a3ab005224e36ab8c3ee9ec043cd891fa22a12930dbd75b46743420988b4
5
5
  SHA512:
6
- metadata.gz: fa06a04c853e7412efdc49d4f4f6b821cb8638dc962a485549881fbdb68ecd19a505ccb379405de262f2f3387186fdcfc8253daf0b23aebd3680d910c28da14c
7
- data.tar.gz: 61f92a76cfeedbd9e1d0d1353961716207baa72d10a7fece3dacd65d6e239902d94d107ae4ef52b4b07f9b229b94e73a44d3db9ae292ca09057116f43ff2fdb9
6
+ metadata.gz: 1d71e3209dcc0d0598fda166312c87d71ec7bab0bfbdbca990b7425ef208f691efced1b4e886eac145c400050eff4dad52a7ec2d6b0ad147847cf3267dadd224
7
+ data.tar.gz: 5f42cbcc462a5c95691cf85b4b713b9291be648f544ee425a9774739075e575ddcec5b38bc98ea8d46ff59a8ba21e21ed0f6f427f5a53dca433dbd1e78a74d67
@@ -12,14 +12,13 @@ $ ->
12
12
  }
13
13
 
14
14
  setup_datepickers = (container)->
15
- container.find('.input-group.date, .form-control.date').datetimepicker
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, .form-control.datetime').datetimepicker
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"
@@ -56,13 +56,17 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
56
56
  def update(&block)
57
57
  authorize(resource) if using_pundit?
58
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"
59
+ respond_to do |format|
60
+ format.html
61
+
62
+ if block.present?
63
+ block.call(format)
64
64
  else
65
- render :edit
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
66
70
  end
67
71
  end
68
72
  end
@@ -77,20 +81,34 @@ class LotusAdmin::ResourceController < LotusAdmin::AuthenticatedController
77
81
  end
78
82
  end
79
83
 
80
- def show
84
+ def show(&block)
81
85
  authorize(resource) if using_pundit?
86
+
87
+ respond_to do |format|
88
+ format.html
89
+
90
+ block.call(format) if block.present?
91
+ end
82
92
  end
83
93
 
84
- def destroy
94
+ def destroy(&block)
85
95
  authorize(resource) if using_pundit?
86
96
 
87
- if resource.destroy
88
- flash[:notice] = "#{ resource_class.model_name.human } has been removed"
89
- else
90
- flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
91
- end
97
+ respond_to do |format|
98
+ format.html
92
99
 
93
- redirect_to after_destroy_redirect
100
+ if block.present?
101
+ block.call(format)
102
+ else
103
+ if resource.destroy
104
+ flash[:notice] = "#{ resource_class.model_name.human } has been removed"
105
+ else
106
+ flash[:error] = "There was an error removing that #{ resource_class.model_name.human }"
107
+ end
108
+
109
+ redirect_to after_destroy_redirect
110
+ end
111
+ end
94
112
  end
95
113
 
96
114
  private
@@ -12,7 +12,7 @@ module LotusAdmin
12
12
  filter :last_sign_in_at
13
13
 
14
14
  def create
15
- super do
15
+ super do |format|
16
16
  resource.password = Devise.friendly_token.first(8)
17
17
 
18
18
  if resource.save
@@ -4,6 +4,10 @@ module LotusAdmin
4
4
  render 'lotus_admin/shared/table/actions', resource: resource
5
5
  end
6
6
 
7
+ def undecorated(resource)
8
+ resource.try(:object).presence || resource
9
+ end
10
+
7
11
  def view_resource_item(resource)
8
12
  if policy(resource).show?
9
13
  content_tag(:li) { view_link(resource) }
@@ -29,7 +33,7 @@ module LotusAdmin
29
33
  end
30
34
 
31
35
  def view_link(resource)
32
- link_to lotus_admin.polymorphic_path(resource) do
36
+ link_to lotus_admin.polymorphic_path(undecorated(resource)) do
33
37
  content_tag(:i, nil, class: 'zmdi zmdi-eye')
34
38
  end
35
39
  end
@@ -41,13 +45,13 @@ module LotusAdmin
41
45
  end
42
46
 
43
47
  def edit_link(resource)
44
- link_to lotus_admin.edit_polymorphic_path(resource) do
48
+ link_to lotus_admin.edit_polymorphic_path(undecorated(resource)) do
45
49
  content_tag(:i, nil, class: 'zmdi zmdi-edit')
46
50
  end
47
51
  end
48
52
 
49
53
  def destroy_link(resource)
50
- 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
51
55
  content_tag(:i, nil, class: 'zmdi zmdi-delete')
52
56
  end
53
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,3 +1,3 @@
1
1
  module LotusAdmin
2
- VERSION = '1.5.1'
2
+ VERSION = '1.5.6'
3
3
  end
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.1
4
+ version: 1.5.6
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-17 00:00:00.000000000 Z
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