catalogs 0.1.0 → 0.2.0

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: 578ee6b1d66a1950c1d44bba7c7079e6635474e13ce47db9094c714451c6c605
4
- data.tar.gz: 2c9d181fe9aa495f70c9b3d219f99fdbefe2dc78bc53797d7ab2c8033c19f679
3
+ metadata.gz: 7db2c7ac39e8295f21d24ad6092a6746f65e520564e58ca95d6e97ec7d573691
4
+ data.tar.gz: aee2be8107cd8f55a89f541fd64acd6bdd30d8ec04f04c6fe368deec1583163a
5
5
  SHA512:
6
- metadata.gz: fd39526a1605fa2715af8decd318b6a62b310db7ff57d334db0c1351c02828d5cab31e07a72fa8a8b1dcf7b494bad205474849ccc0357f8cbbda03c141f464b3
7
- data.tar.gz: 145f8606f3788f73df8da459fb71581ee260e76f50b4673c562d9d12ee61e42349dd7ad2284821dda43757cba389e0517bdc3634a126d5a92f080b05adb14a1c
6
+ metadata.gz: 1e1db9181ce9884c61f9ed9b253a76997f32a2a82311e493d655e5298e539bbadc98d25179c900f8ad248492315f589889cb0637a6f76fd1aa23fc11817b3c6b
7
+ data.tar.gz: ca4823a25a5261bd51b8158c9ca858c8415d42bd1acac665c9929f9cd177a89eea0863fa053a26f4553df938435230be2e364fa98cde459f6da3599f69d9796f
@@ -10,9 +10,15 @@ module Catalogs
10
10
  return instance_variable_get(memoized_variable_name)
11
11
  end
12
12
 
13
- options = Catalogs::Catalog.where(model: model, field: field).pluck(:label, :value)
13
+ options = Catalogs::Catalog.where(model: model, field: field, active: true).pluck(:label, :value, :internationalizable)
14
14
 
15
15
  internationalized_options = options.map do |option|
16
+ if option[0].nil?
17
+ option[0] = option[1]
18
+ end
19
+
20
+ return [option[0], option[1]] unless option[2]
21
+
16
22
  [
17
23
  I18n.t("catalogs.#{model}.#{field}.labels.#{option[0]}", default: option[0]),
18
24
  I18n.t("catalogs.#{model}.#{field}.values.#{option[1]}", default: option[1])
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Catalogs
4
4
  class Catalog < ApplicationRecord
5
- validates_presence_of :model, :field, :label, :value
5
+ validates_presence_of :model, :field, :value
6
6
  validates_uniqueness_of :label, :value, scope: %i[model field]
7
7
  end
8
8
  end
@@ -0,0 +1,5 @@
1
+ class AddActiveToCatalogs < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :catalogs_catalogs, :active, :boolean, default: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddInternationalizableToCatalogs < ActiveRecord::Migration[6.0]
2
+ def change
3
+ add_column :catalogs_catalogs, :internationalizable, :boolean, default: true
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class RemoveNullConstraintFromLabel < ActiveRecord::Migration[6.0]
2
+ def change
3
+ change_column :catalogs_catalogs, :label, :string, null: true
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Catalogs
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: catalogs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eduardo Figarola
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-19 00:00:00.000000000 Z
11
+ date: 2019-09-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -94,6 +94,9 @@ files:
94
94
  - app/views/layouts/catalogs/application.html.erb
95
95
  - config/routes.rb
96
96
  - db/migrate/20190919172839_create_catalogs_catalogs.rb
97
+ - db/migrate/20190922014006_add_active_to_catalogs.rb
98
+ - db/migrate/20190922014546_add_internationalizable_to_catalogs.rb
99
+ - db/migrate/20190922015554_remove_null_constraint_from_label.rb
97
100
  - lib/catalogs.rb
98
101
  - lib/catalogs/engine.rb
99
102
  - lib/catalogs/version.rb