five-two-nw-olivander 0.2.0.0 → 0.2.0.1

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: a9ab27ddf5bd9a9840334c5012d983da406ff25bb6a1352e9ecb7ea09bcb6e86
4
- data.tar.gz: 042da3a6287c67e8643236e8bd32ceb72264d25f389ebc775e9d11de180b4390
3
+ metadata.gz: 5d247c42715b68ca77e28f0b8d99f48b466d042ba197aad6a0fa5694d344d7d3
4
+ data.tar.gz: 5d4f1e94e9c1d85378a0586481ecf276b34d65364fb341e95ae9020f437293f2
5
5
  SHA512:
6
- metadata.gz: a4528a86c47018a50553a2576d7c8c9fdec267956cc738890046d7a617f619575a0e4067802a23bed2d8c6a6250c26a900ea3f91df788b001c0c7d1426f30c86
7
- data.tar.gz: 8c8ee8c14ad71c1b559547258b9cf59f5208cfc5ef2fcbed09acb657a12d511503cdcc5109422a02e850d3cf2965e34eebe79bb697b9255b5b3074f671493d36
6
+ metadata.gz: 336beef33e5b2f9b3242a654d9de9b5cb2b19ef30b25b62ccb0b2bbb74753afbdddf027a289ec6dc65d873e9a53acab6998983f0394aa8162a1c516976c8f8f7
7
+ data.tar.gz: aee825f87643bebac907ccfdf499b1f8d76f1a8e4049f58fa35856eaea663f8d175f808f7b04aa56b1ff0b704f7e1a7c322d6568e945b555c01423c0e6ec29e9
@@ -24,8 +24,7 @@ module Olivander
24
24
  column_attributes &&= only if only.size.positive?
25
25
  column_attributes -= except if except.size.positive?
26
26
  resources_sym = klazz.table_name.to_sym
27
- bulk_action_list = self::ROUTE_BUILDER.resources[resources_sym]&.datatable_bulk_actions || []
28
-
27
+ bulk_action_list = Olivander::CurrentContext.application_context.route_builder.resources[resources_sym]&.datatable_bulk_actions || []
29
28
  default_hidden = %w[
30
29
  id created updated created_at updated_at
31
30
  deleted_at current_user current_action
@@ -34,10 +34,10 @@ module Olivander
34
34
  user.avatar_path
35
35
  end
36
36
 
37
- def authorized_resource_actions(route_builder, resource, for_action: :show)
37
+ def authorized_resource_actions(resource, for_action: :show)
38
38
  raw_name = resource.is_a?(Class) ? resource.name : resource.class.name
39
39
  plural_name = raw_name.demodulize.underscore.pluralize
40
- routed_resource = route_builder.resources[plural_name.to_sym]
40
+ routed_resource = Olivander::CurrentContext.application_context.route_builder.resources[plural_name.to_sym]
41
41
  return [] if routed_resource.nil?
42
42
 
43
43
  actions = if resource.is_a?(Class)
@@ -69,8 +69,8 @@ module Olivander
69
69
  respond_to?('can?') ? can?(action, resource) : true
70
70
  end
71
71
 
72
- def resource_form_actions(route_builder, resource, for_action: :show)
73
- render partial: 'resource_form_actions', locals: { actions: authorized_resource_actions(route_builder, resource, for_action: for_action).select(&:show_in_form) }
72
+ def resource_form_actions(resource, for_action: :show)
73
+ render partial: 'resource_form_actions', locals: { actions: authorized_resource_actions(resource, for_action: for_action).select(&:show_in_form) }
74
74
  end
75
75
 
76
76
  def resource_form_action_label(resource, action)
@@ -95,11 +95,11 @@ module Olivander
95
95
  end
96
96
 
97
97
  def current_user
98
- controller.respond_to?(:current_user) ? controller.current_user : nil
98
+ Olivander::CurrentContext.user || OpenStruct.new({ display_name: 'No User Set' })
99
99
  end
100
100
 
101
101
  def current_ability
102
- controller.respond_to?(:current_ability) ? controller.current_ability : nil
102
+ Olivander::CurrentContext.ability
103
103
  end
104
104
 
105
105
  def resource_attributes(resource, effective_resource)
@@ -130,7 +130,7 @@ module Olivander
130
130
  end
131
131
 
132
132
  def sidebar_context_name
133
- [@context.name, sidebar_context_suffix&.upcase].reject{ |x| x.blank? or x == 'PRODUCTION' }.join(' ')
133
+ [Olivander::CurrentContext.application_context.name, sidebar_context_suffix&.upcase].reject{ |x| x.blank? or x == 'PRODUCTION' }.join(' ')
134
134
  end
135
135
 
136
136
  def sidebar_context_suffix
@@ -144,7 +144,7 @@ module Olivander
144
144
  end
145
145
 
146
146
  def sidebar_background_class
147
- @context.sidebar_background_class ||
147
+ Olivander::CurrentContext.application_context.sidebar_background_class ||
148
148
  ENV['SIDEBAR_BACKGROUND_CLASS'] ||
149
149
  (is_dev_environment? ? 'bg-danger' : 'bg-info')
150
150
  end
@@ -4,7 +4,7 @@
4
4
  .card-header
5
5
  %h3.card-title= @resource.to_s.blank? ? @resource.model_name.human : @resource
6
6
  .card-tools
7
- = resource_form_actions(@context.route_builder, @resource, for_action: action_name.to_sym)
7
+ = resource_form_actions(@resource, for_action: action_name.to_sym)
8
8
  .card-body
9
9
  =f.error_notification
10
10
  =f.error_notification message: f.object.errors[:base].to_sentence if f.object.errors[:base].present?
@@ -33,7 +33,7 @@
33
33
  .card-header
34
34
  %h3.card-title= page_title
35
35
  .card-tools
36
- = resource_form_actions(@context.route_builder, resource.klass, for_action: :index)
36
+ = resource_form_actions(resource.klass, for_action: :index)
37
37
  .card-body
38
38
  - if @datatable
39
39
  = content_for :datatable
@@ -10,7 +10,7 @@
10
10
  .card-header
11
11
  %h3.card-title= @resource.to_s
12
12
  .card-tools
13
- = resource_form_actions(@context.route_builder, @resource, for_action: action_name.to_sym)
13
+ = resource_form_actions(@resource, for_action: action_name.to_sym)
14
14
  .card-body
15
15
  = render_optional_partial 'show_inside_before'
16
16
  = render Olivander::Components::ResourceShowComponent.new(@resource, [])
@@ -1,10 +1,9 @@
1
- - route_builder = @context&.route_builder || datatable.class::ROUTE_BUILDER
2
1
  -# = dropdown(variation: :dropleft, btn_class: btn_class) do
3
- -# - authorized_resource_actions(route_builder, resource, for_action: action_name).select{ |x| x.show_in_datatable }.each do |a|
2
+ -# - authorized_resource_actions(resource, for_action: action_name).select{ |x| x.show_in_datatable }.each do |a|
4
3
  -# - path = a.path_helper.is_a?(Proc) ? a.path_helper.call(resource) : send(a.path_helper, resource.id)
5
4
  -# - data = a.turbo_frame.present? ? { turbo: true, turbo_frame: a.turbo_frame } : {}
6
5
  -# = dropdown_link_to resource_form_action_label(resource, a.sym), path, data: data
7
- - actions = authorized_resource_actions(route_builder, resource, for_action: action_name).select{ |x| x.show_in_datatable }
6
+ - actions = authorized_resource_actions(resource, for_action: action_name).select{ |x| x.show_in_datatable }
8
7
  - crud_actions = actions.select{ |a| a.crud_action }
9
8
  - non_crud_actions = actions.select{ |a| !a.crud_action }
10
9
  .btn-group
@@ -2,7 +2,7 @@
2
2
  %strong
3
3
  Copyright © #{Date.current.year}
4
4
  = succeed "." do
5
- = link_to @context.company.name, @context.company.url
5
+ = link_to Olivander::CurrentContext.application_context.company.name, Olivander::CurrentContext.application_context.company.url
6
6
  All rights reserved.
7
7
  .float-right.d-none.d-sm-inline-block
8
8
  .text-small
@@ -5,7 +5,7 @@
5
5
  %li.nav-item
6
6
  %a.nav-link{"data-widget" => "pushmenu", :href => "#", :role => "button", 'data-enable-remember': "true"}
7
7
  %i.fas.fa-bars
8
- - @context.visible_modules.each do |menu_item|
8
+ - Olivander::CurrentContext.application_context.visible_modules.each do |menu_item|
9
9
  %li.nav-item.d-none.d-sm-inline-block
10
10
  = link_to menu_item.text, menu_item.href, class: 'nav-link'
11
11
  / Right navbar links
@@ -113,7 +113,7 @@
113
113
  %li.user-footer
114
114
  = link_to user_path(current_user), class: 'btn btn-default btn-flat' do
115
115
  Profile
116
- = link_to @context.sign_out_path, method: :delete, class: 'btn btn-default btn-flat float-right' do
116
+ = link_to Olivander::CurrentContext.application_context.sign_out_path, method: :delete, class: 'btn btn-default btn-flat float-right' do
117
117
  Sign out
118
118
  %li.nav-item
119
119
  %a.nav-link{title: 'Full Screen Mode', "data-widget" => "fullscreen", :href => "#", :role => "button"}
@@ -2,7 +2,7 @@
2
2
  %aside.main-sidebar.sidebar-dark-primary.elevation-4{ data: { controller: 'left-nav' }}
3
3
  / Brand Logo
4
4
  %a.brand-link{ href: "/", class: sidebar_background_class }
5
- %img.brand-image.img-circle.elevation-3{:alt => @context.logo.alt, :src => @context.logo.url, :style => "opacity: .8"}/
5
+ %img.brand-image.img-circle.elevation-3{:alt => Olivander::CurrentContext.application_context.logo.alt, :src => Olivander::CurrentContext.application_context.logo.url, :style => "opacity: .8"}/
6
6
  %span.brand-text.font-weight-light= sidebar_context_name
7
7
  / Sidebar
8
8
  .sidebar
@@ -16,7 +16,7 @@
16
16
  / Sidebar Menu
17
17
  %nav.mt-2
18
18
  %ul.nav.nav-pills.nav-sidebar.nav-compact.flex-column{"data-accordion" => "false", "data-widget" => "treeview", :role => "menu"}
19
- - @context.menu_items.each do |menu_item|
19
+ - Olivander::CurrentContext.application_context.menu_items.each do |menu_item|
20
20
  = render Olivander::Components::MenuItemComponent.new(menu_item)
21
21
 
22
22
 
@@ -4,7 +4,7 @@
4
4
  %body.hold-transition.login-page
5
5
  .login-box
6
6
  -# .login-logo
7
- -# %img.brand-image.img-circle.elevation-3{:alt => @context.logo.alt, :src => @context.logo.url, :style => "opacity: .8"}
7
+ -# %img.brand-image.img-circle.elevation-3{:alt => Olivander::CurrentContext.application_context.logo.alt, :src => Olivander::CurrentContext.application_context.logo.url, :style => "opacity: .8"}
8
8
  .card
9
9
  .card-header.text-center{ class: sidebar_background_class }
10
10
  %a.h1{ href: '/' }
@@ -1,6 +1,5 @@
1
1
  !!!
2
2
  %html
3
- - @context ||= Olivander::ApplicationContext.default
4
3
  = render partial: 'layouts/olivander/adminlte/head'
5
4
  - sidebar_collapse = cookies['lte.pushmenu.collapsed'] == 'true' ? 'sidebar-collapse' : ''
6
5
  %body.hold-transition.sidebar-mini.layout-fixed{ class: sidebar_collapse }
@@ -5,6 +5,11 @@ module Olivander
5
5
  def self.default
6
6
  ctx = ApplicationContext.new
7
7
  ctx.company.name = 'Company Name'
8
+ begin
9
+ ctx.route_builder = RouteBuilder.new
10
+ rescue
11
+ ctx.route_builder = OpenStruct.new(resources: [])
12
+ end
8
13
  ctx
9
14
  end
10
15
 
@@ -51,4 +56,13 @@ module Olivander
51
56
  end
52
57
  end
53
58
  end
59
+
60
+ class CurrentContext < ActiveSupport::CurrentAttributes
61
+ attribute :application_context
62
+ attribute :user, :ability
63
+
64
+ def application_context
65
+ @application_context ||= ::Olivander::ApplicationContext.default
66
+ end
67
+ end
54
68
  end
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = '0.2.0.0'.freeze
2
+ VERSION = '0.2.0.1'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: five-two-nw-olivander
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0.0
4
+ version: 0.2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-12 00:00:00.000000000 Z
11
+ date: 2024-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick