tramway-admin 4.0.1.1 → 4.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: ac328eb42232bc603e790685aba070cda1a7e16be185a33ecbca0b3378d07ea0
4
- data.tar.gz: 709d4ee3987dacbf02a550a9de043c307777d4c5c6343015852777cf07366a78
3
+ metadata.gz: 78639584bbf4b055028b8d32816434c049812c9aa8711fdfcc4c988b22e4d28a
4
+ data.tar.gz: fd5f663efbceab4b1ac6aa2276488a2b7f5b287db196564b72419da25f1f2743
5
5
  SHA512:
6
- metadata.gz: 8fe0fc0c0337462214ec2e2da661c924f7c210442a7c3a468dc19cd2d12ad9c2f8bbfc104bfe67f42539eba056f288324f8dddb8f40443ab785d278fdbeddef0
7
- data.tar.gz: 734ed5eb5b5a9d592f938c0dc103381bb2cd3b5cdcf0810b6a493047252897fce98d5ce3d90d412f0ddad80bfbf9ce82de81eb9556f2f7e09006b031a5e35af0
6
+ metadata.gz: d18a9fcb50694c039bfa5bcd702391260312cdc88eaa45922d35564b0a34cdda6049f55299d482a5dfb71ccbc4d3d38407a17156cdcf9705ab89fa6f89a35226
7
+ data.tar.gz: 1b8472ecb0adb65f49146cb5896d1757e82e96e07a3ede8c191bcc3f31ceaf0ab3444430b0a9e023dd8179032338b94ebfc975dae7529e81e4e665fe4c31e9a3
@@ -17,6 +17,7 @@ module Tramway
17
17
  include ::Tramway::Collections::Helper
18
18
  include ::Tramway::Core::CopyToClipboardHelper
19
19
  include ::Tramway::Admin::TramwayModelHelper
20
+ include ::Tramway::Admin::FrontendHelper
20
21
 
21
22
  def object_type(object)
22
23
  object_class_name = if object.class.ancestors.include? ::Tramway::Core::ApplicationDecorator
@@ -0,0 +1,21 @@
1
+ module Tramway::Admin::FrontendHelper
2
+ def react_params(form, action, method)
3
+ url = case action
4
+ when :create
5
+ Tramway::Admin::Engine.routes.url_helpers.records_path(model: form.model.class)
6
+ else
7
+ Tramway::Admin::Engine.routes.url_helpers.record_path(form.model.id, model: form.model.class)
8
+ end
9
+ form.properties.reduce({ action: url, method: method, authenticity_token: form_authenticity_token }) do |hash, property|
10
+ case property[1]
11
+ when :association
12
+ hash.merge!(
13
+ property[0] => {
14
+ collection: build_collection_for_association(form, property[0])
15
+ }
16
+ )
17
+ end
18
+ hash
19
+ end.merge model: form.model.attributes
20
+ end
21
+ end
@@ -8,6 +8,10 @@
8
8
  = javascript_include_tag 'tramway/admin/application'
9
9
  - if File.exists?("#{Rails.root}/app/assets/javascripts/admin/application.js") || File.exists?("#{Rails.root}/app/assets/javascripts/admin/application.js.coffee")
10
10
  = javascript_include_tag 'admin/application'
11
+ - if File.exists?("#{Rails.root}/app/assets/stylesheets/admin/application.css") || File.exists?("#{Rails.root}/app/assets/stylesheets/admin/application.scss")
12
+ = stylesheet_link_tag 'admin/application'
13
+ - if File.exists?("#{Rails.root}/app/javascript/packs/admin/application.js")
14
+ = javascript_pack_tag 'admin/application'
11
15
  = csrf_meta_tags
12
16
  - if @application.favicon.present?
13
17
  = favicon_link_tag @application.favicon
@@ -8,12 +8,15 @@
8
8
  = render 'tramway/core/shared/messages', object: @record_form
9
9
  .row
10
10
  .col-lg-12
11
- = simple_form_for @record_form, url: { controller: :records, action: action, model: @record_form.model.class }, method: method, input_html: { class: 'form-horizontal' } do |f|
12
- - @record_form.properties.each do |property, type|
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
- = hidden_field_tag :redirect, params[:redirect]
15
- = f.button :submit, t('helpers.links.save'), class: 'btn btn-success'
16
- = link_to t('helpers.links.back'), current_model_records_path, class: 'btn btn-secondary'
11
+ - if @record_form.class.is_react_component?
12
+ = react_component "#{@record_form.class.name.gsub('::', '/')}", react_params(@record_form, action, method)
13
+ - else
14
+ = simple_form_for @record_form, url: { controller: :records, action: action, model: @record_form.model.class }, method: method, input_html: { class: 'form-horizontal' } do |f|
15
+ - @record_form.properties.each do |property, type|
16
+ = 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)
17
+ = hidden_field_tag :redirect, params[:redirect]
18
+ = f.button :submit, t('helpers.links.save'), class: 'btn btn-success'
19
+ = link_to t('helpers.links.back'), current_model_records_path, class: 'btn btn-secondary'
17
20
 
18
21
  -# NOTES
19
22
  -# * value_from_params helper is in tramway-core gem app/helpers/inputs_helpers.rb
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '4.0.1.1'
5
+ VERSION = '4.1'
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: 4.0.1.1
4
+ version: '4.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: 2022-02-10 00:00:00.000000000 Z
11
+ date: 2022-02-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tramway-core
@@ -256,6 +256,7 @@ files:
256
256
  - app/helpers/tramway/admin/application_helper.rb
257
257
  - app/helpers/tramway/admin/cases_helper.rb
258
258
  - app/helpers/tramway/admin/focus_generator_helper.rb
259
+ - app/helpers/tramway/admin/frontend_helper.rb
259
260
  - app/helpers/tramway/admin/navbar_helper.rb
260
261
  - app/helpers/tramway/admin/records_helper.rb
261
262
  - app/helpers/tramway/admin/russian_cases_helper.rb