tramway-admin 2.1.2 → 2.1.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/app/controllers/tramway/admin/application_controller.rb +1 -1
- data/app/controllers/tramway/admin/records_controller.rb +1 -1
- data/app/views/tramway/admin/records/_search.html.haml +1 -1
- data/app/views/tramway/admin/shared/show/associations/_habtm_row.html.haml +5 -2
- data/app/views/tramway/admin/shared/show/associations/_list.html.haml +21 -0
- data/lib/tramway/admin/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dcf7895786074971f30f08a973c8bc290a533faff676f5ecc65c444076d7f397
|
4
|
+
data.tar.gz: 0d445fbf425502399899e0d66be21acb78ee0f673ec06abb94d7f2743a29e239
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9d2619f6ab1f3eef6bc2a330f0dd17f91272fad60c478a07329892fd986bcd13c38bfd5312c69576df533946fca4f20219857ac34a68e8b87aa72e8bebb989f4
|
7
|
+
data.tar.gz: b1bb886e6bb88028d7665b545c3b8c1550398e19c585cda994e7863a10eeb45dff197837b2a2b5137a5189c47c60103e063695918880adaad097766f1cf8d48d
|
data/README.md
CHANGED
@@ -541,7 +541,8 @@ class YourModelDecorator < Tramway::Core::ApplicationDecorator
|
|
541
541
|
inner: lambda do # inner HTML you want to see in the button
|
542
542
|
fa_icon 'file-excel'
|
543
543
|
end,
|
544
|
-
color: :success # bootstrap button color
|
544
|
+
color: :success, # bootstrap button color
|
545
|
+
method: :get # HTTP method. get method is a default. Available: :post, :patch: delete
|
545
546
|
}
|
546
547
|
]
|
547
548
|
}
|
@@ -21,7 +21,7 @@ module Tramway
|
|
21
21
|
protected
|
22
22
|
|
23
23
|
def check_available!
|
24
|
-
raise 'Tramway::Admin - Model or Form is not available' if !model_given? && !form_given?
|
24
|
+
raise 'Tramway::Admin - Model or Form is not available. Looks like current user does not have access to change this model. Update your tramway initializer file' if !model_given? && !form_given?
|
25
25
|
end
|
26
26
|
|
27
27
|
def check_available_scope!
|
@@ -9,7 +9,7 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
|
|
9
9
|
if params[:filter].is_a? String
|
10
10
|
params[:filter] = JSON.parse params[:filter]
|
11
11
|
end
|
12
|
-
records = records.ransack(params[:filter]).result
|
12
|
+
records = records.ransack(params[:filter]).result(distinct: true)
|
13
13
|
end
|
14
14
|
params[:list_filters]&.each do |filter, value|
|
15
15
|
case decorator_class.list_filters[filter.to_sym][:type]
|
@@ -8,7 +8,7 @@
|
|
8
8
|
= hidden_field_tag :model, params[:model]
|
9
9
|
= hidden_field_tag :scope, params[:scope]
|
10
10
|
= hidden_field_tag :filter, (params[:filter].is_a?(ActionController::Parameters) ? params[:filter].permit!.to_h.to_json : params[:filter])
|
11
|
-
- decorator_class(model_class).list_filters
|
11
|
+
- decorator_class(model_class).list_filters&.each_slice(3) do |slice|
|
12
12
|
.row-fluid.filters
|
13
13
|
- slice.each do |filter|
|
14
14
|
- case filter[1][:type]
|
@@ -5,7 +5,10 @@
|
|
5
5
|
%hr
|
6
6
|
- association_form = object.send("add_#{association.name}_form")
|
7
7
|
= simple_form_for association_form, url: { controller: :has_and_belongs_to_many_records, action: :create, form: association_form.class, model_class: model_class, object_id: object.id }, method: :post do |f|
|
8
|
-
|
9
|
-
|
8
|
+
- association_form.associations.each do |association_name|
|
9
|
+
- associations = association_form.model.class.reflect_on_all_associations.map(&:name)
|
10
|
+
- if associations.include? association_name
|
11
|
+
= f.association association_name, label: false
|
12
|
+
= f.button :submit, "#{I18n.t('helpers.actions.add')} #{model_class.human_attribute_name(association.name).singularize.downcase}", class: 'btn-success'
|
10
13
|
%td{ colspan: 2 }
|
11
14
|
= render 'tramway/admin/shared/show/associations/list', object: object, association: association
|
@@ -0,0 +1,21 @@
|
|
1
|
+
- association_state_machines = object.send("#{association.name}_state_machines")
|
2
|
+
%table.table.table-striped.table-bordered
|
3
|
+
- object.send(association.name)&.each do |association_object|
|
4
|
+
%tr{ id: "#{association.name}_#{association_object.id}" }
|
5
|
+
%td
|
6
|
+
= association_object.id
|
7
|
+
%td
|
8
|
+
= link_to association_object.name, record_path(association_object.id, model: association.options[:class_name])
|
9
|
+
%td
|
10
|
+
- association_state_machines.each do |state_method|
|
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
|
+
%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'
|
16
|
+
- if destroy_is_available? association_object, object
|
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
|
18
|
+
= fa_icon 'trash-alt'
|
19
|
+
- if habtm_destroy_is_available? association_object, object
|
20
|
+
= delete_button url: has_and_belongs_to_many_record_path(association_object.id, model_class: object.model.class, object_id: object.id, form: "Admin::#{object.model.class.to_s.pluralize}::Remove#{association_object.model.class.to_s}Form", redirect: current_model_record_path(object.id)), button_options: { class: 'btn btn-xs btn-danger delete' } do
|
21
|
+
= fa_icon 'trash-alt'
|
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: 2.1.
|
4
|
+
version: 2.1.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Kalashnikov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-08
|
11
|
+
date: 2021-11-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tramway-core
|
@@ -278,6 +278,7 @@ files:
|
|
278
278
|
- app/views/tramway/admin/shared/errors/server_error.html.haml
|
279
279
|
- app/views/tramway/admin/shared/show/_attribute_tr.html.haml
|
280
280
|
- app/views/tramway/admin/shared/show/associations/_habtm_row.html.haml
|
281
|
+
- app/views/tramway/admin/shared/show/associations/_list.html.haml
|
281
282
|
- app/views/tramway/admin/shared/show/associations/_row.html.haml
|
282
283
|
- app/views/tramway/admin/shared/show/associations/_table_row.html.haml
|
283
284
|
- app/views/tramway/admin/singletons/_form.html.haml
|
@@ -329,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
330
|
- !ruby/object:Gem::Version
|
330
331
|
version: '0'
|
331
332
|
requirements: []
|
332
|
-
rubygems_version: 3.1.
|
333
|
+
rubygems_version: 3.1.2
|
333
334
|
signing_key:
|
334
335
|
specification_version: 4
|
335
336
|
summary: Engine for admin
|