widget_list 1.2.3 → 1.2.4

Sign up to get free protection for your applications and to get access to all the features.
data/lib/widget_list.rb CHANGED
@@ -18,7 +18,7 @@ module WidgetList
18
18
  #
19
19
  def self.go!()
20
20
  if $_REQUEST.key?('iframe')
21
- eval(WidgetList::Administration.new.translate_config_to_code(true))
21
+ eval(WidgetList::Administration.new.translate_config_to_code())
22
22
  return @output
23
23
  else
24
24
  list = WidgetList::List.new()
@@ -28,6 +28,10 @@ module WidgetList
28
28
 
29
29
  class Administration
30
30
  def show_interface()
31
+ config_file = Rails.root.join("config", "widget-list-administration.json")
32
+ if config_file.file? && !$_REQUEST.key?('ajax') && !$_REQUEST.key?('name')
33
+ File.delete(Rails.root.join("config", "widget-list-administration.json"))
34
+ end
31
35
  ac = ActionController::Base.new()
32
36
  default_config = WidgetList::List::get_defaults()
33
37
  config_id, page_config = get_configuration()
@@ -59,11 +63,11 @@ module WidgetList
59
63
  #
60
64
  @fill['<!--POST_URL-->'] = $_SERVER['PATH_INFO']
61
65
  @fill['<!--BUTTONS-->'] = WidgetList::Widgets::widget_button('Step One - Start ->', {'id' => 'start' , 'onclick' => "ShowStart();" , 'innerClass' => "primary" } ) +
62
- WidgetList::Widgets::widget_button('Step Two - Fields ->', {'id' => 'fields' , 'onclick' => "ShowFields();" , 'innerClass' => "primary disabled" } ) +
63
- WidgetList::Widgets::widget_button('Step Three - Rows ->', {'id' => 'rows' , 'onclick' => "ShowRows();" , 'innerClass' => "primary disabled" } ) +
64
- WidgetList::Widgets::widget_button('Step Four - Search ->', {'id' => 'search' , 'onclick' => "ShowSearch();" , 'innerClass' => "primary disabled" } ) +
65
- WidgetList::Widgets::widget_button('Step Four - Footer Actions ->', {'id' => 'footer' , 'onclick' => "ShowFooter();" , 'innerClass' => "primary disabled" } ) +
66
- WidgetList::Widgets::widget_button('Step Five - Misc & Submit ->', {'id' => 'misc_submit', 'onclick' => "ShowSubmit();" , 'innerClass' => "success disabled" } )
66
+ WidgetList::Widgets::widget_button('Step Two - Fields ->', {'id' => 'fields' , 'onclick' => "ShowFields();" , 'innerClass' => "primary disabled" } ) +
67
+ WidgetList::Widgets::widget_button('Step Three - Rows ->', {'id' => 'rows' , 'onclick' => "ShowRows();" , 'innerClass' => "primary disabled" } ) +
68
+ WidgetList::Widgets::widget_button('Step Four - Search ->', {'id' => 'search' , 'onclick' => "ShowSearch();" , 'innerClass' => "primary disabled" } ) +
69
+ WidgetList::Widgets::widget_button('Step Four - Footer Actions ->', {'id' => 'footer' , 'onclick' => "ShowFooter();" , 'innerClass' => "primary disabled" } ) +
70
+ WidgetList::Widgets::widget_button('Step Five - Misc & Submit ->', {'id' => 'misc_submit', 'onclick' => "ShowSubmit();" , 'innerClass' => "success disabled" } )
67
71
 
68
72
 
69
73
  #
@@ -270,8 +274,8 @@ module WidgetList
270
274
  return WidgetList::Utils::fill(@fill , ac.render_to_string(:partial => 'widget_list/administration/output') )
271
275
  end
272
276
 
273
- def translate_config_to_code(tmp=false)
274
- config_id, page_config = get_configuration(tmp)
277
+ def translate_config_to_code()
278
+ config_id, page_config = get_configuration()
275
279
  fields,fields_hidden,fields_function,buttons,footer_buttons,group_by,drill_downs = normalize_configs(page_config)
276
280
  drill_down_code = ''
277
281
  case_statements = ''
@@ -393,8 +397,15 @@ module WidgetList
393
397
  end
394
398
 
395
399
  fields.each { |field,description|
400
+ conditional = ''
401
+ if page_config['useGrouping'] == '1' && page_config['showSearch'] == '1' && !group_by.empty?
402
+ conditional = ' if groupByFilter == \'none\''
403
+ if group_by.key?(field)
404
+ conditional = " if groupByFilter == 'none' || groupByFilter == 'group_#{group_by[field].gsub(/ /,'_').downcase}'"
405
+ end
406
+ end
396
407
  visible_field_code += "
397
- list_parms['fields']['#{field}'] = '#{description}'"
408
+ list_parms['fields']['#{field}'] = '#{description}' #{conditional}"
398
409
  }
399
410
 
400
411
  #------------ BUTTONS ------------
@@ -402,14 +413,13 @@ module WidgetList
402
413
  if page_config['rowButtonsOn'] == '1'
403
414
  visible_field_code += "
404
415
  list_parms['fields'][button_column_name.downcase] = button_column_name.capitalize"
405
- end
406
416
 
407
- button_code += "
417
+ button_code += "
408
418
  mini_buttons = {}
409
419
  "
410
420
 
411
- buttons.each { |field|
412
- button_code += "
421
+ buttons.each { |field|
422
+ button_code += "
413
423
  mini_buttons['button_#{field[0].downcase}'] = {'page' => '#{field[1]['url']}',
414
424
  'text' => '#{field[0]}',
415
425
  'function' => 'Redirect',
@@ -417,11 +427,12 @@ module WidgetList
417
427
  'tags' => {'all'=>'all'}
418
428
  }
419
429
  "
420
- }
430
+ }
421
431
 
422
- button_code += "
432
+ button_code += "
423
433
  list_parms['buttons'] = {button_column_name.downcase => mini_buttons}
424
434
  "
435
+ end
425
436
 
426
437
 
427
438
 
@@ -446,6 +457,10 @@ module WidgetList
446
457
  groupByDesc = '' # Initialize a variable you can use in listDescription to show what the current grouping selection is
447
458
  groupByFilter = 'none' # This variable should be used to control business logic based on the grouping and is a short hand key rather than using what is returned from get_group_by_selection
448
459
  "
460
+
461
+ visible_field_code += "
462
+ list_parms['fields']['cnt'] = 'Count' if groupByFilter != 'none'
463
+ list_parms['fieldFunction']['cnt'] = 'TO_CHAR(COUNT(1))' if groupByFilter != 'none'"
449
464
  descriptions = []
450
465
  group_by.each { |field,description|
451
466
  descriptions << "'" + description + "'"
@@ -574,17 +589,16 @@ module WidgetList
574
589
  EOD
575
590
  end
576
591
 
577
- def get_configuration(tmp=false)
578
- temp = (tmp) ? '-tmp': ''
592
+ def get_configuration()
579
593
 
580
594
  request = $_REQUEST.dup
581
595
  config_id = ''
582
596
  config_id += request['controller'] if request.key?('controller')
583
597
  config_id += request['action'] if request.key?('action')
584
- config_file = Rails.root.join("config", "widget-list-administration#{temp}.json")
598
+ config_file = Rails.root.join("config", "widget-list-administration.json")
585
599
 
586
- if config_file.file?
587
- configuration = JSON.parse(File.new(Rails.root.join("config", "widget-list-administration#{temp}.json")).read)
600
+ if config_file.file? && ($_REQUEST.key?('iframe') || $_REQUEST.key?('name'))
601
+ configuration = JSON.parse(File.new(Rails.root.join("config", "widget-list-administration.json")).read)
588
602
  else
589
603
  configuration = {}
590
604
  end
@@ -762,6 +776,7 @@ module WidgetList
762
776
  @fieldFill['<!--FIELD-->'] = 'Field'
763
777
  @fieldFill['<!--DESC-->'] = 'Desc'
764
778
  @fieldFill['<!--DISABLED-->'] = ''
779
+ @fieldFill['<!--ONBLUR1-->'] = 'InvalidField(this)'
765
780
  @response['group_by'] += WidgetList::Utils::fill(@fieldFill , ac.render_to_string(:partial => 'widget_list/administration/field_row') )
766
781
  }
767
782
 
@@ -870,17 +885,19 @@ module WidgetList
870
885
  config_id += request['controller'] if request.key?('controller')
871
886
  config_id += request['action'] if request.key?('action')
872
887
 
873
- tmp = (request.key?('ajax')) ? '-tmp': ''
874
-
875
- config_file = Rails.root.join("config", "widget-list-administration#{tmp}.json")
888
+ config_file = Rails.root.join("config", "widget-list-administration.json")
876
889
  if config_file.file?
877
- configuration = JSON.parse(File.new(Rails.root.join("config", "widget-list-administration#{tmp}.json")).read)
890
+ configuration = JSON.parse(File.new(Rails.root.join("config", "widget-list-administration.json")).read)
878
891
  else
879
892
  configuration = {}
880
893
  end
881
894
  configuration[config_id] = request
882
895
 
883
- File.open(Rails.root.join("config", "widget-list-administration#{tmp}.json"), "w") do |file|
896
+ File.open(Rails.root.join("config", "widget-list-administration.json"), "w") do |file|
897
+ file.puts configuration.to_json
898
+ end
899
+
900
+ File.open(Rails.root.join("config", "widget-list-administration-all.json"), "w") do |file|
884
901
  file.puts configuration.to_json
885
902
  end
886
903
 
@@ -970,23 +987,23 @@ module WidgetList
970
987
 
971
988
 
972
989
  @items.deep_merge!({ 'statement' =>
973
- {'select'=>
974
- {'view' =>
975
- '
990
+ {'select'=>
991
+ {'view' =>
992
+ '
976
993
  SELECT <!--FIELDS--> FROM <!--SOURCE--> <!--WHERE--> <!--GROUPBY--> <!--ORDERBY--> <!--LIMIT-->
977
994
  '
978
- }
979
- }
995
+ }
996
+ }
980
997
  })
981
998
 
982
999
  @items.deep_merge!({ 'statement' =>
983
- {'count'=>
984
- {'view' =>
985
- '
1000
+ {'count'=>
1001
+ {'view' =>
1002
+ '
986
1003
  SELECT count(1) total FROM <!--VIEW--> <!--WHERE--> <!--GROUPBY-->
987
1004
  '
988
- }
989
- }
1005
+ }
1006
+ }
990
1007
  })
991
1008
  #inject site wide configs before list specific configs if a helper exists
992
1009
 
@@ -1010,8 +1027,8 @@ module WidgetList
1010
1027
  # if no one passed a listSearchForm inject a default one to show the ransack form
1011
1028
  #
1012
1029
  fill = {
1013
- '<!--BUTTON_SEARCH-->' => WidgetList::Widgets::widget_button('Search', {'onclick' => WidgetList::List::build_search_button_click(@items), 'innerClass' => @items['defaultButtonClass'] }),
1014
- '<!--BUTTON_CLOSE-->' => "HideAdvancedSearch(this)"
1030
+ '<!--BUTTON_SEARCH-->' => WidgetList::Widgets::widget_button('Search', {'onclick' => WidgetList::List::build_search_button_click(@items), 'innerClass' => @items['defaultButtonClass'] }),
1031
+ '<!--BUTTON_CLOSE-->' => "HideAdvancedSearch(this)"
1015
1032
  }
1016
1033
  @items['listSearchForm'] = WidgetList::Utils::fill( fill , ac.render_to_string(:partial => 'widget_list/ransack_widget_list_advanced_search') )
1017
1034
 
@@ -1030,19 +1047,19 @@ module WidgetList
1030
1047
  if get_database.db_type == 'oracle'
1031
1048
 
1032
1049
  @items.deep_merge!({'statement' =>
1033
- {'count'=>
1034
- {'view' =>
1035
- '
1050
+ {'count'=>
1051
+ {'view' =>
1052
+ '
1036
1053
  SELECT count(1) total FROM <!--VIEW--> ' + ((@items['groupBy'].empty? && !@active_record_model) ? '<!--WHERE--> <!--GROUPBY-->' : '' )
1037
- }
1038
- }
1054
+ }
1055
+ }
1039
1056
  })
1040
1057
  @items.deep_merge!({'statement' =>
1041
- {'select'=>
1042
- {'view' =>
1043
- 'SELECT <!--FIELDS_PLAIN--> FROM ( SELECT a.*, DENSE_RANK() over (<!--ORDERBY-->) rn FROM ( SELECT ' + ( (!get_view().include?('(')) ? '<!--SOURCE-->' : get_view().strip.split(" ").last ) + '.* FROM <!--SOURCE--> ) a ' + ((@items['groupBy'].empty?) ? '<!--WHERE-->' : '') + ' <!--ORDERBY--> ) <!--LIMIT--> ' + ((!@active_record_model) ? '<!--GROUPBY-->' : '')
1044
- }
1045
- }
1058
+ {'select'=>
1059
+ {'view' =>
1060
+ 'SELECT <!--FIELDS_PLAIN--> FROM ( SELECT a.*, DENSE_RANK() over (<!--ORDERBY-->) rn FROM ( SELECT ' + ( (!get_view().include?('(')) ? '<!--SOURCE-->' : get_view().strip.split(" ").last ) + '.* FROM <!--SOURCE--> ) a ' + ((@items['groupBy'].empty?) ? '<!--WHERE-->' : '') + ' <!--ORDERBY--> ) <!--LIMIT--> ' + ((!@active_record_model) ? '<!--GROUPBY-->' : '')
1061
+ }
1062
+ }
1046
1063
  })
1047
1064
 
1048
1065
  end
@@ -1109,7 +1126,7 @@ module WidgetList
1109
1126
  #
1110
1127
  # Search restore
1111
1128
  #
1112
- if !isSearchRequest && $_SESSION.key?('SEARCH_FILTER') && $_SESSION['SEARCH_FILTER'].key?(@items['name']) && @items['searchSession']
1129
+ if !isSearchRequest && $_SESSION.class.name == 'Hash' && !$_SESSION.empty? && $_SESSION.key?('SEARCH_FILTER') && $_SESSION['SEARCH_FILTER'].key?(@items['name']) && @items['searchSession']
1113
1130
  isSearchRestore = true
1114
1131
  end
1115
1132
 
@@ -1316,7 +1333,7 @@ module WidgetList
1316
1333
  @items['rowLimit'] = @items['ROW_LIMIT'].to_i
1317
1334
  end
1318
1335
 
1319
- if $_SESSION.key?('ROW_LIMIT') && $_SESSION['ROW_LIMIT'].key?(@items['name']) && !$_SESSION['ROW_LIMIT'][@items['name']].empty?
1336
+ if $_SESSION.key?('ROW_LIMIT') && !$_SESSION['ROW_LIMIT'].nil? && $_SESSION['ROW_LIMIT'].key?(@items['name']) && !$_SESSION['ROW_LIMIT'][@items['name']].empty?
1320
1337
  @items['rowLimit'] = $_SESSION['ROW_LIMIT'][@items['name']].to_i
1321
1338
  end
1322
1339
 
@@ -1338,230 +1355,230 @@ module WidgetList
1338
1355
  def get_grouping_functions()
1339
1356
  #http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions003.htm
1340
1357
  [
1341
- 'AVG(',
1342
- 'COLLECT(',
1343
- 'CORR(',
1344
- 'COUNT(',
1345
- 'COVAR_POP(',
1346
- 'COVAR_SAMP(',
1347
- 'CUME_DIST(',
1348
- 'DENSE_RANK(',
1349
- 'FIRST(',
1350
- 'GROUP_ID(',
1351
- 'GROUPING_ID(',
1352
- 'LAST(',
1353
- 'LISTAGG(',
1354
- 'MAX(',
1355
- 'MEDIAN(',
1356
- 'MIN(',
1357
- 'PERCENT_RANK(',
1358
- 'PERCENTILE_CONT(',
1359
- 'PERCENTILE_DISC(',
1360
- 'RANK(',
1361
- 'REGR_SLOPE(',
1362
- 'REGR_INTERCEPT(',
1363
- 'REGR_COUNT(',
1364
- 'REGR_R2(',
1365
- 'REGR_AVGX(',
1366
- 'REGR_AVGY(',
1367
- 'REGR_SXX(',
1368
- 'REGR_SYY(',
1369
- 'REGR_SXY(',
1370
- 'STATS_MINOMIAL_TEST(',
1371
- 'STATS_CROSSTAB(',
1372
- 'STATS_F_TEST(',
1373
- 'STATS_KS_TEST(',
1374
- 'STATS_MODE(',
1375
- 'STATS_MW_TEST(',
1376
- 'STDDEV(',
1377
- 'STDDEV_POP(',
1378
- 'STDDEV_SAMP(',
1379
- 'SUM(',
1380
- 'SYS_XMLAGG(',
1381
- 'VAR_POP(',
1382
- 'VAR_SAMP(',
1383
- 'VARIANCE(',
1384
- 'XMLAGG(',
1358
+ 'AVG(',
1359
+ 'COLLECT(',
1360
+ 'CORR(',
1361
+ 'COUNT(',
1362
+ 'COVAR_POP(',
1363
+ 'COVAR_SAMP(',
1364
+ 'CUME_DIST(',
1365
+ 'DENSE_RANK(',
1366
+ 'FIRST(',
1367
+ 'GROUP_ID(',
1368
+ 'GROUPING_ID(',
1369
+ 'LAST(',
1370
+ 'LISTAGG(',
1371
+ 'MAX(',
1372
+ 'MEDIAN(',
1373
+ 'MIN(',
1374
+ 'PERCENT_RANK(',
1375
+ 'PERCENTILE_CONT(',
1376
+ 'PERCENTILE_DISC(',
1377
+ 'RANK(',
1378
+ 'REGR_SLOPE(',
1379
+ 'REGR_INTERCEPT(',
1380
+ 'REGR_COUNT(',
1381
+ 'REGR_R2(',
1382
+ 'REGR_AVGX(',
1383
+ 'REGR_AVGY(',
1384
+ 'REGR_SXX(',
1385
+ 'REGR_SYY(',
1386
+ 'REGR_SXY(',
1387
+ 'STATS_MINOMIAL_TEST(',
1388
+ 'STATS_CROSSTAB(',
1389
+ 'STATS_F_TEST(',
1390
+ 'STATS_KS_TEST(',
1391
+ 'STATS_MODE(',
1392
+ 'STATS_MW_TEST(',
1393
+ 'STDDEV(',
1394
+ 'STDDEV_POP(',
1395
+ 'STDDEV_SAMP(',
1396
+ 'SUM(',
1397
+ 'SYS_XMLAGG(',
1398
+ 'VAR_POP(',
1399
+ 'VAR_SAMP(',
1400
+ 'VARIANCE(',
1401
+ 'XMLAGG(',
1385
1402
  ]
1386
1403
  end
1387
1404
 
1388
1405
  def self.get_defaults()
1389
1406
  {
1390
- 'errors' => [],
1391
- 'name' => ([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(16).join,
1392
- 'database' => 'primary', #
1393
- 'title' => '',
1394
- 'listDescription' => '',
1395
- 'pageId' => $_SERVER['PATH_INFO'],
1396
- 'view' => '',
1397
- 'data' => {},
1398
- 'collClass' => '',
1399
- 'collAlign' => '',
1400
- 'fields' => {},
1401
- 'fieldsHidden' => [],
1402
- 'bindVars' => [],
1403
- 'bindVarsLegacy' => {},
1404
- 'links' => {},
1405
- 'buttons' => {},
1406
- 'inputs' => {},
1407
- 'filter' => [],
1408
- 'groupBy' => '',
1409
- 'rowStart' => 0,
1410
- 'rowLimit' => 10,
1411
- 'orderBy' => '',
1412
- 'allowHTML' => true,
1413
- 'searchClear' => false,
1414
- 'searchClearAll' => false,
1415
- 'showPagination' => true,
1416
- 'searchSession' => true,
1407
+ 'errors' => [],
1408
+ 'name' => ([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(16).join,
1409
+ 'database' => 'primary', #
1410
+ 'title' => '',
1411
+ 'listDescription' => '',
1412
+ 'pageId' => $_SERVER['PATH_INFO'],
1413
+ 'view' => '',
1414
+ 'data' => {},
1415
+ 'collClass' => '',
1416
+ 'collAlign' => '',
1417
+ 'fields' => {},
1418
+ 'fieldsHidden' => [],
1419
+ 'bindVars' => [],
1420
+ 'bindVarsLegacy' => {},
1421
+ 'links' => {},
1422
+ 'buttons' => {},
1423
+ 'inputs' => {},
1424
+ 'filter' => [],
1425
+ 'groupBy' => '',
1426
+ 'rowStart' => 0,
1427
+ 'rowLimit' => 10,
1428
+ 'orderBy' => '',
1429
+ 'allowHTML' => true,
1430
+ 'searchClear' => false,
1431
+ 'searchClearAll' => false,
1432
+ 'showPagination' => true,
1433
+ 'searchSession' => true,
1417
1434
 
1418
- #
1419
- # carryOverRequests will allow you to post custom things from request to all sort/paging URLS for each ajax
1420
- #
1421
- 'carryOverRequsts' => ['switch_grouping','group_row_id','q'],
1435
+ #
1436
+ # carryOverRequests will allow you to post custom things from request to all sort/paging URLS for each ajax
1437
+ #
1438
+ 'carryOverRequsts' => ['switch_grouping','group_row_id','q'],
1422
1439
 
1423
- #
1424
- # Head/Foot
1425
- #
1440
+ #
1441
+ # Head/Foot
1442
+ #
1426
1443
 
1427
- 'customFooter' => '',
1428
- 'customHeader' => '',
1444
+ 'customFooter' => '',
1445
+ 'customHeader' => '',
1429
1446
 
1430
- #
1431
- # Ajax
1432
- #
1433
- 'ajaxFunctionAll' => '',
1434
- 'ajaxFunction' => 'ListJumpMin',
1447
+ #
1448
+ # Ajax
1449
+ #
1450
+ 'ajaxFunctionAll' => '',
1451
+ 'ajaxFunction' => 'ListJumpMin',
1435
1452
 
1436
- #
1437
- # Search
1438
- #
1439
- 'showSearch' => true,
1440
- 'searchOnkeyup' => "SearchWidgetList('<!--URL-->', '<!--TARGET-->', this);",
1441
- 'searchIdCol' => 'id',
1442
- 'searchTitle' => 'Search by Id or CSV of Ids and more',
1443
- 'searchFieldsIn' => {},
1444
- 'searchFieldsOut' => {'id'=>true},
1445
- 'templateFilter' => '',
1453
+ #
1454
+ # Search
1455
+ #
1456
+ 'showSearch' => true,
1457
+ 'searchOnkeyup' => "SearchWidgetList('<!--URL-->', '<!--TARGET-->', this);",
1458
+ 'searchIdCol' => 'id',
1459
+ 'searchTitle' => 'Search by Id or CSV of Ids and more',
1460
+ 'searchFieldsIn' => {},
1461
+ 'searchFieldsOut' => {'id'=>true},
1462
+ 'templateFilter' => '',
1446
1463
 
1447
- #
1448
- # Export
1449
- #
1450
- 'showExport' => true,
1451
- 'exportButtonTitle' => 'Export CSV',
1464
+ #
1465
+ # Export
1466
+ #
1467
+ 'showExport' => true,
1468
+ 'exportButtonTitle' => 'Export CSV',
1452
1469
 
1453
- #
1454
- # Group By Box
1455
- #
1456
- 'groupByItems' => [],
1457
- 'groupBySelected' => false,
1458
- 'groupByLabel' => 'Group By',
1459
- 'groupByClick' => '',
1460
- 'groupByClickDefault' => "ListChangeGrouping('<!--NAME-->', this);",
1470
+ #
1471
+ # Group By Box
1472
+ #
1473
+ 'groupByItems' => [],
1474
+ 'groupBySelected' => false,
1475
+ 'groupByLabel' => 'Group By',
1476
+ 'groupByClick' => '',
1477
+ 'groupByClickDefault' => "ListChangeGrouping('<!--NAME-->', this);",
1461
1478
 
1462
1479
 
1463
- #
1464
- # Advanced searching
1465
- #
1466
- 'listSearchForm' => '',
1467
- 'ransackSearch' => false,
1480
+ #
1481
+ # Advanced searching
1482
+ #
1483
+ 'listSearchForm' => '',
1484
+ 'ransackSearch' => false,
1468
1485
 
1469
- #
1470
- # Column Specific
1471
- #
1472
- 'columnStyle' => {},
1473
- 'columnClass' => {},
1474
- 'columnPopupTitle' => {},
1475
- 'columnSort' => {},
1476
- 'columnWidth' => {},
1477
- 'columnNoSort' => {},
1486
+ #
1487
+ # Column Specific
1488
+ #
1489
+ 'columnStyle' => {},
1490
+ 'columnClass' => {},
1491
+ 'columnPopupTitle' => {},
1492
+ 'columnSort' => {},
1493
+ 'columnWidth' => {},
1494
+ 'columnNoSort' => {},
1478
1495
 
1479
- #
1480
- # Column Border (on right of each column)
1481
- #
1482
- 'borderedColumns' => false,
1483
- 'borderColumnStyle' => '1px solid #CCCCCC',
1496
+ #
1497
+ # Column Border (on right of each column)
1498
+ #
1499
+ 'borderedColumns' => false,
1500
+ 'borderColumnStyle' => '1px solid #CCCCCC',
1484
1501
 
1485
- #
1486
- # Row Border (on top of each row)
1487
- #
1488
- 'borderedRows' => true,
1489
- 'borderRowStyle' => '1px solid #CCCCCC',
1502
+ #
1503
+ # Row Border (on top of each row)
1504
+ #
1505
+ 'borderedRows' => true,
1506
+ 'borderRowStyle' => '1px solid #CCCCCC',
1490
1507
 
1491
- #
1492
- # Head/Foot border
1493
- #
1494
- 'borderHeadFoot' => false,
1495
- 'headFootBorderStyle' => '1px solid #CCCCCC',
1508
+ #
1509
+ # Head/Foot border
1510
+ #
1511
+ 'borderHeadFoot' => false,
1512
+ 'headFootBorderStyle' => '1px solid #CCCCCC',
1496
1513
 
1497
- 'bordersEverywhere?' => false,
1498
- 'borderEverywhere' => '1px solid #CCCCCC',
1514
+ 'bordersEverywhere?' => false,
1515
+ 'borderEverywhere' => '1px solid #CCCCCC',
1499
1516
 
1500
- #
1501
- # Buttons
1502
- #
1503
- 'defaultButtonClass' => 'info',
1517
+ #
1518
+ # Buttons
1519
+ #
1520
+ 'defaultButtonClass' => 'info',
1504
1521
 
1505
- #
1506
- # Font
1507
- #
1508
- 'fontFamily' => '"Times New Roman", Times, serif',
1509
- 'headerFooterFontSize' => '14px',
1510
- 'dataFontSize' => '14px',
1511
- 'titleFontSize' => '24px',
1522
+ #
1523
+ # Font
1524
+ #
1525
+ 'fontFamily' => '"Times New Roman", Times, serif',
1526
+ 'headerFooterFontSize' => '14px',
1527
+ 'dataFontSize' => '14px',
1528
+ 'titleFontSize' => '24px',
1512
1529
 
1513
- #
1514
- # Table Colors
1515
- #
1516
- 'footerBGColor' => '#ECECEC',
1517
- 'headerBGColor' => '#ECECEC',
1518
- 'footerFontColor' => '#494949',
1519
- 'headerFontColor' => '#494949',
1520
- 'tableBorder' => '1',
1521
- 'cornerRadius' => 15,
1522
-
1523
- 'useBoxShadow' => true,
1524
- 'shadowInset' => 10,
1525
- 'shadowSpread' => 20,
1526
- 'shadowColor' => '#888888',
1530
+ #
1531
+ # Table Colors
1532
+ #
1533
+ 'footerBGColor' => '#ECECEC',
1534
+ 'headerBGColor' => '#ECECEC',
1535
+ 'footerFontColor' => '#494949',
1536
+ 'headerFontColor' => '#494949',
1537
+ 'tableBorder' => '1',
1538
+ 'cornerRadius' => 15,
1539
+
1540
+ 'useBoxShadow' => true,
1541
+ 'shadowInset' => 10,
1542
+ 'shadowSpread' => 20,
1543
+ 'shadowColor' => '#888888',
1527
1544
 
1528
- #
1529
- # Row specifics
1530
- #
1531
- 'rowClass' => '',
1532
- 'rowFontColor' => 'black',
1533
- 'rowColorByStatus' => {},
1534
- 'rowStylesByStatus' => {},
1535
- 'rowOffsets' => ['#FFFFFF','#FFFFFF'],
1536
-
1537
- 'class' => 'listContainerPassive',
1538
- 'tableclass' => 'tableBlowOutPreventer',
1539
- 'noDataMessage' => 'Currently no data.',
1540
- 'useSort' => true,
1541
- 'headerClass' => {},
1542
- 'fieldFunction' => {},
1543
- 'buttonVal' => 'templateListJump',
1544
- 'linkFunction' => 'ButtonLinkPost',
1545
- 'template' => '',
1546
- 'LIST_COL_SORT_ORDER' => 'ASC',
1547
- 'LIST_COL_SORT' => '',
1548
- 'LIST_FILTER_ALL' => '',
1549
- 'ROW_LIMIT' => '',
1550
- 'LIST_SEQUENCE' => 1,
1551
- 'NEW_SEARCH' => false,
1545
+ #
1546
+ # Row specifics
1547
+ #
1548
+ 'rowClass' => '',
1549
+ 'rowFontColor' => 'black',
1550
+ 'rowColorByStatus' => {},
1551
+ 'rowStylesByStatus' => {},
1552
+ 'rowOffsets' => ['#FFFFFF','#FFFFFF'],
1553
+
1554
+ 'class' => 'listContainerPassive',
1555
+ 'tableclass' => 'tableBlowOutPreventer',
1556
+ 'noDataMessage' => 'Currently no data.',
1557
+ 'useSort' => true,
1558
+ 'headerClass' => {},
1559
+ 'fieldFunction' => {},
1560
+ 'buttonVal' => 'templateListJump',
1561
+ 'linkFunction' => 'ButtonLinkPost',
1562
+ 'template' => '',
1563
+ 'LIST_COL_SORT_ORDER' => 'ASC',
1564
+ 'LIST_COL_SORT' => '',
1565
+ 'LIST_FILTER_ALL' => '',
1566
+ 'ROW_LIMIT' => '',
1567
+ 'LIST_SEQUENCE' => 1,
1568
+ 'NEW_SEARCH' => false,
1552
1569
 
1553
- #
1554
- # Checkbox
1555
- #
1556
- 'checkedClass' => 'widgetlist-checkbox',
1557
- 'checkedFlag' => {},
1558
- 'storeSessionChecks' => false,
1570
+ #
1571
+ # Checkbox
1572
+ #
1573
+ 'checkedClass' => 'widgetlist-checkbox',
1574
+ 'checkedFlag' => {},
1575
+ 'storeSessionChecks' => false,
1559
1576
 
1560
- #
1561
- # Hooks
1562
- #
1563
- 'columnHooks' => {},
1564
- 'rowHooks' => {}
1577
+ #
1578
+ # Hooks
1579
+ #
1580
+ 'columnHooks' => {},
1581
+ 'rowHooks' => {}
1565
1582
  }
1566
1583
  end
1567
1584
 
@@ -1783,7 +1800,7 @@ module WidgetList
1783
1800
  if $_REQUEST.key?('switch_grouping')
1784
1801
  groupBy = $_REQUEST['switch_grouping']
1785
1802
  $_SESSION.deep_merge!({'CURRENT_GROUPING' => { list_parms['name'] => groupBy} })
1786
- elsif $_SESSION.key?('CURRENT_GROUPING') && $_SESSION['CURRENT_GROUPING'].key?(list_parms['name'])
1803
+ elsif $_SESSION.key?('CURRENT_GROUPING') && !$_SESSION['CURRENT_GROUPING'].nil? && $_SESSION['CURRENT_GROUPING'].key?(list_parms['name'])
1787
1804
  groupBy = $_SESSION['CURRENT_GROUPING'][list_parms['name']]
1788
1805
  list_parms['groupBySelected'] = groupBy
1789
1806
  else
@@ -1964,7 +1981,7 @@ module WidgetList
1964
1981
  list_search['value'] = ''
1965
1982
 
1966
1983
  if @items['searchSession']
1967
- if $_SESSION.key?('SEARCH_FILTER') && $_SESSION['SEARCH_FILTER'].key?(@items['name'])
1984
+ if $_SESSION.key?('SEARCH_FILTER') && !$_SESSION['SEARCH_FILTER'].nil? && $_SESSION['SEARCH_FILTER'].key?(@items['name'])
1968
1985
  list_search['value'] = $_SESSION['SEARCH_FILTER'][@items['name']]
1969
1986
  end
1970
1987
  end
@@ -1980,11 +1997,11 @@ module WidgetList
1980
1997
  list_search['name'] = 'list_search_name_' + @items['name']
1981
1998
  list_search['class'] = 'inputOuter widget-search-outer ' + @items['name'].downcase + '-search'
1982
1999
  list_search['search_ahead'] = {
1983
- 'url' => searchUrl,
1984
- 'skip_queue' => false,
1985
- 'target' => @items['name'],
1986
- 'search_form' => @items['listSearchForm'],
1987
- 'onkeyup' => (! @items['searchOnkeyup'].empty?) ? WidgetList::Utils::fill({'<!--URL-->'=>searchUrl, '<!--TARGET-->' => @items['name'], '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll']}, @items['searchOnkeyup'] + '<!--FUNCTION_ALL-->') : ''
2000
+ 'url' => searchUrl,
2001
+ 'skip_queue' => false,
2002
+ 'target' => @items['name'],
2003
+ 'search_form' => @items['listSearchForm'],
2004
+ 'onkeyup' => (! @items['searchOnkeyup'].empty?) ? WidgetList::Utils::fill({'<!--URL-->'=>searchUrl, '<!--TARGET-->' => @items['name'], '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll']}, @items['searchOnkeyup'] + '<!--FUNCTION_ALL-->') : ''
1988
2005
  }
1989
2006
 
1990
2007
  @headerPieces['searchBar'] = WidgetList::Widgets::widget_input(list_search)
@@ -2040,8 +2057,8 @@ module WidgetList
2040
2057
  }
2041
2058
 
2042
2059
  list_group['search_ahead'] = {
2043
- 'skip_queue' => false,
2044
- 'search_form'=> '
2060
+ 'skip_queue' => false,
2061
+ 'search_form'=> '
2045
2062
  <div id="advanced-search-container" style="height:100% !important;">
2046
2063
  ' + groupRows.join("\n") + '
2047
2064
  </div>'
@@ -2174,11 +2191,11 @@ module WidgetList
2174
2191
  #Assemble navigation buttons
2175
2192
  #
2176
2193
  pieces = {
2177
- '<!--NEXT_URL-->' => nextUrl,
2178
- '<!--LIST_NAME-->' => @items['name'],
2179
- '<!--PREVIOUS_URL-->' => prevUrl,
2180
- '<!--FUNCTION-->' => @items['ajaxFunction'],
2181
- '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2194
+ '<!--NEXT_URL-->' => nextUrl,
2195
+ '<!--LIST_NAME-->' => @items['name'],
2196
+ '<!--PREVIOUS_URL-->' => prevUrl,
2197
+ '<!--FUNCTION-->' => @items['ajaxFunction'],
2198
+ '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2182
2199
  }
2183
2200
 
2184
2201
  templates['btn_next'] = WidgetList::Utils::fill(pieces,templates['btn_next'])
@@ -2281,23 +2298,23 @@ module WidgetList
2281
2298
  end
2282
2299
 
2283
2300
  jumpSection << WidgetList::Utils::fill({
2284
- '<!--SEQUENCE-->' => page,
2285
- '<!--JUMP_URL-->' => jumpUrl,
2286
- '<!--LIST_NAME-->' => @items['name'],
2287
- '<!--FUNCTION-->' => @items['ajaxFunction'],
2288
- '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2301
+ '<!--SEQUENCE-->' => page,
2302
+ '<!--JUMP_URL-->' => jumpUrl,
2303
+ '<!--LIST_NAME-->' => @items['name'],
2304
+ '<!--FUNCTION-->' => @items['ajaxFunction'],
2305
+ '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2289
2306
  }, jumpTemplate)
2290
2307
  end
2291
2308
 
2292
2309
  pieces = {
2293
- '<!--PREVIOUS_BUTTON-->' => templates['btn_previous'],
2294
- '<!--SEQUENCE-->' => @sequence,
2295
- '<!--NEXT_BUTTON-->' => templates['btn_next'],
2296
- '<!--TOTAL_PAGES-->' => @totalPages,
2297
- '<!--TOTAL_ROWS-->' => @totalRows,
2298
- '<!--PAGE_SEQUENCE_JUMP_LIST-->' => pageSelect,
2299
- '<!--JUMP-->' => jumpSection.join(''),
2300
- '<!--LIST_NAME-->' => @items['name'],
2310
+ '<!--PREVIOUS_BUTTON-->' => templates['btn_previous'],
2311
+ '<!--SEQUENCE-->' => @sequence,
2312
+ '<!--NEXT_BUTTON-->' => templates['btn_next'],
2313
+ '<!--TOTAL_PAGES-->' => @totalPages,
2314
+ '<!--TOTAL_ROWS-->' => @totalRows,
2315
+ '<!--PAGE_SEQUENCE_JUMP_LIST-->' => pageSelect,
2316
+ '<!--JUMP-->' => jumpSection.join(''),
2317
+ '<!--LIST_NAME-->' => @items['name'],
2301
2318
  }
2302
2319
 
2303
2320
  paginationOutput = WidgetList::Utils::fill(pieces,@items['template_pagination_wrapper'])
@@ -2449,7 +2466,7 @@ module WidgetList
2449
2466
 
2450
2467
  if (
2451
2468
  ( (@items.key?('LIST_COL_SORT') && !@items['LIST_COL_SORT'].empty?) && @items['LIST_COL_SORT'] == colSort['LIST_COL_SORT']) ||
2452
- ( $_SESSION.key?('LIST_COL_SORT') && $_SESSION['LIST_COL_SORT'].key?(@sqlHash) && $_SESSION['LIST_COL_SORT'][@sqlHash].key?(field))
2469
+ ( $_SESSION.key?('LIST_COL_SORT') && !$_SESSION['LIST_COL_SORT'].nil? && $_SESSION['LIST_COL_SORT'].key?(@sqlHash) && $_SESSION['LIST_COL_SORT'][@sqlHash].key?(field))
2453
2470
  )
2454
2471
  changedSession = false
2455
2472
  if @items.key?('LIST_COL_SORT') && !@items['LIST_COL_SORT'].empty?
@@ -2592,7 +2609,7 @@ module WidgetList
2592
2609
 
2593
2610
  if input['check_all']
2594
2611
  checkAllId = input['id']
2595
- if $_SESSION.key?('list_checks') && $_SESSION['list_checks'].key?('check_all_' + @sqlHash.to_s + @items['name'].to_s + @sequence.to_s)
2612
+ if $_SESSION.key?('list_checks') && !$_SESSION['list_checks'].nil? && $_SESSION['list_checks'].key?('check_all_' + @sqlHash.to_s + @items['name'].to_s + @sequence.to_s)
2596
2613
  input['checked'] = true
2597
2614
  end
2598
2615
 
@@ -2640,7 +2657,7 @@ module WidgetList
2640
2657
  #
2641
2658
  # Checkbox is checked or not per session (overwrites query)
2642
2659
  #
2643
- if $_SESSION.key?('list_checks') && $_SESSION['list_checks'].key?(@items['name'] + @sqlHash + input['value'].to_s)
2660
+ if $_SESSION.key?('list_checks') && !$_SESSION['list_checks'].nil? && $_SESSION['list_checks'].key?(@items['name'] + @sqlHash + input['value'].to_s)
2644
2661
  input['checked'] = true
2645
2662
  end
2646
2663
 
@@ -2708,41 +2725,41 @@ module WidgetList
2708
2725
  def self.checkbox_helper(list_parms,primary_key)
2709
2726
 
2710
2727
  list_parms.deep_merge!({'inputs' =>
2711
- {'checkbox'=>
2712
- {'type' => 'checkbox'
2713
- }
2714
- }
2728
+ {'checkbox'=>
2729
+ {'type' => 'checkbox'
2730
+ }
2731
+ }
2715
2732
  })
2716
2733
 
2717
2734
  list_parms.deep_merge!({'inputs' =>
2718
- {'checkbox'=>
2719
- {'items' =>
2720
- {
2721
- 'name' => list_parms['name'] + '_visible_checks[]',
2722
- 'value' => primary_key, #the value should be a column name mapping
2723
- 'class_handle' => list_parms['name'] + '_info_tables',
2724
- }
2725
- }
2726
- }
2735
+ {'checkbox'=>
2736
+ {'items' =>
2737
+ {
2738
+ 'name' => list_parms['name'] + '_visible_checks[]',
2739
+ 'value' => primary_key, #the value should be a column name mapping
2740
+ 'class_handle' => list_parms['name'] + '_info_tables',
2741
+ }
2742
+ }
2743
+ }
2727
2744
  })
2728
2745
 
2729
2746
  list_parms.deep_merge!({'inputs' =>
2730
- {'checkbox_header'=>
2731
- {'type' => 'checkbox'
2732
- }
2733
- }
2747
+ {'checkbox_header'=>
2748
+ {'type' => 'checkbox'
2749
+ }
2750
+ }
2734
2751
  })
2735
2752
 
2736
2753
  list_parms.deep_merge!({'inputs' =>
2737
- {'checkbox_header'=>
2738
- {'items' =>
2739
- {
2740
- 'check_all' => true,
2741
- 'id' => list_parms['name'] + '_info_tables_check_all',
2742
- 'class_handle' => list_parms['name'] + '_info_tables',
2743
- }
2744
- }
2745
- }
2754
+ {'checkbox_header'=>
2755
+ {'items' =>
2756
+ {
2757
+ 'check_all' => true,
2758
+ 'id' => list_parms['name'] + '_info_tables_check_all',
2759
+ 'class_handle' => list_parms['name'] + '_info_tables',
2760
+ }
2761
+ }
2762
+ }
2746
2763
  })
2747
2764
  return list_parms
2748
2765
  end
@@ -2753,20 +2770,20 @@ module WidgetList
2753
2770
 
2754
2771
  def self.build_drill_down(*params)
2755
2772
  required_params = {
2756
- :list_id => true, # -- your widget_list name (used for JS)
2757
- :drill_down_name => true, # -- an identifier that is pass for the "column" or "type of drill down" which is passed as $_REQUEST['drill_down'] when the user clicks and returned from get_filter_and_drilldown based on session or request
2758
- :data_to_pass_from_view => true, # -- Any SQL function or column name/value in the resultset in which would be the value passed when the user clicks the drill down
2759
- :column_to_show => true, # -- The visible column or SQL functions to display to user for the link
2773
+ :list_id => true, # -- your widget_list name (used for JS)
2774
+ :drill_down_name => true, # -- an identifier that is pass for the "column" or "type of drill down" which is passed as $_REQUEST['drill_down'] when the user clicks and returned from get_filter_and_drilldown based on session or request
2775
+ :data_to_pass_from_view => true, # -- Any SQL function or column name/value in the resultset in which would be the value passed when the user clicks the drill down
2776
+ :column_to_show => true, # -- The visible column or SQL functions to display to user for the link
2760
2777
  }
2761
2778
 
2762
2779
  optional_params = {
2763
- :column_alias => '', # -- AS XXXX
2764
- :extra_function => '', # -- Onclick of link, call another JS function after the drill down function is called
2765
- :js_function_name => 'ListDrillDown', # -- name of JS Function
2766
- :column_class => '', # -- custom class on the <a> tag
2767
- :link_color => 'blue', # -- whatever color you want the link to be
2768
- :extra_js_func_params => '', # -- Add extra params to ListDrillDown outside of the default
2769
- :primary_database => true, # -- Since this function builds a column before widget_list is instantiated, tell which connection you are using
2780
+ :column_alias => '', # -- AS XXXX
2781
+ :extra_function => '', # -- Onclick of link, call another JS function after the drill down function is called
2782
+ :js_function_name => 'ListDrillDown', # -- name of JS Function
2783
+ :column_class => '', # -- custom class on the <a> tag
2784
+ :link_color => 'blue', # -- whatever color you want the link to be
2785
+ :extra_js_func_params => '', # -- Add extra params to ListDrillDown outside of the default
2786
+ :primary_database => true, # -- Since this function builds a column before widget_list is instantiated, tell which connection you are using
2770
2787
  }
2771
2788
 
2772
2789
  valid = WidgetList::Widgets::validate_items(params[0],required_params)
@@ -3313,7 +3330,7 @@ module WidgetList
3313
3330
  clear_sql_session(@items.key?('searchClearAll'))
3314
3331
  end
3315
3332
 
3316
- if !$_REQUEST.key?('BUTTON_VALUE') && $_SESSION.key?('LIST_SEQUENCE') && $_SESSION['LIST_SEQUENCE'].key?(@sqlHash) && $_SESSION['LIST_SEQUENCE'][@sqlHash] > 0
3333
+ if !$_REQUEST.key?('BUTTON_VALUE') && !$_SESSION['LIST_SEQUENCE'].nil? && $_SESSION.key?('LIST_SEQUENCE') && $_SESSION['LIST_SEQUENCE'].key?(@sqlHash) && $_SESSION['LIST_SEQUENCE'][@sqlHash] > 0
3317
3334
  @sequence = $_SESSION['LIST_SEQUENCE'][@sqlHash]
3318
3335
  generate_limits
3319
3336
  end
@@ -3375,7 +3392,7 @@ module WidgetList
3375
3392
  when 'oracle'
3376
3393
 
3377
3394
  pieces['<!--LIMIT-->'] =
3378
- '
3395
+ '
3379
3396
  WHERE
3380
3397
  (
3381
3398
  rn >' + (@sequence > 1 ? '' : '=') + ' :LOW