tramway-admin 1.33.1.2 → 2.0

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: 4ff2e7ee2cba522a3d021f94ecfbe9da4cf66abc29daf4b2fab2e9d4bf47b0de
4
- data.tar.gz: 89457c61c7d88cab5a9a49f38f6bfb6e83c2b43f520425961b164cde14996b25
3
+ metadata.gz: 5390a8ac2ff22518ce7381eda5eec47f0ede410e0cdcbcbf2ad4577a2e6d7869
4
+ data.tar.gz: 1599e0b6a50ef1f67df55a47d22ce29dc7438bf35d19f127d373d3594de9248a
5
5
  SHA512:
6
- metadata.gz: 329435596809bfae8589f002c23d7372f1ae5a67eb3be42e892272bf64ccbd217466ce55aa1cf50c0cd086157ba329bb7987f9171eb2507aa9a8ef2174029dc9
7
- data.tar.gz: '084403024d287e9c02a93f5bcbcb382ba9ad57932cd0fa0d2d90ec5e6d8bd30685f2e82a03b934e04bd3fddfa0d242d2c02ced387349425e4db4c469925d6063'
6
+ metadata.gz: 296ebeca8c4c69f989c4240e3348f2ec47c77f29d8a2066eb9ce233479e78241f29da09619de0d228332d3cef79f299bc9229008bfa841ca7629d0d782b43cc7
7
+ data.tar.gz: 8fe4ca13d159e6953157ed082caf92a5b5aede82aca7ac609cc00a24be067d3e580c9b1c3625b5736414504bb3a53bd4667cd7704a880c11750155e501366306
data/README.md CHANGED
@@ -10,7 +10,6 @@ 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
14
  gem 'state_machine', github: 'seuros/state_machine'
16
15
  gem 'bcrypt'
@@ -52,16 +52,22 @@ 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
+ end
57
59
  else
58
- render :edit
60
+ if @record_form.submit params[:record]
61
+ redirect_to params[:redirect].present? ? params[:redirect] : record_path(@record_form.model)
62
+ else
63
+ render :edit
64
+ end
59
65
  end
60
66
  end
61
67
 
62
68
  def destroy
63
69
  record = model_class.active.find params[:id]
64
- record.remove
70
+ record.remove!
65
71
  redirect_to params[:redirect].present? ? params[:redirect] : records_path
66
72
  end
67
73
  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'
@@ -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.2'
5
+ VERSION = '2.0'
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.2
4
+ version: '2.0'
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-02-02 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