egov_utils 0.3.0 → 0.3.1

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: db8d02864512bcde337488cdcff4446ab6603d612ff7fe85aebcae592abad8a5
4
- data.tar.gz: 887cb22e5ead25efd16576a9c9481336a5e669a57f485d18933b6be05462f495
3
+ metadata.gz: eae0f0f3e3b9e24657d648a0ae710b0ea209b41385303a0dfe98996475f319b2
4
+ data.tar.gz: 5cf138da356f3ac4068f58a0e18d9fb7a1e51474fa7669c7c07a8e788c7a951b
5
5
  SHA512:
6
- metadata.gz: 621e9e7fbcf99247224f07289dad00275d4f06251e17e4f9cf7e482bed13692cca82690fe880b81d83df56684ff6be65a7c987c6e934621b67821d65dab2f42a
7
- data.tar.gz: b8b6df91a246ad9216f149bf5eea8fbad81947830ae553763a49aa8906ddffbd7807b12163f5dbe0c6086307a9bf4aeadff72cd7397a15a071631538b7980203
6
+ metadata.gz: f657dbbc3c0b06c7a832874d524aaf3bc9c42584c97d1d721c3fe229dd2ecf05a4d0f79ae9157dc35cf5c129d5358c79b9ccaea67d49405cfc6ded7c910deb5d
7
+ data.tar.gz: d7f627e6fa125e04d8520bb6a4fd21c76c1c35415f2756fa9b07a370dfa7fba6ea98ad92041e6f0bd43f64680d13d0d2dcc5be4b5674ea7023c6192d1a9cded0
@@ -19,5 +19,8 @@ module EgovUtils
19
19
  end
20
20
  end
21
21
 
22
+ def show
23
+ end
24
+
22
25
  end
23
26
  end
@@ -27,11 +27,34 @@ module EgovUtils
27
27
  s
28
28
  end
29
29
 
30
+ def entity_template_path_for_schema(schema, id_template='{id}')
31
+ if schema.respond_to?('engine_name')
32
+ self.public_send(schema.engine_name).polymorphic_path(schema.model) + "/#{id_template}"
33
+ else
34
+ polymorphic_path(schema.model) + "/#{id_template}"
35
+ end
36
+ rescue NoMethodError => e
37
+ nil
38
+ end
39
+
40
+ # TODO - what if the attribute is main for associated schema (legal_person-name for person schema)
41
+ def entity_template_path(schema, attribute)
42
+ if attribute.name == schema.main_attribute_name
43
+ entity_template_path_for_schema(schema)
44
+ elsif (base_schema = attribute.try(:base_schema)) && attribute.name =~ /#{base_schema.main_attribute_name}/
45
+ entity_template_path_for_schema(base_schema, "{#{attribute.primary_key_name}}")
46
+ end
47
+ end
48
+
30
49
  def column_for_grid(grid, attribute)
31
50
  s = "{"
32
51
  s << "field: '#{attribute.name}'"
33
52
  s << ", title: '#{attribute.attribute_name.human}'"
34
- s << ", columnTemplate: '<a href=\"#{polymorphic_path(grid.schema.model)}/{id}\">{#{attribute.name}}</div>'" if attribute.name == grid.schema.main_attribute_name
53
+
54
+ if (template_path = entity_template_path(grid.schema, attribute))
55
+ s << ", columnTemplate: '<a href=\"#{template_path}\">{#{attribute.name}}</div>'"
56
+ end
57
+
35
58
  if attribute.type == 'list'
36
59
  s << ", format: ( (value) -> I18n.t('#{attribute.attribute_name.i18n_scoped_list_prefix}'+'.'+value, {defaults: $.map( #{attribute.attribute_name.i18n_list_fallback_prefixes.to_json}, (pref, i)-> {scope: (pref + '.' + value)} )}) ) "
37
60
  elsif attribute.type == 'date'
@@ -1,5 +1,5 @@
1
1
  module EgovUtils
2
- class AddressSchema < AzaharaSchema::ModelSchema
2
+ class AddressSchema < EgovUtils::EngineSchema
3
3
 
4
4
  def attribute_for_column(col)
5
5
  case col.name
@@ -0,0 +1,13 @@
1
+ module EgovUtils
2
+ class EngineSchema < AzaharaSchema::ModelSchema
3
+
4
+ def self.engine_name
5
+ self.name.split('::').first.underscore
6
+ end
7
+
8
+ def engine_name
9
+ self.class.engine_name
10
+ end
11
+
12
+ end
13
+ end
@@ -1,5 +1,5 @@
1
1
  module EgovUtils
2
- class UserSchema < AzaharaSchema::ModelSchema
2
+ class UserSchema < EgovUtils::EngineSchema
3
3
 
4
4
  def main_attribute_name
5
5
  'fullname'
@@ -1,3 +1,3 @@
1
1
  module EgovUtils
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: egov_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
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-05 00:00:00.000000000 Z
11
+ date: 2018-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -426,6 +426,7 @@ files:
426
426
  - app/resources/egov_utils/organization.rb
427
427
  - app/schemas/egov_utils/abstract_person_schema.rb
428
428
  - app/schemas/egov_utils/address_schema.rb
429
+ - app/schemas/egov_utils/engine_schema.rb
429
430
  - app/schemas/egov_utils/legal_person_schema.rb
430
431
  - app/schemas/egov_utils/natural_person_schema.rb
431
432
  - app/schemas/egov_utils/person_schema.rb