tramway-admin 1.24.0.3 → 1.25

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: 8eda1f6e8bd50ccd58ecd499430f865dc8a7a3eea2ffb1111bd54c401926f03a
4
- data.tar.gz: e0cabe64036fbaa4ce9372ca6941c11d62a124f44c257213a9baec475b4e3d20
3
+ metadata.gz: 7852be8e1252b1898b91dfa9d2cb59ea27964a5324dfe28f853b8246c4128f4d
4
+ data.tar.gz: 93324c1d3e853a2c2c7f8e44f850af44e1235282b67ae27ea3b3a996fa09bcc6
5
5
  SHA512:
6
- metadata.gz: ee933112ded2c183e5bb5fe0fc8237cd366874fded372b50691cc66392eb8c8a45f75a353697486376daf3cd1fffe77369f03abe093ba10330ebc62bb3fba618
7
- data.tar.gz: 3ac64984136c06f798cbccf50361ef4de7079454749bfed95db827b12c624abd279346a23692c63057f7e8faba782d1d094589c371c7c1ffbb0a1a60dc2dcd5b
6
+ metadata.gz: c111155d6b7bc46989c9d744e9404a59e7a0a1894d3ad9eabd0e25616891e22368d8602d141c9a9891efe15cf3fc803e0369c23c50f37b031102547672a93622
7
+ data.tar.gz: c748a1042f1c39311b6042a4ab79a241b142611182c7c6819ed7ead59896989a8130035575bdf078d4143f14194cea87c2e77e972bc49a49358274fbf2a5da55
@@ -4,6 +4,7 @@
4
4
  = model_class.human_attribute_name association.name
5
5
  %hr
6
6
  = link_to "#{I18n.t('helpers.actions.add')} #{model_class.human_attribute_name(association.name).singularize.downcase}", new_associated_record_path(association: association, object: object, as: object.send("#{association.name}_as")), class: 'btn btn-primary'
7
+ - association_state_machines = object.send("#{association.name}_state_machines")
7
8
  %td{ colspan: 2 }
8
9
  %table.table.table-striped.table-bordered
9
10
  - object.send(association.name)&.each do |association_object|
@@ -12,6 +13,9 @@
12
13
  = association_object.id
13
14
  %td
14
15
  = link_to association_object.name, record_path(association_object.id, model: association.options[:class_name])
16
+ %td
17
+ - association_state_machines.each do |state_method|
18
+ = state_events_buttons association_object, state_method: state_method, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { redirect: current_model_record_path(object.id), model: association_object.class.model_name }, button_options: { class: :smart_button }
15
19
  %td
16
20
  - if ::Tramway::Admin.action_is_available?(association_object, project: (@application_engine || @application.name), model: association_object.model.class, role: current_user.role, action: :destroy)
17
21
  = delete_button url: record_path(association_object.id, model: association.options[:class_name], redirect: current_model_record_path(object.id)), button_options: { class: 'btn btn-xs btn-danger' } do
@@ -35,8 +35,9 @@ module Tramway
35
35
  end
36
36
 
37
37
  def models_array(models_type:, role:)
38
- # FIXME projects[1] WHAT DA FUCK?!!!!
39
- instance_variable_get("@#{models_type}_models")&.map { |projects| projects[1][role]&.keys }&.flatten || []
38
+ instance_variable_get("@#{models_type}_models")&.map do |projects|
39
+ projects.last[role]&.keys
40
+ end&.flatten || []
40
41
  end
41
42
 
42
43
  def action_is_available?(record, project:, role:, model:, action:)
@@ -19,8 +19,8 @@ module Tramway::Admin::RecordsModels
19
19
  models = get_models_by_key(@available_models, project, role)
20
20
  if project_is_engine?(project)
21
21
  models += engine_class(project).dependencies.map do |dependency|
22
- if @available_models[dependency][role].present?
23
- @available_models[dependency][role]
22
+ if @available_models&.dig(dependency, role).present?
23
+ @available_models&.dig(dependency, role).keys
24
24
  else
25
25
  error = Tramway::Error.new(
26
26
  plugin: :admin,
@@ -4,12 +4,12 @@ module Tramway::Admin::SingletonModels
4
4
  def set_singleton_models(*models, project:, role: :admin)
5
5
  @singleton_models ||= {}
6
6
  @singleton_models[project] ||= {}
7
- @singleton_models[project][role] ||= []
7
+ @singleton_models[project][role] ||= {}
8
8
  models.each do |model|
9
9
  if model.class == Class
10
- @singleton_models[project][role] << { model => [ :index, :show, :update, :create, :destroy ] }
10
+ @singleton_models[project][role].merge! model => [ :index, :show, :update, :create, :destroy ]
11
11
  elsif model.class == Hash
12
- @singleton_models[project][role] << model
12
+ @singleton_models[project][role].merge! model
13
13
  end
14
14
  end
15
15
  @singleton_models = @singleton_models.with_indifferent_access
@@ -19,7 +19,7 @@ module Tramway::Admin::SingletonModels
19
19
  models = get_models_by_key(@singleton_models, project, role)
20
20
  if project_is_engine?(project)
21
21
  models += engine_class(project).dependencies.map do |dependency|
22
- @singleton_models[dependency]
22
+ @singleton_models[dependency][role]&.keys
23
23
  end.flatten.compact
24
24
  end
25
25
  models
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.24.0.3'
5
+ VERSION = '1.25'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.24.0.3
4
+ version: '1.25'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-25 00:00:00.000000000 Z
11
+ date: 2020-02-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-kaminari-views