tramway-core 1.18.6 → 2.0.0.3

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: 6099966ec764bed33f2ff047144f9bde9057da2740626df9dd7070658ea54b8a
4
- data.tar.gz: 95215f84be2eed817f5a6d4741aadb8d68d9a66de216be52c994e0eabca50cf7
3
+ metadata.gz: 8cb5f162d7f0c25e14716d625868a33da89c697af2ec591d7f7979a1be186ec3
4
+ data.tar.gz: '09d897ed92f6a1231178781b82bcf2b670887287f04e1d73404750db13ce44a2'
5
5
  SHA512:
6
- metadata.gz: 8259a4092c24557aeb828575a7966634ae8a707beac890737fdf5630735e534193c3820a0c14a27dec54d0daf1b2a210266f881ce12631364782fa8298e233dc
7
- data.tar.gz: b41e199f893ec054da4d5d1e9716d841acea37e155d6019792b9eb4009c651ad84b33231eaccc8643975ec800e7eca6276744cc32a31c628b11c27a0b5de2dd9
6
+ metadata.gz: 91fa7227004fdd8703de213ac2bdef4d82235389cc807da5ebce079e31549d00543fc01693405bc20784817e2e7ce2e4d4ea36ec8be7451c9244c1979d2e5bfb
7
+ data.tar.gz: d8ebf4899596a26019744c1a93070aa8229d160bec462ea9951e37dfc2faecd57e861fbef4f5bfe2989c133a9b3b8e2cb1c908f1bf794c9f95e538f3dd418581
@@ -9,7 +9,7 @@ module Tramway::Core::Attributes::ViewHelper
9
9
  end
10
10
 
11
11
  def state_machine?(object, attribute_name)
12
- attribute_name.to_s.in? object.class.state_machines.keys.map(&:to_s)
12
+ attribute_name.to_s.in? object.class.state_machines_names.map(&:to_s)
13
13
  end
14
14
 
15
15
  def view_by_value(object, value, attribute)
@@ -10,7 +10,9 @@ module Tramway::Core::Concerns::AttributesDecoratorHelper
10
10
  end
11
11
 
12
12
  def state_machine_view(object, attribute_name)
13
- object.send "human_#{attribute_name}_name"
13
+ I18n.t("state_machines.#{object.class.model_name.to_s.underscore}.#{attribute_name}.states.#{object.send(attribute_name)}")
14
+ rescue
15
+ object.aasm.human_state
14
16
  end
15
17
 
16
18
  BASE64_REGEXP = %r{^(?:[a-zA-Z0-9+/]{4})*(?:|(?:[a-zA-Z0-9+/]{3}=)|
@@ -18,7 +18,11 @@ module Tramway::Core::ApplicationForms::SubmitHelper
18
18
  rescue ArgumentError => e
19
19
  Tramway::Error.raise_error :tramway, :core, :application_form, :save, :argument_error, message: e.message
20
20
  rescue StandardError => e
21
- Tramway::Error.raise_error :tramway, :core, :application_form, :save, :looks_like_you_have_method,
22
- method_name: e.name.to_s.gsub('=', ''), model_class: @@model_class, class_name: self.class
21
+ if e.try :name
22
+ Tramway::Error.raise_error :tramway, :core, :application_form, :save, :looks_like_you_have_method,
23
+ method_name: e.name.to_s.gsub('=', ''), model_class: @@model_class, class_name: self.class
24
+ else
25
+ raise e
26
+ end
23
27
  end
24
28
  end
@@ -4,7 +4,7 @@ module Tramway::Core::ExtendableFormsHelpers::PropertiesHelper
4
4
  def define_properties_method(simple_properties, more_properties)
5
5
  define_method 'properties' do
6
6
  hash = simple_properties.each_with_object({}) do |property, h|
7
- h.merge! property[0] => property[1] unless model.class.state_machines.keys.include?(property[0])
7
+ h.merge! property[0] => property[1] unless model.class.state_machines_names.include?(property[0])
8
8
  end
9
9
  more_properties.reduce(hash) do |h, property|
10
10
  h.merge! property[0] => {
@@ -2,6 +2,7 @@
2
2
 
3
3
  module Tramway::Core::TitleHelper
4
4
  def title(page_title = default_title)
5
+ @application ||= Tramway::Core.application&.model_class&.first || Tramway::Core.application
5
6
  if @application.present?
6
7
  title_text = "#{page_title} | #{@application.try(:title) || @application.public_name}"
7
8
  content_for(:title) { title_text }
@@ -6,13 +6,14 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
6
6
  self.abstract_class = true
7
7
  audited
8
8
  extend ::Enumerize
9
+ include ::AASM
9
10
 
10
- state_machine :state, initial: :active do
11
- state :active
11
+ aasm column: :state do
12
+ state :active, initial: true
12
13
  state :removed
13
14
 
14
15
  event :remove do
15
- transition active: :removed
16
+ transitions from: :active, to: :removed
16
17
  end
17
18
  end
18
19
 
@@ -57,6 +58,10 @@ class Tramway::Core::ApplicationRecord < ActiveRecord::Base
57
58
  def file_extensions
58
59
  @extensions
59
60
  end
61
+
62
+ def state_machines_names
63
+ AASM::StateMachineStore.fetch(self).machine_names
64
+ end
60
65
  end
61
66
 
62
67
  # FIXME: detect inhertited locales
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Core
5
- VERSION = '1.18.6'
5
+ VERSION = '2.0.0.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.6
4
+ version: 2.0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-24 00:00:00.000000000 Z
12
+ date: 2021-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: audited