azahara_schema 0.3.3 → 0.3.4

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: 10b335d3ec510ba75c370ef57465b556b0677a701ccf48b0ac4897caa69badde
4
- data.tar.gz: c19c73e6b9b01aa4a4d391b0f95e0c4a93789864fb8a07f8bb1707b4261d278b
3
+ metadata.gz: 196087578480940bd53363da2e160d13b2af3eb4cd42f4bedfef44493993f2bf
4
+ data.tar.gz: 1c63360964ae78ff48f082219b9c8a1a75d07a63a74562380432cd67a62e67b9
5
5
  SHA512:
6
- metadata.gz: e1fc19074a8cf5e26fcc158788c1575fedc278d5809a8556f9878cc1a08c30a65565ef49f579b0696d1eb19e31db060cdc91d7dd80a937bd58b34fb92dd78d4b
7
- data.tar.gz: 4a663f5fb26982a963eb503d0cb1dad1357152a92181ab78b95ae8f6c785fcd6c50fadc047072d8c7257435f4a199ef617a9755140f4a6f226ecd2e3b9bb065c
6
+ metadata.gz: 68c48995f02cc99264f29bfb43cb231c2edee15eb66dacc5dce937d60e689d02855e69c4e44191b5b25f5f085e3c6ebc4834acdb186b64e20386ed093e370561
7
+ data.tar.gz: 420e5d0d41851c0a60783a6746c8514f4e44c99ad6e8b4afecbc2c84621d5797940aaab391288d7470d3272c3414114a21c9b0b5d3ef7d8a8c00a5c31a9d8109
@@ -2,7 +2,7 @@
2
2
  <%= render 'azahara_schema/index_form', schema: schema %>
3
3
  <% end %>
4
4
  <% schema.outputs.each do |output| %>
5
- <%= render output %>
5
+ <%= render output, schema: schema %>
6
6
  <% end %>
7
7
  <div class="exports text-right">
8
8
  <% if (csv_path = azahara_export_path(schema, :csv)) %>
@@ -84,7 +84,7 @@ module AzaharaSchema
84
84
  def format_value(attribute, unformated_value, **options)
85
85
  case attribute.type
86
86
  when 'datetime'
87
- l(unformated_value)
87
+ unformated_value ? l(unformated_value) : unformated_value
88
88
  else
89
89
  unformated_value
90
90
  end
@@ -23,7 +23,7 @@ module AzaharaSchema
23
23
  end
24
24
 
25
25
  def visibility_scope!(ability, authorization_action=:index)
26
- @entity_scope = model.accessible_by(ability, authorization_action)
26
+ @entity_scope = entity_scope.accessible_by(ability, authorization_action)
27
27
  end
28
28
 
29
29
  def entity_scope
@@ -32,5 +32,9 @@ module AzaharaSchema
32
32
  'azahara_schema/outputs/'+key
33
33
  end
34
34
 
35
+ def formatter(template)
36
+ template.attribute_formatter_for(schema)
37
+ end
38
+
35
39
  end
36
40
  end
@@ -62,7 +62,7 @@ module AzaharaSchema
62
62
  end
63
63
 
64
64
  attr_accessor :model, :enabled_outputs, :association, :parent_schema
65
- attr_accessor :search_query
65
+ attr_accessor :search_query, :default_scope
66
66
  attr_accessor :offset, :limit
67
67
 
68
68
  def initialize(model, **attributes)
@@ -242,7 +242,9 @@ module AzaharaSchema
242
242
  end
243
243
 
244
244
  def entity_scope
245
- model.respond_to?(:visible) ? model.visible : model.all
245
+ scope = model.respond_to?(:visible) ? model.visible : model.all
246
+ scope.send(self.default_scope) if self.default_scope
247
+ scope
246
248
  end
247
249
 
248
250
  def filtered_scope
@@ -329,6 +331,7 @@ module AzaharaSchema
329
331
  add_sort(sort[:path], sort['desc'] == 'true' ? :desc : :asc )
330
332
  end
331
333
  end
334
+ self.default_scope = params[:default_scope] if params[:default_scope]
332
335
  self.search_query = params[:q] if params[:q]
333
336
  self.offset = params[:offset] if params[:offset]
334
337
  self.limit = params[:limit] if params[:limit]
@@ -340,6 +343,7 @@ module AzaharaSchema
340
343
  filters.each do |fname, attrs|
341
344
  params[:f][fname] = "#{attrs[:o]}|#{Array(attrs[:v]).collect{|v| v.to_s}.join('\\')}"
342
345
  end
346
+ params[:default_scope] = default_scope if default_scope
343
347
  params[:c] = column_names
344
348
  params[:q] = search_query if params[:q]
345
349
  params[:offset] = offset
@@ -1,3 +1,3 @@
1
1
  module AzaharaSchema
2
- VERSION = '0.3.3'
2
+ VERSION = '0.3.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: azahara_schema
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ondřej Ezr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-12 00:00:00.000000000 Z
11
+ date: 2018-04-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails