tramway-admin 1.26.1.2 → 1.26.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +57 -2
- data/app/helpers/tramway/admin/cases_helper.rb +5 -1
- data/lib/tramway/admin/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 478a7c86513ae6f6ad86450d01de8dbf2a4d94a546139c9ec45c6b9c9fe38095
|
4
|
+
data.tar.gz: 44d0ac0409b9443cd633800f0daf9aa2693e892dcd9f460f8389c070ab152c25
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35e5136e3916c892f3ad5f31a84d92ad95fb7fb1df0b14aaf646cab6a439461f011f945c633e3ca26bc62d06fc48da4524f26dfabd3e9d4b229e5d24e93929e1
|
7
|
+
data.tar.gz: 63a20290bcbdf8fe72d511aa413f2b43a45e3f5b38579c0960b2a3e89ca8a912597dcc3077c0baf33dc6f1ac76bfb917b4ea3ea5bd07c3010745f0d359f87927
|
data/README.md
CHANGED
@@ -34,6 +34,8 @@ gem 'state_machine_buttons'
|
|
34
34
|
gem 'ckeditor', '4.2.4'
|
35
35
|
gem 'ransack'
|
36
36
|
gem 'smart_buttons'
|
37
|
+
gem 'carrierwave'
|
38
|
+
gem 'validates'
|
37
39
|
```
|
38
40
|
|
39
41
|
#### 2. You should remove gem `turbolinks` from your application and from app/assets/javascripts/application.js
|
@@ -79,6 +81,60 @@ $> Tramway::User::User.create! email: 'your@email.com', password: '123456789', r
|
|
79
81
|
::Tramway::Auth.root_path = '/admin' # you need it to redirect in the admin panel after admin signed_in
|
80
82
|
```
|
81
83
|
|
84
|
+
#### 8. Configurate navbar
|
85
|
+
|
86
|
+
*config/initializers/tramway.rb*
|
87
|
+
```ruby
|
88
|
+
Tramway::Admin.navbar_structure YourModel, AnotherYourModel
|
89
|
+
```
|
90
|
+
|
91
|
+
#### 9. Create decorator for models
|
92
|
+
|
93
|
+
*app/decorators/your_model_decorator.rb
|
94
|
+
```ruby
|
95
|
+
class YourModelDecorator < Tramway::Core::ApplicationDecorator
|
96
|
+
class << self
|
97
|
+
def collections
|
98
|
+
[ :all ]
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
delegate :title, to: :object
|
103
|
+
end
|
104
|
+
```
|
105
|
+
|
106
|
+
#### 10. Add inheritance to YourModel
|
107
|
+
|
108
|
+
*app/models/your_model.rb*
|
109
|
+
```ruby
|
110
|
+
class YourModel < Tramway::Core::ApplicationRecord
|
111
|
+
end
|
112
|
+
```
|
113
|
+
|
114
|
+
#### 11. Create `Admin::YourModelForm`
|
115
|
+
|
116
|
+
*app/forms/admin/your_model_form.rb
|
117
|
+
```ruby
|
118
|
+
class Admin::YourModelForm < Tramway::Core::ApplicationForm
|
119
|
+
properties :title, :description, :text, :date, :logo
|
120
|
+
|
121
|
+
def initialize(object)
|
122
|
+
super(object).tap do
|
123
|
+
form_properties title: :string,
|
124
|
+
logo: :file,
|
125
|
+
description: :ckeditor,
|
126
|
+
date: :date_picker,
|
127
|
+
text: :text
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
```
|
132
|
+
#### 12. Run server `rails s`
|
133
|
+
#### 13. Launch `localhost:3000/admin`
|
134
|
+
|
135
|
+
|
136
|
+
### CRUDs for models
|
137
|
+
|
82
138
|
By default users with role `admin` have access to all models used as arguments in method `::Tramway::Admin.set_available_models`. If you want specify models by roles, use them as keys
|
83
139
|
|
84
140
|
```ruby
|
@@ -111,8 +167,7 @@ You can set conditions for functions which are available for any role:
|
|
111
167
|
|
112
168
|
Here docs about changing roles of `Tramway::User::User` model [Readme](https://github.com/ulmic/tramway-dev/tree/develop/tramway#if-you-want-to-edit-roles-to-the-tramwayuseruser-class)
|
113
169
|
|
114
|
-
|
115
|
-
#### 9. Launch `localhost:3000/admin`
|
170
|
+
|
116
171
|
|
117
172
|
## Date Picker locale
|
118
173
|
|
@@ -7,7 +7,11 @@ module Tramway
|
|
7
7
|
if I18n.locale == :ru
|
8
8
|
russian_plural word
|
9
9
|
else
|
10
|
-
word.model_name
|
10
|
+
if word.respond_to?(:model_name)
|
11
|
+
word.model_name.human.pluralize(I18n.locale)
|
12
|
+
else
|
13
|
+
word.human.pluralize(I18n.locale)
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|