tramway-admin 4.0.0.1 → 4.1.0.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: 5c198a3b0d6fad90c8de0c064e53843dc4c7471087f8ef379aeb28e37e1ee446
4
- data.tar.gz: f0aa47073c3a211e5396179b06499cdf2f5782f255c017c83723e7e50dfeadc4
3
+ metadata.gz: 8b44fe24bffc41f9e73369d01d70066b3454fae31e483ba3b83b13a81efd0fbf
4
+ data.tar.gz: 21f8c5c22448dc3ac1df74ad91cfc8a1fa4ce82f684bcaf990cc1478549ccb87
5
5
  SHA512:
6
- metadata.gz: 380e8552c48f0afc1f70700bd792af2718d9c4bdd486e0fb8a774a07dac46cc9b0a0ae679bffce7b8be8924ea745ebcda4b6b7d3ded34bdc7ecbf1994dcb59db
7
- data.tar.gz: 9dc264f0b6310b6945932894171e780a6cc88da295fe9f0c01b16adb7f69571b10005d1ea7534150c74fae86a1d59fdd5341fe026b7700327ef1ae1920dd735c
6
+ metadata.gz: 31923f43c6a572341ef1c5561630bae7358a6c943651ed044e45a2a03bdb53e1fe6d85d2cda346829219d14b7fb98c060b8266fa05dc6a84707721fca8621e4e
7
+ data.tar.gz: 5873f1f00d1eb3f989d42ac9a3767c38a211ca3b456072ddd6e2c5fed9bd4bf3d1eae7109801ae2902821d397ede0dfb9ad722f37d5e4e319a089ff0cebe4676
@@ -21,6 +21,16 @@ module Tramway::Admin::ActionsHelper
21
21
  )
22
22
  end
23
23
 
24
+ def create_is_available?(association_class)
25
+ ::Tramway::Admin.action_is_available?(
26
+ nil,
27
+ project: (@application_engine || @application.name),
28
+ model_name: association_class,
29
+ role: current_admin.role,
30
+ action: :create
31
+ )
32
+ end
33
+
24
34
  # delete_button is in smart-buttons gem
25
35
 
26
36
  def edit_button(url:, button_options:)
@@ -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
@@ -4,10 +4,14 @@
4
4
  %meta{ content: "width=device-width, initial-scale=1, maximum-scale=0.8", name: "viewport" }
5
5
  %title
6
6
  = yield :title
7
- = stylesheet_link_tag 'tramway/admin/application', media: "all"
7
+ = stylesheet_link_tag 'tramway/admin/application', media: :all
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
@@ -3,8 +3,9 @@
3
3
  .d-flex.flex-row-reverse.filters
4
4
  = form_tag records_path, class: 'form-inline', method: :get do |f|
5
5
  - if searchable_model?(model_class)
6
- .col-md-8
6
+ .input-group
7
7
  = text_field_tag :search, params[:search], class: 'text form-control'
8
+ = submit_tag t('helpers.actions.search'), class: 'btn btn-primary'
8
9
  = hidden_field_tag :model, params[:model]
9
10
  = hidden_field_tag :scope, params[:scope]
10
11
  = hidden_field_tag :filter, (params[:filter].is_a?(ActionController::Parameters) ? params[:filter].permit!.to_h.to_json : params[:filter])
@@ -31,5 +32,3 @@
31
32
  $('#filter_datepicker_begin_date').datepicker();
32
33
  $('#filter_datepicker_end_date').datepicker();
33
34
  });
34
- .col-md-4.submit
35
- = submit_tag t('helpers.actions.search'), class: 'btn btn-primary'
@@ -15,7 +15,7 @@
15
15
  .col
16
16
  = render 'search', model_class: model_class
17
17
  %hr
18
- %ul.nav.nav-tabs
18
+ %ul.nav.nav-tabs.mb-3
19
19
  - if params[:search].present?
20
20
  %li.nav-item
21
21
  = link_to search_tab_title(@records.total_count), '#', class: 'nav-link active'
@@ -7,7 +7,7 @@
7
7
  %td
8
8
  = model_class.human_attribute_name association.name
9
9
  %hr
10
- - if association_type != :has_one || !object.send(association.name).present?
10
+ - if create_is_available?(association.class_name) && (association_type != :has_one || !object.send(association.name).present?)
11
11
  = link_to "#{I18n.t('helpers.actions.add')} #{model_class.human_attribute_name(association.name).singularize.downcase}", new_associated_record_path(association: association, object: object, as: object.send("#{association.name}_as")), class: 'btn btn-primary'
12
12
  %td{ colspan: 2 }
13
13
  - if association_type.in? [ :has_one, :belongs_to ]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Admin
5
- VERSION = '4.0.0.1'
5
+ VERSION = '4.1.0.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.0.1
4
+ version: 4.1.0.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-07 00:00:00.000000000 Z
11
+ date: 2022-02-18 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