optimacms 0.1.15 → 0.1.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/optimacms/admin/pages_controller.rb +93 -81
  3. data/app/controllers/optimacms/admin/templates_controller.rb +22 -4
  4. data/app/controllers/optimacms/application_controller.rb +2 -1
  5. data/app/helpers/optimacms/application_helper.rb +3 -2
  6. data/app/helpers/optimacms/forms_helper.rb +52 -6
  7. data/app/models/optimacms/page.rb +16 -9
  8. data/app/models/optimacms/template.rb +11 -31
  9. data/app/views/optimacms/admin/pages/index.html.haml +15 -3
  10. data/app/views/optimacms/admin/templates/index.html.haml +6 -2
  11. data/config/initializers/simple_form_simple_search_boostrap.rb +6 -0
  12. data/lib/optimacms/engine.rb +2 -0
  13. data/lib/optimacms/filters/form_filter.rb +5 -2
  14. data/lib/optimacms/mycontroller.rb +29 -29
  15. data/lib/optimacms/version.rb +1 -1
  16. data/test/dummy/app/controllers/application_controller.rb +13 -0
  17. data/test/dummy/app/views/pages/about.html.erb +6 -1
  18. data/test/dummy/config/routes.rb +3 -2
  19. data/test/dummy/log/development.log +877 -189112
  20. data/test/dummy/tmp/cache/assets/development/sass/7f871ea7e3a8127767d5a5868622ef2909611f26/noskin.css.scssc +0 -0
  21. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/admin.css.scssc +0 -0
  22. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/admin_tpl.css.scssc +0 -0
  23. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_and_overrides.css.scssc +0 -0
  24. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_custom.css.scssc +0 -0
  25. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_variables.css.scssc +0 -0
  26. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/colors.css.scssc +0 -0
  27. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/tinymce.css.scssc +0 -0
  28. data/test/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/tpl.css.scssc +0 -0
  29. data/test/dummy/tmp/cache/assets/development/sprockets/053f826d1ea01a2fac355de0755e5c40 +0 -0
  30. data/test/dummy/tmp/cache/assets/development/sprockets/0a470277dd21c166b9dfb68b03d34d5c +0 -0
  31. data/test/dummy/tmp/cache/assets/development/sprockets/3240ef40c1dc9d13156bbd790ec2651a +0 -0
  32. data/test/dummy/tmp/cache/assets/development/sprockets/529a74a4530de52f6c3ebbf107ffe9f2 +0 -0
  33. data/test/dummy/tmp/cache/assets/development/sprockets/56c7eb172a7423728c45d0a751d198e3 +0 -0
  34. data/test/dummy/tmp/cache/assets/development/sprockets/6cdbd6f171a27a578bcb07dd5bfa83a2 +0 -0
  35. data/test/dummy/tmp/cache/assets/development/sprockets/6f943f22c610e6417422e4a13e0bcc0d +0 -0
  36. data/test/dummy/tmp/cache/assets/development/sprockets/8956737a82f17db48d50e13f133aeefc +0 -0
  37. data/test/dummy/tmp/cache/assets/development/sprockets/8b5a7992567ebbeb9a882d074778f8c8 +0 -0
  38. data/test/dummy/tmp/cache/assets/development/sprockets/97c1e12a09973e0fb97f23a1dc496443 +0 -0
  39. data/test/dummy/tmp/cache/assets/development/sprockets/99e8d6370ba85ec4a61d953f5ed261af +0 -0
  40. data/test/dummy/tmp/cache/assets/development/sprockets/a64dbcf0e4afe0985b1abd3e209d17cd +0 -0
  41. data/test/dummy/tmp/cache/assets/development/sprockets/a6d357fbe03dae6f590180f6c5e0e148 +0 -0
  42. data/test/dummy/tmp/cache/assets/development/sprockets/aa58fb159780a7200a1bc4c6844cc5c4 +0 -0
  43. data/test/dummy/tmp/cache/assets/development/sprockets/ba9859d0d2b7d4d7d5b03ff3a71ed478 +0 -0
  44. data/test/dummy/tmp/cache/assets/development/sprockets/e3dd086dd858b5bff9cfd60a031c2091 +0 -0
  45. data/test/dummy/tmp/cache/assets/development/sprockets/ec33505f0e2ed4dd12951ecceffa3695 +0 -0
  46. data/test/dummy/tmp/pids/server.pid +1 -1
  47. metadata +69 -7
  48. data/app/views/tableview/_buttons_apply_clear.html.haml +0 -2
  49. data/app/views/tableview/_filter.html.haml +0 -0
  50. data/app/views/tableview/_filter_field.html.haml +0 -15
  51. data/app/views/tableview/_filter_fields.html.haml +0 -3
  52. data/lib/simple_filter/filter.rb +0 -223
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7e2dc6fa03ea942a6e9d3ef195a06363bc18a0f4
4
- data.tar.gz: 798925d1118f0e30a770763fce5347e74d3016b7
3
+ metadata.gz: d690098f1fbebd10c9858d507d9b809782a507ba
4
+ data.tar.gz: 435eab4ff73c4337b0ccce2ee1e81604223fbad4
5
5
  SHA512:
6
- metadata.gz: 3fa5a83ba90ddd2100feb359fbcc9c2eb454785e0bd9ed272662c0188258f93467fa990121ead23da1bb9e362063b8383b24cab31f22ba0aa18679122e44466d
7
- data.tar.gz: bc4891f031058002b7d7154b38a621044a85ec2d93c4b98c87921d353c2a284294f67232914dab33ff842ab08e28c8bab47e6c0e93a51e3f14e21e48e8a1d430
6
+ metadata.gz: 06fb6ac517f14343ade996d544ea762ca4bf475cbe3b76227d0c8252f3de4741f2fc62cff16259e3f0105059b3ad32ce31cf653556ea5425f67e6af3be1602ae
7
+ data.tar.gz: 2b32a323474d1aa598a1d3e12da925149ed09fb9c00247cb602fa9c0750df53d477fc1e47c8b5954a0d58ddd7a1d7162eb6f7aa205e5af05c946edb8bdfce688
@@ -6,24 +6,100 @@ module Optimacms
6
6
  before_action :set_item, only: [:show, :edit, :update, :destroy, :editfolder, :updatefolder]
7
7
  before_action :init_data_form, only: [:edit, :new]
8
8
 
9
- before_action :init_tabledata, :only => [:index, :search]
10
-
11
9
 
12
10
  def index
13
- @items = model.list(@filter, @pg)
11
+ @items = model.by_filter(@filter)
12
+ #@items = model.where(@filter.where).order(@filter.order_string).page(@filter.page)
14
13
 
15
14
  #
16
15
  @parent_id = @filter.v('parent_id')
16
+ #@parent_id = (@parent_id || 0).to_i
17
17
  @parent = Page.find(@parent_id) rescue nil
18
18
 
19
19
  end
20
20
 
21
- def search
21
+ def search_old
22
22
  redirect_to pages_path
23
23
  end
24
24
 
25
25
 
26
26
 
27
+ def url_list
28
+ pages_url
29
+ end
30
+
31
+
32
+ #include SimpleFilter::Controller
33
+ #search_filter :index, {save_session: true, search_method: :post_and_redirect, index_url: :pages_url, search_url: :search_pages_url, search_action: :search} do
34
+ search_filter :index, {save_session: true, search_method: :post_and_redirect, search_url: :search_pages_url, search_action: :search} do
35
+ # define filter
36
+ default_order "created_at", 'desc'
37
+
38
+ # fields
39
+ field :title, :string, :text, {label: '', default_value: '', condition: :like_full}
40
+ field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: 0}
41
+ end
42
+
43
+
44
+ def init_filter_old
45
+
46
+ # input
47
+ @pg = params[:pg].to_i || 1
48
+
49
+ #
50
+ @filter = Filters::FormFilter.new(session, 'admin_pages')
51
+
52
+ # set filter fields
53
+ @filter.add_fields_from_array(
54
+ [
55
+ #{name: 'uid', type: 'text', dbtype: FormFilter::DBTYPE_STRING, title: 'UID', def:'', opt: {width: 80}},
56
+ #{name: 'status', type: 'text', dbtype: FormFilter::DBTYPE_STRING, title: 'Status', def: '', opt: {width: 120}},
57
+ {name: 'title', type: 'text', dbtype: Filters::FormFilter::DBTYPE_STRING, title: 'Title', def: '', opt: {width: 120}},
58
+ {name: 'parent_id', type: 'int', dbtype: Filters::FormFilter::FIELD_TYPE_HIDDEN, title: '', def: 0},
59
+ #{name: 'client_id', type: FormFilter::FIELD_TYPE_HIDDEN, dbtype: FormFilter::DBTYPE_INT, title: 'Client', def: 0, opt: {width: 120}},
60
+ #{name: 'client', type: FormFilter::FIELD_TYPE_SELECT_AUTO, dbtype: FormFilter::DBTYPE_STRING, title: 'Client', def: '', opt: {width: 120, field_id:'client_id', url_query: clients_url(:action=>'list')}},
61
+
62
+ #{name: 'status_id', type: FormFilter::FIELD_TYPE_HIDDEN, dbtype: FormFilter::DBTYPE_INT, title: 'Status', def: 0, opt: {width: 120}},
63
+ #{name: 'status', type: FormFilter::FIELD_TYPE_SELECT_AUTO, dbtype: FormFilter::DBTYPE_STRING, title: 'Status', def: '', opt: {width: 120, field_id:'status_id', url_query: statuses_url(:action=>'list')}},
64
+
65
+ ]
66
+ )
67
+
68
+ #
69
+ if params.has_key? :parent_id
70
+ @filter.set 'parent_id', params[:parent_id]
71
+ end
72
+ #@filter.set 'owner_id', current_user.owner_id
73
+
74
+ #
75
+ @cmd = params[:cmd] || ''
76
+
77
+
78
+ # post
79
+ if request.post? && params[:filter]
80
+ if params[:cmd]=='clear'
81
+ @filter.clear_data
82
+
83
+ redirect_to url_list and return
84
+ else
85
+ @filter.set_data_from_form(params[:filter] || [])
86
+ redirect_to url_list and return
87
+ end
88
+
89
+ end
90
+
91
+ # order
92
+ @filter.set_order_default('created_at' ,'desc')
93
+ #@filter.set_order('created_at' ,'desc')
94
+
95
+ if @cmd=='order'
96
+ @filter.set_order params[:orderby], params[:orderdir]
97
+ redirect_to url_list and return
98
+ end
99
+
100
+
101
+ end
102
+
27
103
  def show
28
104
  end
29
105
 
@@ -111,6 +187,19 @@ module Optimacms
111
187
  end
112
188
 
113
189
 
190
+
191
+
192
+
193
+
194
+ def table_columns
195
+
196
+ @table_columns = [
197
+ {name: "id", title: "##"},
198
+ {name: "title", title: "title"},
199
+ ]
200
+ end
201
+
202
+
114
203
  private
115
204
  def model
116
205
  Page
@@ -137,83 +226,6 @@ module Optimacms
137
226
  end
138
227
 
139
228
 
140
- # filter
141
- #include SimpleFilters::Controller
142
-
143
-
144
- def init_tabledata
145
- init_filter
146
- end
147
-
148
- def init_filter
149
- # input
150
- @pg = params[:pg].to_i || 1
151
-
152
- #
153
- @filter = Filters::FormFilter.new(session, 'admin_pages')
154
-
155
- # set filter fields
156
- @filter.add_fields_from_array(
157
- [
158
- #{name: 'uid', type: 'text', dbtype: FormFilter::DBTYPE_STRING, title: 'UID', def:'', opt: {width: 80}},
159
- #{name: 'status', type: 'text', dbtype: FormFilter::DBTYPE_STRING, title: 'Status', def: '', opt: {width: 120}},
160
- {name: 'title', type: 'text', dbtype: Filters::FormFilter::DBTYPE_STRING, title: 'Title', def: '', opt: {width: 120}},
161
- {name: 'parent_id', type: 'int', dbtype: Filters::FormFilter::FIELD_TYPE_HIDDEN, title: '', def: 0},
162
- #{name: 'client_id', type: FormFilter::FIELD_TYPE_HIDDEN, dbtype: FormFilter::DBTYPE_INT, title: 'Client', def: 0, opt: {width: 120}},
163
- #{name: 'client', type: FormFilter::FIELD_TYPE_SELECT_AUTO, dbtype: FormFilter::DBTYPE_STRING, title: 'Client', def: '', opt: {width: 120, field_id:'client_id', url_query: clients_url(:action=>'list')}},
164
-
165
- #{name: 'status_id', type: FormFilter::FIELD_TYPE_HIDDEN, dbtype: FormFilter::DBTYPE_INT, title: 'Status', def: 0, opt: {width: 120}},
166
- #{name: 'status', type: FormFilter::FIELD_TYPE_SELECT_AUTO, dbtype: FormFilter::DBTYPE_STRING, title: 'Status', def: '', opt: {width: 120, field_id:'status_id', url_query: statuses_url(:action=>'list')}},
167
-
168
- ]
169
- )
170
-
171
- #
172
- if params.has_key? :parent_id
173
- @filter.set 'parent_id', params[:parent_id]
174
- end
175
- #@filter.set 'owner_id', current_user.owner_id
176
-
177
- #
178
- @cmd = params[:cmd] || ''
179
-
180
-
181
- # post
182
- if request.post? && params[:filter]
183
- if params[:cmd]=='clear'
184
- @filter.clear_data
185
-
186
- redirect_to url_list and return
187
- else
188
- @filter.set_data_from_form(params[:filter] || [])
189
- redirect_to url_list and return
190
- end
191
-
192
- end
193
-
194
- # order
195
- @filter.set_order_default('created_at' ,'desc')
196
- #@filter.set_order('created_at' ,'desc')
197
-
198
- if @cmd=='order'
199
- @filter.set_order params[:orderby], params[:orderdir]
200
- redirect_to url_list and return
201
- end
202
-
203
-
204
- end
205
-
206
-
207
- def table_columns
208
-
209
- @table_columns = [
210
- {name: "id", title: "##"},
211
- {name: "title", title: "title"},
212
- ]
213
- end
214
-
215
-
216
-
217
229
  end
218
230
 
219
231
 
@@ -6,7 +6,7 @@ module Optimacms
6
6
  before_action :set_item, only: [:show, :edit, :update, :destroy]
7
7
  before_action :init_common
8
8
  before_action :init_data_form, only: [:new, :edit, :newfolder, :editfolder, :newattach]
9
- before_action :init_tabledata, :only => [:index, :search]
9
+ #before_action :init_tabledata, :only => [:index, :search]
10
10
 
11
11
  before_action :set_layout_modal
12
12
 
@@ -17,6 +17,8 @@ module Optimacms
17
17
  end
18
18
 
19
19
  def index
20
+ #@filter.clear_data
21
+
20
22
  #
21
23
  @parent_id = @filter.v('parent_id').to_i
22
24
  @parent = Template.find(@parent_id) rescue nil
@@ -26,14 +28,30 @@ module Optimacms
26
28
  end
27
29
 
28
30
  #
29
- @items = model.list(@filter, @pg)
31
+ @items = model.by_filter(@filter)
32
+ #@items = model.where(@filter.where).order(@filter.order_string).page(@filter.page)
33
+
30
34
 
31
35
  end
32
36
 
33
- def search
34
- redirect_to pages_path
37
+ #include SimpleFilter::Controller
38
+ search_filter :index, {save_session: true, search_method: :post_and_redirect, search_url: :search_templates_url, search_action: :search} do
39
+ # define filter
40
+ default_order "title", 'asc'
41
+
42
+ # fields
43
+ field :title, :string, :text, {label: '', default_value: '', condition: :like_full}
44
+ #field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: 0, condition: :empty}
45
+ field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: 0, condition: :custom, condition_scope: :of_parent}
46
+
47
+ #field :category_id, :int, :select, {collection: [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last}
48
+ #field :type_id, :int, :select, {label: 'Type', default_value: 0, collection: TemplateType.all, label_method: :title, value_method: :id}
49
+ #field :type, :string, :autocomplete, {label: 'Type', default_value: '', :source_query => :autocomplete_templates_url}
50
+
35
51
  end
36
52
 
53
+
54
+
37
55
  def autocomplete
38
56
  q = params[:q]
39
57
  type_id = (params[:t] || TemplateType::TYPE_PAGE).to_i
@@ -1,5 +1,6 @@
1
1
  module Optimacms
2
- class ApplicationController < ActionController::Base
2
+ #class ApplicationController < ActionController::Base
3
+ class ApplicationController < ::ApplicationController
3
4
  protect_from_forgery with: :exception
4
5
 
5
6
  # include FontAwesome::Rails::IconHelper
@@ -1,8 +1,9 @@
1
1
  module Optimacms
2
2
  module ApplicationHelper
3
3
 
4
- include ActionView::Helpers::ApplicationHelper
5
- x=0
4
+ #include ActionView::Helpers::ApplicationHelper
5
+ #include SimpleFilter::FormsHelper
6
+
6
7
 
7
8
  def method_missing(method, *args, &block)
8
9
  main_app.send(method, *args, &block)
@@ -14,15 +14,61 @@ module Optimacms
14
14
 
15
15
 
16
16
  options[:wrapper] = :horizontal_form
17
- options[:wrapper_mappings] = {
18
- check_boxes: :horizontal_radio_and_checkboxes,
19
- radio_buttons: :horizontal_radio_and_checkboxes,
20
- file: :horizontal_file_input,
21
- boolean: :horizontal_boolean
22
- }
17
+ options[:wrapper_mappings] = {check_boxes: :horizontal_radio_and_checkboxes, radio_buttons: :horizontal_radio_and_checkboxes, file: :horizontal_file_input,boolean: :horizontal_boolean }
23
18
  simple_form_for(resource, options, &block)
24
19
  end
25
20
 
26
21
 
22
+
23
+ def inline_simple_search_form_for(filter_object, options = {}, &block)
24
+ return render 'tableview/filter.html.haml', style: :inline, filter_object: filter_object
25
+ return
26
+
27
+ options[:html] ||= {}
28
+
29
+ options[:url] = send(filter_object.url)
30
+
31
+ options[:html][:role] = 'form'
32
+
33
+ # class
34
+ options[:html][:class] ||= []
35
+ if options[:html][:class].is_a? String
36
+ options[:html][:class] = [options[:html][:class]]
37
+ end
38
+ options[:html][:class] << 'form-inline'
39
+ options[:html][:id] = 'formFilter'
40
+
41
+ options[:wrapper] = :inline_search_form
42
+ options[:wrapper_mappings] = { }
43
+
44
+
45
+ capture do
46
+ simple_form_for(:filter, options) do |f|
47
+ concat(hidden_field_tag 'cmd', 'apply')
48
+ concat(render 'tableview/filter_fields', filter: filter_object, f: f)
49
+ concat(render 'tableview/buttons_apply_clear_inline', filter: filter_object, f: f)
50
+ end
51
+ end
52
+
53
+ end
54
+
55
+
56
+ def horizontal_simple_search_form_for(filter_object, options = {}, &block)
57
+ return render 'tableview/filter.html.haml', style: :horizontal, filter_object: filter_object
58
+ end
59
+
60
+
61
+ def link_to_sortable_column(field_name, title = nil, html_options = nil, &block)
62
+ html_options ||= {}
63
+
64
+ if @filter.search_method_post_and_redirect?
65
+ html_options[:method] = :post
66
+ end
67
+
68
+ url = send(@filter.url, @filter.url_params_for_sortable_column(field_name))
69
+
70
+ link_to(title, url, html_options)
71
+ end
72
+
27
73
  end
28
74
  end
@@ -22,7 +22,13 @@ module Optimacms
22
22
  #
23
23
  paginates_per 10
24
24
 
25
+ # search
26
+ searchable_by_simple_filter
27
+
28
+
29
+
25
30
  #### save
31
+
26
32
  def save
27
33
  begin
28
34
  super
@@ -77,10 +83,10 @@ module Optimacms
77
83
 
78
84
 
79
85
  #### search
80
-
81
- def self.list(filter, pg)
82
-
83
- pg =1 if pg.nil? || pg<=0
86
+ =begin
87
+ def self.search_by_filter(filter)
88
+ pg = filter.page
89
+ #pg =1 if pg.nil? || pg<=0
84
90
 
85
91
  order = filter.order
86
92
 
@@ -92,9 +98,6 @@ module Optimacms
92
98
  orderdir = order[0][1]
93
99
  end
94
100
 
95
- #@items = Task.includes(:status, :client, :contacts).for_user(current_user.id).all
96
- #includes(:status, :client, :contacts).for_user(filter['user_id'])
97
- #includes(:status, :client, :contacts, :received_user)
98
101
  self.where(get_where(filter.data))
99
102
  .order(" #{orderby} #{orderdir}")
100
103
  .page(pg)
@@ -104,11 +107,15 @@ module Optimacms
104
107
  def self.get_where(values)
105
108
  w = '1=1 '
106
109
  #w << " AND uid like '#{values['uid']}%' " if values['uid'] && !values['uid'].blank?
107
- w << " AND title like '%#{values['title']}%' " if values['title'] && !values['title'].blank?
108
- w << " AND parent_id = '#{values['parent_id']}' " if !values['parent_id']!=-1
110
+ v = values[:title]
111
+ w << " AND title like '%#{v}%' " if v && !v.blank?
112
+
113
+ v = values[:parent_id]
114
+ w << " AND parent_id = '#{v}' " if !v!=-1
109
115
 
110
116
  w
111
117
  end
118
+ =end
112
119
 
113
120
  def _before_save
114
121
 
@@ -32,6 +32,13 @@ module Optimacms
32
32
  scope :layouts, -> { where(is_folder: false, type_id: TemplateType::TYPE_LAYOUT) }
33
33
 
34
34
 
35
+ # search
36
+ searchable_by_simple_filter
37
+ scope :of_parent, lambda { |parent_id| where_parent(parent_id) }
38
+
39
+
40
+
41
+
35
42
  ###
36
43
  def to_s
37
44
  "#{title} (#{basepath})"
@@ -56,44 +63,17 @@ module Optimacms
56
63
 
57
64
  ##### search
58
65
 
59
- def self.list(filter, pg)
60
-
61
- pg =1 if pg.nil? || pg<=0
62
-
63
- order = filter.order
64
-
65
- if order.empty?
66
- orderby = 'id'
67
- orderdir = 'asc'
68
- else
69
- orderby = order[0][0]
70
- orderdir = order[0][1]
71
- end
72
-
73
- #@items = Task.includes(:status, :client, :contacts).for_user(current_user.id).all
74
- #includes(:status, :client, :contacts).for_user(filter['user_id'])
75
- #includes(:status, :client, :contacts, :received_user)
76
- q = self.where(get_where(filter.data))
77
-
78
- parent_id = filter.data['parent_id'].to_i
66
+ def self.where_parent(parent_id)
79
67
  if parent_id==0
80
- q = q.roots
68
+ roots
81
69
  elsif parent_id>0
82
- q = q.children_of(parent_id.to_s)
70
+ children_of(parent_id.to_s)
83
71
  end
84
-
85
- q.order(" #{orderby} #{orderdir}").page(pg)
86
72
  end
87
73
 
88
- def self.get_where(values)
89
- w = '1=1 '
90
- #w << " AND uid like '#{values['uid']}%' " if values['uid'] && !values['uid'].blank?
91
- w << " AND title like '%#{values['title']}%' " if values['title'] && !values['title'].blank?
92
- #w << " AND parent_id = '#{values['parent_id']}' " if !values['parent_id']!=-1
93
74
 
94
- w
95
- end
96
75
 
76
+ #### operations
97
77
 
98
78
  def attach
99
79
  # check if file exists
@@ -5,14 +5,25 @@
5
5
  Pages
6
6
  %small
7
7
  <i class="ace-icon fa fa-angle-double-right"></i>
8
- edit pages content and URLs
8
+ manage pages
9
9
  .col-md-5
10
10
  =link_to 'New page', new_page_path(:parent_id=>@parent_id), :class=>'btn btn-sm btn-primary'
11
11
  =link_to 'New folder', newfolder_pages_path(:parent_id=>@parent_id, :is_folder=>1), :class=>'btn btn-sm btn-default'
12
12
 
13
13
 
14
14
  .filter
15
- = form_tag(search_pages_url(:action=>'index'), method: "post", :class=>'form-inline', :name=>'formFilter', :id=>'formFilter') do
15
+ = inline_filter_form_for(@filter)
16
+
17
+ -#= simple_form_for(:filter, url: '/', wrapper: :horizontal_search_form, wrapper_mappings: { check_boxes: :search_horizontal_radio_and_checkboxes, radio_buttons: :search_horizontal_radio_and_checkboxes, boolean: :search_horizontal_boolean },
18
+ -#= simple_form_for(:filter, url: pages_url, wrapper: :inline_search_form, wrapper_mappings: { },
19
+ html: {:id=>'formFilter'}) do |f|
20
+ = hidden_field_tag 'cmd', 'apply'
21
+ = render 'tableview/filter_fields', filter: @filter, f: f
22
+ = render 'tableview/buttons_apply_clear_simple_form_inline', filter: @filter, f: f
23
+
24
+
25
+
26
+ -#= form_tag(search_pages_url(:action=>'index'), method: "post", :class=>'form-inline', :name=>'formFilter', :id=>'formFilter') do
16
27
  = hidden_field_tag 'cmd', 'apply'
17
28
 
18
29
  = render :partial=>'tableview/filter_fields', :locals => {:filter=>@filter}
@@ -29,7 +40,8 @@
29
40
  %table.table.table-striped.table-bordered
30
41
  %tr
31
42
  %th
32
- = link_to 'Title', pages_path(:cmd=>'order', :orderby=>'title', :orderdir=>@filter.get_opposite_order_dir_for_column('title'))
43
+ -#= link_to 'Title', pages_path(:cmd=>'order', :orderby=>'title', :orderdir=>@filter.get_opposite_order_dir_for_column('title'))
44
+ = link_to 'Title', '#'
33
45
  %th Name
34
46
  %th URL
35
47
  %th Commands
@@ -13,7 +13,10 @@
13
13
 
14
14
 
15
15
  .filter
16
- = form_tag(search_templates_url(:action=>'index'), method: "post", :class=>'form-inline', :name=>'formFilter', :id=>'formFilter') do
16
+ = inline_filter_form_for(@filter)
17
+ -#= horizontal_filter_form_for(@filter)
18
+
19
+ -#= form_tag(search_templates_url(:action=>'index'), method: "post", :class=>'form-inline', :name=>'formFilter', :id=>'formFilter') do
17
20
  = hidden_field_tag 'cmd', 'apply'
18
21
 
19
22
  = render :partial=>'tableview/filter_fields', :locals => {:filter=>@filter}
@@ -34,7 +37,8 @@
34
37
  %table.table.table-striped.table-bordered
35
38
  %tr
36
39
  %th
37
- = link_to 'Title', pages_path(:cmd=>'order', :orderby=>'title', :orderdir=>@filter.get_opposite_order_dir_for_column('title'))
40
+ = link_to_sortable_column :title, 'Title'
41
+ -#= link_to 'Title', pages_path(:cmd=>'order', :orderby=>'title', :orderdir=>@filter.get_opposite_order_dir_for_column('title'))
38
42
  %th Path
39
43
  %th Commands
40
44
 
@@ -0,0 +1,6 @@
1
+
2
+ SimpleForm.setup do |config|
3
+
4
+
5
+
6
+ end
@@ -5,12 +5,14 @@ module Optimacms
5
5
 
6
6
 
7
7
  config.watchable_dirs['lib'] = [:rb] if Rails.env.development?
8
+ config.watchable_dirs['app/helpers'] = [:rb] if Rails.env.development?
8
9
 
9
10
  #config.autoload_paths << File.expand_path("../lib/some/path", __FILE__)
10
11
  #config.autoload_paths << File.expand_path("../lib/optimacms/path", __FILE__)
11
12
 
12
13
  config.autoload_paths += Dir["#{Optimacms::Engine.root}/app/helpers/"]
13
14
  config.autoload_paths += Dir["#{Optimacms::Engine.root}/app/helpers/optimacms/"]
15
+ config.autoload_paths += Dir["#{Optimacms::Engine.root}/app/helpers/simple_filter/"]
14
16
  config.autoload_paths += Dir["#{Optimacms::Engine.root}/app/helpers/**/"]
15
17
 
16
18
  config.autoload_paths += Dir["#{Optimacms::Engine.root}/lib/"]
@@ -1,3 +1,4 @@
1
+ =begin
1
2
  module Optimacms
2
3
  module Filters
3
4
  class FormFilter
@@ -92,7 +93,7 @@ module Optimacms
92
93
  end
93
94
 
94
95
  def v(name, v_def=nil)
95
- if (data.has_key? name) && (!data[name].nil?)
96
+ if (data.has_key? name) && (!data[name].nil?) && (!data[name].nil?)
96
97
  return data[name]
97
98
  end
98
99
 
@@ -221,4 +222,6 @@ module Optimacms
221
222
  end
222
223
  end
223
224
  end
224
- end
225
+ end
226
+
227
+ =end
@@ -1,42 +1,42 @@
1
1
  module Optimacms
2
- module Mycontroller
3
- #extend ActiveSupport::Concern
2
+ module Mycontroller
3
+ #extend ActiveSupport::Concern
4
4
 
5
- #included do
6
- # before_filter :my_set_render
7
- #end
5
+ #included do
6
+ # before_filter :my_set_render
7
+ #end
8
8
 
9
- def my_set_render
10
- @is_optimacms = true
9
+ def my_set_render
10
+ @is_optimacms = true
11
11
 
12
- end
13
-
14
- def default_render(*args)
15
- if self.controller_name!='pages' && !@optimacms_tpl.nil? && @is_optimacms
16
- render @optimacms_tpl, :layout=>@optimacms_layout and return
17
- #(render :text => "hello", :layout => @optimacms_layout) and return
12
+ end
18
13
 
19
- # http://stackoverflow.com/questions/21129587/ruby-on-rails-how-to-render-file-as-plain-text-without-any-html
20
- #render :plain will set the content type to text/plain
21
- #render :html will set the content type to text/html
22
- #render :body will not set the content type header.
23
- # render text: "some text". :plain does not work.
24
- end
14
+ def default_render(*args)
15
+ if self.controller_name!='pages' && !@optimacms_tpl.nil? && @is_optimacms
16
+ render @optimacms_tpl, :layout=>@optimacms_layout and return
17
+ #(render :text => "hello", :layout => @optimacms_layout) and return
25
18
 
26
- super
19
+ # http://stackoverflow.com/questions/21129587/ruby-on-rails-how-to-render-file-as-plain-text-without-any-html
20
+ #render :plain will set the content type to text/plain
21
+ #render :html will set the content type to text/html
22
+ #render :body will not set the content type header.
23
+ # render text: "some text". :plain does not work.
27
24
  end
28
25
 
29
- def my_set_render_template(tpl_view, tpl_layout)
30
- @optimacms_tpl = tpl_view
31
- @optimacms_layout = tpl_layout
32
- end
26
+ super
27
+ end
33
28
 
34
- def my_set_meta(meta)
35
- @optimacms_meta_title = meta[:title]
36
- @optimacms_meta_keywords = meta[:keywords]
37
- @optimacms_meta_description = meta[:description]
38
- end
29
+ def my_set_render_template(tpl_view, tpl_layout)
30
+ @optimacms_tpl = tpl_view
31
+ @optimacms_layout = tpl_layout
32
+ end
39
33
 
34
+ def my_set_meta(meta)
35
+ @optimacms_meta_title = meta[:title]
36
+ @optimacms_meta_keywords = meta[:keywords]
37
+ @optimacms_meta_description = meta[:description]
40
38
  end
39
+
40
+ end
41
41
  end
42
42
 
@@ -1,3 +1,3 @@
1
1
  module Optimacms
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.17"
3
3
  end