widget_list 1.2.5 → 1.2.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
@@ -63,11 +63,11 @@ module WidgetList
63
63
  #
64
64
  @fill['<!--POST_URL-->'] = $_SERVER['PATH_INFO']
65
65
  @fill['<!--BUTTONS-->'] = WidgetList::Widgets::widget_button('Step One - Start ->', {'id' => 'start' , 'onclick' => "ShowStart();" , 'innerClass' => "primary" } ) +
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" } )
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" } )
71
71
 
72
72
 
73
73
  #
@@ -299,19 +299,35 @@ module WidgetList
299
299
  checkbox_code = ''
300
300
  button_code = ''
301
301
  grouping_code = ''
302
+ grouping_code2 = ''
303
+ search_out = ''
302
304
  field_function_code = ''
303
-
305
+ database_type = WidgetList::List.get_db_type(page_config['primaryDatabase'] == '1' ? true : false)
306
+ using_grouping = (page_config['useGrouping'] == '1' && page_config['showSearch'] == '1' && !group_by.empty?)
304
307
  #------------ DRILL DOWNS ------------
305
308
  if page_config['drillDownsOn'] == "1" && !drill_downs.empty?
306
- #@todo - (groupByFilter == 'none') ? 'a.name' : 'MAX(a.name)'
309
+
310
+ search_out += "
311
+ list_parms['searchFieldsOut'] = {}"
307
312
 
308
313
  drill_downs.each { |field|
314
+
315
+ search_out += "
316
+ list_parms['searchFieldsOut']#{add_pointer(field[1]['column_to_show'],9)} true"
317
+
318
+ column_to_show = "'#{field[1]['column_to_show'].gsub(/_linked/,'')}'"
319
+ if using_grouping
320
+ if database_type == 'oracle'
321
+ column_to_show = "groupByFilter == 'none' ? '#{field[1]['column_to_show'].gsub(/_linked/,'')}' : 'MAX(#{field[1]['column_to_show'].gsub(/_linked/,'')})'"
322
+ end
323
+ end
324
+
309
325
  field_function_code += "
310
326
  list_parms['fieldFunction']#{add_pointer(field[1]['column_to_show'],7)} WidgetList::List::build_drill_down(
311
327
  :list_id => list_parms['name'],
312
328
  :drill_down_name => '#{field[0]}',
313
- :data_to_pass_from_view => '#{field[1]['column_to_show'].gsub(/_linked/,'')}',
314
- :column_to_show => '#{field[1]['column_to_show'].gsub(/_linked/,'')}',
329
+ :data_to_pass_from_view => #{column_to_show},
330
+ :column_to_show => #{column_to_show},
315
331
  :column_alias => '#{field[1]['column_to_show']}',
316
332
  :primary_database => #{page_config['primaryDatabase'] == '1' ? 'true' : 'false'}
317
333
  )"
@@ -404,13 +420,18 @@ module WidgetList
404
420
  checkbox_code += "
405
421
  list_parms = WidgetList::List.checkbox_helper(list_parms,'#{page_config['checkboxField']}')
406
422
  "
407
- visible_field_code += "
423
+ if using_grouping
424
+ visible_field_code += "
425
+ list_parms['fields']#{add_pointer('checkbox')} #{add_conditional('checkbox_header',"if groupByFilter == 'none'")}"
426
+ else
427
+ visible_field_code += "
408
428
  list_parms['fields']#{add_pointer('checkbox')} 'checkbox_header'"
429
+ end
409
430
  end
410
431
 
411
432
  fields.each { |field,description|
412
433
  conditional = ''
413
- if page_config['useGrouping'] == '1' && page_config['showSearch'] == '1' && !group_by.empty?
434
+ if using_grouping
414
435
  conditional = ' if groupByFilter == \'none\''
415
436
  if group_by.key?(field) || group_by.key?(field.gsub(/_linked/,''))
416
437
  conditional = " if groupByFilter == 'none' || groupByFilter == 'group_#{group_by[field.gsub(/_linked/,'')].gsub(/ /,'_').downcase}'"
@@ -425,7 +446,7 @@ module WidgetList
425
446
 
426
447
  #------------ GROUPING ------------
427
448
 
428
- if page_config['useGrouping'] == '1' && page_config['showSearch'] == '1' && !group_by.empty?
449
+ if using_grouping
429
450
  variable_code += "
430
451
  groupByDesc = '' # Initialize a variable you can use in listDescription to show what the current grouping selection is
431
452
  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
@@ -434,7 +455,7 @@ module WidgetList
434
455
  visible_field_code += "
435
456
  list_parms['fields']#{add_pointer('cnt')} #{add_conditional('Count'," if groupByFilter != 'none'")}
436
457
  "
437
- if WidgetList::List.get_db_type(page_config['primaryDatabase'] == '1' ? true : false) == 'oracle'
458
+ if database_type == 'oracle'
438
459
  count = 'TO_CHAR(COUNT(1))'
439
460
  else
440
461
  count = 'COUNT(1)'
@@ -476,7 +497,14 @@ module WidgetList
476
497
  EOD
477
498
 
478
499
  grouping_code += "
479
- list_parms['groupByItems'] = " + '[' + descriptions.join(', ') + ']' + ""
500
+ list_parms['groupByItems'] = " + '[' + descriptions.join(', ') + ']'
501
+
502
+ grouping_code2 = "
503
+ #
504
+ # Prevent Oracle grouping errors
505
+ #
506
+ list_parms = WidgetList::List.group_by_max_each_field(list_parms,groupByFilter)
507
+ " if database_type == 'oracle'
480
508
  end
481
509
 
482
510
 
@@ -485,6 +513,9 @@ module WidgetList
485
513
  if page_config['rowButtonsOn'] == '1'
486
514
  visible_field_code += "
487
515
  list_parms['fields'][button_column_name.downcase] = button_column_name.capitalize"
516
+ visible_field_code += " if groupByFilter == 'none'" if using_grouping
517
+
518
+
488
519
 
489
520
  button_code += "
490
521
  #
@@ -573,6 +604,8 @@ module WidgetList
573
604
  #{visible_field_code}
574
605
  #{hidden_field_code}
575
606
  #{field_function_code}
607
+ #{search_out}
608
+ #{grouping_code2}
576
609
 
577
610
  #
578
611
  # Model
@@ -1021,23 +1054,23 @@ module WidgetList
1021
1054
 
1022
1055
 
1023
1056
  @items.deep_merge!({ 'statement' =>
1024
- {'select'=>
1025
- {'view' =>
1026
- '
1057
+ {'select'=>
1058
+ {'view' =>
1059
+ '
1027
1060
  SELECT <!--FIELDS_PLAIN--> FROM <!--SOURCE--> <!--WHERE--> <!--GROUPBY--> <!--ORDERBY--> <!--LIMIT-->
1028
1061
  '
1029
- }
1030
- }
1062
+ }
1063
+ }
1031
1064
  })
1032
1065
 
1033
1066
  @items.deep_merge!({ 'statement' =>
1034
- {'count'=>
1035
- {'view' =>
1036
- '
1067
+ {'count'=>
1068
+ {'view' =>
1069
+ '
1037
1070
  SELECT count(1) total FROM <!--VIEW--> <!--WHERE--> <!--GROUPBY-->
1038
1071
  '
1039
- }
1040
- }
1072
+ }
1073
+ }
1041
1074
  })
1042
1075
  #inject site wide configs before list specific configs if a helper exists
1043
1076
 
@@ -1061,8 +1094,8 @@ module WidgetList
1061
1094
  # if no one passed a listSearchForm inject a default one to show the ransack form
1062
1095
  #
1063
1096
  fill = {
1064
- '<!--BUTTON_SEARCH-->' => WidgetList::Widgets::widget_button('Search', {'onclick' => WidgetList::List::build_search_button_click(@items), 'innerClass' => @items['defaultButtonClass'] }),
1065
- '<!--BUTTON_CLOSE-->' => "HideAdvancedSearch(this)"
1097
+ '<!--BUTTON_SEARCH-->' => WidgetList::Widgets::widget_button('Search', {'onclick' => WidgetList::List::build_search_button_click(@items), 'innerClass' => @items['defaultButtonClass'] }),
1098
+ '<!--BUTTON_CLOSE-->' => "HideAdvancedSearch(this)"
1066
1099
  }
1067
1100
  @items['listSearchForm'] = WidgetList::Utils::fill( fill , ac.render_to_string(:partial => 'widget_list/ransack_widget_list_advanced_search') )
1068
1101
 
@@ -1081,19 +1114,19 @@ module WidgetList
1081
1114
  if get_database.db_type == 'oracle'
1082
1115
 
1083
1116
  @items.deep_merge!({'statement' =>
1084
- {'count'=>
1085
- {'view' =>
1086
- '
1117
+ {'count'=>
1118
+ {'view' =>
1119
+ '
1087
1120
  SELECT count(1) total FROM <!--VIEW--> ' + ((@items['groupBy'].empty? && !@active_record_model) ? '<!--WHERE--> <!--GROUPBY-->' : '' )
1088
- }
1089
- }
1121
+ }
1122
+ }
1090
1123
  })
1091
1124
  @items.deep_merge!({'statement' =>
1092
- {'select'=>
1093
- {'view' =>
1094
- '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-->' : '')
1095
- }
1096
- }
1125
+ {'select'=>
1126
+ {'view' =>
1127
+ '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-->' : '')
1128
+ }
1129
+ }
1097
1130
  })
1098
1131
 
1099
1132
  end
@@ -1389,230 +1422,230 @@ module WidgetList
1389
1422
  def get_grouping_functions()
1390
1423
  #http://docs.oracle.com/cd/E11882_01/server.112/e10592/functions003.htm
1391
1424
  [
1392
- 'AVG(',
1393
- 'COLLECT(',
1394
- 'CORR(',
1395
- 'COUNT(',
1396
- 'COVAR_POP(',
1397
- 'COVAR_SAMP(',
1398
- 'CUME_DIST(',
1399
- 'DENSE_RANK(',
1400
- 'FIRST(',
1401
- 'GROUP_ID(',
1402
- 'GROUPING_ID(',
1403
- 'LAST(',
1404
- 'LISTAGG(',
1405
- 'MAX(',
1406
- 'MEDIAN(',
1407
- 'MIN(',
1408
- 'PERCENT_RANK(',
1409
- 'PERCENTILE_CONT(',
1410
- 'PERCENTILE_DISC(',
1411
- 'RANK(',
1412
- 'REGR_SLOPE(',
1413
- 'REGR_INTERCEPT(',
1414
- 'REGR_COUNT(',
1415
- 'REGR_R2(',
1416
- 'REGR_AVGX(',
1417
- 'REGR_AVGY(',
1418
- 'REGR_SXX(',
1419
- 'REGR_SYY(',
1420
- 'REGR_SXY(',
1421
- 'STATS_MINOMIAL_TEST(',
1422
- 'STATS_CROSSTAB(',
1423
- 'STATS_F_TEST(',
1424
- 'STATS_KS_TEST(',
1425
- 'STATS_MODE(',
1426
- 'STATS_MW_TEST(',
1427
- 'STDDEV(',
1428
- 'STDDEV_POP(',
1429
- 'STDDEV_SAMP(',
1430
- 'SUM(',
1431
- 'SYS_XMLAGG(',
1432
- 'VAR_POP(',
1433
- 'VAR_SAMP(',
1434
- 'VARIANCE(',
1435
- 'XMLAGG(',
1425
+ 'AVG(',
1426
+ 'COLLECT(',
1427
+ 'CORR(',
1428
+ 'COUNT(',
1429
+ 'COVAR_POP(',
1430
+ 'COVAR_SAMP(',
1431
+ 'CUME_DIST(',
1432
+ 'DENSE_RANK(',
1433
+ 'FIRST(',
1434
+ 'GROUP_ID(',
1435
+ 'GROUPING_ID(',
1436
+ 'LAST(',
1437
+ 'LISTAGG(',
1438
+ 'MAX(',
1439
+ 'MEDIAN(',
1440
+ 'MIN(',
1441
+ 'PERCENT_RANK(',
1442
+ 'PERCENTILE_CONT(',
1443
+ 'PERCENTILE_DISC(',
1444
+ 'RANK(',
1445
+ 'REGR_SLOPE(',
1446
+ 'REGR_INTERCEPT(',
1447
+ 'REGR_COUNT(',
1448
+ 'REGR_R2(',
1449
+ 'REGR_AVGX(',
1450
+ 'REGR_AVGY(',
1451
+ 'REGR_SXX(',
1452
+ 'REGR_SYY(',
1453
+ 'REGR_SXY(',
1454
+ 'STATS_MINOMIAL_TEST(',
1455
+ 'STATS_CROSSTAB(',
1456
+ 'STATS_F_TEST(',
1457
+ 'STATS_KS_TEST(',
1458
+ 'STATS_MODE(',
1459
+ 'STATS_MW_TEST(',
1460
+ 'STDDEV(',
1461
+ 'STDDEV_POP(',
1462
+ 'STDDEV_SAMP(',
1463
+ 'SUM(',
1464
+ 'SYS_XMLAGG(',
1465
+ 'VAR_POP(',
1466
+ 'VAR_SAMP(',
1467
+ 'VARIANCE(',
1468
+ 'XMLAGG(',
1436
1469
  ]
1437
1470
  end
1438
1471
 
1439
1472
  def self.get_defaults()
1440
1473
  {
1441
- 'errors' => [],
1442
- 'name' => ([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(16).join,
1443
- 'database' => 'primary', #
1444
- 'title' => '',
1445
- 'listDescription' => '',
1446
- 'pageId' => $_SERVER['PATH_INFO'],
1447
- 'view' => '',
1448
- 'data' => {},
1449
- 'collClass' => '',
1450
- 'collAlign' => '',
1451
- 'fields' => {},
1452
- 'fieldsHidden' => [],
1453
- 'bindVars' => [],
1454
- 'bindVarsLegacy' => {},
1455
- 'links' => {},
1456
- 'buttons' => {},
1457
- 'inputs' => {},
1458
- 'filter' => [],
1459
- 'groupBy' => '',
1460
- 'rowStart' => 0,
1461
- 'rowLimit' => 10,
1462
- 'orderBy' => '',
1463
- 'allowHTML' => true,
1464
- 'searchClear' => false,
1465
- 'searchClearAll' => false,
1466
- 'showPagination' => true,
1467
- 'searchSession' => true,
1474
+ 'errors' => [],
1475
+ 'name' => ([*('A'..'Z'),*('0'..'9')]-%w(0 1 I O)).sample(16).join,
1476
+ 'database' => 'primary', #
1477
+ 'title' => '',
1478
+ 'listDescription' => '',
1479
+ 'pageId' => $_SERVER['PATH_INFO'],
1480
+ 'view' => '',
1481
+ 'data' => {},
1482
+ 'collClass' => '',
1483
+ 'collAlign' => '',
1484
+ 'fields' => {},
1485
+ 'fieldsHidden' => [],
1486
+ 'bindVars' => [],
1487
+ 'bindVarsLegacy' => {},
1488
+ 'links' => {},
1489
+ 'buttons' => {},
1490
+ 'inputs' => {},
1491
+ 'filter' => [],
1492
+ 'groupBy' => '',
1493
+ 'rowStart' => 0,
1494
+ 'rowLimit' => 10,
1495
+ 'orderBy' => '',
1496
+ 'allowHTML' => true,
1497
+ 'searchClear' => false,
1498
+ 'searchClearAll' => false,
1499
+ 'showPagination' => true,
1500
+ 'searchSession' => true,
1468
1501
 
1469
- #
1470
- # carryOverRequests will allow you to post custom things from request to all sort/paging URLS for each ajax
1471
- #
1472
- 'carryOverRequsts' => ['switch_grouping','group_row_id','q'],
1502
+ #
1503
+ # carryOverRequests will allow you to post custom things from request to all sort/paging URLS for each ajax
1504
+ #
1505
+ 'carryOverRequsts' => ['switch_grouping','group_row_id','q'],
1473
1506
 
1474
- #
1475
- # Head/Foot
1476
- #
1507
+ #
1508
+ # Head/Foot
1509
+ #
1477
1510
 
1478
- 'customFooter' => '',
1479
- 'customHeader' => '',
1511
+ 'customFooter' => '',
1512
+ 'customHeader' => '',
1480
1513
 
1481
- #
1482
- # Ajax
1483
- #
1484
- 'ajaxFunctionAll' => '',
1485
- 'ajaxFunction' => 'ListJumpMin',
1514
+ #
1515
+ # Ajax
1516
+ #
1517
+ 'ajaxFunctionAll' => '',
1518
+ 'ajaxFunction' => 'ListJumpMin',
1486
1519
 
1487
- #
1488
- # Search
1489
- #
1490
- 'showSearch' => true,
1491
- 'searchOnkeyup' => "SearchWidgetList('<!--URL-->', '<!--TARGET-->', this);",
1492
- 'searchIdCol' => 'id',
1493
- 'searchTitle' => 'Search by Id or CSV of Ids and more',
1494
- 'searchFieldsIn' => {},
1495
- 'searchFieldsOut' => {'id'=>true},
1496
- 'templateFilter' => '',
1520
+ #
1521
+ # Search
1522
+ #
1523
+ 'showSearch' => true,
1524
+ 'searchOnkeyup' => "SearchWidgetList('<!--URL-->', '<!--TARGET-->', this);",
1525
+ 'searchIdCol' => 'id',
1526
+ 'searchTitle' => 'Search by Id or CSV of Ids and more',
1527
+ 'searchFieldsIn' => {},
1528
+ 'searchFieldsOut' => {'id'=>true},
1529
+ 'templateFilter' => '',
1497
1530
 
1498
- #
1499
- # Export
1500
- #
1501
- 'showExport' => true,
1502
- 'exportButtonTitle' => 'Export CSV',
1531
+ #
1532
+ # Export
1533
+ #
1534
+ 'showExport' => true,
1535
+ 'exportButtonTitle' => 'Export CSV',
1503
1536
 
1504
- #
1505
- # Group By Box
1506
- #
1507
- 'groupByItems' => [],
1508
- 'groupBySelected' => false,
1509
- 'groupByLabel' => 'Group By',
1510
- 'groupByClick' => '',
1511
- 'groupByClickDefault' => "ListChangeGrouping('<!--NAME-->', this);",
1537
+ #
1538
+ # Group By Box
1539
+ #
1540
+ 'groupByItems' => [],
1541
+ 'groupBySelected' => false,
1542
+ 'groupByLabel' => 'Group By',
1543
+ 'groupByClick' => '',
1544
+ 'groupByClickDefault' => "ListChangeGrouping('<!--NAME-->', this);",
1512
1545
 
1513
1546
 
1514
- #
1515
- # Advanced searching
1516
- #
1517
- 'listSearchForm' => '',
1518
- 'ransackSearch' => false,
1547
+ #
1548
+ # Advanced searching
1549
+ #
1550
+ 'listSearchForm' => '',
1551
+ 'ransackSearch' => false,
1519
1552
 
1520
- #
1521
- # Column Specific
1522
- #
1523
- 'columnStyle' => {},
1524
- 'columnClass' => {},
1525
- 'columnPopupTitle' => {},
1526
- 'columnSort' => {},
1527
- 'columnWidth' => {},
1528
- 'columnNoSort' => {},
1553
+ #
1554
+ # Column Specific
1555
+ #
1556
+ 'columnStyle' => {},
1557
+ 'columnClass' => {},
1558
+ 'columnPopupTitle' => {},
1559
+ 'columnSort' => {},
1560
+ 'columnWidth' => {},
1561
+ 'columnNoSort' => {},
1529
1562
 
1530
- #
1531
- # Column Border (on right of each column)
1532
- #
1533
- 'borderedColumns' => false,
1534
- 'borderColumnStyle' => '1px solid #CCCCCC',
1563
+ #
1564
+ # Column Border (on right of each column)
1565
+ #
1566
+ 'borderedColumns' => false,
1567
+ 'borderColumnStyle' => '1px solid #CCCCCC',
1535
1568
 
1536
- #
1537
- # Row Border (on top of each row)
1538
- #
1539
- 'borderedRows' => true,
1540
- 'borderRowStyle' => '1px solid #CCCCCC',
1569
+ #
1570
+ # Row Border (on top of each row)
1571
+ #
1572
+ 'borderedRows' => true,
1573
+ 'borderRowStyle' => '1px solid #CCCCCC',
1541
1574
 
1542
- #
1543
- # Head/Foot border
1544
- #
1545
- 'borderHeadFoot' => false,
1546
- 'headFootBorderStyle' => '1px solid #CCCCCC',
1575
+ #
1576
+ # Head/Foot border
1577
+ #
1578
+ 'borderHeadFoot' => false,
1579
+ 'headFootBorderStyle' => '1px solid #CCCCCC',
1547
1580
 
1548
- 'bordersEverywhere?' => false,
1549
- 'borderEverywhere' => '1px solid #CCCCCC',
1581
+ 'bordersEverywhere?' => false,
1582
+ 'borderEverywhere' => '1px solid #CCCCCC',
1550
1583
 
1551
- #
1552
- # Buttons
1553
- #
1554
- 'defaultButtonClass' => 'info',
1584
+ #
1585
+ # Buttons
1586
+ #
1587
+ 'defaultButtonClass' => 'info',
1555
1588
 
1556
- #
1557
- # Font
1558
- #
1559
- 'fontFamily' => '"Times New Roman", Times, serif',
1560
- 'headerFooterFontSize' => '14px',
1561
- 'dataFontSize' => '14px',
1562
- 'titleFontSize' => '24px',
1589
+ #
1590
+ # Font
1591
+ #
1592
+ 'fontFamily' => '"Times New Roman", Times, serif',
1593
+ 'headerFooterFontSize' => '14px',
1594
+ 'dataFontSize' => '14px',
1595
+ 'titleFontSize' => '24px',
1563
1596
 
1564
- #
1565
- # Table Colors
1566
- #
1567
- 'footerBGColor' => '#ECECEC',
1568
- 'headerBGColor' => '#ECECEC',
1569
- 'footerFontColor' => '#494949',
1570
- 'headerFontColor' => '#494949',
1571
- 'tableBorder' => '1',
1572
- 'cornerRadius' => 15,
1573
-
1574
- 'useBoxShadow' => true,
1575
- 'shadowInset' => 10,
1576
- 'shadowSpread' => 20,
1577
- 'shadowColor' => '#888888',
1597
+ #
1598
+ # Table Colors
1599
+ #
1600
+ 'footerBGColor' => '#ECECEC',
1601
+ 'headerBGColor' => '#ECECEC',
1602
+ 'footerFontColor' => '#494949',
1603
+ 'headerFontColor' => '#494949',
1604
+ 'tableBorder' => '1',
1605
+ 'cornerRadius' => 15,
1606
+
1607
+ 'useBoxShadow' => true,
1608
+ 'shadowInset' => 10,
1609
+ 'shadowSpread' => 20,
1610
+ 'shadowColor' => '#888888',
1578
1611
 
1579
- #
1580
- # Row specifics
1581
- #
1582
- 'rowClass' => '',
1583
- 'rowFontColor' => 'black',
1584
- 'rowColorByStatus' => {},
1585
- 'rowStylesByStatus' => {},
1586
- 'rowOffsets' => ['#FFFFFF','#FFFFFF'],
1587
-
1588
- 'class' => 'listContainerPassive',
1589
- 'tableclass' => 'tableBlowOutPreventer',
1590
- 'noDataMessage' => 'Currently no data.',
1591
- 'useSort' => true,
1592
- 'headerClass' => {},
1593
- 'fieldFunction' => {},
1594
- 'buttonVal' => 'templateListJump',
1595
- 'linkFunction' => 'ButtonLinkPost',
1596
- 'template' => '',
1597
- 'LIST_COL_SORT_ORDER' => 'ASC',
1598
- 'LIST_COL_SORT' => '',
1599
- 'LIST_FILTER_ALL' => '',
1600
- 'ROW_LIMIT' => '',
1601
- 'LIST_SEQUENCE' => 1,
1602
- 'NEW_SEARCH' => false,
1612
+ #
1613
+ # Row specifics
1614
+ #
1615
+ 'rowClass' => '',
1616
+ 'rowFontColor' => 'black',
1617
+ 'rowColorByStatus' => {},
1618
+ 'rowStylesByStatus' => {},
1619
+ 'rowOffsets' => ['#FFFFFF','#FFFFFF'],
1620
+
1621
+ 'class' => 'listContainerPassive',
1622
+ 'tableclass' => 'tableBlowOutPreventer',
1623
+ 'noDataMessage' => 'Currently no data.',
1624
+ 'useSort' => true,
1625
+ 'headerClass' => {},
1626
+ 'fieldFunction' => {},
1627
+ 'buttonVal' => 'templateListJump',
1628
+ 'linkFunction' => 'ButtonLinkPost',
1629
+ 'template' => '',
1630
+ 'LIST_COL_SORT_ORDER' => 'ASC',
1631
+ 'LIST_COL_SORT' => '',
1632
+ 'LIST_FILTER_ALL' => '',
1633
+ 'ROW_LIMIT' => '',
1634
+ 'LIST_SEQUENCE' => 1,
1635
+ 'NEW_SEARCH' => false,
1603
1636
 
1604
- #
1605
- # Checkbox
1606
- #
1607
- 'checkedClass' => 'widgetlist-checkbox',
1608
- 'checkedFlag' => {},
1609
- 'storeSessionChecks' => false,
1637
+ #
1638
+ # Checkbox
1639
+ #
1640
+ 'checkedClass' => 'widgetlist-checkbox',
1641
+ 'checkedFlag' => {},
1642
+ 'storeSessionChecks' => false,
1610
1643
 
1611
- #
1612
- # Hooks
1613
- #
1614
- 'columnHooks' => {},
1615
- 'rowHooks' => {}
1644
+ #
1645
+ # Hooks
1646
+ #
1647
+ 'columnHooks' => {},
1648
+ 'rowHooks' => {}
1616
1649
  }
1617
1650
  end
1618
1651
 
@@ -2031,11 +2064,11 @@ module WidgetList
2031
2064
  list_search['name'] = 'list_search_name_' + @items['name']
2032
2065
  list_search['class'] = 'inputOuter widget-search-outer ' + @items['name'].downcase + '-search'
2033
2066
  list_search['search_ahead'] = {
2034
- 'url' => searchUrl,
2035
- 'skip_queue' => false,
2036
- 'target' => @items['name'],
2037
- 'search_form' => @items['listSearchForm'],
2038
- 'onkeyup' => (! @items['searchOnkeyup'].empty?) ? WidgetList::Utils::fill({'<!--URL-->'=>searchUrl, '<!--TARGET-->' => @items['name'], '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll']}, @items['searchOnkeyup'] + '<!--FUNCTION_ALL-->') : ''
2067
+ 'url' => searchUrl,
2068
+ 'skip_queue' => false,
2069
+ 'target' => @items['name'],
2070
+ 'search_form' => @items['listSearchForm'],
2071
+ 'onkeyup' => (! @items['searchOnkeyup'].empty?) ? WidgetList::Utils::fill({'<!--URL-->'=>searchUrl, '<!--TARGET-->' => @items['name'], '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll']}, @items['searchOnkeyup'] + '<!--FUNCTION_ALL-->') : ''
2039
2072
  }
2040
2073
 
2041
2074
  fillRansack = {}
@@ -2092,8 +2125,8 @@ module WidgetList
2092
2125
  }
2093
2126
 
2094
2127
  list_group['search_ahead'] = {
2095
- 'skip_queue' => false,
2096
- 'search_form'=> '
2128
+ 'skip_queue' => false,
2129
+ 'search_form'=> '
2097
2130
  <div id="advanced-search-container" style="height:100% !important;">
2098
2131
  ' + groupRows.join("\n") + '
2099
2132
  </div>'
@@ -2226,11 +2259,11 @@ module WidgetList
2226
2259
  #Assemble navigation buttons
2227
2260
  #
2228
2261
  pieces = {
2229
- '<!--NEXT_URL-->' => nextUrl,
2230
- '<!--LIST_NAME-->' => @items['name'],
2231
- '<!--PREVIOUS_URL-->' => prevUrl,
2232
- '<!--FUNCTION-->' => @items['ajaxFunction'],
2233
- '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2262
+ '<!--NEXT_URL-->' => nextUrl,
2263
+ '<!--LIST_NAME-->' => @items['name'],
2264
+ '<!--PREVIOUS_URL-->' => prevUrl,
2265
+ '<!--FUNCTION-->' => @items['ajaxFunction'],
2266
+ '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2234
2267
  }
2235
2268
 
2236
2269
  templates['btn_next'] = WidgetList::Utils::fill(pieces,templates['btn_next'])
@@ -2333,23 +2366,23 @@ module WidgetList
2333
2366
  end
2334
2367
 
2335
2368
  jumpSection << WidgetList::Utils::fill({
2336
- '<!--SEQUENCE-->' => page,
2337
- '<!--JUMP_URL-->' => jumpUrl,
2338
- '<!--LIST_NAME-->' => @items['name'],
2339
- '<!--FUNCTION-->' => @items['ajaxFunction'],
2340
- '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2369
+ '<!--SEQUENCE-->' => page,
2370
+ '<!--JUMP_URL-->' => jumpUrl,
2371
+ '<!--LIST_NAME-->' => @items['name'],
2372
+ '<!--FUNCTION-->' => @items['ajaxFunction'],
2373
+ '<!--FUNCTION_ALL-->' => @items['ajaxFunctionAll'],
2341
2374
  }, jumpTemplate)
2342
2375
  end
2343
2376
 
2344
2377
  pieces = {
2345
- '<!--PREVIOUS_BUTTON-->' => templates['btn_previous'],
2346
- '<!--SEQUENCE-->' => @sequence,
2347
- '<!--NEXT_BUTTON-->' => templates['btn_next'],
2348
- '<!--TOTAL_PAGES-->' => @totalPages,
2349
- '<!--TOTAL_ROWS-->' => @totalRows,
2350
- '<!--PAGE_SEQUENCE_JUMP_LIST-->' => pageSelect,
2351
- '<!--JUMP-->' => jumpSection.join(''),
2352
- '<!--LIST_NAME-->' => @items['name'],
2378
+ '<!--PREVIOUS_BUTTON-->' => templates['btn_previous'],
2379
+ '<!--SEQUENCE-->' => @sequence,
2380
+ '<!--NEXT_BUTTON-->' => templates['btn_next'],
2381
+ '<!--TOTAL_PAGES-->' => @totalPages,
2382
+ '<!--TOTAL_ROWS-->' => @totalRows,
2383
+ '<!--PAGE_SEQUENCE_JUMP_LIST-->' => pageSelect,
2384
+ '<!--JUMP-->' => jumpSection.join(''),
2385
+ '<!--LIST_NAME-->' => @items['name'],
2353
2386
  }
2354
2387
 
2355
2388
  paginationOutput = WidgetList::Utils::fill(pieces,@items['template_pagination_wrapper'])
@@ -2500,7 +2533,7 @@ module WidgetList
2500
2533
 
2501
2534
  if (
2502
2535
  ( (@items.key?('LIST_COL_SORT') && !@items['LIST_COL_SORT'].empty?) && @items['LIST_COL_SORT'] == colSort['LIST_COL_SORT']) ||
2503
- ( $_SESSION.key?('LIST_COL_SORT') && !$_SESSION['LIST_COL_SORT'].nil? && $_SESSION['LIST_COL_SORT'].key?(@sqlHash) && $_SESSION['LIST_COL_SORT'][@sqlHash].key?(field))
2536
+ ( $_SESSION.key?('LIST_COL_SORT') && !$_SESSION['LIST_COL_SORT'].nil? && $_SESSION['LIST_COL_SORT'].key?(@sqlHash) && $_SESSION['LIST_COL_SORT'][@sqlHash].key?(field))
2504
2537
  )
2505
2538
  changedSession = false
2506
2539
  if @items.key?('LIST_COL_SORT') && !@items['LIST_COL_SORT'].empty?
@@ -2759,65 +2792,100 @@ module WidgetList
2759
2792
  def self.checkbox_helper(list_parms,primary_key)
2760
2793
 
2761
2794
  list_parms.deep_merge!({'inputs' =>
2762
- {'checkbox'=>
2763
- {'type' => 'checkbox'
2764
- }
2765
- }
2795
+ {'checkbox'=>
2796
+ {'type' => 'checkbox'
2797
+ }
2798
+ }
2766
2799
  })
2767
2800
 
2768
2801
  list_parms.deep_merge!({'inputs' =>
2769
- {'checkbox'=>
2770
- {'items' =>
2771
- {
2772
- 'name' => list_parms['name'] + '_visible_checks[]',
2773
- 'value' => primary_key, #the value should be a column name mapping
2774
- 'class_handle' => list_parms['name'] + '_info_tables',
2775
- }
2776
- }
2777
- }
2802
+ {'checkbox'=>
2803
+ {'items' =>
2804
+ {
2805
+ 'name' => list_parms['name'] + '_visible_checks[]',
2806
+ 'value' => primary_key, #the value should be a column name mapping
2807
+ 'class_handle' => list_parms['name'] + '_info_tables',
2808
+ }
2809
+ }
2810
+ }
2778
2811
  })
2779
2812
 
2780
2813
  list_parms.deep_merge!({'inputs' =>
2781
- {'checkbox_header'=>
2782
- {'type' => 'checkbox'
2783
- }
2784
- }
2814
+ {'checkbox_header'=>
2815
+ {'type' => 'checkbox'
2816
+ }
2817
+ }
2785
2818
  })
2786
2819
 
2787
2820
  list_parms.deep_merge!({'inputs' =>
2788
- {'checkbox_header'=>
2789
- {'items' =>
2790
- {
2791
- 'check_all' => true,
2792
- 'id' => list_parms['name'] + '_info_tables_check_all',
2793
- 'class_handle' => list_parms['name'] + '_info_tables',
2794
- }
2795
- }
2796
- }
2821
+ {'checkbox_header'=>
2822
+ {'items' =>
2823
+ {
2824
+ 'check_all' => true,
2825
+ 'id' => list_parms['name'] + '_info_tables_check_all',
2826
+ 'class_handle' => list_parms['name'] + '_info_tables',
2827
+ }
2828
+ }
2829
+ }
2797
2830
  })
2798
2831
  return list_parms
2799
2832
  end
2800
2833
 
2834
+
2835
+ def self.group_by_max_each_field(list_parms,group_by_filter)
2836
+
2837
+ #
2838
+ # Oracle needs MAX on most fields when grouping in order to shy away from 'not a GROUP BY expression' errors
2839
+ #
2840
+ if group_by_filter != 'none'
2841
+ if list_parms.key?('fieldFunction') && !list_parms['fieldFunction'].empty?
2842
+ list_parms['fieldFunction'].each { |k, v|
2843
+ if !k.include?('_linked') && k != 'cnt'
2844
+ list_parms['fieldFunction'][k] = "MAX(#{v})"
2845
+ end
2846
+ }
2847
+ end
2848
+
2849
+ if list_parms.key?('fieldsHidden') && !list_parms['fieldsHidden'].empty?
2850
+ list_parms['fieldsHidden'].each { |k|
2851
+ if (list_parms.key?('fieldFunction') && !list_parms['fieldFunction'].empty? && !list_parms['fieldFunction'].key?(k)) || list_parms['fieldFunction'].empty?
2852
+ list_parms['fieldFunction'][k] = "MAX(#{k})"
2853
+ end
2854
+ }
2855
+ end
2856
+
2857
+ list_parms['fields'].each { |k|
2858
+ if !k.include?('_linked') && k != 'cnt'
2859
+ if (list_parms.key?('fieldFunction') && !list_parms['fieldFunction'].empty? && !list_parms['fieldFunction'].key?(k)) || list_parms['fieldFunction'].empty?
2860
+ list_parms['fieldFunction'][k] = "MAX(#{k})"
2861
+ end
2862
+ end
2863
+ }
2864
+ end
2865
+
2866
+ return list_parms
2867
+ end
2868
+
2801
2869
  def self.drill_down_back(list_name='')
2802
2870
  '<div class="goback" onclick="ListHome(\'' + list_name + '\');" title="Go Back"></div>'
2803
2871
  end
2804
2872
 
2805
2873
  def self.build_drill_down(*params)
2806
2874
  required_params = {
2807
- :list_id => true, # -- your widget_list name (used for JS)
2808
- :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
2809
- :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
2810
- :column_to_show => true, # -- The visible column or SQL functions to display to user for the link
2875
+ :list_id => true, # -- your widget_list name (used for JS)
2876
+ :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
2877
+ :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
2878
+ :column_to_show => true, # -- The visible column or SQL functions to display to user for the link
2811
2879
  }
2812
2880
 
2813
2881
  optional_params = {
2814
- :column_alias => '', # -- AS XXXX
2815
- :extra_function => '', # -- Onclick of link, call another JS function after the drill down function is called
2816
- :js_function_name => 'ListDrillDown', # -- name of JS Function
2817
- :column_class => '', # -- custom class on the <a> tag
2818
- :link_color => 'blue', # -- whatever color you want the link to be
2819
- :extra_js_func_params => '', # -- Add extra params to ListDrillDown outside of the default
2820
- :primary_database => true, # -- Since this function builds a column before widget_list is instantiated, tell which connection you are using
2882
+ :column_alias => '', # -- AS XXXX
2883
+ :extra_function => '', # -- Onclick of link, call another JS function after the drill down function is called
2884
+ :js_function_name => 'ListDrillDown', # -- name of JS Function
2885
+ :column_class => '', # -- custom class on the <a> tag
2886
+ :link_color => 'blue', # -- whatever color you want the link to be
2887
+ :extra_js_func_params => '', # -- Add extra params to ListDrillDown outside of the default
2888
+ :primary_database => true, # -- Since this function builds a column before widget_list is instantiated, tell which connection you are using
2821
2889
  }
2822
2890
 
2823
2891
  valid = WidgetList::Widgets::validate_items(params[0],required_params)
@@ -3429,7 +3497,7 @@ module WidgetList
3429
3497
  when 'oracle'
3430
3498
 
3431
3499
  pieces['<!--LIMIT-->'] =
3432
- '
3500
+ '
3433
3501
  WHERE
3434
3502
  (
3435
3503
  rn >' + (@sequence > 1 ? '' : '=') + ' :LOW
@@ -1,3 +1,3 @@
1
1
  module WidgetList
2
- VERSION = "1.2.5"
2
+ VERSION = "1.2.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: widget_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: