azahara_schema 0.2.6 → 0.2.7
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 855ce45cd183a323fc4b01598cc8ed54b2440284cbe2e888baaf4940d8566d19
|
4
|
+
data.tar.gz: 9450e8a3f0d8d95baf2166f5ff0afe54e0558b71d9b49a91c6c8e09b01c3dc83
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 115e3da2d1d6023c94f3a6052b7c4c5e817e7ffd81579a8ecbba6937d478731faa0dfa4bbb045d388293173d6d489945ab3eb2a74fdac0fa518ca7ca3494271a
|
7
|
+
data.tar.gz: 3084ce3dab7bd6d5f5845d3e5997ab93996af302ca16bd3764f196f23dc7ebd563d856b7f8f2f6a966ba4a03a634cf03b330e6214a17e53ce5611d0975489fac
|
@@ -5,6 +5,15 @@ module AzaharaSchema
|
|
5
5
|
schema.operators_for(filter_name).collect{|o| [o, o]}
|
6
6
|
end
|
7
7
|
|
8
|
+
def azahara_operators_tag(schema, filter, name)
|
9
|
+
field_name = "f[#{name}]"
|
10
|
+
if schema.operators_for(name).count > 1
|
11
|
+
select_tag field_name, options_for_select(operators_for_select(schema, name), schema.operator_for(name)), class: 'form-control operator-field'
|
12
|
+
else
|
13
|
+
hidden_field_tag field_name, schema.operators_for(name).first, class: 'operator-field'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
8
17
|
def filter_field(schema, filter)
|
9
18
|
case filter.format.format_name
|
10
19
|
when 'list', 'love'
|
@@ -14,12 +23,29 @@ module AzaharaSchema
|
|
14
23
|
end
|
15
24
|
end
|
16
25
|
|
26
|
+
def azahara_filter_row(schema, filter, name=nil)
|
27
|
+
name ||= filter.filter_name
|
28
|
+
content_tag(:div, class: 'form-group row filter', data: {name: name}) do
|
29
|
+
s = ''.html_safe
|
30
|
+
s << content_tag(:div, label_tag("f[#{name}]", filter.attribute_name.human), class: 'col-md-2 control-label')
|
31
|
+
|
32
|
+
operators_tag = azahara_operators_tag(schema, filter, name)
|
33
|
+
if schema.operators_for(name).count > 1
|
34
|
+
s << content_tag(:div, operators_tag, class: 'col-md-2')
|
35
|
+
s << content_tag(:div, filter_field(schema, filter), class: 'col-md-8')
|
36
|
+
else
|
37
|
+
s << content_tag(:div, operators_tag + filter_field(schema, filter), class: 'col-md-10')
|
38
|
+
end
|
39
|
+
s
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
17
43
|
# translates values to list_values
|
18
44
|
# TODO: not needed to do it for every value - for example districts are not translatable
|
19
45
|
def list_values_for_select(attribute)
|
20
46
|
if attribute.format.format_name == 'list'
|
21
47
|
attribute.available_values.collect do |l, val|
|
22
|
-
[
|
48
|
+
[attribute.attribute_name.human_list_value(l), val]
|
23
49
|
end
|
24
50
|
else
|
25
51
|
attribute.available_values
|
@@ -1,39 +1,13 @@
|
|
1
1
|
<div id="filters" class="schema-filters">
|
2
2
|
<div id="filters_uncollapsable">
|
3
3
|
<% schema.uncollapsable_filters.each do |name, filter| %>
|
4
|
-
|
5
|
-
<div class="col-md-2 control-label"><%= label_tag "f[#{name}]", filter.attribute_name.human %></div>
|
6
|
-
<% if schema.operators_for(name).count > 1 %>
|
7
|
-
<div class="col-md-2"><%= select_tag "f[#{name}]", options_for_select(operators_for_select(schema, name), schema.operator_for(name)), class: 'form-control operator-field' %></div>
|
8
|
-
<div class="col-md-8">
|
9
|
-
<%= filter_field(schema, filter) %>
|
10
|
-
</div>
|
11
|
-
<% else %>
|
12
|
-
<div class="col-md-10">
|
13
|
-
<%= hidden_field_tag "f[#{name}]", schema.operators_for(name).first, class: 'operator-field' %>
|
14
|
-
<%= filter_field(schema, filter) %>
|
15
|
-
</div>
|
16
|
-
<% end %>
|
17
|
-
</div>
|
4
|
+
<%= azahara_filter_row(schema, filter, name) %>
|
18
5
|
<% end %>
|
19
6
|
</div>
|
20
7
|
<% if schema.collapsable_filters.any? || lookup_context.template_exists?("#{schema.model.model_name.plural}/_additional_filters") %>
|
21
8
|
<div id="filters_collapsable" class="collapse">
|
22
9
|
<% schema.collapsable_filters.each do |name, filter| %>
|
23
|
-
|
24
|
-
<div class="col-md-2 control-label"><%= label_tag "f[#{name}]", t('activerecord.attributes.'+schema.model.name.underscore+'.'+name, default: name.humanize) %></div>
|
25
|
-
<% if schema.operators_for(name).count > 1 %>
|
26
|
-
<div class="col-md-2"><%= select_tag "f[#{name}]", options_for_select(operators_for_select(schema, name), schema.operator_for(name)), class: 'form-control operator-field' %></div>
|
27
|
-
<div class="col-md-8">
|
28
|
-
<%= filter_field(schema, filter) %>
|
29
|
-
</div>
|
30
|
-
<% else %>
|
31
|
-
<div class="col-md-10">
|
32
|
-
<%= hidden_field_tag "f[#{name}]", schema.operators_for(name).first, class: 'operator-field' %>
|
33
|
-
<%= filter_field(schema, filter) %>
|
34
|
-
</div>
|
35
|
-
<% end %>
|
36
|
-
</div>
|
10
|
+
<%= azahara_filter_row(schema, filter, name) %>
|
37
11
|
<% end %>
|
38
12
|
<% if lookup_context.template_exists?("#{schema.model.model_name.plural}/_additional_filters") %>
|
39
13
|
<%= render "#{schema.model.model_name.plural}/additional_filters", schema: schema %>
|
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.2.
|
4
|
+
version: 0.2.7
|
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-02-
|
11
|
+
date: 2018-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|