tramway-admin 1.20.3 → 1.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cb01a97126046445dc8cad97bf599ccfba88834d79fcc81f3d4fb9c69dfb88c2
4
- data.tar.gz: a721e3e880cb80a0aa1f4de92ec69a0700acabe37a9d9079c48d192066422850
3
+ metadata.gz: cfb1c6cbf060937418232e7360bb5926e5a77e0dd7b44f629355f4d0a4e1bced
4
+ data.tar.gz: 8fa7106461c814ebbff02ffb4b84a7c4bbb2ef9d2760872503612e249600b6f6
5
5
  SHA512:
6
- metadata.gz: 8814ec26d243b314ebe174098446905ebaaf95c1c4cf334f537e4edb14449fd3edbc78568a2e1a168d9121cbed29122d2037379306cc85698b25b25447f3188c
7
- data.tar.gz: 5900f6be25d35c92632a22a55ba83fc19c71365da52508f7443a3f9cf1f82920874e1f5571e7d2f8fcb016a34f7f0635ac5c6ea39e531841e15e37a22f9937ab
6
+ metadata.gz: 4509a00137c9980105509b0a449879c91ef5be45b64f8250dc8cc72a673d632cbdf63869eacc81f3e051ba7c80ba512c967e2fc0d527dea306401cd6fb46065a
7
+ data.tar.gz: b2b8f2100f1f446fe2047994ffddb3fcb98f989757418a2b8c26aca9a2d37e87052146156ad2c54fdcdc3755d850a1ee47e1e3ff51f25404bede2e40ad72e559
@@ -43,6 +43,6 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
43
43
  def destroy
44
44
  record = model_class.active.find params[:id]
45
45
  record.remove
46
- redirect_to records_path
46
+ redirect_to params[:redirect] || records_path
47
47
  end
48
48
  end
@@ -6,7 +6,7 @@ module Tramway
6
6
  include ::FontAwesome5::Rails::IconHelper
7
7
  include AuthManagement
8
8
  include AdditionalButtonsBuilder
9
- include SmartButtons
9
+ include ::SmartButtons
10
10
  include CasesHelper
11
11
  include RussianCasesHelper
12
12
  include ::Tramway::Admin::RecordsHelper
@@ -74,12 +74,12 @@ module Tramway::Admin
74
74
  return :active if params[:search].nil? && params[:scope].to_s == tab.to_s
75
75
  end
76
76
 
77
- def new_associated_record_path(object:, association:)
77
+ def new_associated_record_path(object:, association:, as:)
78
78
  unless association.options[:class_name].present?
79
79
  raise "You should set `class_name` for #{association.name} association"
80
80
  end
81
81
 
82
- if association.options[:as].present?
82
+ if association.options[:as].present? # polymorphic? conditiion
83
83
  new_record_path model: association.class_name,
84
84
  redirect: current_model_record_path(object),
85
85
  association.options[:class_name].underscore => {
@@ -88,9 +88,9 @@ module Tramway::Admin
88
88
  }
89
89
  else
90
90
  new_record_path model: association.class_name,
91
- redirect: current_model_record_path(object),
91
+ redirect: current_model_record_path(object.model),
92
92
  association.options[:class_name].underscore => {
93
- object.model.class.name.underscore => object.id
93
+ as || object.model.class.name.underscore => object.id
94
94
  }
95
95
  end
96
96
  end
@@ -11,5 +11,6 @@
11
11
  = simple_form_for @record_form, url: { controller: :records, action: action, model: @record_form.model.class }, method: method, input_html: { class: 'form-horizontal' } do |f|
12
12
  - @record_form.properties.each do |property, type|
13
13
  = render 'tramway/admin/shared/input', property: property, object: :record, type: type, form: f
14
+ = hidden_field_tag :redirect, params[:redirect]
14
15
  = f.button :submit, t('helpers.links.save'), class: 'btn-success'
15
16
  = link_to t('helpers.links.back'), current_model_records_path, class: 'btn btn-secondary'
@@ -2,7 +2,8 @@
2
2
  %tr
3
3
  %td
4
4
  = model_class.human_attribute_name association.name
5
- -#= link_to "Add #{model_class.human_attribute_name(association.name).singularize}", new_associated_record_path(association: association, object: object), class: 'btn btn-primary'
5
+ %hr
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'
6
7
  %td{ colspan: 2 }
7
8
  %table.table.table-striped.table-bordered
8
9
  - object.send(association.name)&.each do |association_object|
@@ -11,3 +12,6 @@
11
12
  = association_object.id
12
13
  %td
13
14
  = link_to association_object.name, record_path(association_object.id, model: association.options[:class_name])
15
+ %td
16
+ = 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
17
+ = fa_icon 'trash-alt'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.20.3'
5
+ VERSION = '1.21'
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.20.3
4
+ version: '1.21'
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-01-25 00:00:00.000000000 Z
11
+ date: 2020-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-kaminari-views