lotus_admin 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7da3c2c63c60b091d7fe7fccaf1b1ef3282d152aaa191b141c0192b7bb8045d8
4
- data.tar.gz: a4c88154204fbf234e7ee29ae03866db5fed7b3a3ade921624fbe6a234a7214e
3
+ metadata.gz: 3f1b026cfd1e070c4d1a0fff64c4d0214818a713c9cfbfaed3a0a476d870321e
4
+ data.tar.gz: cbe3427768813ca6c7c7df6a97bbf6b2a599a2904e1a1c91f3c3c89781a9a56b
5
5
  SHA512:
6
- metadata.gz: 0d73ca1d470aab9dda188eeaa1352cd00e7cf079cd4d52bdc35e78543575c5ee78071210fb7af4e8f106788679e945226e7238cebb002ea98ae02bcd74dcbbea
7
- data.tar.gz: febc6e4b7f3438873edc38507589a32539edf33bcbeee2268b2b2f192517bb38fad084cfe8ae8bb9d778e12d8aeca4855cf6db88b599de5513251dfd42cb3013
6
+ metadata.gz: 644eeb24a1917d4ce1cc6ee9385151b6e059f409a0618fc751b88f5476ffd2aa7bf669c050c6abd17f946b30a53cf017d76a16b3cbb4deac3f51e404abac4522
7
+ data.tar.gz: fbb8c7db19e309b90fed1d44ebc8697cba74420a043560f7a4a2450adbb8c6108e0cea5f06aaa8e888a8836a5bc04f83383050afd7a894fc42e303ad7dbddc3b
@@ -1,4 +1,5 @@
1
1
  @import "lotus_admin/components/alerts";
2
+ @import "lotus_admin/components/badges";
2
3
  @import "lotus_admin/components/datepicker";
3
4
  @import "lotus_admin/components/devise";
4
5
  @import "lotus_admin/components/filters";
@@ -0,0 +1,23 @@
1
+ .badge {
2
+ background-color: $app-gray;
3
+
4
+ &.badge-primary {
5
+ background-color: $brand-primary;
6
+ }
7
+
8
+ &.badge-success {
9
+ background-color: $brand-success;
10
+ }
11
+
12
+ &.badge-info {
13
+ background-color: $brand-info;
14
+ }
15
+
16
+ &.badge-warning {
17
+ background-color: $brand-warning;
18
+ }
19
+
20
+ &.badge-error {
21
+ background-color: $brand-danger;
22
+ }
23
+ }
@@ -0,0 +1,29 @@
1
+ module LotusAdmin
2
+ module Decorations
3
+ extend ActiveSupport::Concern
4
+
5
+ class_methods do
6
+ def decorates_with(decorator_class_or_name)
7
+ self._decorator_class_name = decorator_class_or_name.to_s
8
+ end
9
+ end
10
+
11
+ included do
12
+ class_attribute :_decorator_class_name, instance_accessor: false
13
+
14
+ let(:collection) do
15
+ if self.class._decorator_class_name.present?
16
+ self.class._decorator_class_name.constantize.decorate_collection(end_of_association_chain)
17
+ else
18
+ end_of_association_chain
19
+ end
20
+ end
21
+
22
+ let(:decorated_resource) do
23
+ if self.class._decorator_class_name.present?
24
+ self.class._decorator_class_name.constantize.decorate(resource)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -18,7 +18,6 @@ module LotusAdmin
18
18
 
19
19
  let(:filters_enabled?) { self.class.filters_enabled }
20
20
  let(:ransack_object) { instance_exec(&self.class._beginning_of_scope_chain).ransack(params[:q]) }
21
- let(:collection) { paginate(ransack_object.result) }
22
21
  end
23
22
 
24
23
  class_methods do
@@ -36,5 +35,11 @@ module LotusAdmin
36
35
  self._beginning_of_scope_chain = block
37
36
  end
38
37
  end
38
+
39
+ private
40
+
41
+ def end_of_association_chain
42
+ paginate(ransack_object.result)
43
+ end
39
44
  end
40
45
  end
@@ -3,6 +3,7 @@ class LotusAdmin::AuthenticatedController < LotusAdmin::ApplicationController
3
3
  include LotusAdmin::FilterableController
4
4
  include LotusAdmin::ResourcefulController
5
5
  include LotusAdmin::FileStreamer
6
+ include LotusAdmin::Decorations
6
7
 
7
8
  before_action :authenticate_administrator!
8
9
  around_action :use_user_time_zone, if: :administrator_signed_in?
@@ -0,0 +1,11 @@
1
+ class LotusAdmin::ApplicationDecorator < Draper::Decorator
2
+ def self.collection_decorator_class
3
+ LotusAdmin::PaginatingDecorator
4
+ end
5
+
6
+ private
7
+
8
+ def badge(content, type:)
9
+ h.content_tag(:span, content, class: "badge #{ type }")
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ class LotusAdmin::PaginatingDecorator < Draper::CollectionDecorator
2
+ delegate :current_page, :total_pages, :limit_value, :entry_name, :total_count, :offset_value, :last_page?
3
+ end
@@ -1,3 +1,3 @@
1
1
  module LotusAdmin
2
- VERSION = '1.2.2'
2
+ VERSION = '1.3.0'
3
3
  end
data/lib/lotus_admin.rb CHANGED
@@ -17,6 +17,7 @@ require 'jquery-rails'
17
17
  require 'page_title_helper'
18
18
  require 'kaminari'
19
19
  require 'ransack'
20
+ require 'draper'
20
21
 
21
22
  require 'lotus_admin/configuration'
22
23
  require 'lotus_admin/form_builder'
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.2.2
4
+ version: 1.3.0
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-03-24 00:00:00.000000000 Z
11
+ date: 2020-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -226,6 +226,20 @@ dependencies:
226
226
  - - ">="
227
227
  - !ruby/object:Gem::Version
228
228
  version: '2.3'
229
+ - !ruby/object:Gem::Dependency
230
+ name: draper
231
+ requirement: !ruby/object:Gem::Requirement
232
+ requirements:
233
+ - - ">="
234
+ - !ruby/object:Gem::Version
235
+ version: '4.0'
236
+ type: :runtime
237
+ prerelease: false
238
+ version_requirements: !ruby/object:Gem::Requirement
239
+ requirements:
240
+ - - ">="
241
+ - !ruby/object:Gem::Version
242
+ version: '4.0'
229
243
  - !ruby/object:Gem::Dependency
230
244
  name: pg
231
245
  requirement: !ruby/object:Gem::Requirement
@@ -343,11 +357,13 @@ files:
343
357
  - app/assets/stylesheets/lotus_admin/application.css.scss
344
358
  - app/assets/stylesheets/lotus_admin/components/_alerts.scss
345
359
  - app/assets/stylesheets/lotus_admin/components/_all.scss
360
+ - app/assets/stylesheets/lotus_admin/components/_badges.scss
346
361
  - app/assets/stylesheets/lotus_admin/components/_datepicker.scss
347
362
  - app/assets/stylesheets/lotus_admin/components/_devise.scss
348
363
  - app/assets/stylesheets/lotus_admin/components/_filters.scss
349
364
  - app/assets/stylesheets/lotus_admin/components/_forms.scss
350
365
  - app/assets/stylesheets/lotus_admin/components/_tables.scss
366
+ - app/controllers/concerns/lotus_admin/decorations.rb
351
367
  - app/controllers/concerns/lotus_admin/devise_controllers.rb
352
368
  - app/controllers/concerns/lotus_admin/exposure.rb
353
369
  - app/controllers/concerns/lotus_admin/file_streamer.rb
@@ -363,6 +379,8 @@ files:
363
379
  - app/controllers/lotus_admin/resource_controller.rb
364
380
  - app/controllers/lotus_admin/sessions_controller.rb
365
381
  - app/controllers/lotus_admin/users_controller.rb
382
+ - app/decorators/lotus_admin/application_decorator.rb
383
+ - app/decorators/lotus_admin/paginating_decorator.rb
366
384
  - app/helpers/lotus_admin/application_helper.rb
367
385
  - app/helpers/lotus_admin/filter_helpers.rb
368
386
  - app/helpers/lotus_admin/form_helpers.rb