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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4c266371ff441a58ba52540f4f2110c1daca84b4a3a30ce9ee6705ad320e1d8a
4
- data.tar.gz: 920e028b1ae7a9b058701e56b4c9c52d76c0a34f6120e1ac5415baa6edacfe95
3
+ metadata.gz: b472aebdf03b3eef04ec1841972e3962cfd448287454422572b9b7f6ebf2b941
4
+ data.tar.gz: 4883c98c8a25ee54d23e6406d445e7ab4c85c76e2a0ba92793762671659b6080
5
5
  SHA512:
6
- metadata.gz: d6e7d0193b6abd26b1255f18a9b57a8d82f488321349a39ca80e1d789d5da31db6c5ecbfc5d9879423aaf0bb643a4b5ee41a1c9cb64aefcf94ce8d06251dbe33
7
- data.tar.gz: ec305808b14d11bd92d70cd59dabffa83f259592a4b38d47bb39917146663f711e9203f58a5009ad320a2820c88de7d7e7963b020c6b97845a75e3a779708683
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 'state_machine', github: 'seuros/state_machine'
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 @record_form.submit params[:record]
56
- redirect_to params[:redirect].present? ? params[:redirect] : record_path(@record_form.model)
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
- render :edit
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
@@ -2,6 +2,7 @@
2
2
 
3
3
  class Tramway::User::User < ::Tramway::Core::ApplicationRecord
4
4
  has_secure_password # FIXME: remove repeating from tramway-user
5
+ include ::AASM
5
6
 
6
7
  enumerize :role, in: %i[user admin], default: :admin
7
8
 
@@ -28,7 +28,7 @@
28
28
  %br
29
29
  %br
30
30
  .btn-group{ data: { toggle: :buttons } }
31
- - record.model.class.state_machines.keys.each do |state_method|
32
- - unless state_method == :state
33
- = state_events_buttons record, state_method: state_method, 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 }
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
- .col-md-8
3
- .search
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
- = text_field_tag :search, params[:search], class: 'text form-control'
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
- .row-fluid.filters
34
- .col-md-4.offset-md-8.submit
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
- = render 'search', model_class: model_class
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.state_machines.keys.include?(attribute_name.to_sym)
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 }
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.33.1'
5
+ VERSION = '2.0.0.2'
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.33.1
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-01-25 00:00:00.000000000 Z
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