symphonia 3.4.0 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +3 -4
  3. data/CHANGELOG.md +12 -0
  4. data/README.md +16 -0
  5. data/app/controllers/symphonia/admin_controller.rb +1 -4
  6. data/app/views/symphonia/admin/index.html.erb +1 -11
  7. data/db/migrate/20130714140501_create_roles.rb +6 -4
  8. data/db/migrate/20200428180001_add_uuid_to_users.rb +4 -2
  9. data/db/migrate/20210509141420_roles_change_permissions_to_json.rb +18 -0
  10. data/db/migrate/20210509180525_roles_change_permissions_to_native_json.rb +7 -0
  11. data/lib/generators/symphonia/setup/setup_generator.rb +17 -14
  12. data/lib/generators/symphonia/setup/templates/{settings.rb → app/config/initializers/settings.rb.tt} +0 -0
  13. data/lib/generators/symphonia/setup/templates/{404.html → public/404.html.tt} +2 -2
  14. data/lib/generators/symphonia/setup/templates/{500.html → public/500.html.tt} +2 -2
  15. data/lib/generators/symphonia/setup/templates/{spec_helper.rb → spec/spec_helper.rb.tt} +3 -2
  16. data/lib/symphonia.rb +4 -1
  17. data/lib/symphonia/model_attributes/attribute.rb +30 -14
  18. data/lib/symphonia/model_filters/base.rb +13 -15
  19. data/lib/symphonia/model_filters/boolean_filter.rb +10 -11
  20. data/lib/symphonia/model_filters/date_filter.rb +32 -31
  21. data/lib/symphonia/model_filters/integer_filter.rb +4 -5
  22. data/lib/symphonia/model_filters/select_filter.rb +19 -17
  23. data/lib/symphonia/model_filters/string_filter.rb +4 -5
  24. data/lib/symphonia/query.rb +10 -34
  25. data/lib/symphonia/query_columns.rb +1 -2
  26. data/lib/symphonia/query_columns/attribute_column.rb +59 -5
  27. data/lib/symphonia/spec_helper.rb +5 -3
  28. data/lib/symphonia/version.rb +3 -1
  29. data/spec/controllers/account_controller_spec.rb +66 -69
  30. data/spec/controllers/admin_controller_spec.rb +24 -25
  31. data/spec/libs/some_lib_spec.rb +1 -1
  32. data/spec/rails_helper.rb +4 -3
  33. data/spec/spec_helper.rb +3 -8
  34. metadata +71 -158
  35. data/app/models/symphonia/admin_module.rb +0 -18
  36. data/app/views/symphonia/filters/table.html.erb +0 -21
  37. data/db/migrate/20130828175114_create_attachments.rb +0 -20
  38. data/db/migrate/20141213204351_create_admin_modules.rb +0 -20
  39. data/lib/symphonia/query_columns/generic_column.rb +0 -165
@@ -1,18 +0,0 @@
1
- module Symphonia
2
- class AdminModule < ApplicationRecord
3
- self.table_name = 'admin_modules'
4
-
5
- belongs_to :user
6
- store :settings, coder: JSON
7
-
8
- validates :title, presence: true
9
- validates :panel_type, inclusion: { in: %w(default primary success info warning danger) }
10
-
11
-
12
- def body_path
13
- # override me
14
- self.description
15
- end
16
- end
17
-
18
- end
@@ -1,21 +0,0 @@
1
- <%# if entities.any? %>
2
- <div id="query_data">
3
- <table class="table <%= query.entity.name.pluralize.underscore %> table-striped">
4
- <thead>
5
- <tr>
6
- <%= table_header_tag_for(query.model) do |t|
7
- query.columns.each{|c| c.header(t)}
8
- end %>
9
- <th></th>
10
- </tr>
11
- </thead>
12
- <tbody>
13
- <%= tbody %>
14
- </tbody>
15
- </table>
16
-
17
- <%#= will_paginate entities %>
18
- </div>
19
- <%# else %>
20
- <%#= render_no_data %>
21
- <%# end %>
@@ -1,20 +0,0 @@
1
- class CreateAttachments < ActiveRecord::Migration[5.1]
2
- def change
3
- create_table :attachments do |t|
4
- t.string :type
5
- t.string :attachment_file_name, null: false
6
- t.string :attachment_content_type, null: false
7
- t.integer :attachment_file_size, null: false
8
- t.datetime :attachment_updated_at, null: false
9
-
10
- t.references :attachable, polymorphic: true, null: true
11
-
12
- t.text :description, null: true
13
- t.integer :position, default: 1, index: true
14
-
15
- t.timestamps null: false
16
-
17
- t.index([:type, :attachable_type])
18
- end
19
- end
20
- end
@@ -1,20 +0,0 @@
1
- class CreateAdminModules < ActiveRecord::Migration[5.1]
2
- def up
3
- create_table :admin_modules do |t|
4
- t.string :type
5
- t.string :title
6
- t.text :description
7
- t.string :panel_type, :default => 'default'
8
- t.text :settings#, :limit => 100.megabytes
9
- t.belongs_to :user, :null => true
10
-
11
- t.integer :position, default: 1, index: true
12
-
13
- t.timestamps
14
- end
15
- end
16
-
17
- def down
18
- drop_table(:admin_modules)
19
- end
20
- end
@@ -1,165 +0,0 @@
1
- module Symphonia
2
- module QueryColumns
3
- class GenericColumn
4
-
5
- attr_reader :name, :query, :model, :includes, :preload, :joins
6
- attr_writer :sort_column_name, :sort_definition
7
- attr_accessor :sort, :header, :default
8
-
9
- def initialize(name, klass = nil, options={})
10
- ::ActiveSupport::Deprecation.warn 'Maybe this class is over...'
11
- @name = name
12
- if klass.is_a? Symphonia::Query
13
- @query = klass
14
- @model = @query.model
15
- elsif klass < ActiveRecord::Base
16
- @model = klass
17
- else # default fallback
18
- @model = ActiveRecord::Base
19
- end
20
- @options = options
21
-
22
- # @sort_options = @options.delete(:sort_options) || {}
23
- self.header = @options.delete(:header).nil?
24
- self.sort = @options.delete(:sort).nil?
25
-
26
- @includes = Array(options.delete(:includes)) || []
27
- @preload = Array(options.delete(:preload)) || []
28
- @joins = Array(options.delete(:joins)) || []
29
- end
30
-
31
- def summarize?
32
- false
33
- end
34
-
35
- def header?
36
- !(@header === false)
37
- end
38
-
39
- def sort?
40
- !(@sort === false)
41
- end
42
-
43
- def default?
44
- !!@default
45
- end
46
-
47
- def header(view)
48
- ::ActiveSupport::Deprecation.warn 'Header method is deprecated -> use app/helpers/symphonia/renderer_helper.rb:59'
49
- if @no_header || @header === false
50
- title
51
- else
52
- view.symphonia_query_sort_tag(self)
53
- end
54
- end
55
-
56
- def sort_definition
57
- return nil unless sort?
58
- @sort_definition ||= SortableTable::SortColumnCustomDefinition.new(@name, {asc: "#{sort_column_name} asc", desc: "#{sort_column_name} desc"})
59
- end
60
-
61
- def title
62
- ::ActiveSupport::Deprecation.warn 'method is deprecated'
63
- @model.human_attribute_name(@name, @options[:i18n] || {})
64
- end
65
-
66
- def sort_options
67
- @sort_options
68
- end
69
-
70
- def value(entity)
71
- entity.send(name)
72
- end
73
-
74
- def format_value(view, entity)
75
- if @options[:formatter].is_a?(Proc)
76
- @options[:formatter].call(view, entity).to_s
77
- else
78
- case @options[:with_link]
79
- when :entity, true
80
- view.link_to(value(entity).to_s, entity)
81
- when :value
82
- view.link_to(value(entity).to_s, value(entity))
83
- else
84
- value(entity).to_s
85
- end
86
- end
87
- end
88
-
89
- def sum_value(view)
90
- format_value(view, OpenStruct.new(name => sum))
91
- end
92
-
93
- def sum
94
- return nil unless summarize?
95
- @sum ||= query.entities.sum(name)
96
- end
97
-
98
- def css_classes
99
- @name.to_s
100
- end
101
-
102
- def inspect
103
- "#<#{self.class.name} name='#{name}' options=#{@options.inspect}>"
104
- end
105
-
106
- private
107
-
108
- def t(*args)
109
- I18n.translate(*args)
110
- end
111
-
112
- def l(*args)
113
- I18n.localize(*args)
114
- end
115
-
116
- def sort_column_name
117
- @sort_column_name.presence || [@model.table_name, @name].join('.')
118
- end
119
- end
120
-
121
- class TextColumn < GenericColumn
122
-
123
- def format_value(view, entity)
124
- view.format_text(super(view, entity))
125
- end
126
-
127
- end
128
-
129
- class NumberColumn < GenericColumn
130
-
131
- def summarize?
132
- true
133
- end
134
-
135
- end
136
-
137
- class PriceColumn < NumberColumn
138
-
139
- def format_value(view, entity)
140
- view.format_price(super(view, entity))
141
- end
142
-
143
- end
144
-
145
- class DateColumn < GenericColumn
146
-
147
- def format_value(view, entity)
148
- value(entity) && l(value(entity), format: @options[:format])
149
- end
150
-
151
- end
152
-
153
- class BooleanColumn < GenericColumn
154
-
155
- def format_value(view, entity)
156
- if value(entity)
157
- view.fa_icon('true', title: t(:true))
158
- end
159
- end
160
-
161
- end
162
-
163
- end
164
-
165
- end