tramway-admin 1.29.1.4 → 1.29.1.5

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: b59a73d88e6909a7e355dd778bae9f36e5fd6f28b981f548aea85ab07c4ecedd
4
- data.tar.gz: 1f0bfa52f18e76ae53b3859fa820e617073f7efcb4821ae429211809ebbef80d
3
+ metadata.gz: 684985c2ee2576e0240cdf2a35308044f98cbac2cf03d68ac45f6c986b7042ea
4
+ data.tar.gz: 3c009c10ec87984dea44de3193f37d2bb494f7ffa26e1ecb29e7f0e7fe50cad7
5
5
  SHA512:
6
- metadata.gz: c003742f10c1c1fce366e32b444f60137f64b7fbc823da6d5b7e4887c012345b834ee9355eeccd7ef3f8d79548526b0d7188f3b013bd90437550d6472a3f9948
7
- data.tar.gz: a7fd90211fb9c081484e1032d1af32fc3aa018d38f1f2122b3097d8105d210c96a9c27935fcbbb41d992afa363df0cd4c571a621f1401cc078b59161d8f26c96
6
+ metadata.gz: 6cc5247ac2bd3006c58aaf0e3eba492d96a2b95478fe199fe2561e62e25aba4b2aa3fd87a05afd06f93707da3a83616675e6f3f7d2f543a75bf5228335781110
7
+ data.tar.gz: f521d26062127bde2bb94fe5be738bac88d098cc79fd18b826f29080916e3b9c2baf05c7bcb30a3499e01d5f464fa763a3065bd0d99bd9d8e5137900e9f1eaa6
data/README.md CHANGED
@@ -85,7 +85,16 @@ $> Tramway::User::User.create! email: 'your@email.com', password: '123456789', r
85
85
 
86
86
  *config/initializers/tramway.rb*
87
87
  ```ruby
88
- Tramway::Admin.navbar_structure YourModel, AnotherYourModel
88
+ Tramway::Admin.navbar_structure(
89
+ YourModel, # this line will create first-level link in your navbar, which will send you to the YourModel management
90
+ {
91
+ my_dropdown: [ # this line contains dropdown link name
92
+ AnotherYourModel # this line will create 2nd-level link in your navbar, which will send you to the YourModel management,
93
+ :divider # this line adds bootstrap divider to the dropdown list
94
+ ]
95
+ },
96
+ project: :your_application_name
97
+ )
89
98
  ```
90
99
 
91
100
  #### 9. Create decorator for models
@@ -167,7 +176,79 @@ You can set conditions for functions which are available for any role:
167
176
 
168
177
  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)
169
178
 
179
+ ## Associations management
180
+
181
+ ### has_and_belongs_to_many
182
+
183
+ We have models Game and Packs.
184
+
185
+ *app/models/game.rb*
186
+ ```ruby
187
+ class Game < Tramway::Core::ApplicationRecord
188
+ has_and_belongs_to_many :packs
189
+ end
190
+ ```
191
+
192
+ *app/models/pack.rb*
193
+ ```ruby
194
+ class Pack < Tramway::Core::ApplicationRecord
195
+ has_and_belongs_to_many :games
196
+ end
197
+ ```
198
+
199
+ **You want to manage games in the Pack show admin page**
200
+
201
+ #### 1. Add association to PackDecorator
202
+
203
+ *app/decorators/pack_decorator.rb*
204
+ ```ruby
205
+ class PackDecorator < Tramway::Core::ApplicationDecorator
206
+ decorate_association :games
207
+ end
208
+ ```
170
209
 
210
+ #### 2. Create `Admin::Packs::AddGameForm` and `Admin::Packs::RemoveGameForm`
211
+
212
+ *app/forms/admin/packs/add_game_form.rb*
213
+ ```ruby
214
+ class Admin::Packs::AddGameForm < Tramway::Core::ApplicationForm
215
+ properties :game_ids
216
+ association :games
217
+
218
+ def initialize(object)
219
+ super(object).tap do
220
+ form_properties games: :association
221
+ end
222
+ end
223
+
224
+ def submit(params)
225
+ params[:game_ids].each do |id|
226
+ model.games << Game.find(id) if id.present?
227
+ end
228
+ model.save!
229
+ end
230
+ end
231
+ ```
232
+
233
+ *app/forms/admin/packs/remove_game_form.rb*
234
+ ```ruby
235
+ class Admin::Packs::RemoveGameForm < Tramway::Core::ApplicationForm
236
+ properties :id
237
+
238
+ def submit(params)
239
+ model.games -= [Game.find(params)] if id.present?
240
+ model.save!
241
+ end
242
+ end
243
+
244
+ ```
245
+
246
+ #### 3. Add this forms to initializer
247
+
248
+ *config/initializers/tramway/admin/forms.rb*
249
+ ```ruby
250
+ Tramway::Admin.forms = 'packs/add_game', 'packs/remove_game'
251
+ ```
171
252
 
172
253
  ## Date Picker locale
173
254
 
@@ -216,6 +297,7 @@ Start page of admin panel contains only `application.name` by default. To manage
216
297
 
217
298
  Example:
218
299
 
300
+ *config/initializers/tramway/admin.rb*
219
301
  ```ruby
220
302
  ::Tramway::Admin.welcome_page_actions = lambda do
221
303
  @content = '<a href="http://it-way.pro">IT Way</a>'
@@ -237,7 +319,8 @@ Tramway::Admin.navbar_structure(
237
319
  AnotherYourModel # this line will create 2nd-level link in your navbar, which will send you to the YourModel management,
238
320
  :divider # this line adds bootstrap divider to the dropdown list
239
321
  ]
240
- }
322
+ },
323
+ project: :your_application_name
241
324
  )
242
325
  ```
243
326
 
@@ -26,3 +26,8 @@ td.actions
26
26
  .smart_button
27
27
  float: right
28
28
  margin-bottom: 0
29
+
30
+ .scrollable
31
+ height: auto
32
+ max-height: 30em
33
+ overflow-x: hidden
@@ -23,7 +23,7 @@ module Tramway::Admin::ActionsHelper
23
23
 
24
24
  # delete_button is in smart-buttons gem
25
25
 
26
- def edit_button(url:, button_options:, &block)
26
+ def edit_button(url:, button_options:)
27
27
  link_to(url, **button_options) { yield }
28
28
  end
29
29
 
@@ -38,7 +38,7 @@
38
38
  = link_to '#', class: 'nav-link icon-in-navbar dropdown-toggle', id: :notifications_dropdown, role: :button, aria: { haspopup: true, expanded: false }, data: { toggle: :dropdown } do
39
39
  %span.badge.badge-light
40
40
  = @notifications_count
41
- .dropdown-menu.dropdown-menu-right{ aria: { labelledby: :notifications_dropdown } }
41
+ .dropdown-menu.dropdown-menu-right.scrollable{ aria: { labelledby: :notifications_dropdown } }
42
42
  - @notifications.each_with_index do |collection, index|
43
43
  - collection[1].each do |item|
44
44
  = link_to decorator_class(item.class).decorate(item).title, record_path(item, model: item.class), class: 'dropdown-item'
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '1.29.1.4'
5
+ VERSION = '1.29.1.5'
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.29.1.4
4
+ version: 1.29.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-14 00:00:00.000000000 Z
11
+ date: 2020-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-kaminari-views