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 +4 -4
- data/app/assets/javascripts/tramway/core/application.js.coffee +9 -4
- data/app/decorators/tramway/core/application_decorator.rb +9 -0
- data/app/forms/tramway/core/application_form.rb +5 -1
- data/app/forms/tramway/core/extended_application_form.rb +9 -9
- data/app/helpers/tramway/core/title_helper.rb +5 -1
- data/app/views/tramway/core/shared/_input_extended.html.haml +1 -1
- data/config/locales/en/dates.yml +10 -0
- data/config/locales/en/helpers.yml +19 -0
- data/config/locales/en/messages.yml +6 -0
- data/config/locales/en/models.yml +9 -0
- data/config/locales/en/simple_form_extension.yml +8 -0
- data/config/locales/en/state_machines.yml +8 -0
- data/config/locales/ru/helpers.yml +5 -0
- data/config/locales/ru/messages.yml +2 -0
- data/lib/tramway/core/version.rb +1 -1
- metadata +8 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98fc3b4eb72607b71692a66f9984842cc63cd135f7c498090b5a89ec22d25648
|
4
|
+
data.tar.gz: 955159d6eb34fc36e753a3aba3167846a788a7ce37e9e5d3d657fb542c0d6312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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:
|
12
|
-
language:
|
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
|
-
|
22
|
-
|
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
|
-
|
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
|
6
|
+
super(*args)
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
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
|
-
|
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
|
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,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
|
data/lib/tramway/core/version.rb
CHANGED
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.
|
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
|
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
|