tramway-admin 1.33.1 → 2.0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -4
- data/app/controllers/tramway/admin/application_controller.rb +0 -11
- data/app/controllers/tramway/admin/records_controller.rb +11 -4
- data/app/helpers/tramway/admin/records_helper.rb +1 -1
- data/app/models/tramway/user/user.rb +1 -0
- data/app/views/tramway/admin/records/_list.html.haml +3 -3
- data/app/views/tramway/admin/records/_search.html.haml +6 -6
- data/app/views/tramway/admin/records/index.html.haml +2 -1
- data/app/views/tramway/admin/shared/show/_attribute_tr.html.haml +1 -1
- data/lib/tramway/admin/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b472aebdf03b3eef04ec1841972e3962cfd448287454422572b9b7f6ebf2b941
|
4
|
+
data.tar.gz: 4883c98c8a25ee54d23e6406d445e7ab4c85c76e2a0ba92793762671659b6080
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bee644c43815bfe9765bfa77ea89fcf24a0ba47d7b2abd78f63497e06751cea1a360a7643b2fd2625245a488acd64aedf5d4985b83abbf03d6ae6f87ed9a07e0
|
7
|
+
data.tar.gz: e8913bce766c0d816d7c0b53a0c70de3850c87acd26a7d80c81baca467b902c69c159599b6b1d03bf5c67abe42ad35cbc66bdfd84c36c66bb0b145704982b816
|
data/README.md
CHANGED
@@ -10,9 +10,8 @@ How to use my plugin.
|
|
10
10
|
*Gemfile*
|
11
11
|
```ruby
|
12
12
|
gem 'tramway-admin'
|
13
|
-
gem 'tramway-auth'
|
14
13
|
gem 'tramway-user'
|
15
|
-
gem '
|
14
|
+
gem 'aasm'
|
16
15
|
gem 'bcrypt'
|
17
16
|
gem 'haml-rails'
|
18
17
|
gem 'selectize-rails'
|
@@ -421,6 +420,9 @@ def state
|
|
421
420
|
state_machine_view object, :state
|
422
421
|
end
|
423
422
|
```
|
423
|
+
|
424
|
+
It takes locales from `I18n.t("state_machines.#{model_name}.#{state_machine_name}.states.#{state_value}")`
|
425
|
+
|
424
426
|
#### image_view
|
425
427
|
Returns an image in a particular format depending on the parameters of the original image file
|
426
428
|
|
@@ -537,7 +539,7 @@ Tramway uses [audited](https://github.com/collectiveidea/audited) to log actions
|
|
537
539
|
#### 1. Add Audited::Audit model to available models
|
538
540
|
|
539
541
|
*config/initializers/tramway.rb*
|
540
|
-
```
|
542
|
+
```ruby
|
541
543
|
Tramway::Admin.set_available_models(
|
542
544
|
Audited::Audit,
|
543
545
|
project: :your_project_name
|
@@ -546,7 +548,7 @@ Tramway::Admin.set_available_models(
|
|
546
548
|
|
547
549
|
#### 2. Add this model to navbar
|
548
550
|
|
549
|
-
```
|
551
|
+
```ruby
|
550
552
|
Tramway::Admin.set_navbar_structure(
|
551
553
|
Audited::Audit,
|
552
554
|
project: :your_project_name
|
@@ -72,17 +72,6 @@ module Tramway
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
-
if Rails.env.production?
|
76
|
-
rescue_from StandardError do |exception|
|
77
|
-
Rails.logger.warn "ERROR MESSAGE: #{exception.message}"
|
78
|
-
Rails.logger.warn "BACKTRACE: #{exception.backtrace.first(30).join("\n")}"
|
79
|
-
Raven.capture_exception exception if defined?(Raven)
|
80
|
-
|
81
|
-
@exception = exception
|
82
|
-
render 'tramway/admin/shared/errors/server_error', status: 500, layout: false
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
75
|
include Tramway::ClassNameHelpers
|
87
76
|
|
88
77
|
def model_class
|
@@ -52,16 +52,23 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
|
|
52
52
|
|
53
53
|
def update
|
54
54
|
@record_form = admin_form_class.new model_class.active.find params[:id]
|
55
|
-
if
|
56
|
-
|
55
|
+
if params[:record][:aasm_event].present?
|
56
|
+
if @record_form.model.send("may_#{params[:record][:aasm_event]}?")
|
57
|
+
@record_form.model.send("#{params[:record][:aasm_event]}!")
|
58
|
+
redirect_to params[:redirect].present? ? params[:redirect] : record_path(@record_form.model)
|
59
|
+
end
|
57
60
|
else
|
58
|
-
|
61
|
+
if @record_form.submit params[:record]
|
62
|
+
redirect_to params[:redirect].present? ? params[:redirect] : record_path(@record_form.model)
|
63
|
+
else
|
64
|
+
render :edit
|
65
|
+
end
|
59
66
|
end
|
60
67
|
end
|
61
68
|
|
62
69
|
def destroy
|
63
70
|
record = model_class.active.find params[:id]
|
64
|
-
record.remove
|
71
|
+
record.remove!
|
65
72
|
redirect_to params[:redirect].present? ? params[:redirect] : records_path
|
66
73
|
end
|
67
74
|
end
|
@@ -95,7 +95,7 @@ module Tramway::Admin
|
|
95
95
|
new_record_path model: association.class_name,
|
96
96
|
redirect: current_model_record_path(object.model),
|
97
97
|
association.options[:class_name].underscore => {
|
98
|
-
as || object.model.class.name.underscore => object.id
|
98
|
+
as || object.model.class.name.underscore.gsub('/', '_') => object.id
|
99
99
|
}
|
100
100
|
end
|
101
101
|
end
|
@@ -28,7 +28,7 @@
|
|
28
28
|
%br
|
29
29
|
%br
|
30
30
|
.btn-group{ data: { toggle: :buttons } }
|
31
|
-
- record.model.class.
|
32
|
-
- unless
|
33
|
-
= state_events_buttons record, state_method:
|
31
|
+
- record.model.class.state_machines_names.each do |state_machine_name|
|
32
|
+
- unless state_machine_name == 'default'
|
33
|
+
= state_events_buttons record, state_method: state_machine_name, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { redirect: current_model_records_path(page: params[:page], scope: params[:scope], filter: params[:filter], focus: focus_selector(index)), model: record.class.model_name }, button_options: { class: :smart_button }
|
34
34
|
= paginate @records, theme: 'twitter-bootstrap-4'
|
@@ -1,9 +1,10 @@
|
|
1
1
|
- if searchable_model?(model_class) || is_there_any_filters?(model_class)
|
2
|
-
.
|
3
|
-
.
|
2
|
+
.search
|
3
|
+
.d-flex.flex-row-reverse.filters
|
4
4
|
= form_tag records_path, class: 'form-inline', method: :get do |f|
|
5
5
|
- if searchable_model?(model_class)
|
6
|
-
|
6
|
+
.col-md-8
|
7
|
+
= text_field_tag :search, params[:search], class: 'text form-control'
|
7
8
|
= hidden_field_tag :model, params[:model]
|
8
9
|
= hidden_field_tag :scope, params[:scope]
|
9
10
|
= hidden_field_tag :filter, (params[:filter].is_a?(ActionController::Parameters) ? params[:filter].permit!.to_h.to_json : params[:filter])
|
@@ -30,6 +31,5 @@
|
|
30
31
|
$('#filter_datepicker_begin_date').datepicker();
|
31
32
|
$('#filter_datepicker_end_date').datepicker();
|
32
33
|
});
|
33
|
-
.
|
34
|
-
.
|
35
|
-
= submit_tag t('helpers.actions.search'), class: 'btn btn-primary'
|
34
|
+
.col-md-4.submit
|
35
|
+
= submit_tag t('helpers.actions.search'), class: 'btn btn-primary'
|
@@ -12,7 +12,8 @@
|
|
12
12
|
= link_to fa_icon(:plus), new_current_model_record_path, class: 'btn btn-primary'
|
13
13
|
- if defined? Tramway::Export::Engine
|
14
14
|
= render 'tramway/export/button'
|
15
|
-
|
15
|
+
.col
|
16
|
+
= render 'search', model_class: model_class
|
16
17
|
%hr
|
17
18
|
%ul.nav.nav-tabs
|
18
19
|
- if params[:search].present?
|
@@ -5,5 +5,5 @@
|
|
5
5
|
= value
|
6
6
|
%td
|
7
7
|
- if tramway_model?(model_class)
|
8
|
-
- if attribute_name.to_s != 'state' && object.model.class.
|
8
|
+
- if attribute_name.to_s != 'state' && object.model.class.aasm.states.map(&:name).include?(attribute_name.to_sym)
|
9
9
|
= state_events_buttons object, state_method: attribute_name, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { model: object.class.model_name }, button_options: { class: :smart_button }
|
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:
|
4
|
+
version: 2.0.0.2
|
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-
|
11
|
+
date: 2021-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tramway-core
|
@@ -196,6 +196,20 @@ dependencies:
|
|
196
196
|
- - '='
|
197
197
|
- !ruby/object:Gem::Version
|
198
198
|
version: '3.0'
|
199
|
+
- !ruby/object:Gem::Dependency
|
200
|
+
name: aasm
|
201
|
+
requirement: !ruby/object:Gem::Requirement
|
202
|
+
requirements:
|
203
|
+
- - ">="
|
204
|
+
- !ruby/object:Gem::Version
|
205
|
+
version: '0'
|
206
|
+
type: :runtime
|
207
|
+
prerelease: false
|
208
|
+
version_requirements: !ruby/object:Gem::Requirement
|
209
|
+
requirements:
|
210
|
+
- - ">="
|
211
|
+
- !ruby/object:Gem::Version
|
212
|
+
version: '0'
|
199
213
|
- !ruby/object:Gem::Dependency
|
200
214
|
name: pg
|
201
215
|
requirement: !ruby/object:Gem::Requirement
|