tramway-admin 1.2 → 1.2.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: f958353c638d04e501d274aaf555084edd43630474d63d5a7682f7a6b8565da7
4
- data.tar.gz: 270474b2cbe1394790cbc4a6346737186c204dd03d750025adb2158946c418d0
3
+ metadata.gz: 82b79fa9390f6866be725ce3cdc095b6158456571462b860be1de9b7115cda00
4
+ data.tar.gz: 8cc8e23372e075cff26512f3193eeb5c715b85135a871860038d4d4b55b9cb4b
5
5
  SHA512:
6
- metadata.gz: 4ca5455bd4191f663f6186e007d93f53f8fd9c2eb68289a8d409756bc75c2ad6bbee1f56781d9df2789585a94d53d56a2f5aca164546990a4deb01c2aeb396d2
7
- data.tar.gz: b0a7c65aed9447ebe1171445b832946bdca147d3721f7f098f44cbc221502dc66ef82e925b7f198dc55a980c509792a3a0532c69b69ba6347756d1457d8b4edd
6
+ metadata.gz: 8604bf514e0c54656ad2039112710aa15627ba7b316d10b7261c6ebf6a3a79af406152d37d02ce8d5649fa9fdb7e3af24c121acaec77ff9d1e52f56909fcf827
7
+ data.tar.gz: d22e39c639b3371864436a09e7fe7965cc4bb598793378c6c864024a18ec8ab38507c61df318385c93dc2b8032c2c78ae4a39ed9da59a33d84d9bff9cb593a49
@@ -1,13 +1,28 @@
1
1
  module Tramway::Admin
2
2
  class SingletonsController < ApplicationController
3
3
  def show
4
- @singleton = decorator_class.decorate model_class.active.first
4
+ if model_class.active.first.present?
5
+ @singleton = decorator_class.decorate model_class.active.first
6
+ else
7
+ @singleton_form = form_class.new model_class.new
8
+ render :new
9
+ return
10
+ end
5
11
  end
6
12
 
7
13
  def edit
8
14
  @singleton_form = form_class.new model_class.active.first
9
15
  end
10
16
 
17
+ def create
18
+ @singleton_form = form_class.new model_class.new
19
+ if @singleton_form.submit params[:singleton]
20
+ redirect_to params[:redirect] || singleton_path(model: params[:model])
21
+ else
22
+ render :edit
23
+ end
24
+ end
25
+
11
26
  def update
12
27
  @singleton_form = form_class.new model_class.active.first
13
28
  if @singleton_form.submit params[:singleton]
@@ -1,18 +1,20 @@
1
1
  module Tramway::Admin::AdditionalButtonsBuilder
2
2
  def build_buttons(additional_buttons)
3
- additional_buttons = additional_buttons.is_a?(Hash) ? [ additional_buttons ] : additional_buttons
4
- additional_buttons.each do |button|
5
- concat(
6
- link_to(
7
- send(
8
- "#{button[:action]}_record_path",
9
- build_params(button[:params]).merge(model: button[:model_name])
10
- ),
11
- class: "btn btn-#{button_color(button[:action])} btn-xs"
12
- ) do
13
- button[:text] || button_icon(button[:action])
14
- end
15
- )
3
+ if additional_buttons
4
+ additional_buttons = additional_buttons.is_a?(Hash) ? [ additional_buttons ] : additional_buttons
5
+ additional_buttons.each do |button|
6
+ concat(
7
+ link_to(
8
+ send(
9
+ "#{button[:action]}_record_path",
10
+ build_params(button[:params]).merge(model: button[:model_name])
11
+ ),
12
+ class: "btn btn-#{button_color(button[:action])} btn-xs"
13
+ ) do
14
+ button[:text] || button_icon(button[:action])
15
+ end
16
+ )
17
+ end
16
18
  end
17
19
  return
18
20
  end
@@ -5,6 +5,8 @@ module Tramway
5
5
  include AuthManagment
6
6
  include AdditionalButtonsBuilder
7
7
  include RussianCasesHelper
8
+ include ::Tramway::Admin::RecordsHelper
9
+ include ::Tramway::Admin::SingletonHelper
8
10
 
9
11
  def title(page_title = default_title)
10
12
  title_text = "#{page_title} | #{t('application.name')}"
@@ -0,0 +1 @@
1
+ = render partial: 'form', locals: { action: :create }
data/config/routes.rb CHANGED
@@ -4,5 +4,5 @@ Tramway::Admin::Engine.routes.draw do
4
4
  root to: 'welcome#index'
5
5
 
6
6
  resources :records
7
- resource :singleton, only: [ :show, :edit, :update ]
7
+ resource :singleton, only: [ :new, :create, :show, :edit, :update ]
8
8
  end
data/lib/tramway/admin.rb CHANGED
@@ -43,7 +43,7 @@ module Tramway
43
43
  @additional_buttons[project].merge! buttons
44
44
  end
45
45
 
46
- def additional_buttons(project:, view: nil, record: nil)
46
+ def additional_buttons(view: nil, record: nil)
47
47
  @additional_buttons&.dig record, view
48
48
  end
49
49
 
@@ -1,5 +1,5 @@
1
1
  module Tramway
2
2
  module Admin
3
- VERSION = '1.2'
3
+ VERSION = '1.2.1'
4
4
  end
5
5
  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.2'
4
+ version: 1.2.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: 2018-07-21 00:00:00.000000000 Z
11
+ date: 2018-08-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tramway-user
@@ -176,6 +176,7 @@ files:
176
176
  - app/views/tramway/admin/records/show.html.haml
177
177
  - app/views/tramway/admin/singletons/_form.html.haml
178
178
  - app/views/tramway/admin/singletons/edit.html.haml
179
+ - app/views/tramway/admin/singletons/new.html.haml
179
180
  - app/views/tramway/admin/singletons/show.html.haml
180
181
  - app/views/tramway/admin/welcome/index.html.haml
181
182
  - config/initializers/assets.rb