tramway-admin 1.28.2.1 → 1.29

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: 21711fbc990c317fce293234d1ffd68bff6dffbc1b27ee5f67bf182300362ce2
4
- data.tar.gz: 91329b3c8f18e24bd9b15b08a0fd5482bd1714b65a5c0271d5822275b431d7f4
3
+ metadata.gz: 01f0328f6e541ce9e16109272920c6878a90dc89577e21a85614f66c54ea29e9
4
+ data.tar.gz: c457d21a480b855835a3e55192ba771a2af6a28e8ba663910e2cad3e7e1b86d6
5
5
  SHA512:
6
- metadata.gz: c7c3520f8e5e5a51748b17d62dd94b2a82c84f3e33ddab57cae6e8b8513b46d2babee79478d1892d68455bb0adb0c2ce960c33e880e222eea64ad3ff92b720af
7
- data.tar.gz: 41092240f6c997c9e34f3ea22185e1668be2f721fdf719f4af4959a1fae55a0c88ceaf8cc6f1be544f9282e170baabbb6751a0bb290be74f20df3d68032558c0
6
+ metadata.gz: 63da1c38228db68cf4863e3461953a495141f99d2e8452f5c605d2150803dea6dd942196bb8ff57d36c3ec386570b52377708e119c2497f1aaa203d8137a33a7
7
+ data.tar.gz: 2944d285dd6ad080b573eb368b752cc47f1a4012cc2c6294c5e54bd72527a1d41a6c3d504bfa7407b7a2a66d6aab28252d22ccdce9ffeb69c86866aa05c25c66
@@ -84,11 +84,11 @@ module Tramway
84
84
  end
85
85
 
86
86
  def form_given?
87
- # FIXME add tramway error locales to the tramway admin gem
88
- #Tramway::Error.raise_error(
87
+ # FIXME: add tramway error locales to the tramway admin gem
88
+ # Tramway::Error.raise_error(
89
89
  # :tramway, :admin, :application_controller, :form_given, :model_not_included_to_tramway_admin,
90
90
  # model: params[:model]
91
- #)
91
+ # )
92
92
  raise "Looks like model #{params[:model]} is not included to tramway-admin for `#{current_user.role}` role. Add it in the `config/initializers/tramway.rb`. This way `Tramway::Admin.set_available_models(#{params[:model]})`"
93
93
  Tramway::Admin.forms.include? params[:form].underscore.sub(%r{^admin/}, '').sub(/_form$/, '')
94
94
  end
@@ -11,6 +11,22 @@ module Tramway::Admin::ActionsHelper
11
11
  )
12
12
  end
13
13
 
14
+ def update_is_available?(association_object, _main_object)
15
+ ::Tramway::Admin.action_is_available?(
16
+ association_object,
17
+ project: (@application_engine || @application.name),
18
+ model_name: association_object.model.class.name,
19
+ role: current_user.role,
20
+ action: :update
21
+ )
22
+ end
23
+
24
+ # delete_button is in smart-buttons gem
25
+
26
+ def edit_button(url:, button_options:, &block)
27
+ link_to(url, **button_options) { yield }
28
+ end
29
+
14
30
  def habtm_destroy_is_available?(association_object, main_object)
15
31
  ::Tramway::Admin.forms&.include?("#{main_object.model.class.to_s.underscore.pluralize}/remove_#{association_object.model.class.to_s.underscore}")
16
32
  end
@@ -81,17 +81,17 @@ module Tramway::Admin
81
81
 
82
82
  if association.options[:as].present? # polymorphic? conditiion
83
83
  new_record_path model: association.class_name,
84
- redirect: current_model_record_path(object.model),
85
- association.options[:class_name].underscore => {
86
- association.options[:as] => object.id,
87
- association.type => object.class.model_name
88
- }
84
+ redirect: current_model_record_path(object.model),
85
+ association.options[:class_name].underscore => {
86
+ association.options[:as] => object.id,
87
+ association.type => object.class.model_name
88
+ }
89
89
  else
90
90
  new_record_path model: association.class_name,
91
- redirect: current_model_record_path(object.model),
92
- association.options[:class_name].underscore => {
93
- as || object.model.class.name.underscore => object.id
94
- }
91
+ redirect: current_model_record_path(object.model),
92
+ association.options[:class_name].underscore => {
93
+ as || object.model.class.name.underscore => object.id
94
+ }
95
95
  end
96
96
  end
97
97
  end
@@ -10,6 +10,9 @@
10
10
  - association_state_machines.each do |state_method|
11
11
  = 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 }
12
12
  %td
13
+ - if update_is_available? association_object, object
14
+ = edit_button url: edit_record_path(association_object.id, model: association.options[:class_name], redirect: current_model_record_path(object.id)), button_options: { class: 'btn btn-xs btn-warning edit' } do
15
+ = fa_icon 'pencil-alt'
13
16
  - if destroy_is_available? association_object, object
14
17
  = 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 delete' } do
15
18
  = fa_icon 'trash-alt'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.28.2.1'
5
+ VERSION = '1.29'
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.28.2.1
4
+ version: '1.29'
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-04-08 00:00:00.000000000 Z
11
+ date: 2020-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-kaminari-views