tramway-admin 1.18.0.1 → 1.18.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: 35b6318151955442c7ad9d91bf827427aa89ab4bc0b6fd62a7d517983cb02a24
4
- data.tar.gz: fa995938d701f58e1f9fc04f5ed2970dd3d209795be71342e2f9ebe40b83ead7
3
+ metadata.gz: 4ae22115d6b8978b050c7b090d9c75a96a34495dfaa6ed27000e5f39b1d09fa9
4
+ data.tar.gz: 292ab0a60acca87a47584493e0037ca20d1f9a7f2361123d08b674bea5040a85
5
5
  SHA512:
6
- metadata.gz: 465f44031834545790dc9984b927253f8b69f4356e5c7b6d7144a35bd2a93bf51737a26ea89885c118dac8ef605e2aced92c48aa5b46810eb3c48f3d4f7765f8
7
- data.tar.gz: 8151b061193bd620c6b2476ead745afe79d0f2a20c3a9a300df5449e9d0ad7d921b250ac6a1f80a2def3a94954d8037da86550269ad47d8299ee7d2002eecf64
6
+ metadata.gz: a584a11cc8d7f628c94dd73c449ff181efda27e33164e0f88c38c0290aefac0bf259723c17cc944decabf2f6ec82d5d2d01ebb700c8fabad0fa9053daf888b89
7
+ data.tar.gz: 8ae159127aee9165412773cc71b361ab75fac67993b5c1d85a1a044d9f9e08a7be46d2594f4c36fdd886436997e2b87d31400291377352dba69f54a5e9023f3d
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  begin
2
4
  require 'bundler/setup'
3
5
  rescue LoadError
@@ -14,14 +16,11 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
16
  rdoc.rdoc_files.include('lib/**/*.rb')
15
17
  end
16
18
 
17
- APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
19
+ APP_RAKEFILE = File.expand_path('test/dummy/Rakefile', __dir__)
18
20
  load 'rails/tasks/engine.rake'
19
21
 
20
-
21
22
  load 'rails/tasks/statistics.rake'
22
23
 
23
-
24
-
25
24
  require 'bundler/gem_tasks'
26
25
 
27
26
  require 'rake/testtask'
@@ -32,5 +31,4 @@ Rake::TestTask.new(:test) do |t|
32
31
  t.verbose = false
33
32
  end
34
33
 
35
-
36
34
  task default: :test
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tramway/helpers/class_name_helpers'
2
4
 
3
5
  module Tramway
@@ -57,7 +59,7 @@ module Tramway
57
59
  end
58
60
 
59
61
  def admin_form_class
60
- if model_class.to_s.include? "Tramway"
62
+ if model_class.to_s.include? 'Tramway'
61
63
  form_class_name
62
64
  else
63
65
  "::Admin::#{model_class}Form".constantize
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationController
2
4
  def index
3
5
  scope = params[:scope].present? ? params[:scope] : :all
@@ -11,29 +13,29 @@ class Tramway::Admin::RecordsController < ::Tramway::Admin::ApplicationControlle
11
13
  @record = decorator_class.decorate model_class.active.find params[:id]
12
14
  end
13
15
 
14
- def edit
15
- @record_form = admin_form_class.new model_class.active.find params[:id]
16
+ def new
17
+ @record_form = admin_form_class.new model_class.new
16
18
  end
17
19
 
18
- def update
19
- @record_form = admin_form_class.new model_class.active.find params[:id]
20
+ def create
21
+ @record_form = admin_form_class.new model_class.new
20
22
  if @record_form.submit params[:record]
21
23
  redirect_to params[:redirect] || record_path(@record_form.model)
22
24
  else
23
- render :edit
25
+ render :new
24
26
  end
25
27
  end
26
28
 
27
- def new
28
- @record_form = admin_form_class.new model_class.new
29
+ def edit
30
+ @record_form = admin_form_class.new model_class.active.find params[:id]
29
31
  end
30
32
 
31
- def create
32
- @record_form = admin_form_class.new model_class.new
33
+ def update
34
+ @record_form = admin_form_class.new model_class.active.find params[:id]
33
35
  if @record_form.submit params[:record]
34
36
  redirect_to params[:redirect] || record_path(@record_form.model)
35
37
  else
36
- render :new
38
+ render :edit
37
39
  end
38
40
  end
39
41
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Admin
2
4
  class SingletonsController < ApplicationController
3
5
  def show
@@ -6,7 +8,7 @@ module Tramway::Admin
6
8
  else
7
9
  @singleton_form = form_class.new model_class.new
8
10
  render :new
9
- return
11
+ nil
10
12
  end
11
13
  end
12
14
 
@@ -35,7 +37,7 @@ module Tramway::Admin
35
37
 
36
38
  private
37
39
 
38
- # FIXME replace to module
40
+ # FIXME: replace to module
39
41
  def singleton_path(*args, **options)
40
42
  super args, options.merge(model: params[:model])
41
43
  end
@@ -1,6 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Admin::WelcomeController < Tramway::Admin::ApplicationController
2
4
  skip_before_action :check_available!
3
5
 
4
- def index
5
- end
6
+ def index; end
6
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::Export::ApplicationController < Tramway::Core::ApplicationController
2
4
  before_action :authenticate_admin!
3
5
  end
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Admin::AdditionalButtonsBuilder
2
4
  def build_buttons(additional_buttons)
3
5
  if additional_buttons
4
- additional_buttons = additional_buttons.is_a?(Hash) ? [ additional_buttons ] : additional_buttons
6
+ additional_buttons = additional_buttons.is_a?(Hash) ? [additional_buttons] : additional_buttons
5
7
  additional_buttons.each do |button|
6
8
  concat(
7
9
  link_to(
@@ -16,7 +18,7 @@ module Tramway::Admin::AdditionalButtonsBuilder
16
18
  )
17
19
  end
18
20
  end
19
- return
21
+ nil
20
22
  end
21
23
 
22
24
  private
@@ -27,7 +29,7 @@ module Tramway::Admin::AdditionalButtonsBuilder
27
29
  edit: { color: :warning, icon: :pencil },
28
30
  update: { color: :warning, icon: :pencil },
29
31
  delete: { color: :danger, icon: :remove }
30
- }
32
+ }.freeze
31
33
 
32
34
  def button_color(action)
33
35
  BUTTON_STYLES[action][:color]
@@ -43,9 +45,7 @@ module Tramway::Admin::AdditionalButtonsBuilder
43
45
  params.each do |model_name, model_attributes|
44
46
  attributes = {}
45
47
  model_attributes.each do |name, value|
46
- if value.is_a? Proc
47
- value = record.model.instance_exec(&value)
48
- end
48
+ value = record.model.instance_exec(&value) if value.is_a? Proc
49
49
  attributes.merge! name => value
50
50
  end
51
51
  param.merge! model_name => attributes
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  module ApplicationHelper
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  module CasesHelper
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module ::Tramway::Admin::FocusGeneratorHelper
2
- #FIXME create independent focus generator
4
+ # FIXME: create independent focus generator
3
5
  def focus_selector(index)
4
6
  "table:nth-child(2)>tbody>tr:nth-child(#{index - 1})"
5
7
  end
@@ -1,11 +1,14 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  module InputsHelper
4
6
  def association_params(form_object:, property:, value:, object:)
5
7
  full_class_name_association = form_object.class.full_class_name_association(property)
6
8
  unless full_class_name_association
7
- raise "It seems you\'ve defined association attributes with `property` method. Please, use `association` method. `association :#{property}`"
9
+ raise "It seems you\'ve defined association attributes with `property` method. Please, use `association` method. `association :#{property}`"
8
10
  end
11
+
9
12
  {
10
13
  label: false,
11
14
  input_html: {
@@ -16,7 +19,7 @@ module Tramway
16
19
  selected: (form_object.model.send("#{property}_id") || value),
17
20
  collection: full_class_name_association.active.map do |obj|
18
21
  decorator_class(full_class_name_association).decorate obj
19
- end.sort_by { |obj| obj.name }
22
+ end.sort_by(&:name)
20
23
  }
21
24
  end
22
25
 
@@ -49,7 +52,7 @@ module Tramway
49
52
  when :polymorphic_association
50
53
  {
51
54
  id: params.dig(model_class.to_s.underscore, property.to_s),
52
- type: params.dig(model_class.to_s.underscore, "#{property}_type"),
55
+ type: params.dig(model_class.to_s.underscore, "#{property}_type")
53
56
  }
54
57
  else
55
58
  params.dig(model_class.to_s.underscore, property.to_s)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  module NavbarHelper
@@ -1,6 +1,8 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Admin
2
4
  module RecordsHelper
3
- # FIXME replace to module
5
+ # FIXME: replace to module
4
6
  def current_model_record_path(*args, **options)
5
7
  record_path args, options.merge(model: params[:model])
6
8
  end
@@ -29,7 +31,7 @@ module Tramway::Admin
29
31
  "#{model_name || model_class}Decorator".constantize
30
32
  end
31
33
 
32
- def get_collection(model_class)
34
+ def get_collection(_model_class)
33
35
  decorator_class.collections
34
36
  end
35
37
 
@@ -38,7 +40,7 @@ module Tramway::Admin
38
40
  end
39
41
 
40
42
  def search_tab_title(count)
41
- "#{t("helpers.scope.found")} / #{count}"
43
+ "#{t('helpers.scope.found')} / #{count}"
42
44
  end
43
45
 
44
46
  def searchable_model?(model_class)
@@ -56,12 +58,12 @@ module Tramway::Admin
56
58
  def collection_human_name(model_name:, collection_name:)
57
59
  if t("default.collections.#{collection_name}").include?('<span')
58
60
  t("collections.#{model_name}.#{collection_name}").pluralize(:ru)
59
- else
61
+ else
60
62
  t("default.collections.#{collection_name}")
61
63
  end
62
64
  end
63
65
 
64
- def tab_title(model_class, tab, count, state_method = :state)
66
+ def tab_title(model_class, tab, count, _state_method = :state)
65
67
  model = model_class.name.underscore
66
68
  name = collection_human_name model_name: model, collection_name: tab
67
69
  params[:filter].present? ? name : "#{name} / #{count}"
@@ -73,12 +75,23 @@ module Tramway::Admin
73
75
  end
74
76
 
75
77
  def new_associated_record_path(object:, association:)
76
- new_record_path model: association.class_name,
77
- redirect: current_model_record_path(object),
78
- association.options[:class_name].underscore => {
79
- association.options[:as] => object.id,
80
- association.type => object.class.model_name
81
- }
78
+ unless association.options[:class_name].present?
79
+ raise "You should set `class_name` for #{association.name} association"
80
+ end
81
+ if association.polymorphic?
82
+ new_record_path model: association.class_name,
83
+ redirect: current_model_record_path(object),
84
+ association.options[:class_name].underscore => {
85
+ association.options[:as] => object.id,
86
+ association.type => object.class.model_name
87
+ }
88
+ else
89
+ new_record_path model: association.class_name,
90
+ redirect: current_model_record_path(object),
91
+ association.options[:class_name].underscore => {
92
+ object.model.class.name.underscore => object.id
93
+ }
94
+ end
82
95
  end
83
96
  end
84
97
  end
@@ -1,9 +1,12 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  module RussianCasesHelper
4
6
  def case_word(model_name, case_name)
5
7
  word_case = I18n.t("cases.#{model_name.name.underscore}.#{case_name}")
6
8
  return word_case if word_case.present?
9
+
7
10
  raise "There is not #{case_name} implementation for \"#{model_name}\""
8
11
  end
9
12
 
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway::Admin::SingletonHelper
2
- # FIXME replace to module
4
+ # FIXME: replace to module
3
5
  def current_model_singleton_path(*args, **options)
4
6
  singleton_path args, options.merge(model: params[:model])
5
7
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  class ApplicationJob < ActiveJob::Base
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  class ApplicationMailer < ActionMailer::Base
@@ -1,7 +1,9 @@
1
+ # frozen_string_literal: true
2
+
1
3
  class Tramway::User::User < ::Tramway::Core::ApplicationRecord
2
- has_secure_password #FIXME remove repeating from tramway-user
4
+ has_secure_password # FIXME: remove repeating from tramway-user
3
5
 
4
- enumerize :role, in: [ :user, :admin ], default: :user
6
+ enumerize :role, in: %i[user admin], default: :user
5
7
 
6
8
  def admin?
7
9
  role.admin?
@@ -2,7 +2,7 @@
2
2
  %tr
3
3
  %td
4
4
  = model_class.human_attribute_name association.name
5
- = link_to "Add #{model_class.human_attribute_name association.name}", new_associated_record_path(association: association, object: object), class: 'btn btn-primary'
5
+ = link_to "Add #{model_class.human_attribute_name(association.name).singularize}", new_associated_record_path(association: association, object: object), class: 'btn btn-primary'
6
6
  %td{ colspan: 2 }
7
7
  %table.table.table-striped.table-bordered
8
8
  - object.send(association.name)&.each do |association_object|
@@ -1 +1,3 @@
1
- Rails.application.config.assets.precompile += %w( tramway/admin/ckeditor/* )
1
+ # frozen_string_literal: true
2
+
3
+ Rails.application.config.assets.precompile += %w[tramway/admin/ckeditor/*]
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Ckeditor.setup do |config|
2
- require "ckeditor/orm/active_record"
4
+ require 'ckeditor/orm/active_record'
3
5
 
4
- config.assets_plugins = [ 'image', 'copyformatting', 'filebrowser', 'sourcedialog' ]
6
+ config.assets_plugins = %w[image copyformatting filebrowser sourcedialog]
5
7
  end
@@ -1,11 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  Tramway::Admin::Engine.routes.draw do
2
4
  mount Tramway::Auth::Engine, at: '/auth'
3
- if defined? Tramway::Export::Engine
4
- mount Tramway::Export::Engine, at: '/'
5
- end
5
+ mount Tramway::Export::Engine, at: '/' if defined? Tramway::Export::Engine
6
6
 
7
7
  root to: 'welcome#index'
8
8
 
9
9
  resources :records
10
- resource :singleton, only: [ :new, :create, :show, :edit, :update ]
10
+ resource :singleton, only: %i[new create show edit update]
11
11
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # desc "Explaining what the task does"
2
4
  # task :tramway_admin do
3
5
  # # Task goes here
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tramway/admin/engine'
2
4
  require 'tramway/error'
3
5
 
@@ -35,7 +37,7 @@ module Tramway
35
37
  if @available_models
36
38
  @available_models.values.flatten
37
39
  else
38
- error = Tramway::Error.new(plugin: :admin, method: :available_models, message: ('List of available_models is empty. You should add some of them using `::Tramway::Admin.set_available_models(*list_of_classes, project: :your_project_name)` in `config/initializers/tramway.rb`'))
40
+ error = Tramway::Error.new(plugin: :admin, method: :available_models, message: 'List of available_models is empty. You should add some of them using `::Tramway::Admin.set_available_models(*list_of_classes, project: :your_project_name)` in `config/initializers/tramway.rb`')
39
41
  raise error.message
40
42
  end
41
43
  end
@@ -70,9 +72,7 @@ module Tramway
70
72
  @additional_buttons&.dig record, view
71
73
  end
72
74
 
73
- def customized_admin_navbar
74
- @customized_admin_navbar
75
- end
75
+ attr_reader :customized_admin_navbar
76
76
 
77
77
  def engine_class(project)
78
78
  class_name = "::Tramway::#{project.to_s.camelize}"
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  require 'tramway/admin/record_routes_helper'
2
4
  require 'tramway/auth'
3
5
  require 'font-awesome-rails'
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
5
  module RecordRoutesHelper
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Tramway
2
4
  module Admin
3
- VERSION = '1.18.0.1'
5
+ VERSION = '1.18.1'
4
6
  end
5
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.18.0.1
4
+ version: 1.18.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: 2019-10-06 00:00:00.000000000 Z
11
+ date: 2019-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bootstrap-kaminari-views
@@ -39,45 +39,45 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: 4.2.4
41
41
  - !ruby/object:Gem::Dependency
42
- name: font-awesome-rails
42
+ name: copyright_mafa
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '4.7'
48
45
  - - ">="
49
46
  - !ruby/object:Gem::Version
50
- version: 4.7.0.1
47
+ version: 0.1.2
48
+ - - "~>"
49
+ - !ruby/object:Gem::Version
50
+ version: 0.1.2
51
51
  type: :runtime
52
52
  prerelease: false
53
53
  version_requirements: !ruby/object:Gem::Requirement
54
54
  requirements:
55
- - - "~>"
56
- - !ruby/object:Gem::Version
57
- version: '4.7'
58
55
  - - ">="
59
56
  - !ruby/object:Gem::Version
60
- version: 4.7.0.1
57
+ version: 0.1.2
58
+ - - "~>"
59
+ - !ruby/object:Gem::Version
60
+ version: 0.1.2
61
61
  - !ruby/object:Gem::Dependency
62
- name: copyright_mafa
62
+ name: font-awesome-rails
63
63
  requirement: !ruby/object:Gem::Requirement
64
64
  requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
67
- version: 0.1.2
68
65
  - - "~>"
69
66
  - !ruby/object:Gem::Version
70
- version: 0.1.2
67
+ version: '4.7'
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 4.7.0.1
71
71
  type: :runtime
72
72
  prerelease: false
73
73
  version_requirements: !ruby/object:Gem::Requirement
74
74
  requirements:
75
- - - ">="
76
- - !ruby/object:Gem::Version
77
- version: 0.1.2
78
75
  - - "~>"
79
76
  - !ruby/object:Gem::Version
80
- version: 0.1.2
77
+ version: '4.7'
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ version: 4.7.0.1
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: kaminari
83
83
  requirement: !ruby/object:Gem::Requirement
@@ -99,27 +99,21 @@ dependencies:
99
99
  - !ruby/object:Gem::Version
100
100
  version: 1.1.1
101
101
  - !ruby/object:Gem::Dependency
102
- name: state_machine_buttons
102
+ name: ransack
103
103
  requirement: !ruby/object:Gem::Requirement
104
104
  requirements:
105
105
  - - ">="
106
106
  - !ruby/object:Gem::Version
107
- version: 0.4.1
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: 0.4.1
107
+ version: '0'
111
108
  type: :runtime
112
109
  prerelease: false
113
110
  version_requirements: !ruby/object:Gem::Requirement
114
111
  requirements:
115
112
  - - ">="
116
113
  - !ruby/object:Gem::Version
117
- version: 0.4.1
118
- - - "~>"
119
- - !ruby/object:Gem::Version
120
- version: 0.4.1
114
+ version: '0'
121
115
  - !ruby/object:Gem::Dependency
122
- name: ransack
116
+ name: selectize-rails
123
117
  requirement: !ruby/object:Gem::Requirement
124
118
  requirements:
125
119
  - - ">="
@@ -133,19 +127,25 @@ dependencies:
133
127
  - !ruby/object:Gem::Version
134
128
  version: '0'
135
129
  - !ruby/object:Gem::Dependency
136
- name: selectize-rails
130
+ name: state_machine_buttons
137
131
  requirement: !ruby/object:Gem::Requirement
138
132
  requirements:
139
133
  - - ">="
140
134
  - !ruby/object:Gem::Version
141
- version: '0'
135
+ version: 0.4.1
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.4.1
142
139
  type: :runtime
143
140
  prerelease: false
144
141
  version_requirements: !ruby/object:Gem::Requirement
145
142
  requirements:
146
143
  - - ">="
147
144
  - !ruby/object:Gem::Version
148
- version: '0'
145
+ version: 0.4.1
146
+ - - "~>"
147
+ - !ruby/object:Gem::Version
148
+ version: 0.4.1
149
149
  description: Engine for admin
150
150
  email:
151
151
  - kalashnikovisme@gmail.com