tramway-admin 1.26.1.2 → 1.26.1.3

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e74929c977533c46f0275270e00650c217553b733cc05f1fc42efb032a78e58
4
- data.tar.gz: 1585d1a11659364ac3754bd30ac54fc98b81b1ac97dbf196c22a56e51337b1b6
3
+ metadata.gz: 478a7c86513ae6f6ad86450d01de8dbf2a4d94a546139c9ec45c6b9c9fe38095
4
+ data.tar.gz: 44d0ac0409b9443cd633800f0daf9aa2693e892dcd9f460f8389c070ab152c25
5
5
  SHA512:
6
- metadata.gz: a3ae80b23d1c8876b1ad29633a3dc850e5b9acd4382895bbb760356ae99fea480fcd9205bd863423f21fd1d95540f3e61d47468113d6bd5ff58e0ee714300dbf
7
- data.tar.gz: 1e2c46b96d3694ebcd5a667052929c2941cc2e1a409301fb637671406127f4299bbd3558d8d484afa82836a4ede2edab7181edf26f249b81ea040d64aad9be30
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
- #### 8. Run server `rails s`
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.human.pluralize(I18n.locale)
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.26.1.2'
5
+ VERSION = '1.26.1.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-admin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.26.1.2
4
+ version: 1.26.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov