widget_list 1.0.7 → 1.0.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +22 -6
- data/lib/widget_list/sequel.rb +3 -2
- data/lib/widget_list/version.rb +1 -1
- data/lib/widget_list/widgets.rb +18 -0
- data/lib/widget_list.rb +80 -32
- data/vendor/assets/stylesheets/widget_list.css +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -245,11 +245,13 @@ Style a row based on the value of the column.
|
|
245
245
|
### Example Calling Page That Sets up Config and calls WidgetList.render
|
246
246
|
|
247
247
|
|
248
|
+
|
248
249
|
#
|
249
250
|
# Load Sample "items" Data. Comment out in your first time executing a widgetlist to create the items table
|
250
251
|
#
|
252
|
+
=begin
|
251
253
|
begin
|
252
|
-
WidgetList::List.
|
254
|
+
WidgetList::List.get_sequel.create_table :items do
|
253
255
|
primary_key :id
|
254
256
|
String :name
|
255
257
|
Float :price
|
@@ -257,7 +259,7 @@ Style a row based on the value of the column.
|
|
257
259
|
String :active
|
258
260
|
Date :date_added
|
259
261
|
end
|
260
|
-
items = WidgetList::List.
|
262
|
+
items = WidgetList::List.get_sequel[:items]
|
261
263
|
100.times {
|
262
264
|
items.insert(:name => 'ab\'c_quoted_' + rand(35).to_s, :price => rand * 100, :date_added => '2008-02-01', :sku => rand(9999), :active => 'Yes')
|
263
265
|
items.insert(:name => '12"3_' + rand(35).to_s, :price => rand * 100, :date_added => '2008-02-02', :sku => rand(9999), :active => 'Yes')
|
@@ -271,6 +273,7 @@ Style a row based on the value of the column.
|
|
271
273
|
#
|
272
274
|
logger.info "Test table in items already exists? " + e.to_s
|
273
275
|
end
|
276
|
+
=end
|
274
277
|
|
275
278
|
begin
|
276
279
|
|
@@ -344,8 +347,21 @@ Style a row based on the value of the column.
|
|
344
347
|
list_parms['fieldsHidden'] = ['sku']
|
345
348
|
|
346
349
|
drill_downs = []
|
347
|
-
|
348
|
-
drill_downs << WidgetList::List::
|
350
|
+
|
351
|
+
drill_downs << WidgetList::List::build_drill_down( :list_id => list_parms['name'],
|
352
|
+
:drill_down_name => 'filter_by_name',
|
353
|
+
:data_to_pass_from_view => 'a.name',
|
354
|
+
:column_to_show => 'a.name',
|
355
|
+
:column_alias => 'name_linked'
|
356
|
+
)
|
357
|
+
|
358
|
+
drill_downs << WidgetList::List::build_drill_down(
|
359
|
+
:list_id => list_parms['name'],
|
360
|
+
:drill_down_name => 'filter_by_sku',
|
361
|
+
:data_to_pass_from_view => 'a.sku',
|
362
|
+
:column_to_show => 'a.sku',
|
363
|
+
:column_alias => 'sku_linked'
|
364
|
+
)
|
349
365
|
|
350
366
|
list_parms['view'] = '(
|
351
367
|
SELECT
|
@@ -379,7 +395,7 @@ Style a row based on the value of the column.
|
|
379
395
|
|
380
396
|
|
381
397
|
list_parms['noDataMessage'] = 'No Ruby Items Found'
|
382
|
-
list_parms['title'] = 'Ruby Items!!!'
|
398
|
+
list_parms['title'] = 'Ruby Items Using Sequel!!!'
|
383
399
|
|
384
400
|
#
|
385
401
|
# Create small button array and pass to the buttons key
|
@@ -399,7 +415,7 @@ Style a row based on the value of the column.
|
|
399
415
|
list_parms['buttons'] = {button_column_name => mini_buttons}
|
400
416
|
list_parms['fieldFunction'] = {
|
401
417
|
button_column_name => "''",
|
402
|
-
'date_added' => ['postgres','oracle'].include?(WidgetList::List
|
418
|
+
'date_added' => ['postgres','oracle'].include?(WidgetList::List::get_db_type) ? "TO_CHAR(date_added, 'MM/DD/YYYY')" : "date_added"
|
403
419
|
}
|
404
420
|
|
405
421
|
list_parms['groupByItems'] = ['All Records', 'Item Name', 'Sku Number']
|
data/lib/widget_list/sequel.rb
CHANGED
data/lib/widget_list/version.rb
CHANGED
data/lib/widget_list/widgets.rb
CHANGED
@@ -588,6 +588,24 @@ module WidgetList
|
|
588
588
|
items
|
589
589
|
end
|
590
590
|
|
591
|
+
def self.validate_items(list,items)
|
592
|
+
valid = true
|
593
|
+
unless items.empty?
|
594
|
+
items.each { |k,v|
|
595
|
+
if !list.to_s.empty? && !list.key?(k)
|
596
|
+
valid = false
|
597
|
+
throw "Required item '#{k.to_s}' only passed in #{items.inspect}"
|
598
|
+
end
|
599
|
+
}
|
600
|
+
end
|
601
|
+
|
602
|
+
if list.to_s.empty? && !items.empty?
|
603
|
+
valid = false
|
604
|
+
throw "Required items are needing to be passed #{items.inspect} are all required for this function"
|
605
|
+
end
|
606
|
+
return valid
|
607
|
+
end
|
608
|
+
|
591
609
|
# WidgetButton
|
592
610
|
def self.widget_button(text='', list={}, small=false)
|
593
611
|
items = {
|
data/lib/widget_list.rb
CHANGED
@@ -387,7 +387,7 @@ module WidgetList
|
|
387
387
|
end
|
388
388
|
|
389
389
|
matchesCurrentList = $_REQUEST.key?('BUTTON_VALUE') && $_REQUEST['BUTTON_VALUE'] == @items['buttonVal']
|
390
|
-
isSearchRequest = $_REQUEST.key?('search_filter')
|
390
|
+
isSearchRequest = $_REQUEST.key?('search_filter') && $_REQUEST['search_filter'] != 'undefined'
|
391
391
|
templateCustomSearch = !@items['templateFilter'].empty? # if you define templateFilter WidgetList will not attempt to build a where clause with search
|
392
392
|
|
393
393
|
#
|
@@ -1648,7 +1648,54 @@ module WidgetList
|
|
1648
1648
|
'<div class="goback" onclick="ListHome(\'' + list_name + '\');" title="Go Back"></div>'
|
1649
1649
|
end
|
1650
1650
|
|
1651
|
+
def self.build_drill_down(*params)
|
1652
|
+
required_params = {
|
1653
|
+
:list_id => true, # -- your widget_list name (used for JS)
|
1654
|
+
: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
|
1655
|
+
: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
|
1656
|
+
:column_to_show => true, # -- The visible column or SQL functions to display to user for the link
|
1657
|
+
}
|
1658
|
+
|
1659
|
+
optional_params = {
|
1660
|
+
:column_alias => '', # -- AS XXXX
|
1661
|
+
:extra_function => '', # -- Onclick of link, call another JS function after the drill down function is called
|
1662
|
+
:js_function_name => 'ListDrillDown', # -- name of JS Function
|
1663
|
+
:column_class => '', # -- custom class on the <a> tag
|
1664
|
+
:link_color => 'blue', # -- whatever color you want the link to be
|
1665
|
+
:extra_js_func_params => '', # -- Add extra params to ListDrillDown outside of the default
|
1666
|
+
:primary_database => true, # -- Since this function builds a column before widget_list is instantiated, tell which connection you are using
|
1667
|
+
}
|
1668
|
+
|
1669
|
+
valid = WidgetList::Widgets::validate_items(params[0],required_params)
|
1670
|
+
items = WidgetList::Widgets::populate_items(params[0],optional_params)
|
1671
|
+
|
1672
|
+
if items[:column_alias].empty?
|
1673
|
+
items[:column_alias] = items[:column_to_show]
|
1674
|
+
end
|
1675
|
+
|
1676
|
+
if !items[:column_class].empty?
|
1677
|
+
items[:column_class] = ' "' + WidgetList::List::concat_string(items[:primary_database]) + items[:column_class] + WidgetList::List::concat_string(items[:primary_database]) + '"'
|
1678
|
+
end
|
1679
|
+
|
1680
|
+
if WidgetList::List.get_db_type(items[:primary_database]) == 'oracle'
|
1681
|
+
if $_REQUEST.key?('export_widget_list')
|
1682
|
+
link = "#{items[:column_to_show]} #{WidgetList::List::is_sequel(items[:primary_database]) ? " as #{items[:column_alias]} " : ""}"
|
1683
|
+
else
|
1684
|
+
link = %[q'[<a style='cursor:pointer;color:#{items[:link_color]};' class='#{items[:column_alias]}_drill#{items[:column_class]}' onclick='#{items[:js_function_name]}("#{items[:drill_down_name]}", ListDrillDownGetRowValue(this) ,"#{items[:list_id]}"#{items[:extra_js_func_params]});#{items[:extra_function]}'>]' #{WidgetList::List::concat_string(items[:primary_database])}#{items[:column_to_show]}#{WidgetList::List::concat_string(items[:primary_database])}q'[</a><script class='val-db' type='text'>]' #{WidgetList::List::concat_string(items[:primary_database])} #{items[:data_to_pass_from_view]} #{WidgetList::List::concat_string(items[:primary_database])} q'[</script>]' #{WidgetList::List::concat_outer(items[:primary_database])} #{WidgetList::List::is_sequel(items[:primary_database]) ? " as #{items[:column_alias]} " : ""}]
|
1685
|
+
end
|
1686
|
+
else
|
1687
|
+
if $_REQUEST.key?('export_widget_list')
|
1688
|
+
link = "#{items[:column_to_show]} #{WidgetList::List::is_sequel(items[:primary_database]) ? " as #{items[:column_alias]} " : ""}"
|
1689
|
+
else
|
1690
|
+
link = %[#{WidgetList::List::concat_inner(items[:primary_database])}"<a style='cursor:pointer;color:#{items[:link_color]};' class='#{items[:column_alias]}_drill#{items[:column_class]}' onclick='#{items[:js_function_name]}(#{WidgetList::List::double_quote(items[:primary_database])}#{items[:drill_down_name]}#{WidgetList::List::double_quote(items[:primary_database])}, ListDrillDownGetRowValue(this) ,#{WidgetList::List::double_quote(items[:primary_database])}#{items[:list_id]}#{WidgetList::List::double_quote(items[:primary_database])}#{items[:extra_js_func_params]});#{items[:extra_function]}'>"#{WidgetList::List::concat_string(items[:primary_database])}#{items[:column_to_show]}#{WidgetList::List::concat_string(items[:primary_database])}"</a><script class='val-db' type='text'>"#{WidgetList::List::concat_string(items[:primary_database])} #{items[:data_to_pass_from_view]} #{WidgetList::List::concat_string(items[:primary_database])}"</script>"#{WidgetList::List::concat_outer(items[:primary_database])} #{WidgetList::List::is_sequel(items[:primary_database]) ? " as #{items[:column_alias]} " : ""}]
|
1691
|
+
end
|
1692
|
+
end
|
1693
|
+
return link
|
1694
|
+
|
1695
|
+
end
|
1696
|
+
|
1651
1697
|
def self.build_drill_down_link(listId,drillDownName,dataToPassFromView,columnToShow,columnAlias='',extraFunction='',functionName='ListDrillDown',columnClass='',color='blue',extraJSFunctionParams='',primary=true)
|
1698
|
+
warn "`build_drill_down_link` is deprecated. Use `build_drill_down` instead."
|
1652
1699
|
if columnAlias.empty?
|
1653
1700
|
columnAlias = columnToShow
|
1654
1701
|
end
|
@@ -1670,8 +1717,7 @@ module WidgetList
|
|
1670
1717
|
link = %[#{WidgetList::List::concat_inner(primary)}"<a style='cursor:pointer;color:#{color};' class='#{columnAlias}_drill#{columnClass}' onclick='#{functionName}(#{WidgetList::List::double_quote(primary)}#{drillDownName}#{WidgetList::List::double_quote(primary)}, ListDrillDownGetRowValue(this) ,#{WidgetList::List::double_quote(primary)}#{listId}#{WidgetList::List::double_quote(primary)}#{extraJSFunctionParams});#{extraFunction}'>"#{WidgetList::List::concat_string(primary)}#{columnToShow}#{WidgetList::List::concat_string(primary)}"</a><script class='val-db' type='text'>"#{WidgetList::List::concat_string(primary)} #{dataToPassFromView} #{WidgetList::List::concat_string(primary)}"</script>"#{WidgetList::List::concat_outer(primary)} #{WidgetList::List::is_sequel(primary) ? " as #{columnAlias} " : ""}]
|
1671
1718
|
end
|
1672
1719
|
end
|
1673
|
-
|
1674
|
-
|
1720
|
+
return link
|
1675
1721
|
end
|
1676
1722
|
|
1677
1723
|
def self.concat_string(primary)
|
@@ -2319,7 +2365,7 @@ module WidgetList
|
|
2319
2365
|
end
|
2320
2366
|
end
|
2321
2367
|
|
2322
|
-
def self.get_db_type(primary)
|
2368
|
+
def self.get_db_type(primary=true)
|
2323
2369
|
WidgetList::List::load_widget_list_yml()
|
2324
2370
|
if primary
|
2325
2371
|
database_conn = $widget_list_conf[:primary]
|
@@ -2329,13 +2375,13 @@ module WidgetList
|
|
2329
2375
|
WidgetList::List::determine_db_type(database_conn)
|
2330
2376
|
end
|
2331
2377
|
|
2332
|
-
def get_db_type(primary)
|
2378
|
+
def get_db_type(primary=true)
|
2333
2379
|
WidgetList::List::get_db_type(primary)
|
2334
2380
|
end
|
2335
2381
|
|
2336
2382
|
def get_view
|
2337
2383
|
@active_record_model = false
|
2338
|
-
if @
|
2384
|
+
if (@is_primary_sequel && @items['database'] == 'primary') || (@is_secondary_sequel && @items['database'] == 'secondary')
|
2339
2385
|
return @items['view']
|
2340
2386
|
elsif @items['view'].respond_to?('scoped') && @items['view'].scoped.respond_to?('to_sql')
|
2341
2387
|
@active_record_model = @items['view'].name.constantize
|
@@ -2383,6 +2429,7 @@ module WidgetList
|
|
2383
2429
|
end
|
2384
2430
|
|
2385
2431
|
def connect
|
2432
|
+
|
2386
2433
|
@has_connected = true
|
2387
2434
|
begin
|
2388
2435
|
if Rails.root.join("config", "widget-list.yml").file?
|
@@ -2396,17 +2443,18 @@ module WidgetList
|
|
2396
2443
|
throw 'widget-list.yml not found'
|
2397
2444
|
end
|
2398
2445
|
|
2399
|
-
@
|
2400
|
-
|
2401
|
-
|
2446
|
+
@is_primary_sequel = true
|
2447
|
+
@is_secondary_sequel = true
|
2448
|
+
if @primary_conn != false && ! @primary_conn.include?(':/')
|
2449
|
+
@is_primary_sequel = false
|
2402
2450
|
end
|
2403
2451
|
|
2404
|
-
if @secondary_conn != false && !@secondary_conn.include?('
|
2405
|
-
@
|
2452
|
+
if @secondary_conn != false && !@secondary_conn.include?(':/')
|
2453
|
+
@is_secondary_sequel = false
|
2406
2454
|
end
|
2407
2455
|
|
2408
2456
|
if @primary_conn != false
|
2409
|
-
if @primary_conn.include?('
|
2457
|
+
if @primary_conn.include?(':/')
|
2410
2458
|
@widget_list_sequel_conn = Sequel.connect(@primary_conn)
|
2411
2459
|
@widget_list_sequel_conn.db_type = WidgetList::List::determine_db_type(@primary_conn)
|
2412
2460
|
else
|
@@ -2416,7 +2464,7 @@ module WidgetList
|
|
2416
2464
|
end
|
2417
2465
|
|
2418
2466
|
if @secondary_conn != false
|
2419
|
-
if @secondary_conn.include?('
|
2467
|
+
if @secondary_conn.include?(':/')
|
2420
2468
|
@widget_list_sequel_conn2 = Sequel.connect(@secondary_conn)
|
2421
2469
|
@widget_list_sequel_conn2.db_type = WidgetList::List::determine_db_type(@secondary_conn)
|
2422
2470
|
else
|
@@ -2426,7 +2474,7 @@ module WidgetList
|
|
2426
2474
|
end
|
2427
2475
|
|
2428
2476
|
rescue Exception => e
|
2429
|
-
|
2477
|
+
Rails.logger.info "widget-list.yml and connection to @widget_list_sequel_conn or @widget_list_sequel_conn2 failed. Please fix and try again (" + e.to_s + ")"
|
2430
2478
|
end
|
2431
2479
|
|
2432
2480
|
end
|
@@ -2446,36 +2494,36 @@ module WidgetList
|
|
2446
2494
|
return is_sequel
|
2447
2495
|
end
|
2448
2496
|
|
2497
|
+
def self.get_sequel(primary=true)
|
2498
|
+
WidgetList::List::load_widget_list_yml()
|
2499
|
+
if primary
|
2500
|
+
Sequel.connect($widget_list_conf[:primary])
|
2501
|
+
else
|
2502
|
+
Sequel.connect($widget_list_conf[:secondary])
|
2503
|
+
end
|
2504
|
+
end
|
2505
|
+
|
2449
2506
|
def get_database
|
2450
2507
|
|
2451
2508
|
if @has_connected.nil?
|
2452
2509
|
connect
|
2453
2510
|
end
|
2454
2511
|
|
2455
|
-
if @
|
2456
|
-
|
2457
|
-
|
2458
|
-
|
2459
|
-
|
2460
|
-
|
2461
|
-
if @current_db_selection == 'secondary'
|
2462
|
-
@widget_list_sequel_conn2.test_connection
|
2463
|
-
end
|
2464
|
-
else
|
2465
|
-
connect
|
2466
|
-
end
|
2467
|
-
rescue
|
2468
|
-
connect
|
2469
|
-
end
|
2512
|
+
if @is_primary_sequel && @widget_list_sequel_conn.class.name.to_s.split('::').first == 'Sequel' && @current_db_selection == 'primary' || @current_db_selection.nil?
|
2513
|
+
@widget_list_sequel_conn.test_connection
|
2514
|
+
end
|
2515
|
+
|
2516
|
+
if @is_secondary_sequel && @widget_list_sequel_conn2.class.name.to_s.split('::').first == 'Sequel' && @current_db_selection == 'secondary'
|
2517
|
+
@widget_list_sequel_conn2.test_connection
|
2470
2518
|
end
|
2471
2519
|
|
2472
2520
|
case @current_db_selection
|
2473
2521
|
when 'primary'
|
2474
|
-
return (@
|
2522
|
+
return (@is_primary_sequel) ? @widget_list_sequel_conn : @widget_list_ar_conn
|
2475
2523
|
when 'secondary'
|
2476
|
-
return (@
|
2524
|
+
return (@is_secondary_sequel) ? @widget_list_sequel_conn2 : @widget_list_ar_conn2
|
2477
2525
|
else
|
2478
|
-
return (@
|
2526
|
+
return (@is_primary_sequel) ? @widget_list_sequel_conn : @widget_list_ar_conn
|
2479
2527
|
end
|
2480
2528
|
|
2481
2529
|
end
|
@@ -633,7 +633,7 @@ div.inputOuter .inputInner input.search-ahead {width:97%}
|
|
633
633
|
* Search Ahead Magifier Glass
|
634
634
|
*/
|
635
635
|
.widget-search-magnifier {background: url('../assets/images/gobblecons/mid-gray/search-16.png') no-repeat scroll 0px 0px transparent;float:right;margin:7px;position: relative;right:-13px;top:-30px;cursor:pointer;border:0px solid red;height:20px;width:20px}
|
636
|
-
.widget-search-magnifier:hover {background: url('../assets/images/gobblecons/
|
636
|
+
.widget-search-magnifier:hover {background: url('../assets/images/gobblecons/mid-gray/search-16.png') no-repeat scroll 0px 0px transparent}
|
637
637
|
|
638
638
|
/**
|
639
639
|
* Advanced Search Close Button
|
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.0.
|
4
|
+
version: 1.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-02-
|
12
|
+
date: 2013-02-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sequel
|