tramway-core 1.12.1 → 1.13.1.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: 16172a47127987a0492d51f269ccd76ab319bf8323636ba20f3ac36745fb2007
4
- data.tar.gz: ac86409a6b1fbc1462f07a5a5b999ff81755a9af28c8b3e834a786983915f006
3
+ metadata.gz: 98fc3b4eb72607b71692a66f9984842cc63cd135f7c498090b5a89ec22d25648
4
+ data.tar.gz: 955159d6eb34fc36e753a3aba3167846a788a7ce37e9e5d3d657fb542c0d6312
5
5
  SHA512:
6
- metadata.gz: 6e45054851f49dbc7c1aff4c267c5eb0a6c95a95569808649313991699160bf90e93f96293c69658ad5b23a60b5b188ab585eb1da8ec05e902a689544e3f82d6
7
- data.tar.gz: 58786a322921c254d038f39dfc3d4b8338f78f77bb7a8d6c6826b916c8b6957530a034229ad42dfc93165f0f1ffb5d9e9c779a86a9510b54bdd7bb20ab25ae77
6
+ metadata.gz: 8901bf8f3c13d43b4bc750dfef901e079bc351eae922674883066ffffaca448c7ba5c3913ef96bf7caed2f52d1872358780295d3dd46c07178f758b6e5ab35b5
7
+ data.tar.gz: ceb839ae0aa3d97d75a0e7c98c212bd8502ad21f8f411d20871bce24f608fd7818d67284ed271a0ffa22515d8c47b0403422f9aa0aa559b0b66f9e174c0cf2c5
@@ -5,11 +5,16 @@
5
5
  #= require font_awesome5
6
6
  #= require_tree .
7
7
 
8
+ window.i18n_locale = (locale) ->
9
+ switch locale
10
+ when 'en' then { date_format: 'yyyy-mm-dd', locale: locale }
11
+ when 'ru' then { date_format: 'dd.mm.yyyy', locale: locale }
12
+
8
13
  $(document).ready ->
9
14
  unless $('.date_picker').length == 0
10
15
  $('.date_picker').datepicker({
11
- format: 'dd.mm.yyyy',
12
- language: 'ru'
16
+ format: window.current_locale.date_format,
17
+ language: window.current_locale.locale
13
18
  })
14
19
 
15
20
  $('.link').click ->
@@ -18,6 +23,6 @@ $(document).ready ->
18
23
  location.href = href
19
24
  else
20
25
  anchor = $(this).data('anchor')
21
- console.log(anchor)
22
- $(window).scrollTop $(anchor).offset().top
26
+ unless $(anchor).offset() == undefined
27
+ $(window).scrollTop $(anchor).offset().top
23
28
 
@@ -111,8 +111,17 @@ class Tramway::Core::ApplicationDecorator
111
111
 
112
112
  include Tramway::Core::Concerns::AttributesDecoratorHelper
113
113
 
114
+ RESERVED_WORDS = [ 'fields' ]
115
+
114
116
  def attributes
115
117
  object.attributes.reduce({}) do |hash, attribute|
118
+ if attribute[0].in? RESERVED_WORDS
119
+ error = Tramway::Error.new(
120
+ plugin: :core,
121
+ method: :attributes,
122
+ message: ("Method `#{attribute[0]}` is reserved word. Please, create or delegate method in #{self.class.name} with another name."))
123
+ raise error.message
124
+ end
116
125
  value = try(attribute[0]) ? send(attribute[0]) : object.send(attribute[0])
117
126
  if attribute[0].to_s.in? object.class.state_machines.keys.map(&:to_s)
118
127
  hash.merge! attribute[0] => state_machine_view(object, attribute[0])
@@ -11,7 +11,11 @@ module Tramway::Core
11
11
  if class_name.is_a? Array
12
12
  self.class.send(:define_method, "#{association}=") do |value|
13
13
  association_class = send("#{association}_type")
14
- super association_class.constantize.find value
14
+ if association_class.nil?
15
+ raise Tramway::Error.new(plugin: :core, method: :initialize, message: 'Polymorphic association class is nil. Maybe, you should write `assocation #{association_name}` after `properties #{association_name}_id, #{association_name}_type`')
16
+ else
17
+ super association_class.constantize.find value
18
+ end
15
19
  end
16
20
  else
17
21
  self.class.send(:define_method, "#{association}=") do |value|
@@ -3,19 +3,19 @@ class Tramway::Core::ExtendedApplicationForm < Tramway::Core::ApplicationForm
3
3
  def properties(*args)
4
4
  @@extendable_properties ||= []
5
5
  @@extendable_properties += args
6
- super *args
6
+ super(*args)
7
7
  end
8
8
  end
9
9
 
10
- def initialize(model)
11
- @@extendable_properties.each do |prop|
12
- unless model.respond_to? prop
13
- model.class.define_method prop do
14
- end
15
- model.class.define_method "#{prop}=" do |value|
16
- end
10
+ def initialize(model)
11
+ @@extendable_properties.each do |prop|
12
+ unless model.respond_to? prop
13
+ model.class.define_method prop do
14
+ end
15
+ model.class.define_method "#{prop}=" do |value|
17
16
  end
18
17
  end
19
- super
20
18
  end
19
+ super
20
+ end
21
21
  end
@@ -16,7 +16,11 @@ module Tramway
16
16
  end
17
17
 
18
18
  def page_title(action, model_name)
19
- t("helpers.actions.#{action}") + ' ' + genitive(model_name)
19
+ if I18n.locale == :ru
20
+ t("helpers.actions.#{action}") + ' ' + genitive(model_name)
21
+ else
22
+ t("helpers.actions.#{action}") + ' ' + model_name.model_name.human.downcase
23
+ end
20
24
  end
21
25
  end
22
26
  end
@@ -7,7 +7,7 @@
7
7
  = f.input field.title.to_sym, as: field.field_type, input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }
8
8
  - when 'select'
9
9
  - parsed_json = field.options.is_a?(Hash) ? field.options : (JSON.parse(field.options) unless field.options == '')
10
- - if parsed_json && parsed_json.dig('collection', 'name')
10
+ - if parsed_json&.dig('collection', 'name')
11
11
  - if value.present?
12
12
  = f.input field.title.to_sym, as: :select, collection: collection_list_by(name: parsed_json['collection']['name']), input_html: { class: class_name, id: "#{class_name}_#{field.title}", name: "#{class_name}[#{field.title}]" }, selected: value
13
13
  - else
@@ -0,0 +1,10 @@
1
+ en:
2
+ date:
3
+ from: from
4
+ to: to
5
+ formats:
6
+ default: "%m/%d/%Y"
7
+ month_names: [~, January, February, March, April, May, June, July, August, September, October, November, December]
8
+ time:
9
+ formats:
10
+ default: "%m/%d/%Y %H:%M"
@@ -0,0 +1,19 @@
1
+ en:
2
+ helpers:
3
+ links:
4
+ enter: Sign In
5
+ save: Save
6
+ back: Back
7
+ sign_out: Sign Out
8
+ actions: Actions
9
+ open: Open
10
+ actions:
11
+ create: Create
12
+ update: Update
13
+ search: Search
14
+ reset: Reset
15
+ download: Download
16
+ scope:
17
+ found: Found
18
+ "yes": yes
19
+ "no": no
@@ -0,0 +1,6 @@
1
+ en:
2
+ tramway:
3
+ core:
4
+ shared:
5
+ messages:
6
+ some_errors_was_found: There are errors
@@ -0,0 +1,9 @@
1
+ en:
2
+ activerecord:
3
+ attributes:
4
+ tramway/core/application_record:
5
+ created_at: Created at
6
+ updated_at: Updated at
7
+ state: State
8
+ errors:
9
+ wrong_email_or_password: Wrong email or password
@@ -0,0 +1,8 @@
1
+ en:
2
+ simple_form:
3
+ extension:
4
+ selectize:
5
+ add: Add
6
+ file:
7
+ select: Select file
8
+ change: Change file
@@ -0,0 +1,8 @@
1
+ en:
2
+ activerecord:
3
+ state_machines:
4
+ tramway/core/application_record:
5
+ state:
6
+ states:
7
+ active: Active
8
+ removed: Removed
@@ -17,3 +17,8 @@ ru:
17
17
  found: Найденные
18
18
  "yes": Да
19
19
  "no": Нет
20
+ tramway:
21
+ admin:
22
+ welcome:
23
+ index:
24
+ title: Админка
@@ -4,3 +4,5 @@ ru:
4
4
  shared:
5
5
  messages:
6
6
  some_errors_was_found: Найдены ошибки
7
+ errors:
8
+ wrong_email_or_password: Неверный логин или пароль
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Core
3
- VERSION = '1.12.1'
3
+ VERSION = '1.13.1.1'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.12.1
4
+ version: 1.13.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-07 00:00:00.000000000 Z
11
+ date: 2019-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reform-rails
@@ -356,6 +356,12 @@ files:
356
356
  - config/initializers/assets.rb
357
357
  - config/initializers/carrierwave.rb
358
358
  - config/initializers/plurals.rb
359
+ - config/locales/en/dates.yml
360
+ - config/locales/en/helpers.yml
361
+ - config/locales/en/messages.yml
362
+ - config/locales/en/models.yml
363
+ - config/locales/en/simple_form_extension.yml
364
+ - config/locales/en/state_machines.yml
359
365
  - config/locales/ru/dates.yml
360
366
  - config/locales/ru/helpers.yml
361
367
  - config/locales/ru/messages.yml