widget_list 1.0.5 → 1.0.6

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.
data/lib/widget_list.rb CHANGED
@@ -80,139 +80,139 @@ module WidgetList
80
80
  def initialize(list={})
81
81
 
82
82
  @items = {
83
- 'name' => ([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(16).join,
84
- 'database' => 'primary',
85
- 'title' => '',# will add <h1> title and horizontal rule
86
- 'listDescription' => '',# will add grey header box
87
- 'pageId' => $_SERVER['PATH_INFO'],
88
- 'sql' => '',
89
- 'table' => '',
90
- 'view' => '',
91
- 'data' => {},
92
- 'mode' => 'passive',
93
- 'collClass' => '',
94
- 'collAlign' => '',
95
- 'fields' => {},
96
- 'columns' => {},
97
- 'bindVars' => [],
98
- 'bindVarsLegacy' => {},
99
- 'links' => {},
100
- 'results' => {},
101
- 'buttons' => {},
102
- 'inputs' => {},
103
- 'filter' => [],
104
- 'rowStart' => 0,
105
- 'rowLimit' => 10,
106
- 'orderBy' => '',
107
- 'allowHTML' => true,
108
- 'strlength' => 30,
109
- 'searchClear' => false, # build a custom conditional for each page to clear session
110
- 'searchClearAll' => false, # build a custom conditional for each page to clear session
111
- 'showPagination' => true,
112
- 'searchSession' => true, #on list render use last filter
83
+ 'name' => ([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(16).join,
84
+ 'database' => 'primary',
85
+ 'title' => '',# will add <h1> title and horizontal rule
86
+ 'listDescription' => '',# will add grey header box
87
+ 'pageId' => $_SERVER['PATH_INFO'],
88
+ 'sql' => '',
89
+ 'table' => '',
90
+ 'view' => '',
91
+ 'data' => {},
92
+ 'mode' => 'passive',
93
+ 'collClass' => '',
94
+ 'collAlign' => '',
95
+ 'fields' => {},
96
+ 'columns' => {},
97
+ 'bindVars' => [],
98
+ 'bindVarsLegacy' => {},
99
+ 'links' => {},
100
+ 'results' => {},
101
+ 'buttons' => {},
102
+ 'inputs' => {},
103
+ 'filter' => [],
104
+ 'rowStart' => 0,
105
+ 'rowLimit' => 10,
106
+ 'orderBy' => '',
107
+ 'allowHTML' => true,
108
+ 'strlength' => 30,
109
+ 'searchClear' => false, # build a custom conditional for each page to clear session
110
+ 'searchClearAll' => false, # build a custom conditional for each page to clear session
111
+ 'showPagination' => true,
112
+ 'searchSession' => true, #on list render use last filter
113
113
 
114
- #
115
- # Custom count query
116
- #
117
- 'force_count_sql' => '',
118
- 'force_query_sql' => '',
114
+ #
115
+ # Custom count query
116
+ #
117
+ 'force_count_sql' => '',
118
+ 'force_query_sql' => '',
119
119
 
120
- #
121
- # Counts
122
- #
123
- 'count_cache_time' => 180, #
124
- 'cachedCount' => -1, #pass the count
120
+ #
121
+ # Ajax
122
+ #
123
+ 'ajax_action' => '',
124
+ 'ajax_function' => 'ListJumpMin',
125
+ 'ajax_search_function'=> 'ListJumpMin',
125
126
 
126
- #
127
- # Ajax
128
- #
129
- 'ajax_action' => '',
130
- 'ajax_function' => 'ListJumpMin',
131
- 'ajax_search_function'=> 'ListJumpMin',
127
+ #
128
+ # Search
129
+ #
130
+ 'showSearch' => true,
131
+ 'searchOnkeyup' => '',
132
+ 'searchOnclick' => '',
133
+ 'searchIdCol' => 'id', #By default `id` column is here because typically if you call your PK's id and are auto-increment
134
+ 'searchInputLegacyCSS'=> false,
135
+ 'searchBtnName' => 'Search by Id or a list of Ids and more',
136
+ 'searchTitle' => '',
137
+ 'searchFieldsIn' => {}, #White list of fields to include in a alpha-numeric based search
138
+ 'searchFieldsOut' => {'id'=>true}, #Black list of fields to include in a alpha-numeric based search (default `id` to NEVER search when alpha seach)
132
139
 
133
- #
134
- # Search
135
- #
136
- 'showSearch' => true,
137
- 'searchOnkeyup' => '',
138
- 'searchOnclick' => '',
139
- 'searchIdCol' => 'id', #By default `id` column is here because typically if you call your PK's id and are auto-increment
140
- 'searchInputLegacyCSS'=> false,
141
- 'searchBtnName' => 'Search by Id or a list of Ids and more',
142
- 'searchTitle' => '',
143
- 'searchFieldsIn' => {}, #White list of fields to include in a alpha-numeric based search
144
- 'searchFieldsOut' => {'id'=>true}, #Black list of fields to include in a alpha-numeric based search (default `id` to NEVER search when alpha seach)
140
+ #
141
+ # Export
142
+ #
143
+ 'showExport' => true,
145
144
 
146
- #
147
- # Export
148
- #
149
- 'showExport' => true,
145
+ #
146
+ # Group By Box
147
+ #
148
+ 'groupByItems' => [], #array of strings (each a new "select option")
149
+ 'groupBySelected' => false, #initially selected grouping - defaults to first in list if not
150
+ 'groupByLabel' => 'Group By',
150
151
 
151
- #
152
- # Group By Box
153
- #
154
- 'groupByItems' => [], #array of strings (each a new "select option")
155
- 'groupBySelected' => false, #initially selected grouping - defaults to first in list if not
156
- 'groupByLabel' => 'Group By',
157
152
 
153
+ #
154
+ # Advanced searching
155
+ #
156
+ 'list_search_form' => '', #The HTML form used for the advanced search drop down
157
+ 'list_search_attribs' => {}, #widgetinput "search_ahead" attributes
158
158
 
159
- #
160
- # Advanced searching
161
- #
162
- 'list_search_form' => '', #The HTML form used for the advanced search drop down
163
- 'list_search_attribs' => {}, #widgetinput "search_ahead" attributes
159
+ #
160
+ # Column Specific
161
+ #
162
+ 'columnStyle' => {},
163
+ 'columnClass' => {},
164
+ 'columnPopupTitle' => {},
165
+ 'columnSort' => {},
166
+ 'columnWidth' => {},
167
+ 'columnNoSort' => {},
168
+ 'columnFilter' => {},
164
169
 
165
- #
166
- # Column Specific
167
- #
168
- 'columnStyle' => {},
169
- 'columnClass' => {},
170
- 'columnPopupTitle' => {},
171
- 'columnSort' => {},
172
- 'columnWidth' => {},
173
- 'columnNoSort' => {},
174
- 'columnFilter' => {},
170
+ #
171
+ # Column Border (on right)
172
+ #
173
+ 'borderedColumns' => false,
174
+ 'borderColumnStyle' => '1px solid #CCCCCC',
175
175
 
176
- #
177
- # Row specifics
178
- #
179
- 'rowColor' => '#FFFFFF',
180
- 'rowClass' => '',
181
- 'rowColorByStatus' => {},
182
- 'rowStylesByStatus' => {},
183
- 'offsetRows' => true,
184
- 'rowOffsets' => ['FFFFFF','FFFFFF'],
185
-
186
- 'class' => 'listContainerPassive',
187
- 'tableclass' => '',
188
- 'noDataMessage' => 'Currently no data.',
189
- 'useSort' => true,
190
- 'headerClass' => {},
191
- 'groupBy' => '',
192
- 'fieldFunction' => {},
193
- 'buttonVal' => 'templateListJump',
194
- 'linkFunction' => 'ButtonLinkPost',
195
- 'template' => '',
196
- 'templateFilter' => '',
197
- 'pagerFull' => true,
198
- 'LIST_COL_SORT_ORDER' => 'ASC',
199
- 'LIST_COL_SORT' => '',
200
- 'LIST_FILTER_ALL' => '',
201
- 'ROW_LIMIT' => '',
202
- 'LIST_SEQUENCE' => 1,
203
- 'NEW_SEARCH' => false,
176
+ #
177
+ # Row specifics
178
+ #
179
+ 'rowColor' => '#FFFFFF',
180
+ 'rowClass' => '',
181
+ 'rowColorByStatus' => {},
182
+ 'rowStylesByStatus' => {},
183
+ 'offsetRows' => true,
184
+ 'rowOffsets' => ['FFFFFF','FFFFFF'],
185
+
186
+ 'class' => 'listContainerPassive',
187
+ 'tableclass' => 'tableBlowOutPreventer',
188
+ 'noDataMessage' => 'Currently no data.',
189
+ 'useSort' => true,
190
+ 'headerClass' => {},
191
+ 'groupBy' => '',
192
+ 'fieldFunction' => {},
193
+ 'buttonVal' => 'templateListJump',
194
+ 'linkFunction' => 'ButtonLinkPost',
195
+ 'template' => '',
196
+ 'templateFilter' => '',
197
+ 'pagerFull' => true,
198
+ 'LIST_COL_SORT_ORDER' => 'ASC',
199
+ 'LIST_COL_SORT' => '',
200
+ 'LIST_FILTER_ALL' => '',
201
+ 'ROW_LIMIT' => '',
202
+ 'LIST_SEQUENCE' => 1,
203
+ 'NEW_SEARCH' => false,
204
204
 
205
- #
206
- # Checkbox
207
- #
208
- 'checked_class' => 'widgetlist-checkbox',
209
- 'checked_flag' => {},
205
+ #
206
+ # Checkbox
207
+ #
208
+ 'checked_class' => 'widgetlist-checkbox',
209
+ 'checked_flag' => {},
210
210
 
211
- #
212
- # Hooks
213
- #
214
- 'column_hooks' => {},
215
- 'row_hooks' => {}
211
+ #
212
+ # Hooks
213
+ #
214
+ 'column_hooks' => {},
215
+ 'row_hooks' => {}
216
216
  }
217
217
 
218
218
  @csv = []
@@ -231,94 +231,97 @@ module WidgetList
231
231
  @templateFill = {}
232
232
  @results = {}
233
233
 
234
+ #the main template and outer shell
234
235
  @items.deep_merge!({'template' =>
235
- '
236
- <!--HEADER-->
237
- <div class="<!--CLASS-->" id="<!--NAME-->">
238
- <table class="list <!--TABLE_CLASS-->" style="<!--INLINE_STYLE-->" border="0" width="100%" cellpadding="0" cellspacing="0">
239
- <!--LIST_TITLE-->
240
- <tr class="list_header"><!--HEADERS--></tr>
241
- <!--DATA-->
242
- <tr>
243
- <td colspan="<!--COLSPAN_FULL-->" align="left" style="padding:0px;margin:0px;text-align:left">
244
- <div style="background-color:#ECECEC;height:50px;"><div style="padding:10px"><!--CUSTOM_CONTENT--></div>
245
- </td>
246
- </tr>
247
- </table>
248
- <div class="pagination" style="float:left;text-align:left;width:100%;margin:0px;padding:0px;"><div style="margin:auto;float:left;margin:0px;padding:0px;"><!--PAGINATION_LIST--></div></div>
249
- <!--FILTER-->
250
- <input type="hidden" name="<!--JUMP_URL_NAME-->" id="<!--JUMP_URL_NAME-->" value="<!--JUMP_URL-->">
251
- </div>
252
- '
236
+ '
237
+ <!--WRAP_START-->
238
+ <!--HEADER-->
239
+ <div class="<!--CLASS-->" id="<!--NAME-->">
240
+ <table class="widget_list <!--TABLE_CLASS-->" style="<!--INLINE_STYLE-->" border="0" width="100%" cellpadding="0" cellspacing="0">
241
+ <!--LIST_TITLE-->
242
+ <tr class="widget_list_header"><!--HEADERS--></tr>
243
+ <!--DATA-->
244
+ <tr>
245
+ <td colspan="<!--COLSPAN_FULL-->" align="left" style="padding:0px;margin:0px;text-align:left">
246
+ <div style="background-color:#ECECEC;height:50px;"><div style="padding:10px"><!--CUSTOM_CONTENT--></div>
247
+ </td>
248
+ </tr>
249
+ </table>
250
+ <div class="pagination" style="float:left;text-align:left;width:100%;margin:0px;padding:0px;"><div style="margin:auto;float:left;margin:0px;padding:0px;"><!--PAGINATION_LIST--></div></div>
251
+ <!--FILTER-->
252
+ <input type="hidden" name="<!--JUMP_URL_NAME-->" id="<!--JUMP_URL_NAME-->" value="<!--JUMP_URL-->">
253
+ </div>
254
+ <!--WRAP_END-->
255
+ '
253
256
  })
254
257
 
255
258
  @items.deep_merge!({'row' =>
256
- '
259
+ '
257
260
  <tr style="background-color:<!--BGCOLOR-->;<!--ROWSTYLE-->" class="<!--ROWCLASS-->"><!--CONTENT--></tr>
258
- '
261
+ '
259
262
  })
260
263
 
261
264
  @items.deep_merge!({'list_description' =>
262
- '
265
+ '
263
266
  <tr class="summary">
264
- <td id="<!--LIST_NAME-->_list_description" class="header" style="text-align:left;padding-bottom:5px;padding-top:5px;" colspan="<!--COLSPAN-->"><!--LIST_DESCRIPTION--></td>
267
+ <td id="<!--LIST_NAME-->_list_description" class="header" style="text-align: left;padding-bottom: 2px;padding-top: 7px;font-size: 20px;" colspan="<!--COLSPAN-->"><!--LIST_DESCRIPTION--></td>
265
268
  </tr>
266
- '
269
+ '
267
270
  })
268
271
 
269
272
  @items.deep_merge!({'col' =>
270
- '
273
+ '
271
274
  <td class="<!--CLASS-->" align="<!--ALIGN-->" title="<!--TITLE-->" onclick="<!--ONCLICK-->" style="<!--STYLE-->"><!--CONTENT--></td>
272
- '
275
+ '
273
276
  })
274
277
 
275
278
  @items.deep_merge!({'templateSequence' =>
276
- '
279
+ '
277
280
  <!--LIST_SEQUENCE--> of <!--TOTAL_PAGES-->
278
- '
281
+ '
279
282
  })
280
283
  #Sorting
281
284
  #
282
285
  @items.deep_merge!({'templateSortColumn' =>
283
- '
284
- <td style="font-weight:bold;<!--INLINE_STYLE-->" id="<!--COL_HEADER_ID-->" class="<!--COL_HEADER_CLASS-->" valign="middle"><span onclick="<!--FUNCTION-->(\'<!--COLSORTURL-->\',\'<!--NAME-->\')" style="cursor:pointer;background:none;" title="<!--TITLE_POPUP-->"><!--TITLE--><!--COLSORTICON-></span></td>
285
- '
286
+ '
287
+ <td style="font-weight:bold;<!--INLINE_STYLE--><!--INLINE_STYLE-->" id="<!--COL_HEADER_ID-->" class="<!--COL_HEADER_CLASS-->" valign="middle"><span onclick="<!--FUNCTION-->(\'<!--COLSORTURL-->\',\'<!--NAME-->\')" style="cursor:pointer;background:none;" title="<!--TITLE_POPUP-->"><!--TITLE--><!--COLSORTICON-></span></td>
288
+ '
286
289
  })
287
290
 
288
291
  @items.deep_merge!({'templateNoSortColumn' =>
289
- '
292
+ '
290
293
  <td style="font-weight:bold;<!--INLINE_STYLE-->" title="<!--TITLE_POPUP-->" id="<!--COL_HEADER_ID-->" class="<!--COL_HEADER_CLASS-->" valign="middle"><span style="background:none;"><!--TITLE--></span></td>
291
- '
294
+ '
292
295
  })
293
296
 
294
297
  @items.deep_merge!({'statement' =>
295
- {'select'=>
296
- {'view' =>
297
- '
298
- SELECT <!--FIELDS--> FROM <!--SOURCE--> <!--WHERE--> <!--GROUPBY--> <!--ORDERBY--> <!--LIMIT-->
299
- '
300
- }
301
- }
298
+ {'select'=>
299
+ {'view' =>
300
+ '
301
+ SELECT <!--FIELDS--> FROM <!--SOURCE--> <!--WHERE--> <!--GROUPBY--> <!--ORDERBY--> <!--LIMIT-->
302
+ '
303
+ }
304
+ }
302
305
  })
303
306
 
304
307
  @items.deep_merge!({'statement' =>
305
- {'count'=>
306
- {'view' =>
307
- '
308
- SELECT count(1) total FROM <!--VIEW--> <!--WHERE-->
309
- '
310
- }
311
- }
308
+ {'count'=>
309
+ {'view' =>
310
+ '
311
+ SELECT count(1) total FROM <!--VIEW--> <!--WHERE-->
312
+ '
313
+ }
314
+ }
312
315
  })
313
316
 
314
317
  #Pagintion
315
318
  #
316
319
 
317
320
  @items.deep_merge!({'template_pagination_wrapper' =>
318
- '
321
+ '
319
322
  <ul id="pagination" class="page_legacy">
320
323
  Page <!--PREVIOUS_BUTTON-->
321
- <input type="text" value="<!--SEQUENCE-->" size="1" style="width:15px;padding:0px;font-size:10px;">
324
+ <input type="text" value="<!--SEQUENCE-->" size="1" style="width:15px;padding:0px;font-size:10px;" onblur="">
322
325
  <input type="hidden" id="<!--LIST_NAME-->_total_rows" value="<!--TOTAL_ROWS-->">
323
326
  <!--NEXT_BUTTON--> of <!--TOTAL_PAGES--> pages <span style="margin-left:20px">Total <!--TOTAL_ROWS--> records found</span>
324
327
  <span style="padding-left:20px;">Show <!--PAGE_SEQUENCE_JUMP_LIST--> per page</span>
@@ -327,37 +330,37 @@ module WidgetList
327
330
  })
328
331
 
329
332
  @items.deep_merge!({'template_pagination_next_active' =>
330
- "
333
+ "
331
334
  <li><span onclick=\"<!--FUNCTION-->('<!--NEXT_URL-->','<!--LIST_NAME-->')\" style=\"cursor:pointer;background: transparent url(<!--HTTP_SERVER-->images/page-next.gif) no-repeat\">&nbsp;</span></li>
332
335
  "
333
336
  })
334
337
 
335
338
  @items.deep_merge!({'template_pagination_next_disabled' =>
336
- "
339
+ "
337
340
  <li><span style=\"opacity:0.4;filter:alpha(opacity=40);background: transparent url(<!--HTTP_SERVER-->images/page-next.gif) no-repeat\">&nbsp;</span></li>
338
341
  "
339
342
  })
340
343
 
341
344
  @items.deep_merge!({'template_pagination_previous_active' =>
342
- "
345
+ "
343
346
  <li><span onclick=\"<!--FUNCTION-->('<!--PREVIOUS_URL-->','<!--LIST_NAME-->')\" style=\"cursor:pointer;background: transparent url(<!--HTTP_SERVER-->images/page-back.gif) no-repeat\">&nbsp;</span></li>
344
347
  "
345
348
  })
346
349
 
347
350
  @items.deep_merge!({'template_pagination_previous_disabled' =>
348
- "
351
+ "
349
352
  <li><span style=\"opacity:0.4;filter:alpha(opacity=40);background: transparent url(<!--HTTP_SERVER-->images/page-back.gif) no-repeat\">&nbsp;</span></li>
350
353
  "
351
354
  })
352
355
 
353
356
  @items.deep_merge!({'template_pagination_jump_active' =>
354
- '
357
+ '
355
358
  <li><div class="active"><!--SEQUENCE--></div></li>
356
359
  '
357
360
  })
358
361
 
359
362
  @items.deep_merge!({'template_pagination_jump_unactive' =>
360
- '
363
+ '
361
364
  <li onclick="<!--FUNCTION-->(\'<!--JUMP_URL-->\',\'<!--LIST_NAME-->\')"><div><!--SEQUENCE--></div></li>
362
365
  '
363
366
  })
@@ -369,13 +372,13 @@ module WidgetList
369
372
 
370
373
  if WidgetList::List.get_database.db_type == 'oracle'
371
374
  @items.deep_merge!({'statement' =>
372
- {'select'=>
373
- {'view' =>
374
- '
375
- SELECT <!--FIELDS-->, rn FROM ( SELECT ' + ( (!@items['view'].include?('(')) ? '<!--SOURCE-->' : @items['view'].strip.split(" ").last ) + '.*, rank() over (<!--ORDERBY-->) rn FROM <!--SOURCE--> ) a <!--WHERE--> <!--GROUPBY--> <!--ORDERBY--> <!--LIMIT-->
376
- '
377
- }
378
- }
375
+ {'select'=>
376
+ {'view' =>
377
+ '
378
+ SELECT <!--FIELDS-->, rn FROM ( SELECT ' + ( (!@items['view'].include?('(')) ? '<!--SOURCE-->' : @items['view'].strip.split(" ").last ) + '.*, rank() over (<!--ORDERBY-->) rn FROM <!--SOURCE--> ) a <!--WHERE--> <!--GROUPBY--> <!--ORDERBY--> <!--LIMIT-->
379
+ '
380
+ }
381
+ }
379
382
  })
380
383
 
381
384
  end
@@ -604,17 +607,13 @@ module WidgetList
604
607
 
605
608
  if ! $_REQUEST.key?('BUTTON_VALUE') && !@items['title'].empty?
606
609
  @items['templateHeader'] = '
607
- <h1><!--TITLE--></h1><div class="horizontal_rule"></div>
608
- <!--FILTER_HEADER-->
609
- '
610
- else
611
- if !$_REQUEST.key?('BUTTON_VALUE')
612
- # Only if not in ajax would we want to output the filter header
613
- #
614
- @items['templateHeader'] = '
615
- <!--FILTER_HEADER-->
616
- '
617
- end
610
+ <h1><!--TITLE--></h1><div class="horizontal_rule"></div>
611
+ <!--FILTER_HEADER-->
612
+ '
613
+ elsif !$_REQUEST.key?('BUTTON_VALUE')
614
+ # Only if not in ajax would we want to output the filter header
615
+ #
616
+ @items['templateHeader'] = '<!--FILTER_HEADER-->'
618
617
  end
619
618
 
620
619
  # Build the filter (If any)
@@ -771,6 +770,14 @@ module WidgetList
771
770
  $_SESSION['ROW_LIMIT'].delete(@items['name'])
772
771
  end
773
772
 
773
+ if $_SESSION.key?('DRILL_DOWNS') && $_SESSION['DRILL_DOWNS'].key?(@items['name'])
774
+ $_SESSION['DRILL_DOWNS'].delete(@items['name'])
775
+ end
776
+
777
+ if $_SESSION.key?('DRILL_DOWN_FILTERS') && $_SESSION['DRILL_DOWN_FILTERS'].key?(@items['name'])
778
+ $_SESSION['DRILL_DOWN_FILTERS'].delete(@items['name'])
779
+ end
780
+
774
781
  if all && $_SESSION.key?('SEARCH_FILTER')
775
782
  $_SESSION.delete('SEARCH_FILTER')
776
783
  end
@@ -810,19 +817,19 @@ module WidgetList
810
817
  WidgetList::List::clear_check_box_session(listId)
811
818
  end
812
819
 
813
- if $_REQUEST.key?('drill_down')
820
+ if $_REQUEST.key?('drill_down') && !$_REQUEST.key?('searchClear')
814
821
  drillDown = $_REQUEST['drill_down']
815
- $_SESSION.deep_merge!({'DRILL_DOWNS' => { listId => drillDown} })
816
- elsif $_SESSION.key?('DRILL_DOWNS') && $_SESSION['DRILL_DOWNS'].key?(listId)
822
+ $_SESSION.deep_merge!({'DRILL_DOWNS' => { listId => drillDown} }) && !$_REQUEST.key?('searchClear')
823
+ elsif $_SESSION.key?('DRILL_DOWNS') && $_SESSION['DRILL_DOWNS'].key?(listId) && !$_REQUEST.key?('searchClear')
817
824
  drillDown = $_SESSION['DRILL_DOWNS'][listId]
818
825
  else
819
826
  drillDown = 'default'
820
827
  end
821
828
 
822
- if $_REQUEST.key?('filter')
829
+ if $_REQUEST.key?('filter') && !$_REQUEST.key?('searchClear')
823
830
  filter = $_REQUEST['filter']
824
831
  $_SESSION.deep_merge!({'DRILL_DOWN_FILTERS' => { listId => filter} })
825
- elsif $_SESSION.key?('DRILL_DOWN_FILTERS') && $_SESSION['DRILL_DOWN_FILTERS'].key?(listId)
832
+ elsif $_SESSION.key?('DRILL_DOWN_FILTERS') && $_SESSION['DRILL_DOWN_FILTERS'].key?(listId) && !$_REQUEST.key?('searchClear')
826
833
  filter = $_SESSION['DRILL_DOWN_FILTERS'][listId]
827
834
  end
828
835
  return drillDown, filter
@@ -906,6 +913,21 @@ module WidgetList
906
913
  listJumpUrl['list_action'] = @items['ajax_action']
907
914
  end
908
915
 
916
+ if $_REQUEST.key?('switch_grouping')
917
+ listJumpUrl['switch_grouping'] = $_REQUEST['switch_grouping']
918
+ end
919
+
920
+
921
+
922
+
923
+ @templateFill['<!--WRAP_START-->'] = ''
924
+ @templateFill['<!--WRAP_END-->'] = ''
925
+ if !$_REQUEST.key?('BUTTON_VALUE')
926
+ @templateFill['<!--WRAP_START-->'] = '<div class="widget_list_outer">
927
+ <input type="hidden" id="<!--NAME-->_jump_url_original" value="<!--JUMP_URL-->"/>'
928
+ @templateFill['<!--WRAP_END-->'] = '</div>'
929
+ end
930
+
909
931
  @templateFill['<!--HEADER-->'] = @items['templateHeader']
910
932
  @templateFill['<!--TITLE-->'] = @items['title']
911
933
  @templateFill['<!--NAME-->'] = @items['name']
@@ -919,6 +941,7 @@ module WidgetList
919
941
  else
920
942
  @templateFill['<!--INLINE_STYLE-->'] = 'table-layout:auto;'
921
943
  end
944
+
922
945
  #Filter form
923
946
  #
924
947
  if @items['showSearch'] === true
@@ -947,6 +970,9 @@ module WidgetList
947
970
  filterParameters['list_action'] = @items['ajax_action']
948
971
  end
949
972
 
973
+ if $_REQUEST.key?('switch_grouping')
974
+ filterParameters['switch_grouping'] = $_REQUEST['switch_grouping']
975
+ end
950
976
  searchUrl = WidgetList::Utils::build_url(@items['pageId'], filterParameters, (!$_REQUEST.key?('BUTTON_VALUE')))
951
977
 
952
978
  list_search = {}
@@ -972,12 +998,12 @@ module WidgetList
972
998
  list_search['name'] = 'list_search_name_' + @items['name']
973
999
  list_search['class'] = 'inputOuter widget-search-outer ' + @items['name'].downcase + '-search'
974
1000
  list_search['search_ahead'] = {
975
- 'url' => searchUrl,
976
- 'skip_queue' => false,
977
- 'target' => @items['name'],
978
- 'search_form' => @items['list_search_form'],
979
- 'onclick' => (! @items['searchOnclick'].empty? && ! @items['list_search_form'].empty?) ? @items['searchOnclick'] : '',
980
- 'onkeyup' => (! @items['searchOnkeyup'].empty?) ? @items['searchOnkeyup'] : ''
1001
+ 'url' => searchUrl,
1002
+ 'skip_queue' => false,
1003
+ 'target' => @items['name'],
1004
+ 'search_form' => @items['list_search_form'],
1005
+ 'onclick' => (! @items['searchOnclick'].empty? && ! @items['list_search_form'].empty?) ? @items['searchOnclick'] : '',
1006
+ 'onkeyup' => (! @items['searchOnkeyup'].empty?) ? @items['searchOnkeyup'] : ''
981
1007
  }
982
1008
 
983
1009
  @templateFill['<!--FILTER_HEADER-->'] = WidgetList::Widgets::widget_input(list_search)
@@ -1021,12 +1047,12 @@ module WidgetList
1021
1047
  }
1022
1048
 
1023
1049
  list_group['search_ahead'] = {
1024
- 'skip_queue' => false,
1025
- 'search_form'=> '
1050
+ 'skip_queue' => false,
1051
+ 'search_form'=> '
1026
1052
  <div id="advanced-search-container" style="height:100% !important;">
1027
1053
  ' + groupRows.join("\n") + '
1028
1054
  </div>',
1029
- 'onclick' => @items['searchOnclick']
1055
+ 'onclick' => @items['searchOnclick']
1030
1056
  }
1031
1057
  if !@templateFill.key?('<!--FILTER_HEADER-->')
1032
1058
  @templateFill['<!--FILTER_HEADER-->'] = ''
@@ -1102,6 +1128,10 @@ module WidgetList
1102
1128
  urlTags['list_action'] = @items['ajax_action']
1103
1129
  end
1104
1130
 
1131
+ if $_REQUEST.key?('switch_grouping')
1132
+ urlTags['switch_grouping'] = $_REQUEST['switch_grouping']
1133
+ end
1134
+
1105
1135
  if (@sequence == @totalPages || ! (@totalPages > 0))
1106
1136
  showNext = false
1107
1137
  else
@@ -1127,11 +1157,11 @@ module WidgetList
1127
1157
  #Assemble navigation buttons
1128
1158
  #
1129
1159
  pieces = {
1130
- '<!--NEXT_URL-->' => nextUrl,
1131
- '<!--LIST_NAME-->' => @items['name'],
1132
- '<!--HTTP_SERVER-->' => $_SERVER['rack.url_scheme'] + '://' + $_SERVER['HTTP_HOST'] + '/assets/',
1133
- '<!--PREVIOUS_URL-->' => prevUrl,
1134
- '<!--FUNCTION-->' => @items['ajax_function']
1160
+ '<!--NEXT_URL-->' => nextUrl,
1161
+ '<!--LIST_NAME-->' => @items['name'],
1162
+ '<!--HTTP_SERVER-->' => $_SERVER['rack.url_scheme'] + '://' + $_SERVER['HTTP_HOST'] + '/assets/',
1163
+ '<!--PREVIOUS_URL-->' => prevUrl,
1164
+ '<!--FUNCTION-->' => @items['ajax_function']
1135
1165
  }
1136
1166
 
1137
1167
  templates['btn_next'] = WidgetList::Utils::fill(pieces,templates['btn_next'])
@@ -1145,6 +1175,10 @@ module WidgetList
1145
1175
  urlTags['LIST_SEQUENCE'] = @sequence
1146
1176
  urlTags['ROW_LIMIT'] = 10
1147
1177
 
1178
+ if $_REQUEST.key?('switch_grouping')
1179
+ urlTags['switch_grouping'] = $_REQUEST['switch_grouping']
1180
+ end
1181
+
1148
1182
  # Automate select box and rules
1149
1183
  #
1150
1184
  rowLimitSelect = [10,20,50,100,500,1000]
@@ -1231,14 +1265,14 @@ module WidgetList
1231
1265
  end
1232
1266
 
1233
1267
  pieces = {
1234
- '<!--PREVIOUS_BUTTON-->' => templates['btn_previous'],
1235
- '<!--SEQUENCE-->' => @sequence,
1236
- '<!--NEXT_BUTTON-->' => templates['btn_next'],
1237
- '<!--TOTAL_PAGES-->' => @totalPages,
1238
- '<!--TOTAL_ROWS-->' => @totalRows,
1239
- '<!--PAGE_SEQUENCE_JUMP_LIST-->' => pageSelect,
1240
- '<!--JUMP-->' => jumpSection.join(''),
1241
- '<!--LIST_NAME-->' => @items['name'],
1268
+ '<!--PREVIOUS_BUTTON-->' => templates['btn_previous'],
1269
+ '<!--SEQUENCE-->' => @sequence,
1270
+ '<!--NEXT_BUTTON-->' => templates['btn_next'],
1271
+ '<!--TOTAL_PAGES-->' => @totalPages,
1272
+ '<!--TOTAL_ROWS-->' => @totalRows,
1273
+ '<!--PAGE_SEQUENCE_JUMP_LIST-->' => pageSelect,
1274
+ '<!--JUMP-->' => jumpSection.join(''),
1275
+ '<!--LIST_NAME-->' => @items['name'],
1242
1276
  }
1243
1277
 
1244
1278
  paginationOutput = WidgetList::Utils::fill(pieces,@items['template_pagination_wrapper'])
@@ -1275,6 +1309,10 @@ module WidgetList
1275
1309
  end
1276
1310
  end
1277
1311
 
1312
+ if @items['borderedColumns']
1313
+ colWidthStyle += 'border-right: ' + @items['borderColumnStyle'] + ';'
1314
+ end
1315
+
1278
1316
  $_SESSION.deep_merge!({'LIST_SEQUENCE' => { @sqlHash => @sequence} })
1279
1317
 
1280
1318
  #Hover Title
@@ -1351,7 +1389,7 @@ module WidgetList
1351
1389
 
1352
1390
  if (
1353
1391
  ( (@items.key?('LIST_COL_SORT') && !@items['LIST_COL_SORT'].empty?) && @items['LIST_COL_SORT'] == colSort['LIST_COL_SORT']) ||
1354
- ( $_SESSION.key?('LIST_COL_SORT') && $_SESSION['LIST_COL_SORT'].key?(@sqlHash) && $_SESSION['LIST_COL_SORT'][@sqlHash].key?(field))
1392
+ ( $_SESSION.key?('LIST_COL_SORT') && $_SESSION['LIST_COL_SORT'].key?(@sqlHash) && $_SESSION['LIST_COL_SORT'][@sqlHash].key?(field))
1355
1393
  )
1356
1394
  changedSession = false
1357
1395
  if @items.key?('LIST_COL_SORT') && !@items['LIST_COL_SORT'].empty?
@@ -1390,6 +1428,10 @@ module WidgetList
1390
1428
  end
1391
1429
  end
1392
1430
 
1431
+ if $_REQUEST.key?('switch_grouping')
1432
+ colSort['switch_grouping'] = $_REQUEST['switch_grouping']
1433
+ end
1434
+
1393
1435
  if @items.key?('ajax_action') && ! @items['ajax_action'].empty?
1394
1436
  colSort['list_action'] = @items['ajax_action']
1395
1437
  end
@@ -1554,7 +1596,11 @@ module WidgetList
1554
1596
  return content
1555
1597
  end
1556
1598
 
1557
- def self.build_drill_down_link(listId,drillDownName,dataToPassFromView,columnToShow,columnAlias='',functionName='ListDrillDown',columnClass='')
1599
+ def self.drill_down_back(list_name='')
1600
+ '<div class="goback" onclick="ListHome(\'' + list_name + '\');" title="Go Back"></div>'
1601
+ end
1602
+
1603
+ def self.build_drill_down_link(listId,drillDownName,dataToPassFromView,columnToShow,columnAlias='',functionName='ListDrillDown',columnClass='',color='blue')
1558
1604
  if columnAlias.empty?
1559
1605
  columnAlias = columnToShow
1560
1606
  end
@@ -1563,15 +1609,14 @@ module WidgetList
1563
1609
  columnClass = ' "' + WidgetList::List::concat_string() + columnClass + WidgetList::List::concat_string() + '"'
1564
1610
  end
1565
1611
 
1566
- return %[#{WidgetList::List::concat_inner()}"<a style='cursor:pointer;color:blue;' class='#{columnAlias}_drill#{columnClass}' onclick='#{functionName}(#{WidgetList::List::double_quote()}#{drillDownName}#{WidgetList::List::double_quote()},#{WidgetList::List::double_quote()}"#{WidgetList::List::concat_string()} #{dataToPassFromView} #{WidgetList::List::concat_string()} "#{WidgetList::List::double_quote()},#{WidgetList::List::double_quote()}#{listId}#{WidgetList::List::double_quote()})'>"#{WidgetList::List::concat_string()}#{columnToShow}#{WidgetList::List::concat_string()}"</a>"#{WidgetList::List::concat_outer()} as #{columnAlias},]
1612
+ link = %[#{WidgetList::List::concat_inner()}"<a style='cursor:pointer;color:#{color};' class='#{columnAlias}_drill#{columnClass}' onclick='#{functionName}(#{WidgetList::List::double_quote()}#{drillDownName}#{WidgetList::List::double_quote()}, ListDrillDownGetRowValue(this) ,#{WidgetList::List::double_quote()}#{listId}#{WidgetList::List::double_quote()});'>"#{WidgetList::List::concat_string()}#{columnToShow}#{WidgetList::List::concat_string()}"</a><script class='val-db' type='text'>"#{WidgetList::List::concat_string()} #{dataToPassFromView} #{WidgetList::List::concat_string()}"</script>"#{WidgetList::List::concat_outer()} as #{columnAlias},]
1567
1613
  end
1568
1614
 
1569
1615
  def self.concat_string
1570
1616
  case WidgetList::List.get_database.db_type
1571
1617
  when 'mysql'
1572
1618
  ' , '
1573
- when 'oracle'
1574
- when 'sqlite'
1619
+ when 'oracle','sqlite'
1575
1620
  ' || '
1576
1621
  else
1577
1622
  ','
@@ -1582,8 +1627,7 @@ module WidgetList
1582
1627
  case WidgetList::List.get_database.db_type
1583
1628
  when 'mysql'
1584
1629
  '\\"'
1585
- when 'oracle'
1586
- when 'sqlite'
1630
+ when 'oracle','sqlite'
1587
1631
  '""'
1588
1632
  else
1589
1633
  '"'
@@ -1629,15 +1673,15 @@ module WidgetList
1629
1673
  if @results.key?(tag.upcase) && @results[tag.upcase][j]
1630
1674
 
1631
1675
  buttonAttribs.deep_merge!({'args' =>
1632
- {
1633
- tagName => @results[tag.upcase][j]
1634
- }
1676
+ {
1677
+ tagName => @results[tag.upcase][j]
1678
+ }
1635
1679
  })
1636
1680
  else
1637
1681
  buttonAttribs.deep_merge!({'args' =>
1638
- {
1639
- tagName => tag
1640
- }
1682
+ {
1683
+ tagName => tag
1684
+ }
1641
1685
  })
1642
1686
  end
1643
1687
  }
@@ -1876,7 +1920,7 @@ module WidgetList
1876
1920
  if !@items['rowStylesByStatus'].empty? && @items['rowStylesByStatus'].key?(column) && !@items['rowStylesByStatus'][column].empty?
1877
1921
  @items['rowStylesByStatus'][column].each { |status,inlineStyle|
1878
1922
  if status === content
1879
- customRowStyle = color
1923
+ customRowStyle = inlineStyle
1880
1924
  end
1881
1925
  }
1882
1926
  end
@@ -1887,6 +1931,11 @@ module WidgetList
1887
1931
  colPieces['<!--CLASS-->'] = colClass
1888
1932
  colPieces['<!--ALIGN-->'] = @items['collAlign']
1889
1933
  colPieces['<!--STYLE-->'] = theStyle + colWidthStyle
1934
+
1935
+ if @items['borderedColumns']
1936
+ colPieces['<!--STYLE-->'] += 'border-right: ' + @items['borderColumnStyle'] + ';'
1937
+ end
1938
+
1890
1939
  colPieces['<!--ONCLICK-->'] = onClick
1891
1940
  colPieces['<!--TITLE-->'] = contentTitle #todo htmlentities needed ?
1892
1941
  colPieces['<!--CONTENT-->'] = content
@@ -1926,7 +1975,7 @@ module WidgetList
1926
1975
  pieces['<!--ROWCLASS-->'] = @items['rowClass']
1927
1976
  else
1928
1977
  pieces['<!--BGCOLOR-->'] = !customRowColor.empty? ? customRowColor : @items['rowColor']
1929
- pieces['<!--ROWSTYLE-->'] = customRowStyle.empty? ? customRowStyle : ''
1978
+ pieces['<!--ROWSTYLE-->'] = !customRowStyle.empty? ? customRowStyle : ''
1930
1979
  pieces['<!--ROWCLASS-->'] = @items['rowClass']
1931
1980
  end
1932
1981
  rows << WidgetList::Utils::fill(pieces, @items['row'])
@@ -2020,12 +2069,16 @@ module WidgetList
2020
2069
  pieces['<!--GROUPBY-->'] += ' GROUP BY ' + @items['groupBy']
2021
2070
  end
2022
2071
 
2023
- if !@items['LIST_COL_SORT'].empty? || $_SESSION.key?('LIST_COL_SORT') && $_SESSION['LIST_COL_SORT'].class.name == 'Hash' && $_SESSION['LIST_COL_SORT'].key?(@sqlHash)
2072
+ if !@items['LIST_COL_SORT'].empty? || ($_SESSION.key?('LIST_COL_SORT') && $_SESSION['LIST_COL_SORT'].class.name == 'Hash' && $_SESSION['LIST_COL_SORT'].key?(@sqlHash))
2024
2073
  if ! @items['LIST_COL_SORT'].empty?
2025
- pieces['<!--ORDERBY-->'] += ' ORDER BY ' + tick_field() + @items['LIST_COL_SORT'] + tick_field() + " " + @items['LIST_COL_SORT_ORDER']
2074
+ if @items['fields'].key?(@items['LIST_COL_SORT'])
2075
+ pieces['<!--ORDERBY-->'] += ' ORDER BY ' + tick_field() + @items['LIST_COL_SORT'] + tick_field() + " " + @items['LIST_COL_SORT_ORDER']
2076
+ end
2026
2077
  else
2027
2078
  $_SESSION['LIST_COL_SORT'][@sqlHash].each_with_index { |order,void|
2028
- pieces['<!--ORDERBY-->'] += ' ORDER BY ' + tick_field() + order[0] + tick_field() + " " + order[1]
2079
+ if @items['fields'].key?(order[0])
2080
+ pieces['<!--ORDERBY-->'] += ' ORDER BY ' + tick_field() + order[0] + tick_field() + " " + order[1]
2081
+ end
2029
2082
  } if $_SESSION.key?('LIST_COL_SORT') && $_SESSION['LIST_COL_SORT'].class.name == 'Hash' && $_SESSION['LIST_COL_SORT'].key?(@sqlHash)
2030
2083
  end
2031
2084
 
@@ -2055,7 +2108,7 @@ module WidgetList
2055
2108
  and_where = ' WHERE '
2056
2109
  end
2057
2110
  pieces['<!--WHERE-->'] += and_where +
2058
- '
2111
+ '
2059
2112
  (
2060
2113
  a.rn >= :LOW
2061
2114
  AND
@@ -2102,7 +2155,7 @@ module WidgetList
2102
2155
 
2103
2156
  if ! sql.empty?
2104
2157
  if @items['showPagination']
2105
- if WidgetList::List.get_database._select(sql, [], @items['bindVarsLegacy']) > 0
2158
+ if WidgetList::List.get_database._select(sql, @items['bindVars'], @items['bindVarsLegacy']) > 0
2106
2159
  rows = WidgetList::List.get_database.final_results['TOTAL'][0]
2107
2160
  else
2108
2161
  rows = 0