five-two-nw-olivander 0.1.2.25 → 0.1.2.27

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: c84745db767e205f4aec15220fedbd5dd8d4dc3dc973e4a24624e51c59301443
4
- data.tar.gz: 635805ef6e29cc864c36afc572811a452205aa947dbcce7bbac914cbb3740ecb
3
+ metadata.gz: 575201e4ba97a06d33425fffb69b3550f2c3fddc58e1ccb030a827914cbd65f0
4
+ data.tar.gz: e1570ff90c9a44764ea6c8e5d8b269d6482377c47010c36475eeabbbfcb5e1e1
5
5
  SHA512:
6
- metadata.gz: a4f3cd18eccd926ef5fbc6e555ffa3450713f1c91647accfe6625d51df3ec2ccf0c11588c6d68f2a441d89087af319604916d5f9cc1368d45c7362f219541522
7
- data.tar.gz: 9d9c6ccc4a03f07d14c98f9f20ba3fcc9c5f56cc782f9c7ffd2632bedcf38773cd9a1c981614e184dbefb4d1baea4155f5159827b4789e5bdad54ed3692e9ddf
6
+ metadata.gz: 97a5958aab8927d392183d9aea8b193491bf346af4a65fadc9faa96a4f57a54478e7a7247060ca0ec84a25fe7b09dd0c063001f5ae8dc50f59bdb03e86b1475a
7
+ data.tar.gz: 3c237985f2aee2131498cbf501734aa9d517f7827eee5d23fb0549452c0d96aadd2913f66269e937a0ae9b5280654c39d3bd179f203b7f42ea7af49584481b7d
@@ -18,27 +18,36 @@ module Olivander
18
18
  def self.auto_datatable(klazz, collection: nil, link_path: nil, only: [], except: [], hide: [], show: [], order_by: [])
19
19
  Rails.logger.debug "initializing datatable for #{klazz}"
20
20
 
21
- attributes = klazz.new.attributes.collect{ |x| x[0] }
22
- attributes &&= only if only.size.positive?
23
- attributes -= except if except.size.positive?
21
+ klazz_attributes = klazz.new.attributes.collect{ |x| x[0] }
22
+ column_attributes = klazz_attributes
23
+ column_attributes &&= only if only.size.positive?
24
+ column_attributes -= except if except.size.positive?
24
25
 
25
26
  default_hidden = %w[id created updated created_at updated_at deleted_at current_user current_action]
26
27
 
27
28
  collection do
28
- collection.nil? ? klazz.all : collection
29
+ dc = collection.nil? ? klazz.all : collection
30
+
31
+ attributes.each do |att|
32
+ dc = dc.where("#{att[0]} = ?", att[1]) if klazz_attributes.include?(att[0].to_s)
33
+ end
34
+
35
+ dc
29
36
  end
30
37
 
31
38
  datatable do
32
39
  order(order_by[0], order_by[1]) if order_by.size == 2
33
40
  bulk_actions_col
34
- attributes.each do |key|
41
+ column_attributes.each do |key|
35
42
  label = field_label_for(klazz, key)
36
- sym = key.gsub('_id', '').to_sym
43
+ sym = key.gsub('_id', '') #.to_sym
37
44
  visible = show.include?(key) || !(default_hidden.include?(key) || hide.include?(key))
38
45
  if link_path.present? && sym == :id
39
46
  link_col sym, link_path, :id, visible: visible
40
47
  elsif link_path.present? && sym == :name
41
48
  link_col sym, link_path, :id, visible: visible
49
+ elsif sym.include?('.')
50
+ col sym, visible: visible, label: label
42
51
  else
43
52
  col sym, visible: visible, label: label
44
53
  end
@@ -79,7 +79,8 @@ module Olivander
79
79
  end
80
80
 
81
81
  def field_label_for(resource_class, sym)
82
- i18n_key = "activerecord.attributes.#{resource_class.name.underscore}.#{sym}"
82
+ sym_s = sym.to_s.gsub('.', '_')
83
+ i18n_key = "activerecord.attributes.#{resource_class.name.underscore}.#{sym_s}"
83
84
  return I18n.t(i18n_key) if I18n.exists?(i18n_key)
84
85
 
85
86
  sym.to_s.titleize
@@ -109,9 +110,41 @@ module Olivander
109
110
  (is_dev_environment? ? 'bg-danger' : 'bg-info')
110
111
  end
111
112
 
113
+ def header_page_title
114
+ [is_dev_environment? ? sidebar_context_suffix.upcase : nil, page_title].reject(&:blank?).join(' ')
115
+ end
116
+
112
117
  def favicon_link
113
118
  favicon_path = is_dev_environment? ? '/images/favicon-dev.png' : '/images/favicon.ico'
114
119
  favicon_link_tag(image_path(favicon_path))
115
120
  end
121
+
122
+ def flash_class key
123
+ case key
124
+ when "error"
125
+ "danger"
126
+ when "notice"
127
+ "info"
128
+ when "alert"
129
+ "danger"
130
+ else
131
+ key
132
+ end
133
+ end
134
+
135
+ def flash_icon key
136
+ case key
137
+ when "error"
138
+ "fas fa-exclamation-circle"
139
+ when "notice"
140
+ "fas fa-info-circle"
141
+ when "alert"
142
+ "fas fa-info-circle"
143
+ when "success"
144
+ "fas fa-check-circle"
145
+ else
146
+ "fas fa-question-circle"
147
+ end
148
+ end
116
149
  end
117
150
  end
@@ -1,5 +1,5 @@
1
1
  <h2>Log in</h2>
2
- ;lkjasd;lkjasdf
2
+
3
3
  <%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
4
4
  <div class="form-inputs">
5
5
  <%= f.input :email,
@@ -1,6 +1,6 @@
1
1
  %head
2
2
  %meta{:content => "text/html; charset=UTF-8", "http-equiv" => "Content-Type"}/
3
- %title= page_title
3
+ %title= header_page_title
4
4
  %meta{:content => "width=device-width,initial-scale=1", :name => "viewport"}/
5
5
  = favicon_link
6
6
  = csrf_meta_tags
@@ -0,0 +1,4 @@
1
+ - flash.to_hash.slice("alert", "error", "notice", "success").each do |key, value|
2
+ .span.alert{ class: "alert-#{flash_class(key)}" }
3
+ %i.icon{ class: flash_icon(key) }
4
+ = value
@@ -1,3 +1,3 @@
1
1
  module Olivander
2
- VERSION = '0.1.2.25'.freeze
2
+ VERSION = '0.1.2.27'.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.1.2.25
4
+ version: 0.1.2.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Dennis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-07-28 00:00:00.000000000 Z
11
+ date: 2023-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: chartkick