manage 1.3.21 → 1.3.22

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
  SHA1:
3
- metadata.gz: 5652d11db7e96887d8a3762a8364c7470eb647be
4
- data.tar.gz: 16753aaa3e98ccb07b40905b0fe3456b84ba266b
3
+ metadata.gz: 80ddb3f33e8c26c57deb60f1eae3ad8470601c35
4
+ data.tar.gz: a4c557c81b2a8c491c5bc369cbf545355dda8358
5
5
  SHA512:
6
- metadata.gz: e6c1c273d41c21e41848ec11917d65be0f85ba9cd8ca3f5a5a79145668232ad6b5886a84a829a2d3391558ad454100a621ab0b453682b6d7897deeb5c13a2bc1
7
- data.tar.gz: 3387051f8227f686f6fba0a723979d8154939cfd05faee683fdb8d3543a67addaa5a40aa5b77611bd963a3111df9631f49f6316abfc702df92b74790fe758d5d
6
+ metadata.gz: b7b579db7b3ba7aaf89e4cb32b9540563a11dcdef91d061812c060286a1b5ff86f483cd9f460a8b03f779f167fb1357ccef4986969f0da1451eb9cf08f31a70a
7
+ data.tar.gz: 4cf49d981a924481c665541ef7d9643d20704d9c6e8bb923e0c8d6dc301a6133d6fcd993b0d38feca878a4d04f98df0081fdeb4323f5e575ee5122872b8ef492
@@ -1,45 +1,50 @@
1
- .main {
2
- margin: 0 10px;
3
- }
4
-
5
- .row {
6
- width: auto;
7
- max-width: none;
8
- margin-left: -10px;
9
- margin-right: -10px;
10
- margin-bottom: 0;
11
- }
12
- .row .columns, .row .row .columns {
13
- padding-left: 10px;
14
- padding-right: 10px;
15
- }
16
-
17
- table {
18
- width: 100%;
19
-
20
- ul.inline-list {
21
- margin-bottom: 0;
22
- line-height: inherit;
23
- }
24
- }
25
-
26
- .pagination li.active {
27
- @extend .current;
28
- }
29
-
30
- body.index {
31
- .panel {
32
- padding: 0 10px;
33
- }
34
-
35
- fieldset {
36
- margin: 0;
37
- }
38
- }
39
-
40
-
41
- .collection_actions {
42
- form {
43
- display: inline-block;
44
- }
1
+ .main {
2
+ margin: 0 10px;
3
+ }
4
+
5
+ .row {
6
+ width: auto;
7
+ max-width: none;
8
+ margin-left: -10px;
9
+ margin-right: -10px;
10
+ margin-bottom: 0;
11
+ }
12
+ .row .columns, .row .row .columns {
13
+ padding-left: 10px;
14
+ padding-right: 10px;
15
+ }
16
+
17
+ table {
18
+ width: 100%;
19
+
20
+ td {
21
+ max-width: 700px;
22
+ word-break: break-word;
23
+ }
24
+
25
+ ul.inline-list {
26
+ margin-bottom: 0;
27
+ line-height: inherit;
28
+ }
29
+ }
30
+
31
+ .pagination li.active {
32
+ @extend .current;
33
+ }
34
+
35
+ body.index {
36
+ .panel {
37
+ padding: 0 10px;
38
+ }
39
+
40
+ fieldset {
41
+ margin: 0;
42
+ }
43
+ }
44
+
45
+
46
+ .collection_actions {
47
+ form {
48
+ display: inline-block;
49
+ }
45
50
  }
@@ -1,125 +1,125 @@
1
- require_dependency "manage/application_controller"
2
- require_dependency 'kaminari'
3
-
4
- class Manage::ResourceController < Manage::ApplicationController
5
- inherit_resources
6
-
7
- cattr_accessor :per_page
8
-
9
- self.responder = Manage::Responder
10
-
11
- layout 'manage/application'
12
-
13
- respond_to :html
14
-
15
- helper_method :list_index_fields, :list_edit_fields, :list_search_fields, :list_action_links, :resource_actions, :collection_actions
16
-
17
- def end_of_association_chain
18
- if self.resources_configuration[:self][:search_fields].blank?
19
- self.class.search_fields :all
20
- end
21
-
22
- config = self.resources_configuration[:self]
23
- @search = config[:search].new(clean_search_params(params[:f]))
24
-
25
- @search.results
26
- end
27
-
28
- protected
29
-
30
- def clean_search_params(search_params)
31
- return {} unless search_params.is_a?(Hash)
32
- search_params = search_params.dup
33
- search_params.delete_if do |key, value|
34
- value == ''
35
- end
36
- search_params
37
- end
38
-
39
- def collection
40
- assocation = end_of_association_chain.page(params[:page] || 1)
41
- per_page ? assocation.per(per_page) : assocation
42
- end
43
-
44
- def permitted_params
45
- params.permit!
46
- end
47
-
48
- def self.index_fields(*fields)
49
- setup_fields(:index_fields, *fields)
50
- end
51
-
52
- def self.edit_fields(*fields)
53
- setup_fields(:edit_fields, *fields)
54
- end
55
-
56
- def self.search_fields(*fields)
57
- setup_fields(:search_fields, *fields)
58
-
59
- config = self.resources_configuration[:self]
60
- config[:search] = Manage::Fields::Searcher.generate_search_object(resource_class, config[:search_fields])
61
- end
62
-
63
- def self.action_links(*fields)
64
- setup_fields(:action_links, *fields)
65
- end
66
-
67
- def list_index_fields
68
- list_fields(:index_fields)
69
- end
70
-
71
- def list_edit_fields
72
- list_fields(:edit_fields)
73
- end
74
-
75
- def list_search_fields
76
- list_fields(:search_fields)
77
- end
78
-
79
- def list_action_links
80
- if self.resources_configuration[:self][:action_links].blank?
81
- []
82
- else
83
- self.resources_configuration[:self][:action_links]
84
- end
85
- end
86
-
87
- #
88
- # This doubles the list_action_links.
89
- # It provides actions on existing resource.
90
- # actions are used in index/show/edit screens
91
- # returns html string
92
- def resource_actions resource
93
- nil
94
- end
95
-
96
- # This method provides links on which to submit all collection / selected items
97
- # Example:
98
- #
99
- def collection_actions resource
100
- nil
101
- end
102
-
103
- private
104
- def self.setup_fields(key, *fields)
105
- # :all means all the fields - default
106
- if not fields.first.is_a?(Hash) and fields.first.to_sym == :all
107
- options = fields.extract_options!
108
- options[:except] ||= []
109
- options[:include] ||= []
110
-
111
- self.resources_configuration[:self][key] = (resource_class.attribute_names + Array(options[:include])) - Array(options[:except]).map(&:to_s)
112
- else
113
- self.resources_configuration[:self][key] = fields
114
- end
115
- end
116
-
117
- def list_fields(key)
118
- if self.resources_configuration[:self][key].blank?
119
- resource_class.attribute_names - %w(id created_at updated_at)
120
- else
121
- self.resources_configuration[:self][key]
122
- end
123
- end
124
-
125
- end
1
+ require_dependency "manage/application_controller"
2
+ require_dependency 'kaminari'
3
+
4
+ class Manage::ResourceController < Manage::ApplicationController
5
+ inherit_resources
6
+
7
+ cattr_accessor :per_page
8
+
9
+ self.responder = Manage::Responder
10
+
11
+ layout 'manage/application'
12
+
13
+ respond_to :html
14
+
15
+ helper_method :list_index_fields, :list_edit_fields, :list_search_fields, :list_action_links, :resource_actions, :collection_actions
16
+
17
+ def end_of_association_chain
18
+ if self.resources_configuration[:self][:search_fields].blank?
19
+ self.class.search_fields :all
20
+ end
21
+
22
+ config = self.resources_configuration[:self]
23
+ @search = config[:search].new(clean_search_params(params[:f]))
24
+
25
+ @search.results
26
+ end
27
+
28
+ protected
29
+
30
+ def clean_search_params(search_params)
31
+ return {} unless search_params.is_a?(Hash)
32
+ search_params = search_params.dup
33
+ search_params.delete_if do |key, value|
34
+ value == ''
35
+ end
36
+ search_params
37
+ end
38
+
39
+ def collection
40
+ assocation = end_of_association_chain.page(params[:page] || 1)
41
+ per_page ? assocation.per(per_page) : assocation
42
+ end
43
+
44
+ def permitted_params
45
+ params.permit!
46
+ end
47
+
48
+ def self.index_fields(*fields)
49
+ setup_fields(:index_fields, *fields)
50
+ end
51
+
52
+ def self.edit_fields(*fields)
53
+ setup_fields(:edit_fields, *fields)
54
+ end
55
+
56
+ def self.search_fields(*fields)
57
+ setup_fields(:search_fields, *fields)
58
+
59
+ config = self.resources_configuration[:self]
60
+ config[:search] = Manage::Fields::Searcher.generate_search_object(resource_class, config[:search_fields])
61
+ end
62
+
63
+ def self.action_links(*fields)
64
+ setup_fields(:action_links, *fields)
65
+ end
66
+
67
+ def list_index_fields
68
+ list_fields(:index_fields)
69
+ end
70
+
71
+ def list_edit_fields
72
+ list_fields(:edit_fields)
73
+ end
74
+
75
+ def list_search_fields
76
+ list_fields(:search_fields)
77
+ end
78
+
79
+ def list_action_links
80
+ if self.resources_configuration[:self][:action_links].blank?
81
+ []
82
+ else
83
+ self.resources_configuration[:self][:action_links]
84
+ end
85
+ end
86
+
87
+ #
88
+ # This doubles the list_action_links.
89
+ # It provides actions on existing resource.
90
+ # actions are used in index/show/edit screens
91
+ # returns html string
92
+ def resource_actions resource
93
+ nil
94
+ end
95
+
96
+ # This method provides links on which to submit all collection / selected items
97
+ # Example:
98
+ #
99
+ def collection_actions resource
100
+ nil
101
+ end
102
+
103
+ private
104
+ def self.setup_fields(key, *fields)
105
+ # :all means all the fields - default
106
+ if not fields.first.is_a?(Hash) and fields.first.to_sym == :all
107
+ options = fields.extract_options!
108
+ options[:except] ||= []
109
+ options[:include] ||= []
110
+
111
+ self.resources_configuration[:self][key] = (resource_class.attribute_names + Array(options[:include])) - Array(options[:except]).map(&:to_s)
112
+ else
113
+ self.resources_configuration[:self][key] = fields
114
+ end
115
+ end
116
+
117
+ def list_fields(key)
118
+ if self.resources_configuration[:self][key].blank?
119
+ resource_class.attribute_names - %w(id created_at updated_at)
120
+ else
121
+ self.resources_configuration[:self][key]
122
+ end
123
+ end
124
+
125
+ end
@@ -1,22 +1,22 @@
1
- = manage_form_for @search, as: :f, method: :get, url: "#{resource_class.name.underscore.pluralize}", html: {id: 'search-form'} do |f|
2
- fieldset
3
- legend Filter
4
- - list_search_fields.each do |field|
5
- .row
6
- .columns.large-12
7
- - label_text = resource_class.human_attribute_name(field)
8
- - if resource_class.columns_hash[field.to_s].blank?
9
- label #{label_text}
10
- = f.search_field field.to_sym, placeholder: label_text
11
- - elsif resource_class.columns_hash[field.to_s].type == :datetime
12
- label #{label_text}
13
- = f.date_field field.to_sym, placeholder: label_text
14
- - elsif resource_class.columns_hash[field.to_s].type == :integer
15
- label #{label_text}
16
- = f.number_field field.to_sym, placeholder: label_text
17
- - else
18
- label #{label_text}
19
- = f.search_field field.to_sym, placeholder: label_text
20
- .row
21
- .columns.large-12
22
- = f.submit 'Search', class: 'button small'
1
+ = manage_form_for @search, as: :f, method: :get, url: "#{resource_class.name.underscore.pluralize}", html: {id: 'search-form'} do |f|
2
+ fieldset
3
+ legend Filter
4
+ - list_search_fields.each do |field|
5
+ .row
6
+ .columns.large-12
7
+ - label_text = resource_class.human_attribute_name(field)
8
+ - if resource_class.columns_hash[field.to_s].blank?
9
+ label #{label_text}
10
+ = f.search_field field.to_sym, placeholder: label_text
11
+ - elsif resource_class.columns_hash[field.to_s].type == :datetime
12
+ label #{label_text}
13
+ = f.date_field field.to_sym, placeholder: label_text, value: (f.object.params[field.to_s] ? Date.parse(f.object.params[field.to_s]) : nil)
14
+ - elsif resource_class.columns_hash[field.to_s].type == :integer
15
+ label #{label_text}
16
+ = f.number_field field.to_sym, placeholder: label_text
17
+ - else
18
+ label #{label_text}
19
+ = f.search_field field.to_sym, placeholder: label_text
20
+ .row
21
+ .columns.large-12
22
+ = f.submit 'Search', class: 'button small'
@@ -1,51 +1,51 @@
1
- module Manage
2
- module Fields
3
- class Searcher
4
- class << self
5
- def generate_search_object(resource_class, search_fields)
6
- search_class = Class.new do
7
- include SearchObject.module(:model, :sorting)
8
-
9
- def escape_search_term(term)
10
- "%#{term.gsub(/\s+/, '%')}%".downcase
11
- end
12
-
13
- def parse_date(date)
14
- Date.strptime(date, '%Y-%m-%d') rescue nil
15
- end
16
- end
17
-
18
-
19
- search_class.scope { resource_class.all }
20
- Object.const_set("#{resource_class.name.gsub(/:/, '')}Searcher", search_class)
21
-
22
- search_fields.select {|f| not f.to_s.include?('.')}.each do |field|
23
- field_type = resource_class.columns_hash[field.to_s].type
24
- case field_type
25
- when *[:text, :string]
26
- search_class.option field.to_sym do |scope, value|
27
- value.blank? ? scope : scope.where("lower(#{field.to_s}) LIKE lower(?)", escape_search_term(value))
28
- end
29
- when :datetime
30
- search_class.option field.to_sym do |scope, value|
31
- date = parse_date value
32
- scope.where("DATE(#{field.to_s}) >= ?", date) if date.present?
33
- end
34
- when :integer
35
- search_class.option field.to_sym
36
- when :boolean
37
- search_class.option field.to_sym
38
- else
39
- search_class.option field.to_sym do |scope, value|
40
- scope.where "#{field.to_s} = '?'", escape_search_term(value)
41
- end
42
- end
43
- end
44
-
45
- search_class
46
- end
47
- end
48
- end
49
- end
50
- end
51
-
1
+ module Manage
2
+ module Fields
3
+ class Searcher
4
+ class << self
5
+ def generate_search_object(resource_class, search_fields)
6
+ search_class = Class.new do
7
+ include SearchObject.module(:model, :sorting)
8
+
9
+ def escape_search_term(term)
10
+ "%#{term.gsub(/\s+/, '%')}%".downcase
11
+ end
12
+
13
+ def parse_date(date)
14
+ Date.strptime(date, '%Y-%m-%d') rescue nil
15
+ end
16
+ end
17
+
18
+
19
+ search_class.scope { resource_class.all }
20
+ Object.const_set("#{resource_class.name.gsub(/:/, '')}Searcher", search_class)
21
+
22
+ search_fields.select {|f| not f.to_s.include?('.')}.each do |field|
23
+ field_type = resource_class.columns_hash[field.to_s].type
24
+ case field_type
25
+ when *[:text, :string]
26
+ search_class.option field.to_sym do |scope, value|
27
+ value.blank? ? scope : scope.where("lower(#{field.to_s}) LIKE lower(?)", escape_search_term(value))
28
+ end
29
+ when :datetime
30
+ search_class.option field.to_sym do |scope, value|
31
+ date = parse_date value
32
+ scope.where("DATE(#{field.to_s}) >= ?", date) if date.present?
33
+ end
34
+ when :integer
35
+ search_class.option field.to_sym
36
+ when :boolean
37
+ search_class.option field.to_sym
38
+ else
39
+ search_class.option field.to_sym do |scope, value|
40
+ scope.where "#{field.to_s} = '?'", escape_search_term(value)
41
+ end
42
+ end
43
+ end
44
+
45
+ search_class
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -1,3 +1,3 @@
1
1
  module Manage
2
- VERSION = "1.3.21"
2
+ VERSION = "1.3.22"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: manage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.21
4
+ version: 1.3.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Empower United
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-02-03 00:00:00.000000000 Z
12
+ date: 2014-02-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails