symphonia 3.4.0 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -4
- data/CHANGELOG.md +12 -0
- data/README.md +16 -0
- data/app/controllers/symphonia/admin_controller.rb +1 -4
- data/app/views/symphonia/admin/index.html.erb +1 -11
- data/db/migrate/20130714140501_create_roles.rb +6 -4
- data/db/migrate/20200428180001_add_uuid_to_users.rb +4 -2
- data/db/migrate/20210509141420_roles_change_permissions_to_json.rb +18 -0
- data/db/migrate/20210509180525_roles_change_permissions_to_native_json.rb +7 -0
- data/lib/generators/symphonia/setup/setup_generator.rb +17 -14
- data/lib/generators/symphonia/setup/templates/{settings.rb → app/config/initializers/settings.rb.tt} +0 -0
- data/lib/generators/symphonia/setup/templates/{404.html → public/404.html.tt} +2 -2
- data/lib/generators/symphonia/setup/templates/{500.html → public/500.html.tt} +2 -2
- data/lib/generators/symphonia/setup/templates/{spec_helper.rb → spec/spec_helper.rb.tt} +3 -2
- data/lib/symphonia.rb +4 -1
- data/lib/symphonia/model_attributes/attribute.rb +30 -14
- data/lib/symphonia/model_filters/base.rb +13 -15
- data/lib/symphonia/model_filters/boolean_filter.rb +10 -11
- data/lib/symphonia/model_filters/date_filter.rb +32 -31
- data/lib/symphonia/model_filters/integer_filter.rb +4 -5
- data/lib/symphonia/model_filters/select_filter.rb +19 -17
- data/lib/symphonia/model_filters/string_filter.rb +4 -5
- data/lib/symphonia/query.rb +10 -34
- data/lib/symphonia/query_columns.rb +1 -2
- data/lib/symphonia/query_columns/attribute_column.rb +59 -5
- data/lib/symphonia/spec_helper.rb +5 -3
- data/lib/symphonia/version.rb +3 -1
- data/spec/controllers/account_controller_spec.rb +66 -69
- data/spec/controllers/admin_controller_spec.rb +24 -25
- data/spec/libs/some_lib_spec.rb +1 -1
- data/spec/rails_helper.rb +4 -3
- data/spec/spec_helper.rb +3 -8
- metadata +71 -158
- data/app/models/symphonia/admin_module.rb +0 -18
- data/app/views/symphonia/filters/table.html.erb +0 -21
- data/db/migrate/20130828175114_create_attachments.rb +0 -20
- data/db/migrate/20141213204351_create_admin_modules.rb +0 -20
- data/lib/symphonia/query_columns/generic_column.rb +0 -165
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c44e1f10ceb644917147a7e5cd28caa1a6054a8bffed6e85fa7e76a90d9956
|
4
|
+
data.tar.gz: dfaa2c7d6d6e0c6960a59722998542af1e16ca644fdeefbe6ffcc5be5087ef96
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f9b8fca0586ade8130cf789e367b5724a38f7cf44597f48b15819098034a53b3e2d42007d05a13fd73e70e91922e3cd681fffef284abc70a67b1fef868586ca
|
7
|
+
data.tar.gz: '08bc13b2b16c0001c9389238771b2dfc0c1c97400fecad96540f6fdadcd9ac343a2c918bcd8699b8c7bf11fe9c862b0826ae6be62628fbec54518b9b6480ff95'
|
data/.rubocop.yml
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
AllCops:
|
2
2
|
TargetRubyVersion: 2.5
|
3
|
+
NewCops: enable
|
3
4
|
|
4
5
|
Layout/EmptyLinesAroundClassBody:
|
5
6
|
EnforcedStyle: empty_lines_special
|
@@ -12,15 +13,13 @@ Metrics/AbcSize:
|
|
12
13
|
Enabled: false
|
13
14
|
Metrics/BlockLength:
|
14
15
|
Enabled: false
|
15
|
-
#Metrics/LineLength:
|
16
|
-
# Enabled: false
|
17
16
|
Metrics/MethodLength:
|
18
17
|
Enabled: false
|
19
18
|
|
20
|
-
#Style/BracesAroundHashParameters:
|
21
|
-
# EnforcedStyle: context_dependent
|
22
19
|
Style/Documentation:
|
23
20
|
Enabled: false
|
21
|
+
Style/FrozenStringLiteralComment:
|
22
|
+
Enabled: false
|
24
23
|
Style/MutableConstant:
|
25
24
|
Enabled: false
|
26
25
|
Style/NegatedIf:
|
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,18 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
### Removed
|
9
|
+
- development dependency in gemspec replaced by `symphonia_spec` gem
|
10
|
+
- GenericColumn in Query
|
11
|
+
- AdminModule class/table = its not used, its not working
|
12
|
+
### Changed
|
13
|
+
- Rails 6.1 support
|
14
|
+
- Query#to_params boolean argument to named
|
15
|
+
- update generators
|
16
|
+
- use native JSON columns instead of serializations
|
17
|
+
### Added
|
18
|
+
- Gemfile.lock
|
19
|
+
|
8
20
|
## [3.4.0] - 2021-03-22
|
9
21
|
### Changed
|
10
22
|
- upgrade authlogic to 6.4.1 (rails6.1 compatible)
|
data/README.md
CHANGED
@@ -14,3 +14,19 @@ after `bundle install` run post-installation: `rails g symphonia:setup`
|
|
14
14
|
> Setup prepare `config/initializers/settings.rb`, create `spec/spec_helper.rb`, add stylesheets and javascripts references and copy basic layout.
|
15
15
|
|
16
16
|
|
17
|
+
## Upgrade to v4.0
|
18
|
+
1. update Gemfile:
|
19
|
+
```ruby
|
20
|
+
gem 'rails', '~> 6.1'
|
21
|
+
gem 'symphonia', '~> 4.0'
|
22
|
+
source "https://gems.luk4s.cz" do
|
23
|
+
gem 'symphonia_spec', group: %i[development test]
|
24
|
+
end
|
25
|
+
```
|
26
|
+
And `bundle update`
|
27
|
+
2. upgrade rails:
|
28
|
+
https://guides.rubyonrails.org/upgrading_ruby_on_rails.html
|
29
|
+
```bash
|
30
|
+
export THOR_MERGE=vimdiff
|
31
|
+
rails app:update
|
32
|
+
```
|
@@ -3,9 +3,6 @@ module Symphonia
|
|
3
3
|
before_action :login_require
|
4
4
|
|
5
5
|
def index
|
6
|
-
@admin_modules = AdminModule.where(user_id: [nil, current_user.id]).order(:position).all
|
7
|
-
@modules_count = @admin_modules.count
|
8
|
-
|
9
6
|
respond_to do |format|
|
10
7
|
format.html
|
11
8
|
end
|
@@ -19,4 +16,4 @@ module Symphonia
|
|
19
16
|
|
20
17
|
end
|
21
18
|
|
22
|
-
end
|
19
|
+
end
|
@@ -1,15 +1,5 @@
|
|
1
1
|
<%= title 'Administrace' %>
|
2
|
-
<% @admin_modules.each_with_index do |admin_module, _index| %>
|
3
|
-
<div class="col-lg-<%= @modules_count == 1 ? '12' : '6' %>" id="<%= dom_id(admin_module) %>">
|
4
|
-
<h3><%= t(admin_module.title, scope: [:admin_module, :titles], default: admin_module.title) %></h3>
|
5
|
-
<% if admin_module.body_path.is_a?(Symbol) %>
|
6
|
-
<%= render(partial: "admin_modules/#{admin_module.body_path}", locals: { admin_module: admin_module }) -%>
|
7
|
-
<% else %>
|
8
|
-
<%= format_text(admin_module.body_path) -%>
|
9
|
-
<% end -%>
|
10
|
-
</div>
|
11
|
-
<% end -%>
|
12
2
|
|
13
3
|
<%= content_for :meta_tags do %>
|
14
4
|
<meta name="turbolinks-root" content="/admin">
|
15
|
-
<% end %>
|
5
|
+
<% end %>
|
@@ -1,10 +1,11 @@
|
|
1
|
-
class CreateRoles < ActiveRecord::Migration[
|
1
|
+
class CreateRoles < ActiveRecord::Migration[6.1]
|
2
|
+
|
2
3
|
def up
|
3
4
|
create_table :roles do |t|
|
4
|
-
t.string
|
5
|
-
t.text
|
5
|
+
t.string :name, null: false
|
6
|
+
t.text :description, null: true
|
6
7
|
|
7
|
-
t.text
|
8
|
+
t.text :permissions
|
8
9
|
|
9
10
|
t.timestamps
|
10
11
|
end
|
@@ -13,4 +14,5 @@ class CreateRoles < ActiveRecord::Migration[5.1]
|
|
13
14
|
def down
|
14
15
|
drop_table :roles
|
15
16
|
end
|
17
|
+
|
16
18
|
end
|
@@ -1,6 +1,8 @@
|
|
1
1
|
class AddUuidToUsers < ActiveRecord::Migration[6.0]
|
2
|
+
|
2
3
|
def change
|
3
|
-
uuid_type = connection.adapter_name =~ /PostgreSQL/i ? :uuid : :string
|
4
|
-
add_column :users, :uuid,
|
4
|
+
# uuid_type = connection.adapter_name =~ /PostgreSQL/i ? :uuid : :string
|
5
|
+
add_column :users, :uuid, :uuid
|
5
6
|
end
|
7
|
+
|
6
8
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class RolesChangePermissionsToJson < ActiveRecord::Migration[6.1]
|
2
|
+
|
3
|
+
def up
|
4
|
+
say_with_time "Convert 'roles.permissions' YAML to JSON" do
|
5
|
+
i = 0
|
6
|
+
Symphonia::Role.where.not(permissions: nil).each do |role|
|
7
|
+
yaml = product.read_attribute_before_type_cast :permissions
|
8
|
+
next unless yaml.start_with? "---"
|
9
|
+
|
10
|
+
role.update_columns permissions: YAML.safe_load(yaml)
|
11
|
+
i += 1
|
12
|
+
end
|
13
|
+
|
14
|
+
i
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
@@ -2,17 +2,16 @@ require 'rails/generators'
|
|
2
2
|
|
3
3
|
module Symphonia
|
4
4
|
class SetupGenerator < Rails::Generators::Base
|
5
|
-
# include Rails::Generators::Migration
|
6
5
|
|
7
6
|
source_root File.expand_path('templates', __dir__)
|
8
7
|
|
9
8
|
def create_settings
|
10
|
-
|
9
|
+
template 'config/initializers/settings.rb'
|
11
10
|
end
|
12
11
|
|
13
12
|
def copy_static
|
14
|
-
|
15
|
-
|
13
|
+
template 'public/404.html'
|
14
|
+
template 'public/500.html'
|
16
15
|
end
|
17
16
|
|
18
17
|
def copy_assets
|
@@ -22,16 +21,14 @@ module Symphonia
|
|
22
21
|
end
|
23
22
|
|
24
23
|
def copy_rspec
|
25
|
-
|
24
|
+
template 'spec/spec_helper.rb'
|
26
25
|
|
27
26
|
create_file '.rspec' do
|
28
|
-
|
29
|
-
'--format documentation'
|
27
|
+
"--require spec_helper"
|
30
28
|
end
|
31
29
|
end
|
32
30
|
|
33
31
|
def copy_setup_file
|
34
|
-
|
35
32
|
copy_file 'base_layout.html.erb', 'app/views/layouts/application.html.erb'
|
36
33
|
|
37
34
|
append_to_file 'db/seeds.rb', 'Symphonia::Engine.load_seed'
|
@@ -40,14 +37,20 @@ module Symphonia
|
|
40
37
|
inject_into_file 'config/routes.rb', after: "Rails.application.routes.draw do\n" do
|
41
38
|
" mount Symphonia::Engine => '/'"
|
42
39
|
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def rubocop
|
43
|
+
create_file '.rubocop.yml' do
|
44
|
+
"inherit_gem:\n symphonia: .rubocop.yml"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
def setup_gemfile
|
49
|
+
append_to_file 'Gemfile' do
|
50
|
+
"gem 'symphonia-spec', source: 'https://gems.luk4s.cz', group: %w[development test]"
|
51
|
+
end
|
43
52
|
|
44
53
|
end
|
45
54
|
|
46
|
-
# def setup_gemfile
|
47
|
-
# append_to_file 'Gemfile' do
|
48
|
-
# File.read(File.join(File.dirname(__FILE__), 'templates/Gemfile'))
|
49
|
-
# end
|
50
|
-
#
|
51
|
-
# end
|
52
55
|
end
|
53
56
|
end
|
data/lib/generators/symphonia/setup/templates/{settings.rb → app/config/initializers/settings.rb.tt}
RENAMED
File without changes
|
@@ -4,8 +4,8 @@
|
|
4
4
|
<meta charset="UTF-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>404 STránka nenalezena</title>
|
7
|
-
<link rel="stylesheet" href="//
|
8
|
-
<link rel="stylesheet" href="
|
7
|
+
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" />
|
8
|
+
<link rel="stylesheet" href="//stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
|
9
9
|
</head>
|
10
10
|
|
11
11
|
<body>
|
@@ -26,10 +26,10 @@
|
|
26
26
|
<h3>Lukáš Pokorný</h3>
|
27
27
|
</li>
|
28
28
|
<li>
|
29
|
-
<i class="fa fa-li fa
|
29
|
+
<i class="fa fa-li fa-envelope"></i>e-mail: <a href="mailto:admin@lagrace.cz">admin@luk4s.cz</a>
|
30
30
|
</li>
|
31
31
|
<li>
|
32
|
-
<i class="fa fa-li fa
|
32
|
+
<i class="fa fa-li fa-mobile-phone"></i>tel: 604484983
|
33
33
|
</li>
|
34
34
|
</ul>
|
35
35
|
</div>
|
@@ -1,11 +1,11 @@
|
|
1
1
|
ENV['RAILS_ENV'] ||= 'test'
|
2
|
-
|
2
|
+
require_relative '../../config/environment'
|
3
3
|
# Prevent database truncation if the environment is production
|
4
4
|
abort('The Rails environment is running in production mode!') if Rails.env.production?
|
5
5
|
|
6
6
|
# require 'symphonia'
|
7
7
|
RSpec.configure do |config|
|
8
|
-
Dir.glob(File.join(__dir__, 'support', '*.rb')).each { |f| require f }
|
8
|
+
Dir.glob(File.join(__dir__, 'support', '*.rb')).sort.each { |f| require f }
|
9
9
|
|
10
10
|
require 'symphonia/spec_helper'
|
11
11
|
|
@@ -15,4 +15,5 @@ RSpec.configure do |config|
|
|
15
15
|
|
16
16
|
config.infer_spec_type_from_file_location!
|
17
17
|
config.filter_rails_from_backtrace!
|
18
|
+
config.profile_examples = true
|
18
19
|
end
|
data/lib/symphonia.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
# Dir[File.dirname(__FILE__) + '/symphonia/*.rb'].each {|file| require file }
|
2
1
|
module Symphonia
|
2
|
+
|
3
3
|
include ::ActiveSupport::Configurable
|
4
4
|
|
5
5
|
autoload :BaseController, 'symphonia/base_controller'
|
@@ -13,8 +13,11 @@ module Symphonia
|
|
13
13
|
autoload :QueryColumns, 'symphonia/query_columns'
|
14
14
|
|
15
15
|
module ActionCable
|
16
|
+
|
16
17
|
autoload :Connection, 'symphonia/action_cable/connection'
|
18
|
+
|
17
19
|
end
|
20
|
+
|
18
21
|
end
|
19
22
|
|
20
23
|
require 'symphonia/engine'
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Symphonia
|
2
2
|
module ModelAttributes
|
3
|
+
|
3
4
|
class Attribute
|
4
5
|
|
5
|
-
attr_reader :name, :options
|
6
|
-
attr_reader :format_options, :sort_column
|
6
|
+
attr_reader :name, :options, :format_options, :sort_column
|
7
7
|
attr_accessor :filter
|
8
8
|
|
9
9
|
def initialize(name, klass, options, formatter)
|
@@ -78,27 +78,34 @@ module Symphonia
|
|
78
78
|
def format_value(_view, value, _entity)
|
79
79
|
value.to_s
|
80
80
|
end
|
81
|
+
|
81
82
|
end
|
82
83
|
|
83
84
|
|
84
85
|
class TextAttribute < Attribute
|
85
|
-
|
86
|
+
|
87
|
+
def format_value(view, value, _entity)
|
86
88
|
view.format_text(value)
|
87
89
|
end
|
88
90
|
|
89
91
|
def input_field
|
90
92
|
:text_area
|
91
93
|
end
|
94
|
+
|
92
95
|
end
|
96
|
+
|
93
97
|
class DecimalAttribute < Attribute
|
94
|
-
|
98
|
+
|
99
|
+
def format_value(view, value, _entity)
|
95
100
|
view.format_price(value)
|
96
101
|
end
|
102
|
+
|
97
103
|
end
|
98
104
|
|
99
105
|
class EnumAttribute < Attribute
|
106
|
+
|
100
107
|
# TODO: @klass.name || @klass.base_class.name || entity.class.name
|
101
|
-
def format_value(view, value,
|
108
|
+
def format_value(view, value, _entity)
|
102
109
|
view.t("#{@klass.name.underscore}.#{name.to_s.pluralize}.#{value}", format_options)
|
103
110
|
end
|
104
111
|
|
@@ -109,26 +116,27 @@ module Symphonia
|
|
109
116
|
def input_options
|
110
117
|
[]
|
111
118
|
end
|
119
|
+
|
112
120
|
end
|
113
121
|
|
114
122
|
class LinkAttribute < Attribute
|
123
|
+
|
115
124
|
def format_value(view, value, entity)
|
116
125
|
view.link_to value.to_s, entity, format_options
|
117
126
|
end
|
127
|
+
|
118
128
|
end
|
119
129
|
|
120
130
|
class MailAttribute < Attribute
|
121
|
-
|
131
|
+
|
132
|
+
def format_value(view, value, _entity)
|
122
133
|
view.mail_to value.to_s, value.to_s, format_options
|
123
134
|
end
|
135
|
+
|
124
136
|
end
|
125
137
|
|
126
138
|
class ReferenceAttribute < Attribute
|
127
139
|
|
128
|
-
def initialize(name, klass, options, formatter)
|
129
|
-
super
|
130
|
-
end
|
131
|
-
|
132
140
|
def title
|
133
141
|
if (ref = @klass.reflect_on_association(name)).macro == :belongs_to
|
134
142
|
@klass.human_attribute_name(ref.foreign_key, @options[:i18n] || {})
|
@@ -138,7 +146,7 @@ module Symphonia
|
|
138
146
|
|
139
147
|
end
|
140
148
|
|
141
|
-
def format_value(view, value,
|
149
|
+
def format_value(view, value, _entity)
|
142
150
|
if value.is_a?(ActiveRecord::Associations::CollectionProxy) || value.is_a?(Array)
|
143
151
|
value.collect { |v| view.link_to v.to_s, v, format_options }.join("\n").html_safe
|
144
152
|
else
|
@@ -153,7 +161,8 @@ module Symphonia
|
|
153
161
|
end
|
154
162
|
|
155
163
|
class BooleanAttribute < Attribute
|
156
|
-
|
164
|
+
|
165
|
+
def format_value(view, value, _entity)
|
157
166
|
if value.to_boolean
|
158
167
|
view.icon('true', view.t(:true))
|
159
168
|
else
|
@@ -164,21 +173,28 @@ module Symphonia
|
|
164
173
|
def input_field
|
165
174
|
:check_box
|
166
175
|
end
|
176
|
+
|
167
177
|
end
|
168
178
|
|
169
179
|
class DateAttribute < Attribute
|
170
|
-
|
180
|
+
|
181
|
+
def format_value(view, value, _entity)
|
171
182
|
value && view.l(value.to_date, format_options)
|
172
183
|
end
|
184
|
+
|
173
185
|
end
|
174
186
|
|
175
187
|
class DateTimeAttribute < Attribute
|
176
|
-
|
188
|
+
|
189
|
+
def format_value(view, value, _entity)
|
177
190
|
value && view.l(value.localtime, format_options)
|
178
191
|
end
|
192
|
+
|
179
193
|
end
|
194
|
+
|
180
195
|
class DatetimeAttribute < DateTimeAttribute
|
181
196
|
# alias
|
182
197
|
end
|
198
|
+
|
183
199
|
end
|
184
200
|
end
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Symphonia
|
2
2
|
module ModelFilters
|
3
3
|
class Base
|
4
|
-
attr_reader :name, :type, :
|
4
|
+
attr_reader :name, :type, :options, :query, :value, :operator
|
5
5
|
|
6
6
|
# @param [Symphonia::ModelAttributes::Attribute] attribute
|
7
7
|
# @param [Symphonia::Query] query
|
@@ -24,7 +24,7 @@ module Symphonia
|
|
24
24
|
@caption ||= query.model.human_attribute_name(name)
|
25
25
|
end
|
26
26
|
|
27
|
-
def form_field(
|
27
|
+
def form_field(_context)
|
28
28
|
raise NotImplementError
|
29
29
|
end
|
30
30
|
|
@@ -36,20 +36,18 @@ module Symphonia
|
|
36
36
|
!!query.active_filters[name]
|
37
37
|
end
|
38
38
|
|
39
|
-
def value=(
|
40
|
-
if (m =
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@value
|
39
|
+
def value=(to)
|
40
|
+
@value = if (m = to.downcase.match(/^([!~><]+)(.*)/))
|
41
|
+
self.operator = m[1]
|
42
|
+
m[2]
|
43
|
+
else
|
44
|
+
@operator ||= 'eq'
|
45
|
+
to
|
46
|
+
end
|
49
47
|
end
|
50
48
|
|
51
|
-
def operator=(
|
52
|
-
@operator = case
|
49
|
+
def operator=(to)
|
50
|
+
@operator = case to
|
53
51
|
when '!'
|
54
52
|
'not_eq'
|
55
53
|
when '~'
|
@@ -79,4 +77,4 @@ module Symphonia
|
|
79
77
|
|
80
78
|
end
|
81
79
|
end
|
82
|
-
end
|
80
|
+
end
|