tramway-admin 2.1.3.3 → 4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +22 -2
- data/app/assets/stylesheets/tramway/admin/application.sass +3 -2
- data/app/controllers/tramway/admin/application_controller.rb +1 -1
- data/app/controllers/tramway/admin/records_controller.rb +6 -6
- data/app/controllers/tramway/admin/sessions_controller.rb +1 -1
- data/app/controllers/tramway/admin/singletons_controller.rb +4 -4
- data/app/views/layouts/tramway/admin/shared/_navbar.html.haml +28 -27
- data/app/views/tramway/admin/records/_form.html.haml +1 -1
- data/app/views/tramway/admin/records/_list.html.haml +14 -13
- data/app/views/tramway/admin/shared/show/associations/_table_row.html.haml +7 -6
- data/app/views/tramway/admin/singletons/_form.html.haml +1 -1
- data/lib/tramway/admin/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0da53840f67044b77ccf8d8c37b2dd02d23fde702aa09550182062056032fc5f
|
4
|
+
data.tar.gz: 50ae25d697d79b09e8aeb59b19d35a6be14b3b904dfaf0a47562cf5bc3e28401
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7f23e28049699b42619820d7c643dcaff51983aa3430da9b5b77d8424e484531fd19f09ba4b07e540ed416c0d3eeb0a12b8551c001fc437634110e0247b0432
|
7
|
+
data.tar.gz: af55df2f1614906fd42ca0313e1acf463b08aa78dcb71f4ca1cca50aafe0de8f0f1af20995ea91910b3016d9e062bbdc06bc4dffa8e7f2d09062784a5e360f43
|
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
|
```
|
@@ -192,6 +191,9 @@ en:
|
|
192
191
|
class Admin::YourModelForm < Tramway::Core::ApplicationForm
|
193
192
|
properties :title, :description, :text, :date, :logo
|
194
193
|
|
194
|
+
association :associated
|
195
|
+
association :another_polymorphic_associated
|
196
|
+
|
195
197
|
def initialize(object)
|
196
198
|
super(object).tap do
|
197
199
|
form_properties title: :string,
|
@@ -199,6 +201,8 @@ class Admin::YourModelForm < Tramway::Core::ApplicationForm
|
|
199
201
|
description: :ckeditor,
|
200
202
|
date: :date_picker,
|
201
203
|
text: :text,
|
204
|
+
associated: :association,
|
205
|
+
another_polymorphic_association: :polymorphic_association,
|
202
206
|
birth_date: {
|
203
207
|
type: :default,
|
204
208
|
input_options: {
|
@@ -210,6 +214,22 @@ class Admin::YourModelForm < Tramway::Core::ApplicationForm
|
|
210
214
|
end
|
211
215
|
```
|
212
216
|
|
217
|
+
**NOTE**
|
218
|
+
If you want fill inputs of this form, just send query params
|
219
|
+
|
220
|
+
```
|
221
|
+
params = {
|
222
|
+
your_model: {
|
223
|
+
logo: '/file/url',
|
224
|
+
description: 'some text',
|
225
|
+
text: 'some another text',
|
226
|
+
associated_id: 5,
|
227
|
+
another_polymorphic_associated: 56,
|
228
|
+
another_polymorphic_associated_type: 'AnotherModel'
|
229
|
+
}
|
230
|
+
}
|
231
|
+
```
|
232
|
+
|
213
233
|
#### 10. Add inheritance to YourModel
|
214
234
|
|
215
235
|
*app/models/your_model.rb*
|
@@ -465,7 +485,7 @@ To add notification to application, you need just set queries in initializers.
|
|
465
485
|
# Example from tramway-event gem (you also can push context variables here)
|
466
486
|
|
467
487
|
::Tramway::Admin.set_notificable_queries new_participants: -> (current_user) do
|
468
|
-
::Tramway::Event::Participant.
|
488
|
+
::Tramway::Event::Participant.where(participation_state: :requested).send "#{current_user}_scope", current_user.id
|
469
489
|
end
|
470
490
|
```
|
471
491
|
|
@@ -30,7 +30,7 @@ module Tramway
|
|
30
30
|
|
31
31
|
def collections_counts
|
32
32
|
@counts = decorator_class.collections.reduce({}) do |hash, collection|
|
33
|
-
records = model_class.
|
33
|
+
records = model_class.send(collection)
|
34
34
|
records = records.send "#{current_admin.role}_scope", current_admin.id
|
35
35
|
records = records.ransack(params[:filter]).result if params[:filter].present?
|
36
36
|
params[:list_filters]&.each do |filter, value|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationController
|
4
4
|
def index
|
5
5
|
scope = params[:scope].present? ? params[:scope] : :all
|
6
|
-
records = model_class.
|
6
|
+
records = model_class.order(id: :desc).send scope
|
7
7
|
records = records.full_text_search params[:search] if params[:search].present?
|
8
8
|
if params[:filter].present?
|
9
9
|
if params[:filter].is_a? String
|
@@ -30,7 +30,7 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def show
|
33
|
-
@record = decorator_class.decorate model_class.
|
33
|
+
@record = decorator_class.decorate model_class.find params[:id]
|
34
34
|
end
|
35
35
|
|
36
36
|
def new
|
@@ -47,11 +47,11 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def edit
|
50
|
-
@record_form = admin_form_class.new model_class.
|
50
|
+
@record_form = admin_form_class.new model_class.find params[:id]
|
51
51
|
end
|
52
52
|
|
53
53
|
def update
|
54
|
-
@record_form = admin_form_class.new model_class.
|
54
|
+
@record_form = admin_form_class.new model_class.find params[:id]
|
55
55
|
if params[:record][:aasm_event].present?
|
56
56
|
if @record_form.model.send("may_#{params[:record][:aasm_event]}?")
|
57
57
|
@record_form.model.send("#{params[:record][:aasm_event]}!")
|
@@ -67,8 +67,8 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
|
|
67
67
|
end
|
68
68
|
|
69
69
|
def destroy
|
70
|
-
record = model_class.
|
71
|
-
record.
|
70
|
+
record = model_class.find params[:id]
|
71
|
+
record.destroy
|
72
72
|
redirect_to params[:redirect].present? ? params[:redirect] : records_path
|
73
73
|
end
|
74
74
|
end
|
@@ -10,7 +10,7 @@ class Tramway::Admin::SessionsController < ::Tramway::Admin::ApplicationControll
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def create
|
13
|
-
@session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.
|
13
|
+
@session_form = ::Tramway::Auth::SessionForm.new ::Tramway::User::User.find_or_initialize_by email: params[:user][:email]
|
14
14
|
if @session_form.validate params[:user]
|
15
15
|
admin_sign_in @session_form.model
|
16
16
|
redirect_to Tramway::Admin::Engine.routes.url_helpers.root_path
|
@@ -3,8 +3,8 @@
|
|
3
3
|
module Tramway::Admin
|
4
4
|
class SingletonsController < ApplicationController
|
5
5
|
def show
|
6
|
-
if model_class.
|
7
|
-
@singleton = decorator_class.decorate model_class.
|
6
|
+
if model_class.first.present?
|
7
|
+
@singleton = decorator_class.decorate model_class.first
|
8
8
|
else
|
9
9
|
@singleton_form = admin_form_class.new model_class.new
|
10
10
|
render :new
|
@@ -13,7 +13,7 @@ module Tramway::Admin
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def edit
|
16
|
-
@singleton_form = admin_form_class.new model_class.
|
16
|
+
@singleton_form = admin_form_class.new model_class.first
|
17
17
|
end
|
18
18
|
|
19
19
|
def create
|
@@ -26,7 +26,7 @@ module Tramway::Admin
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def update
|
29
|
-
@singleton_form = admin_form_class.new model_class.
|
29
|
+
@singleton_form = admin_form_class.new model_class.first
|
30
30
|
if @singleton_form.submit params[:singleton]
|
31
31
|
redirect_to params[:redirect] || singleton_path(model: params[:model])
|
32
32
|
else
|
@@ -3,34 +3,35 @@
|
|
3
3
|
- if ::Tramway::Admin.customized_admin_navbar.present?
|
4
4
|
= ::Tramway::Admin.customized_admin_navbar
|
5
5
|
- else
|
6
|
-
|
7
|
-
|
8
|
-
%
|
9
|
-
|
10
|
-
-
|
11
|
-
|
12
|
-
-
|
13
|
-
-
|
14
|
-
|
15
|
-
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
-
|
25
|
-
|
26
|
-
|
27
|
-
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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-
|
2
|
+
%table.table.table-striped.table-hover
|
3
3
|
%thead
|
4
4
|
%tr
|
5
|
-
%th
|
6
|
-
|
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
|
9
|
-
|
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
|
-
%
|
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
|
-
.
|
22
|
-
|
23
|
-
=
|
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
|
@@ -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
|
-
|
8
|
-
|
9
|
-
-
|
10
|
-
|
11
|
-
|
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'
|
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:
|
4
|
+
version: '4.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:
|
11
|
+
date: 2022-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: tramway-core
|
@@ -70,20 +70,20 @@ dependencies:
|
|
70
70
|
name: copyright_mafa
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: 0.1.2
|
76
|
-
- - "
|
76
|
+
- - "~>"
|
77
77
|
- !ruby/object:Gem::Version
|
78
78
|
version: 0.1.2
|
79
79
|
type: :runtime
|
80
80
|
prerelease: false
|
81
81
|
version_requirements: !ruby/object:Gem::Requirement
|
82
82
|
requirements:
|
83
|
-
- - "
|
83
|
+
- - ">="
|
84
84
|
- !ruby/object:Gem::Version
|
85
85
|
version: 0.1.2
|
86
|
-
- - "
|
86
|
+
- - "~>"
|
87
87
|
- !ruby/object:Gem::Version
|
88
88
|
version: 0.1.2
|
89
89
|
- !ruby/object:Gem::Dependency
|
@@ -330,7 +330,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
330
330
|
- !ruby/object:Gem::Version
|
331
331
|
version: '0'
|
332
332
|
requirements: []
|
333
|
-
rubygems_version: 3.1
|
333
|
+
rubygems_version: 3.0.3.1
|
334
334
|
signing_key:
|
335
335
|
specification_version: 4
|
336
336
|
summary: Engine for admin
|