zuora_connect_ui 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE.txt +21 -0
  3. data/README.md +39 -0
  4. data/app/assets/javascripts/zuora_connect_ui/input.js +9 -0
  5. data/app/assets/javascripts/zuora_connect_ui.js +30 -0
  6. data/app/assets/stylesheets/_zuora_connect_ui.scss +125 -0
  7. data/app/assets/stylesheets/zuora_connect_ui/base.scss +130 -0
  8. data/app/assets/stylesheets/zuora_connect_ui/box.scss +115 -0
  9. data/app/assets/stylesheets/zuora_connect_ui/breadcrumb_bar.scss +110 -0
  10. data/app/assets/stylesheets/zuora_connect_ui/buttons.scss +185 -0
  11. data/app/assets/stylesheets/zuora_connect_ui/datatables.scss +290 -0
  12. data/app/assets/stylesheets/zuora_connect_ui/grid_view.scss +174 -0
  13. data/app/assets/stylesheets/zuora_connect_ui/input.scss +267 -0
  14. data/app/assets/stylesheets/zuora_connect_ui/modal.scss +40 -0
  15. data/app/assets/stylesheets/zuora_connect_ui/tabs.scss +42 -0
  16. data/app/helpers/input_helper.rb +6 -0
  17. data/app/views/partials/_admin_menu.html.erb +22 -0
  18. data/app/views/partials/_filters.html.erb +34 -0
  19. data/app/views/partials/_table.html.erb +395 -0
  20. data/app/views/peek/views/_connect.html.erb +5 -0
  21. data/lib/peek/views/connect.rb +13 -0
  22. data/lib/zuora_connect_ui/version.rb +3 -0
  23. data/lib/zuora_connect_ui.rb +13 -0
  24. data/vendor/assets/awesome-bootstrap-checkbox/css/awesome-bootstrap-checkbox.scss +256 -0
  25. data/vendor/assets/icons/css/icons.scss +7118 -0
  26. data/vendor/assets/icons/img/FontAwesome.otf +0 -0
  27. data/vendor/assets/icons/img/fontawesome-webfont.eot +0 -0
  28. data/vendor/assets/icons/img/fontawesome-webfont.svg +685 -0
  29. data/vendor/assets/icons/img/fontawesome-webfont.ttf +0 -0
  30. data/vendor/assets/icons/img/fontawesome-webfont.woff +0 -0
  31. data/vendor/assets/icons/img/fontawesome-webfont.woff2 +0 -0
  32. data/vendor/assets/icons/img/glyphicons-filetypes-regular.eot +0 -0
  33. data/vendor/assets/icons/img/glyphicons-filetypes-regular.svg +158 -0
  34. data/vendor/assets/icons/img/glyphicons-filetypes-regular.woff +0 -0
  35. data/vendor/assets/icons/img/glyphicons-halfling-life_preserver.png +0 -0
  36. data/vendor/assets/icons/img/glyphicons-halflings-red.png +0 -0
  37. data/vendor/assets/icons/img/glyphicons-halflings-regular.eot +0 -0
  38. data/vendor/assets/icons/img/glyphicons-halflings-regular.svg +229 -0
  39. data/vendor/assets/icons/img/glyphicons-halflings-regular.ttf +0 -0
  40. data/vendor/assets/icons/img/glyphicons-halflings-regular.woff +0 -0
  41. data/vendor/assets/icons/img/glyphicons-halflings-white.png +0 -0
  42. data/vendor/assets/icons/img/glyphicons-halflings.png +0 -0
  43. data/vendor/assets/icons/img/glyphicons-regular.eot +0 -0
  44. data/vendor/assets/icons/img/glyphicons-regular.otf +0 -0
  45. data/vendor/assets/icons/img/glyphicons-regular.svg +498 -0
  46. data/vendor/assets/icons/img/glyphicons-regular.ttf +0 -0
  47. data/vendor/assets/icons/img/glyphicons-regular.woff +0 -0
  48. data/vendor/assets/icons/img/glyphicons-social-regular.eot +0 -0
  49. data/vendor/assets/icons/img/glyphicons-social-regular.svg +79 -0
  50. data/vendor/assets/icons/img/glyphicons-social-regular.ttf +0 -0
  51. data/vendor/assets/icons/img/glyphicons-social-regular.woff +0 -0
  52. data/vendor/assets/icons/img/glyphicons_search.png +0 -0
  53. data/vendor/assets/icons/img/zuora.eot +0 -0
  54. data/vendor/assets/icons/img/zuora.svg +557 -0
  55. data/vendor/assets/icons/img/zuora.ttf +0 -0
  56. data/vendor/assets/icons/img/zuora.woff +0 -0
  57. metadata +211 -0
@@ -0,0 +1,395 @@
1
+ <% columns = columns.map{ |column| column.symbolize_keys! } %>
2
+ <% if !cookies["#{table_name}_table"].blank? %>
3
+ <% json = JSON.parse(cookies["#{table_name}_table"]) %>
4
+ <% if !json['columns'].blank? %>
5
+ <% columns.each_with_index do |column, key| %>
6
+ <% column[:visible] = json['columns'].include?(column[:data].to_s) ? true : false %>
7
+ <% end %>
8
+ <% end %>
9
+ <% if !json['view'].blank? %>
10
+ <% default_view = json['view'] %>
11
+ <% end %>
12
+ <% sort = json['sort'].blank? ? sort : json['sort'] %>
13
+ <% initial_size = json['table_size'].blank? ? initial_size : json['table_size'] %>
14
+ <% ordering = json['ordering'].blank? ? [] : json['ordering'] %>
15
+ <% end %>
16
+
17
+ <% if !ordering.blank? %>
18
+ <% columns = columns.sort_by{ |v| ordering.index(v[:data]).blank? ? 9999 : ordering.index(v[:data])} %>
19
+ <% end %>
20
+ <% mapping = columns.each_with_index.map {|v,i| [v[:data],i]}.to_h %>
21
+ <% sort = sort.map{|col,dir| [mapping[col].blank? ? 1 : mapping[col] ,dir]} %>
22
+ <% debug = !defined?(debug) ? false : debug %>
23
+
24
+ <div id='<%= "#{table_name}_content" %>'>
25
+ <div class='table-header'>
26
+ <div class="table-header-left" >
27
+ <div class="btn-group">
28
+ <% if defined?(table_filters) %>
29
+ <% table_filters.each_with_index do |table_filter, index| %>
30
+ <% table_filter["selection"] = return_cookie_filters(cookie_key: "#{table_name}_table", filter_key: "#{table_filter["name"].parameterize('_')}_filter", values: table_filter["values"], type: table_filter["type"], defaults: table_filter["defaults"]) %>
31
+ <%= render(:partial=>"partials/filters", locals: {:table_filter => table_filter, :index => index, :filter_count => table_filters.size, :table_name => table_name}, :formats => [:html]) %>
32
+ <% end %>
33
+ <% end %>
34
+ </div>
35
+ </div>
36
+
37
+ <div class="table-header-right" >
38
+ <div class="btn-group" data-toggle="buttons">
39
+ <% if defined?(table_actions) && !table_actions.blank? %>
40
+ <%= table_actions %>
41
+ <% end %>
42
+ <div class="dropdown">
43
+ <button type="button" class="hidden table-btn dropdown-toggle group_actions" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
44
+ <span class='fa fa-gears'></span>
45
+ </button>
46
+ <ul class="dropdown-menu" >
47
+ <li style="white-space: nowrap;"><div class="col-sm-12">Export</div></li>
48
+ </ul>
49
+ </div>
50
+ <div class="dropdown">
51
+ <button id='<%= "#{table_name}_visiblity" %>' type="button" class="table-btn dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
52
+ <span class='fa fa-eye'></span>
53
+ </button>
54
+ <ul class="dropdown-menu table_visibility" >
55
+ <% columns.each_with_index do |column, key| %>
56
+ <li>
57
+ <div class='checkbox checkbox-primary'>
58
+ <input type="checkbox" data-key="<%= column[:data] %>" name="<%= table_name %>[table_column_vis][]" <%= column[:visible] == false ? '' : 'checked' %> value="<%= key %>">
59
+ <label><%= ["#{table_name}__actions"].include?(column[:data]) ? 'Actions' : column[:title] %></label>
60
+ </div>
61
+ <span class="icon z-icon-hamburger"></span>
62
+ </li>
63
+ <% end %>
64
+ </ul>
65
+ </div>
66
+
67
+ <% default_view ||= table_views.select {|k,v| v == true }.first[0].to_s %>
68
+ <% table_view = table_views[:table] %>
69
+ <% grid_view = table_views[:grid] %>
70
+
71
+ <label id='<%= "#{table_name}_view_table" %>'class="btn table-btn <%= default_view == 'table' ? 'active' : '' %> <%= !table_view ? 'hidden' : '' %>">
72
+ <input type="radio" name="<%= table_name %>[view_mode]" <%= default_view == 'table' ? 'checked' : '' %> value='table' />
73
+ <span class="fa fa-table"></span>
74
+ </label>
75
+ <label id='<%= "#{table_name}_view_grid" %>'class="btn table-btn <%= default_view == 'grid' ? 'active' : '' %> <%= !grid_view ? 'hidden' : '' %>" >
76
+ <input type="radio" name="<%= table_name %>[view_mode]" <%= default_view == 'grid' ? 'checked' : '' %> value='grid' />
77
+ <span class="fa fa-th-large"></span>
78
+ </label>
79
+ <label id='<%= "#{table_name}_refresh" %>' class="table-btn table_refresh">
80
+ <span class="z-icon-refresh"></span>
81
+ </label>
82
+ </div>
83
+ <div id="<%= "#{table_name}_search_wrapper" %>" class="search-wrapper">
84
+ <span id="<%="#{table_name}_search_btn" %>" class="z-icon-search table-btn"></span>
85
+ <input id='<%= "#{table_name}_search" %>' type="search" name='table[search]' class="form-control" placeholder='Search..'>
86
+ </div>
87
+ </div>
88
+ </div>
89
+ <table id='<%= "#{table_name}" %>' data-source="<%= table_url %>" class="table bootstrap-datatable datatable hidden" style="width: 100% !important;"></table>
90
+ </div>
91
+
92
+ <% content_for :scripts do %>
93
+ columns = <%= raw(columns.to_json) %>;
94
+ $.each(columns, function(key, column) {
95
+ $.each(column, function(key, value) {
96
+ if(key=='render'){columns[0][key] = new Function('data', 'type', 'row', value);};
97
+ });
98
+ });
99
+
100
+ var <%= table_name %> = $('#<%= "#{table_name}_content" %>').find('table.datatable').dataTable({
101
+ "sDom": "<'datatable-scroll-wrapper't><'row'<'grid_view col-lg-12'>><'table_footer'i<'<%="\##{table_name}_select_container" %>.select_container'>p>",
102
+ "pagingType": "full_numbers",
103
+ "language" : {
104
+ "paginate" : {
105
+ "previous" : "<span class='z-icon-arrow-left' />",
106
+ "next" : "<span class='z-icon-arrow-right' />"
107
+ }
108
+ },
109
+ "bProcessing": true,
110
+ "bServerSide": true,
111
+ "colReorder": true,
112
+ "select": false, //{ style: 'multi'},
113
+ "columns": [].concat(columns),
114
+ "aaSorting": <%= raw(sort.to_json) %>,
115
+ "sAjaxSource": $('#<%= "#{table_name}_content" %>').find('table.datatable').data('source'),
116
+ "iDisplayLength": <%= initial_size %> ,
117
+ "fnServerParams": function ( aoData ) {
118
+ aoData.push(
119
+ { "name": "table_view_mode", "value": $('#<%= "#{table_name}_content" %>').find('input[type=radio][name="<%= table_name %>[view_mode]"]:checked').val()},
120
+ { "name": "sSearch", "value": $('#<%= "#{table_name}_content" %>').find('input[name="table[search]"]').val()}
121
+ );
122
+ <% if !aoData.blank? %>
123
+ <% aoData.each do |data| %>
124
+ aoData.push(<%= raw(data.to_json) %>);
125
+ <% end %>
126
+ <% end %>
127
+ <% if defined?(table_filters) %>
128
+ <% table_filters.each do |table_filter| %>
129
+ <% if table_filter["type"] == "checkbox" %>
130
+ aoData.push({ "name": "<%= table_filter["name"].parameterize('_') %>", "value": $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_filter["name"].parameterize('_') %>[]"]:checked').map(function(_, el) { return $(el).val()}).get() });
131
+ <% elsif table_filter["type"] == "boolean" %>
132
+ aoData.push({ "name": "<%= table_filter["name"].parameterize('_') %>", "value": $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_filter["name"].parameterize('_') %>"]:checked').val() });
133
+ <% elsif table_filter["type"] == "select" %>
134
+ aoData.push({ "name": "<%= table_filter["name"].parameterize('_') %>", "value": $('#<%= "#{table_name}_content" %>').find('select[name="<%= table_filter["name"].parameterize('_') %>"]').val() });
135
+ <% end %>
136
+ <% end %>
137
+ <% end %>
138
+ },
139
+ "fnDrawCallback": function( oSettings ) {
140
+ $('#<%= "#{table_name}_content" %>').find('.table [rel="status_popover"], .table[data-rel="status_popover"]').popover({ placement: "left", html: 'true', container: '.table'});
141
+ $('#<%= "#{table_name}_content" %>').find('.table [data-toggle="tooltip"]').tooltip();
142
+ view_mode = $('#<%= "#{table_name}_content" %>').find('input[type=radio][name="<%= table_name %>[view_mode]"]:checked').val();
143
+
144
+ $('#<%= "#{table_name}_content" %>').find('.grid_view').addClass('hidden');
145
+ $('#<%= "#{table_name}_content" %>').find('table.datatable').addClass("hidden");
146
+
147
+ if(view_mode == 'grid'){
148
+ $('#<%= "#{table_name}_content .grid_view" %>').html('');
149
+
150
+ $.each(oSettings.aoData, function(index, result) {
151
+ $('#<%= "#{table_name}_content .grid_view" %>').append(result._aData.grid_view);
152
+ });
153
+ if (oSettings.aoData.length == 0) {
154
+ $(".login_grid").append("<div class='row'><div class='col-md-12 center'><h3>" + oSettings.oLanguage.sEmptyTable + "</h3></div></div>")
155
+ }
156
+ $('#<%= "#{table_name}_content" %>').find('.grid_view').removeClass('hidden')
157
+ }else if(view_mode == 'table'){
158
+ $('#<%= "#{table_name}_content" %>').find('table.datatable').removeClass("hidden");
159
+ }
160
+
161
+ <%= table_name %>.find('input[type="checkbox"].select_row').on('click', function(e){
162
+ if($('#<%= "#{table_name}_select_all" %>').is(':checked')){ $('#<%= "#{table_name}_select_all" %>').prop("checked", false);}
163
+ });
164
+ if( <%= table_name %>.find('tr[processing="true"]').length > 0 && <%= table_name %>.is(":visible")){
165
+ setTimeout(function(){
166
+ <%= table_name %>.api().draw(false);
167
+ }, 1000);
168
+ }
169
+ if(<%= table_name %>.find('tr[processing="true"]').length > 0 && $('#<%= table_name %>_wrapper .grid_view').is(":visible")){
170
+ setTimeout(function(){
171
+ <%= table_name %>.api().draw(false);
172
+ }, 1000);
173
+ }
174
+ },
175
+ "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) {
176
+ data = aoData;
177
+ if ( data && $.isArray(data) ) {
178
+ var tmp = {};var rbracket = /(.*?)\[\]$/;
179
+ $.each( data, function (key, val) {
180
+ var match = val.name.match(rbracket);
181
+ if ( match ) {var name = match[0];if ( ! tmp[ name ] ) {tmp[ name ] = [];}tmp[ name ].push( val.value );}else {tmp[val.name] = val.value;}
182
+ });
183
+ data = tmp;
184
+ }
185
+ <% if debug %>console.log(fnCallback); console.log(oSettings);console.log(data);<% end %>
186
+ oSettings.jqXHR = $.ajax({"dataType": 'json', "url": sSource, "data": data, "success": fnCallback,"error": function (textStatus, errorThrown) {
187
+ if(textStatus.status == 400 || textStatus.status == 302 ){
188
+ window.location.replace("/");
189
+ }else if(textStatus.status == 500 ){
190
+ alert('<%= "Table Server Error: #{table_name} Contact Support" %>');
191
+ }else{
192
+ window.location.replace("/");
193
+ };
194
+ }});
195
+ }
196
+ }).on( 'draw.dt', function () {
197
+ <% if debug %> console.log('Drawing Trigger <%= table_name %>'); <% end %>
198
+ <%= table_name + '_cookie' %>();
199
+ }).on( 'processing.dt', function ( e, settings, processing ) {
200
+ if(processing){
201
+ $('#<%= "#{table_name}_content" %>').find('.table_refresh i').addClass('fa-spin');
202
+ }else{
203
+ $('#<%= "#{table_name}_content" %>').find('.table_refresh i').removeClass('fa-spin');
204
+ }
205
+ });
206
+
207
+ function <%= table_name + '_cookie' %>(){
208
+ <% if debug %> console.log('Save Cookie <%= table_name %>'); <% end %>
209
+ columns = $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_name %>[table_column_vis][]"]:checked').map(function(_, el) { return $(el).data('key')}).toArray();
210
+ view = $('#<%= "#{table_name}_content" %>').find('input[type=radio][name="<%= table_name %>[view_mode]"]:checked').val();
211
+ sort = <%= table_name %>.fnSettings().aaSorting;
212
+ table_size = <%= table_name %>.fnSettings()._iDisplayLength;
213
+ sort = sort.map(function(value,key) {
214
+ column = <%= table_name %>.api().column(value[0]).dataSrc();
215
+ return [column,value[1]]
216
+ })
217
+
218
+ var orderedItems = [];
219
+ $.each(<%= table_name %>.api().colReorder.order(), function(value) {
220
+ data_key = <%= table_name %>.api().column(value).dataSrc();
221
+ if (data_key != null && data_key.length > 0 ){orderedItems.push(data_key);}
222
+ });
223
+
224
+ if (Cookies.get('<%= "#{table_name}_table" %>') != null){
225
+ data = $.parseJSON( Cookies.get('<%= "#{table_name}_table" %>'));
226
+ data['columns'] = columns;
227
+ data['view'] = view;
228
+ data['sort'] = sort;
229
+ data['table_size'] = table_size;
230
+ data['ordering'] = orderedItems;
231
+ }else{
232
+ data = {'columns' : columns, 'view' : view, 'sort' : sort, 'table_size' : table_size, 'orderedItems' : orderedItems};
233
+ }
234
+
235
+ Cookies.set('<%= "#{table_name}_table" %>', data);
236
+ }
237
+
238
+ function <%= table_name + '_column_vis' %>(sorting){
239
+ $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_name %>[table_column_vis][]"]').on("change", function(e) {
240
+ index = <%= table_name %>.api().colReorder.transpose(parseInt($(this).val()),'toCurrent');
241
+ column = <%= table_name %>.api().column(index);
242
+ column.visible($(this).is(':checked'));
243
+ <%= table_name + '_cookie' %>();
244
+ });
245
+ if(sorting){
246
+ $('#<%= "#{table_name}_content" %>').find('.table_visibility').sortable({axis: 'y'}).on("sortstop", function( event, ui ) {
247
+ <% if debug %> console.log('Sort Stop Trigger <%= table_name %>'); <% end %>
248
+ items = $('#<%= "#{table_name}_content" %>').find('.table_visibility li input');
249
+ var orderedItems = [];
250
+ $.each(items, function(index, value) {
251
+ index = <%= table_name %>.api().colReorder.transpose(parseInt($(value).val()),'toCurrent');
252
+ column = <%= table_name %>.api().column(index);
253
+ if (column != null && column.length > 0 ){orderedItems.push(column.index());}
254
+ });
255
+ <%= table_name %>.api().colReorder.order(orderedItems);
256
+ });
257
+ $('#<%= "#{table_name}_content" %>').find('.table_visibility').disableSelection();
258
+ }
259
+ }
260
+ <%= table_name + '_column_vis' %>(true);
261
+
262
+ //Datable Select
263
+ function <%= table_name + '_row_select' %>(select, data){
264
+ var count = <%= table_name %>.api().rows({ selected: true }).count();
265
+ if(count > 0){
266
+ $('#<%= "#{table_name}_content" %>').find('.group_actions').removeClass('hidden');
267
+ }else {
268
+ $('#<%= "#{table_name}_content" %>').find('.group_actions').addClass('hidden');
269
+ }
270
+ if(select){
271
+ <% if debug %>
272
+ console.log('Selected');
273
+ console.log(data);
274
+ <% end %>
275
+ }else{
276
+ <% if debug %>
277
+ console.log('Deselected');
278
+ console.log(data);
279
+ <% end %>
280
+ }
281
+ }
282
+ <%= table_name %>.api().on('select', function ( e, dt, type, indexes ) {
283
+ <%= table_name + '_row_select' %>(true, <%= table_name %>.api().rows( indexes ).data());
284
+ });
285
+ <%= table_name %>.api().on('deselect', function ( e, dt, type, indexes ) {
286
+ <%= table_name + '_row_select' %>(false, <%= table_name %>.api().rows( indexes ).data());
287
+ });
288
+
289
+ //Datatable header reorder
290
+ <%= table_name %>.api().on('column-reorder', function ( e, settings, details ) {
291
+ <% if debug %> console.log('Ordering Trigger <%= table_name %>'); <% end %>
292
+ var orderedItems = [];
293
+ $.each(<%= table_name %>.api().colReorder.order(), function(value) {
294
+ data_key = <%= table_name %>.api().column(value).dataSrc();
295
+ item = $('#<%= "#{table_name}_content" %>').find('.table_visibility li input[data-key="' + data_key + '"]').parents('li');
296
+ if (item != null && item.length > 0 ){orderedItems.push(item);}
297
+ });
298
+ <% if debug %> console.log('Ordering Trigger Rebuild DropDown <%= table_name %>'); <% end %>
299
+ $('#<%= "#{table_name}_content" %>').find('.table_visibility').empty().html(orderedItems);
300
+ <%= table_name + '_column_vis' %>(false);
301
+ <%= table_name + '_cookie' %>();
302
+ });
303
+
304
+ $('#<%= "#{table_name}_select_all" %>').on('click', function(e){
305
+ if($(this).is(':checked')){<%= table_name %>.find('input[type="checkbox"].select_row').prop("checked", true);}else{<%= table_name %>.find('input[type="checkbox"].select_row').prop("checked", false);}
306
+ });
307
+
308
+ $('#<%= "#{table_name}_content" %>').find('.table_refresh').click(function(e){<%= table_name %>.api().draw(false)});
309
+
310
+ // Add the row # select to the footer
311
+ const <%= "#{table_name}_select" %> = $('<select>')
312
+ .attr('id', 'table_size')
313
+ .attr('class', '')
314
+ .attr('name', 'table_size')
315
+ .appendTo('<%="\##{table_name}_select_container" %>');
316
+ [10, 25, 50, 100].forEach(e => {
317
+ <%= "#{table_name}_select" %>.append($('<option>').attr('value', e).text(e));
318
+ });
319
+ <%= "#{table_name}_select" %>.val("<%= initial_size.to_s %>");
320
+ <%= "#{table_name}_select" %>.select2({
321
+ minimumResultsForSearch: Infinity,
322
+ dropdownAutoWidth: true,
323
+ width: '100%',
324
+ });
325
+
326
+ $('#<%= "#{table_name}_search_btn" %>').on('click', () => {
327
+ $('#<%= "#{table_name}_search_wrapper" %>').toggleClass('active');
328
+ $('#<%= "#{table_name}_search" %>').focus();
329
+ });
330
+
331
+ $('#<%= "#{table_name}_content" %>').find('select[name="table_size"]').on("change", function(e) {
332
+ <%= table_name %>.fnSettings()._iDisplayLength = $(this).val();<%= table_name %>.api().draw(false);
333
+ });
334
+
335
+ $('#<%= "#{table_name}_content" %>').find('input[type=radio][name="<%= table_name %>[view_mode]"]').on("change", function(e) {
336
+ <%= table_name %>.api().draw(false)
337
+ });
338
+
339
+ var timer;
340
+ var timeout = 300;
341
+ $('#<%= "#{table_name}_content" %>').find('input[name="table[search]"]').keydown(function(){
342
+ clearTimeout(timer);
343
+ var search = $(this);
344
+ if (search.val()) {timer = setTimeout(function(){<%= table_name %>.api().draw();}, timeout);}
345
+ });
346
+
347
+ <% if defined?(table_filters) %>
348
+ <% table_filters.each do |table_filter| %>
349
+ <% cache = table_filter["cache"].blank? ? false : table_filter["cache"] %>
350
+ <% if table_filter["type"] == "checkbox" %>
351
+ $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_filter["name"].parameterize('_') %>[]"]').click(function(){
352
+ filters = $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_filter["name"].parameterize('_') %>[]"]:checked').map(function(_, el) { return $(el).val()}).toArray();
353
+ <% if cache %>
354
+ if (Cookies.get('<%= "#{table_name}_table" %>') != null){
355
+ data = $.parseJSON( Cookies.get('<%= "#{table_name}_table" %>'));
356
+ data['<%= table_filter["name"].parameterize('_') %>_filter'] = filters
357
+ }else{
358
+ data = {'<%= table_filter["name"].parameterize('_') %>_filter' : filters }
359
+ }
360
+ Cookies.set('<%= "#{table_name}_table" %>', data);
361
+ <% end %>
362
+ return $("table#<%= table_name %>").dataTable().api().draw()
363
+ });
364
+ <% elsif table_filter["type"] == "select" %>
365
+ $('#<%= "#{table_name}_content" %>').find('select[name="<%= table_filter["name"].parameterize('_') %>"]').change(function(){
366
+ filter = $('#<%= "#{table_name}_content" %>').find('select[name="<%= table_filter["name"].parameterize('_') %>"]').val();
367
+ <% if cache %>
368
+ if (Cookies.get('<%= "#{table_name}_table" %>') != null){
369
+ data = $.parseJSON( Cookies.get('<%= "#{table_name}_table" %>'));
370
+ data['<%= table_filter["name"].parameterize('_') %>_filter'] = filter
371
+ }else{
372
+ data = {'<%= table_filter["name"].parameterize('_') %>_filter' : filter }
373
+ }
374
+ Cookies.set('<%= "#{table_name}_table" %>', data);
375
+ <% end %>
376
+ return $("table#<%= table_name %>").dataTable().api().draw()
377
+ });
378
+ <% elsif table_filter["type"] == "boolean" %>
379
+ $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_filter["name"].parameterize('_') %>"]').change(function(){
380
+ filter = $('#<%= "#{table_name}_content" %>').find('input[name="<%= table_filter["name"].parameterize('_') %>"]:checked').val();
381
+ <% if cache %>
382
+ if (Cookies.get('<%= "#{table_name}_table" %>') != null){
383
+ data = $.parseJSON( Cookies.get('<%= "#{table_name}_table" %>'));
384
+ data['<%= table_filter["name"].parameterize('_') %>_filter'] = filter
385
+ }else{
386
+ data = {'<%= table_filter["name"].parameterize('_') %>_filter' : filter }
387
+ }
388
+ Cookies.set('<%= "#{table_name}_table" %>', data);
389
+ <% end %>
390
+ return $("table#<%= table_name %>").dataTable().api().draw()
391
+ });
392
+ <% end %>
393
+ <% end %>
394
+ <% end %>
395
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <strong>Zuora Connect Gem Version:</strong>
2
+ <%= view.gem_version %>
3
+ <strong>App Instance:</strong>
4
+ <%= view.app_instance %>
5
+
@@ -0,0 +1,13 @@
1
+ module Peek
2
+ module Views
3
+ class Connect < View
4
+ def gem_version
5
+ Gem.loaded_specs["zuora_connect"].version
6
+ end
7
+
8
+ def app_instance
9
+ Thread.current[:appinstance].id
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,3 @@
1
+ module ZuoraConnectUi
2
+ VERSION = '0.1.0'.freeze
3
+ end
@@ -0,0 +1,13 @@
1
+ require 'zuora_connect_ui/version'
2
+ require 'jquery-ui-rails'
3
+ require 'bootstrap-sass'
4
+ require 'select2-rails'
5
+ require 'jquery-datatables-rails'
6
+ require 'peek'
7
+ require 'peek/views/connect'
8
+
9
+ # UI for Connect Applications
10
+ module ZuoraConnectUi
11
+ class Engine < ::Rails::Engine
12
+ end
13
+ end