tramway-admin 3.0.1 → 4.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: 02b3fd52b732d4e15e693c4cc89aad5e2f631cdeadea0856eedcfdfefa0089c0
4
- data.tar.gz: fdd63869e0e5a63280fce0902e80d23f2f77430c7c1de04d040cb8dba3e38c17
3
+ metadata.gz: 4f49bf5b4e9e0ac337b90230037a618c730eb92fc0d11c2139a8452e4a44fc66
4
+ data.tar.gz: 1560fc7b9a504b76a78a3272f9feae6c672add55ce468255aee7593c4453f1dd
5
5
  SHA512:
6
- metadata.gz: ab4de60de6b8b1b52f515f234d58dc42d15ab56a6417dce6d25e21c3446d10b684faf34cab7a873d3c29470b5b77187723834e963a4d943b757839514dfdec00
7
- data.tar.gz: '086e0b2ab7575f43e07b4a1925faf826a4d9014cbc2eb61cec7c3c275154f5fb29608ca77136b1f051be9ecee30169c7f99f4f8f9d8ec5dbc3576e15a6d25128'
6
+ metadata.gz: 27ce4b592fed1ea8a20b2c164187947313a35f044bea80cffa324647fad7191518e97b37e2b1eb6e0d2e23eae3d2afec95bddcdfbb03789ca5d93fbe1a3092f8
7
+ data.tar.gz: 3d44b49c30c6fea3c44db3e934613e8341cc0198e0c18280c6990965eedd91befa1bd8589a7c34f10816f4afe281830484839ecf54d5dbf144c281b519c45cd9
data/README.md CHANGED
@@ -48,7 +48,6 @@ end
48
48
  #### 5. And then execute:
49
49
 
50
50
  ```bash
51
- $ bundle
52
51
  $ rails g tramway:user:install
53
52
  $ rails db:migrate
54
53
  ```
@@ -11,8 +11,9 @@
11
11
  .container
12
12
  padding-top: 2rem
13
13
 
14
- td.actions
15
- width: 8rem
14
+ td
15
+ &.actions
16
+ width: 8rem
16
17
 
17
18
  .icon-in-navbar
18
19
  font-size: 15pt
@@ -21,6 +21,16 @@ module Tramway::Admin::ActionsHelper
21
21
  )
22
22
  end
23
23
 
24
+ def create_is_available?(association_class)
25
+ ::Tramway::Admin.action_is_available?(
26
+ nil,
27
+ project: (@application_engine || @application.name),
28
+ model_name: association_class,
29
+ role: current_admin.role,
30
+ action: :create
31
+ )
32
+ end
33
+
24
34
  # delete_button is in smart-buttons gem
25
35
 
26
36
  def edit_button(url:, button_options:)
@@ -4,7 +4,7 @@
4
4
  %meta{ content: "width=device-width, initial-scale=1, maximum-scale=0.8", name: "viewport" }
5
5
  %title
6
6
  = yield :title
7
- = stylesheet_link_tag 'tramway/admin/application', media: "all"
7
+ = stylesheet_link_tag 'tramway/admin/application', media: :all
8
8
  = javascript_include_tag 'tramway/admin/application'
9
9
  - if File.exists?("#{Rails.root}/app/assets/javascripts/admin/application.js") || File.exists?("#{Rails.root}/app/assets/javascripts/admin/application.js.coffee")
10
10
  = javascript_include_tag 'admin/application'
@@ -3,34 +3,35 @@
3
3
  - if ::Tramway::Admin.customized_admin_navbar.present?
4
4
  = ::Tramway::Admin.customized_admin_navbar
5
5
  - else
6
- = link_to @application&.try(:title) || @application&.public_name || t('aplication.title'), ::Tramway::Admin::Engine.routes.url_helpers.root_path, class: 'navbar-brand'
7
- %button.navbar-toggler.collapsed{ aria: { controls: :navbar, expanded: "false", label: 'Toggle Navigation' }, data: { target: "#navbar", toggle: :collapse }, type: :button }
8
- %span.navbar-toggler-icon
9
- .navbar-collapse.collapse#navbar
10
- - if current_admin
11
- %ul.navbar-nav
12
- - ::Tramway::Admin.navbar_items_for(@application_engine || @application.name, role: current_admin.role)&.each do |item|
13
- - case item.keys.first
14
- - when Class, String
15
- - model = item.keys.first.is_a?(String) ? item.keys.first.constantize : item.keys.first
16
- - case item.values.first
17
- - when :singleton
18
- = model_menu_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.singleton_path(model: model)
19
- - when :record
20
- = model_menu_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.records_path(model: model, scope: decorator_class(model).collections.first), pluralize: plural(model.model_name).capitalize
21
- - when Symbol, String
22
- = dropdown t("admin.navbar.links.#{item.keys.first}") do
23
- - item.values.first.each do |sub_item|
24
- - if sub_item == :divider
25
- = dropdown_divider
26
- - else
27
- - model = sub_item.keys.first
28
- - if sub_item.values.first == :singleton
29
- = dropdown_model_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.singleton_path(model: model)
30
- - if sub_item.values.first == :record
31
- = dropdown_model_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.records_path(model: model, scope: decorator_class(model).collections.first), pluralize: plural(model.constantize.model_name).capitalize
6
+ .container-fluid
7
+ = link_to @application&.try(:title) || @application&.public_name || t('aplication.title'), ::Tramway::Admin::Engine.routes.url_helpers.root_path, class: 'navbar-brand'
8
+ %button.navbar-toggler.collapsed{ aria: { controls: :navbar, expanded: "false", label: 'Toggle Navigation' }, data: { target: "#navbar", toggle: :collapse }, type: :button }
9
+ %span.navbar-toggler-icon
10
+ .navbar-collapse.collapse#navbar
11
+ - if current_admin
12
+ %ul.navbar-nav
13
+ - ::Tramway::Admin.navbar_items_for(@application_engine || @application.name, role: current_admin.role)&.each do |item|
14
+ - case item.keys.first
15
+ - when Class, String
16
+ - model = item.keys.first.is_a?(String) ? item.keys.first.constantize : item.keys.first
17
+ - case item.values.first
18
+ - when :singleton
19
+ = model_menu_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.singleton_path(model: model)
20
+ - when :record
21
+ = model_menu_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.records_path(model: model, scope: decorator_class(model).collections.first), pluralize: plural(model.model_name).capitalize
22
+ - when Symbol, String
23
+ = dropdown t("admin.navbar.links.#{item.keys.first}") do
24
+ - item.values.first.each do |sub_item|
25
+ - if sub_item == :divider
26
+ = dropdown_divider
27
+ - else
28
+ - model = sub_item.keys.first
29
+ - if sub_item.values.first == :singleton
30
+ = dropdown_model_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.singleton_path(model: model)
31
+ - if sub_item.values.first == :record
32
+ = dropdown_model_item model: model, route: ::Tramway::Admin::Engine.routes.url_helpers.records_path(model: model, scope: decorator_class(model).collections.first), pluralize: plural(model.constantize.model_name).capitalize
32
33
 
33
- %ul.nav.navbar-nav.ml-auto
34
+ %ul.nav.navbar-nav.ml-auto.justify-content-end
34
35
  - if current_admin
35
36
  %li.nav-item
36
37
  %span.nav-link
@@ -12,7 +12,7 @@
12
12
  - @record_form.properties.each do |property, type|
13
13
  = render 'tramway/core/shared/input', property: property, object: :record, type: type, form: f, destination: :admin, value: value_from_params(model_class: model_class, property: property, type: type)
14
14
  = hidden_field_tag :redirect, params[:redirect]
15
- = f.button :submit, t('helpers.links.save'), class: 'btn-success'
15
+ = f.button :submit, t('helpers.links.save'), class: 'btn btn-success'
16
16
  = link_to t('helpers.links.back'), current_model_records_path, class: 'btn btn-secondary'
17
17
 
18
18
  -# NOTES
@@ -1,29 +1,30 @@
1
1
  = paginate @records, theme: 'twitter-bootstrap-4'
2
- %table.table.table-striped.table-bordered
2
+ %table.table.table-striped.table-hover
3
3
  %thead
4
4
  %tr
5
- %th= model_class.human_attribute_name(:id)
6
- %th= model_class.human_attribute_name(:name)
5
+ %th{ scope: :col }
6
+ = model_class.human_attribute_name(:id)
7
+ %th{ scope: :col }
8
+ = model_class.human_attribute_name(:name)
7
9
  - decorator_class.list_attributes.each do |attribute|
8
- %th= model_class.human_attribute_name attribute
9
- %th= t 'helpers.links.actions'
10
+ %th{ scope: :col }
11
+ = model_class.human_attribute_name attribute
12
+ %th{ scope: :col }
13
+ = t 'helpers.links.actions'
10
14
  %tbody
11
15
  - @records.each_with_index do |record, index|
12
16
  %tr
13
- %td
17
+ %th{ scope: :row }
14
18
  = link_to record.id, current_model_record_path(record.id)
15
- %td
19
+ %td.link{ data: { href: current_model_record_path(record.id) } }
16
20
  = link_to record.name, current_model_record_path(record.id)
17
21
  - decorator_class.list_attributes.each do |attribute|
18
22
  %td
19
23
  = record.send attribute
20
24
  %td.actions
21
- .row
22
-    
23
- = link_to fa_icon('pencil-alt'), edit_current_model_record_path(record.id, redirect: current_model_records_path(record.id)), class: 'btn btn-warning btn-xs'
24
-   
25
- = delete_button url: current_model_record_path(record.id), form_options: { class: :smart_button }, button_options: { class: 'btn btn-xs btn-danger' } do
26
- = fa_icon 'trash-alt'
25
+ = link_to fa_icon('pencil-alt'), edit_current_model_record_path(record.id, redirect: current_model_records_path(record.id)), class: 'btn btn-warning btn-xs'
26
+ = delete_button url: current_model_record_path(record.id), form_options: { class: :smart_button }, button_options: { class: 'btn btn-xs btn-danger' } do
27
+ = fa_icon 'trash-alt'
27
28
  - if tramway_model?(model_class)
28
29
  %br
29
30
  %br
@@ -7,7 +7,7 @@
7
7
  %td
8
8
  = model_class.human_attribute_name association.name
9
9
  %hr
10
- - if association_type != :has_one || !object.send(association.name).present?
10
+ - if create_is_available?(association.name) && (association_type != :has_one || !object.send(association.name).present?)
11
11
  = link_to "#{I18n.t('helpers.actions.add')} #{model_class.human_attribute_name(association.name).singularize.downcase}", new_associated_record_path(association: association, object: object, as: object.send("#{association.name}_as")), class: 'btn btn-primary'
12
12
  %td{ colspan: 2 }
13
13
  - if association_type.in? [ :has_one, :belongs_to ]
@@ -4,13 +4,14 @@
4
4
  = association_object.id
5
5
  %td
6
6
  = link_to association_object.name, record_path(association_object.id, model: association.options[:class_name])
7
- %td
8
- - association_object.model.class.state_machines_names.each do |state_method|
9
- - unless state_method == 'default'
10
- = state_events_buttons association_object, state_method: state_method, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { redirect: current_model_record_path(object.id), model: association_object.class.model_name }, button_options: { class: :smart_button }
11
- %td
7
+ - if association_object.model.class.state_machines_names.count > 1
8
+ %td
9
+ - association_object.model.class.state_machines_names.each do |state_method|
10
+ - unless state_method == 'default'
11
+ = state_events_buttons association_object, state_method: state_method, model_param_name: :record, controller: 'tramway/admin/records', action: :update, parameters: { redirect: current_model_record_path(object.id), model: association_object.class.model_name }, button_options: { class: :smart_button }
12
+ %td{ style: 'display: flex; justify-content: space-evenly' }
12
13
  - if update_is_available? association_object, object
13
- = edit_button url: edit_record_path(association_object.id, model: association.options[:class_name], redirect: current_model_record_path(object.id)), button_options: { class: 'btn btn-xs btn-warning edit' } do
14
+ = edit_button url: edit_record_path(association_object.id, model: association.options[:class_name], redirect: current_model_record_path(object.id)), button_options: { class: 'btn btn-xs btn-warning edit', style: 'height: max-content' } do
14
15
  = fa_icon 'pencil-alt'
15
16
  - if destroy_is_available? association_object, object
16
17
  = delete_button url: record_path(association_object.id, model: association.options[:class_name], redirect: current_model_record_path(object.id)), button_options: { class: 'btn btn-xs btn-danger delete' } do
@@ -11,5 +11,5 @@
11
11
  = simple_form_for @singleton_form.model, url: { controller: :singletons, action: action, model: @singleton_form.model.class }, input_html: { class: 'form-horizontal' } do |f|
12
12
  - @singleton_form.properties.each do |property, type|
13
13
  = render 'tramway/core/shared/input', property: property, object: :singleton, type: type, form: f, destination: :admin, value: value_from_params(model_class: model_class, property: property, type: type)
14
- = f.button :submit, t('helpers.links.save'), class: 'btn-success'
14
+ = f.button :submit, t('helpers.links.save'), class: 'btn btn-success'
15
15
  = link_to t('helpers.links.back'), singleton_path, class: 'btn btn-secondary'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '3.0.1'
5
+ VERSION = '4.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: 3.0.1
4
+ version: 4.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: 2022-01-13 00:00:00.000000000 Z
11
+ date: 2022-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tramway-core
@@ -180,16 +180,16 @@ dependencies:
180
180
  name: trap
181
181
  requirement: !ruby/object:Gem::Requirement
182
182
  requirements:
183
- - - '='
183
+ - - "~>"
184
184
  - !ruby/object:Gem::Version
185
- version: '3.0'
185
+ version: '4.0'
186
186
  type: :runtime
187
187
  prerelease: false
188
188
  version_requirements: !ruby/object:Gem::Requirement
189
189
  requirements:
190
- - - '='
190
+ - - "~>"
191
191
  - !ruby/object:Gem::Version
192
- version: '3.0'
192
+ version: '4.0'
193
193
  - !ruby/object:Gem::Dependency
194
194
  name: aasm
195
195
  requirement: !ruby/object:Gem::Requirement