tramway-admin 1.33.0.1 → 2.0.0.1

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: 2a2170c93de0fe4f501e76ad2b66b3cf07e622974d1db732dccd3f0fa751ebcb
4
- data.tar.gz: 432f1bf0bc5c5eedc821023e5a9156c32e9428842629ad763bef407239eb4195
3
+ metadata.gz: 1e602a60fe22a20f37a92bd8394367a478aafd76322faada559a3a41fe146341
4
+ data.tar.gz: 01ae5f655caa7d8739522be9715caf07e9f2ac9622a68a5c56807d3d90c53c1b
5
5
  SHA512:
6
- metadata.gz: cdc0d555ddc0d23d2a526cb918234dd6380f226db163db773b2fd5ac310a698080ef0c245a178cae63aab89f567efd2245a2da67651f1d0975d9d3cab4169211
7
- data.tar.gz: 621ee6dae256c59292cfbd788af17a2051ee2d43b636fee44452e31cbff25818e4dd5a0f9a08303a8026da465635e7058b4e88c9305504ea595decdecc43e09c
6
+ metadata.gz: 18e37c9857ed8846e50a8132a82425eda92c8c81fcdfa61ef4109c8de3a2a9822e9020f9a13578ef43b10d3f1e876d5dde46d1c095c4d8603f9e302a01059c02
7
+ data.tar.gz: 36754d82837a6164d8511fe125fb9ec8e7b972ee5300559554e770ba3c1499b82f9b6698c6219c398f622d26d1ff95e29593e852cee270683428956bed6d2538
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'
@@ -537,7 +536,7 @@ Tramway uses [audited](https://github.com/collectiveidea/audited) to log actions
537
536
  #### 1. Add Audited::Audit model to available models
538
537
 
539
538
  *config/initializers/tramway.rb*
540
- ```
539
+ ```ruby
541
540
  Tramway::Admin.set_available_models(
542
541
  Audited::Audit,
543
542
  project: :your_project_name
@@ -546,7 +545,7 @@ Tramway::Admin.set_available_models(
546
545
 
547
546
  #### 2. Add this model to navbar
548
547
 
549
- ```
548
+ ```ruby
550
549
  Tramway::Admin.set_navbar_structure(
551
550
  Audited::Audit,
552
551
  project: :your_project_name
@@ -72,15 +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
- @exception = exception
80
- render 'tramway/admin/shared/errors/server_error', status: 500, layout: false
81
- end
82
- end
83
-
84
75
  include Tramway::ClassNameHelpers
85
76
 
86
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
@@ -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.0.1'
5
+ VERSION = '2.0.0.1'
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.0.1
4
+ version: 2.0.0.1
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-12-24 00:00:00.000000000 Z
11
+ date: 2021-02-04 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