tramway-admin 1.33.1.1 → 2.0.0.3

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: 8fb4fb3d9ec6d2f5bb4f56e65806cb737bf0898ee1186e2ada89498b4ce6fcdc
4
- data.tar.gz: bd03f075aed1aa8fdd5b20af8c2c6e97be419f23a88369fcb0276c48a5e896b7
3
+ metadata.gz: 06da6f5c18c17f0be24539b30236b26b5f2e3c6c0056f284573dfd6bccfb20ba
4
+ data.tar.gz: 552df82bb3a6e29c6e7dc8cdc0bac707fe4223edbb4c9a7ab8cc0c3b2a8c51f1
5
5
  SHA512:
6
- metadata.gz: '0936fb8b540e95c62e6c9e981a4c674b6a18f3e9732ccb82797df43c2b2090775fcbb8bd884cb7d5249ba8705e58b36ab69425beba5a2cdab809bc4a0391c39d'
7
- data.tar.gz: 9c583df3d9be61ee6db2abe021ed717b422a0f8c93afd4a2764ca68931e8c9f454a5b2d8a9033e1dfdb51fd490ae0525d6ef00927593d9dea23e219e96e111f6
6
+ metadata.gz: aa6a08b7aa985dab46a7fbd2282c870edd6eabb66205ccd57bbea979e9482f298eee10091448a0e9211168cd57b4832210015b60e626028e3b8e511326e9cffd
7
+ data.tar.gz: 96c116c1996b4597ee1858c46b8230565adbc060561900470c4ccbf440080c27c8803b536966230b361f7c831c01374f0891ca069ef095c7a1d5b8951d98123b
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
@@ -5,4 +5,9 @@
5
5
  //= require bootstrap-sprockets
6
6
  //= require ckeditor/init
7
7
  //= require selectize
8
+ //= require clipboard
8
9
  //= require_tree .
10
+
11
+ $(document).ready(function() {
12
+ let clipboard = new Clipboard('.clipboard-btn');
13
+ })
@@ -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.1'
5
+ VERSION = '2.0.0.3'
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.1
4
+ version: 2.0.0.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-01-25 00:00:00.000000000 Z
11
+ date: 2021-02-25 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
@@ -322,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
322
336
  - !ruby/object:Gem::Version
323
337
  version: '0'
324
338
  requirements: []
325
- rubygems_version: 3.1.2
339
+ rubygems_version: 3.1.4
326
340
  signing_key:
327
341
  specification_version: 4
328
342
  summary: Engine for admin