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 +4 -4
- data/app/datatables/olivander/datatable.rb +1 -2
- data/app/helpers/olivander/application_helper.rb +8 -8
- data/app/views/application/_form.html.haml +1 -1
- data/app/views/application/index.html.haml +1 -1
- data/app/views/application/show.html.haml +1 -1
- data/app/views/effective/resource/_actions_dropleft.html.haml +2 -3
- data/app/views/layouts/olivander/adminlte/_footer.html.haml +1 -1
- data/app/views/layouts/olivander/adminlte/_navbar.html.haml +2 -2
- data/app/views/layouts/olivander/adminlte/_sidebar.html.haml +2 -2
- data/app/views/layouts/olivander/adminlte/login.html.haml +1 -1
- data/app/views/layouts/olivander/adminlte/main.html.haml +0 -1
- data/lib/olivander/application_context.rb +14 -0
- data/lib/olivander/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5d247c42715b68ca77e28f0b8d99f48b466d042ba197aad6a0fa5694d344d7d3
|
4
|
+
data.tar.gz: 5d4f1e94e9c1d85378a0586481ecf276b34d65364fb341e95ae9020f437293f2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 =
|
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(
|
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(
|
73
|
-
render partial: 'resource_form_actions', locals: { actions: authorized_resource_actions(
|
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
|
-
|
98
|
+
Olivander::CurrentContext.user || OpenStruct.new({ display_name: 'No User Set' })
|
99
99
|
end
|
100
100
|
|
101
101
|
def current_ability
|
102
|
-
|
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
|
-
[
|
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
|
-
|
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(@
|
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(
|
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(@
|
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(
|
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(
|
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
|
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
|
-
-
|
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
|
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 =>
|
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
|
-
-
|
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 =>
|
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
|
data/lib/olivander/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2024-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: chartkick
|