noventius 1.0.0 → 2.0.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 (60) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/{nuntius → noventius}/application.js +10 -10
  3. data/app/assets/javascripts/noventius/columns.js +61 -0
  4. data/app/assets/javascripts/{nuntius → noventius}/filters.js +1 -4
  5. data/app/assets/javascripts/noventius/filters/select.js +92 -0
  6. data/app/assets/javascripts/noventius/forms.js +39 -0
  7. data/app/assets/javascripts/noventius/nested.js +29 -0
  8. data/app/assets/javascripts/{nuntius → noventius}/reports.js +4 -4
  9. data/app/assets/stylesheets/{nuntius → noventius}/application.css +6 -5
  10. data/app/assets/stylesheets/{nuntius → noventius}/nested.css +0 -0
  11. data/app/assets/stylesheets/{nuntius → noventius}/reports.css +1 -1
  12. data/app/controllers/concerns/{nuntius → noventius}/filter_params.rb +1 -1
  13. data/app/controllers/{nuntius → noventius}/application_controller.rb +2 -2
  14. data/app/controllers/{nuntius → noventius}/reports_controller.rb +2 -2
  15. data/app/helpers/concerns/{nuntius → noventius}/filter_wrappers.rb +1 -1
  16. data/app/helpers/{nuntius → noventius}/alerts_helper.rb +1 -1
  17. data/app/helpers/{nuntius → noventius}/application_helper.rb +2 -2
  18. data/app/helpers/{nuntius → noventius}/cells_helper.rb +1 -1
  19. data/app/helpers/{nuntius → noventius}/columns_helper.rb +1 -1
  20. data/app/helpers/{nuntius → noventius}/filters_helper.rb +3 -3
  21. data/app/helpers/{nuntius → noventius}/forms_helper.rb +1 -1
  22. data/app/helpers/{nuntius → noventius}/rows_helper.rb +1 -1
  23. data/app/views/layouts/{nuntius → noventius}/application.html.erb +4 -4
  24. data/app/views/{nuntius → noventius}/reports/_filter.erb +0 -0
  25. data/app/views/{nuntius → noventius}/reports/_form.erb +0 -0
  26. data/app/views/{nuntius → noventius}/reports/_table.erb +0 -0
  27. data/app/views/{nuntius → noventius}/reports/index.erb +0 -0
  28. data/app/views/{nuntius → noventius}/reports/nested.erb +0 -0
  29. data/app/views/{nuntius → noventius}/reports/show.erb +0 -0
  30. data/app/views/shared/{nuntius → noventius}/_header.erb +0 -0
  31. data/config/locales/en.bootstrap.yml +23 -0
  32. data/config/routes.rb +1 -1
  33. data/lib/noventius.rb +13 -0
  34. data/lib/noventius/assets.rb +7 -0
  35. data/lib/{nuntius → noventius}/column.rb +1 -1
  36. data/lib/{nuntius → noventius}/columns_group.rb +1 -1
  37. data/lib/{nuntius → noventius}/engine.rb +2 -2
  38. data/lib/{nuntius → noventius}/extensions/date_query.rb +2 -2
  39. data/lib/{nuntius → noventius}/filter.rb +1 -1
  40. data/lib/{nuntius → noventius}/post_processors/date_ranges.rb +23 -8
  41. data/lib/{nuntius → noventius}/report.rb +13 -1
  42. data/lib/{nuntius → noventius}/report/dsl.rb +1 -1
  43. data/lib/{nuntius → noventius}/report/dsl/columns.rb +2 -2
  44. data/lib/{nuntius → noventius}/report/dsl/filters.rb +1 -1
  45. data/lib/{nuntius → noventius}/report/dsl/nested.rb +1 -1
  46. data/lib/{nuntius → noventius}/report/dsl/post_processors.rb +1 -1
  47. data/lib/{nuntius → noventius}/report/dsl/validations.rb +1 -1
  48. data/lib/{nuntius → noventius}/report/interpolator.rb +1 -1
  49. data/lib/{nuntius → noventius}/serializers/csv.rb +2 -2
  50. data/lib/{nuntius → noventius}/validation.rb +1 -1
  51. data/lib/noventius/version.rb +5 -0
  52. data/lib/tasks/nuntius_tasks.rake +1 -1
  53. metadata +139 -50
  54. data/app/assets/javascripts/nuntius/columns.js +0 -57
  55. data/app/assets/javascripts/nuntius/filters/select.js +0 -88
  56. data/app/assets/javascripts/nuntius/forms.js +0 -38
  57. data/app/assets/javascripts/nuntius/nested.js +0 -25
  58. data/config/initializers/assets.rb +0 -1
  59. data/lib/nuntius.rb +0 -13
  60. data/lib/nuntius/version.rb +0 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cc617e8561a3d80508c66c26477028e6d8bf6fc
4
- data.tar.gz: 5dc709e45a22849681cc05e2d9ae4f632f39b7f6
3
+ metadata.gz: 62c4cea8aeef8cb726c35f40b7bc99455ce6bb95
4
+ data.tar.gz: 81eb082efbc4966ad895dfa00dc5115e3cf1f245
5
5
  SHA512:
6
- metadata.gz: 349a9fd40d315d93b23ba0bac28d3ad7fb19c5bec4901868af0ec19eff7a7c6548c774bd7efaf22437ac1d67e7f2bf4a2fa31964d8d0317590a3eb9ddac16e7f
7
- data.tar.gz: f4f3397862a83e647b06479beaee2b17dcd84e13cf8fb59be731931fb20b10687737c1a9d3206782375e89b3d41fe66c79f7e47d3b7d21d56cf26d8dbca5524c
6
+ metadata.gz: 14fbf5d142b5685dd00ba111dcf71458fb2e1e83fd4207e19bd4221ed3dd13dec6bdedbc2eeb8336a2fa2ed0392fec4e79c7b217d067b47a2c4a8fe2da21c50c
7
+ data.tar.gz: 4f9e9d9b6f68e1706fd25e1c8ee6dad358daceeb0fd46ca78a1f7ca58e15d8f0339d10b7a706d1439f8cfc1f4df57ab61f55c803158961bab2c31d015687a75d
@@ -10,18 +10,18 @@
10
10
  // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
11
11
  // about supported directives.
12
12
  //
13
- //= require jquery/dist/jquery.min
14
- //= require bootstrap/dist/js/bootstrap.min
15
- //= require moment/min/moment-with-locales.min
16
- //= require moment-timezone/builds/moment-timezone-with-data.min
17
- //= require eonasdan-bootstrap-datetimepicker/build/js/bootstrap-datetimepicker.min
18
- //= require jquery-validation/dist/jquery.validate.min
19
- //= require jquery-validation/dist/additional-methods.min
20
- //= require select2-dist/dist/js/select2.full
21
- //= require jquery-tablesorter
13
+ //= require jquery
14
+ //= require jquery_ujs
15
+ //= require twitter/bootstrap
22
16
  //= require moment
17
+ //= require moment-timezone-with-data
18
+ //= require bootstrap-datetimepicker
19
+ //= require jquery.validate
20
+ //= require jquery.validate.additional-methods
21
+ //= require select2/select2.full
22
+ //= require jquery-tablesorter
23
23
  //= require_self
24
- //= require nuntius/reports
24
+ //= require noventius/reports
25
25
 
26
26
  var DATE_FORMAT = 'DD/MM/YYYY';
27
27
  var DATETIME_FORMAT = 'DD/MM/YYYY HH:mm';
@@ -0,0 +1,61 @@
1
+ (function(){
2
+
3
+ function getSorterForType(type) {
4
+ switch(type) {
5
+ case 'datetime':
6
+ case 'date':
7
+ return 'date';
8
+ break;
9
+ case 'integer':
10
+ case 'float':
11
+ return 'digit';
12
+ break;
13
+ default:
14
+ return 'text';
15
+ }
16
+ }
17
+
18
+ function addColumnsSorting(table) {
19
+ var $this = $(table);
20
+
21
+ var headers = $this.find('th').map(function(index, element) {
22
+ var $element = $(element);
23
+ var sorter;
24
+
25
+ if ($element.hasClass('column-header')) {
26
+ var type = $element.data('type');
27
+ sorter = getSorterForType(type);
28
+ } else {
29
+ sorter = false;
30
+ }
31
+
32
+ return { sorter: sorter };
33
+ });
34
+
35
+ $this.tablesorter({
36
+ theme: 'bootstrap',
37
+ widthFixed: true,
38
+ headerTemplate: '{content} {icon}',
39
+ widgets: ['uitheme'],
40
+ headers: headers
41
+ });
42
+ }
43
+
44
+ $(function() {
45
+ $.tablesorter.addParser({
46
+ id: 'date',
47
+ is: function(s) {
48
+ return false;
49
+ },
50
+ format: function(datetime) {
51
+ return moment(datetime).utc().format('x');
52
+ },
53
+ type: 'numeric'
54
+ });
55
+
56
+ $('table').each(function() {
57
+ addColumnsSorting(this);
58
+ });
59
+ });
60
+
61
+ })();
@@ -1,9 +1,6 @@
1
- // Place all the behaviors and hooks related to the matching controller here.
2
- // All this logic will automatically be available in application.js.
3
1
  (function(){
4
2
 
5
- $(document).on('ready page:load', function(){
6
-
3
+ $(function() {
7
4
  // Initialize all DatePickers
8
5
  $("[type='date']").each(function (index, el) {
9
6
  var $el = $(el);
@@ -0,0 +1,92 @@
1
+ (function(){
2
+ function dependencyValue(dependency) {
3
+
4
+ return $('select.noventius-filter#q_' + dependency).val();
5
+ }
6
+
7
+ function handleSelectChange(filter, clear) {
8
+ var filterId = $(filter).attr('id').replace('q_', '');
9
+
10
+ $('select.noventius-filter').each(function() {
11
+ var $this = $(this);
12
+ var dependentFilters = $this.data('dependent') || [];
13
+
14
+ if (!Array.isArray(dependentFilters)) {
15
+ dependentFilters = [dependentFilters];
16
+ }
17
+
18
+ if (dependentFilters.includes(filterId)) {
19
+ if (clear) {
20
+ clearDependentSelect($this);
21
+ } else {
22
+ updateDependentSelect($this, dependentFilters);
23
+ }
24
+ }
25
+ });
26
+ }
27
+
28
+ function clearDependentSelect($filter) {
29
+ $filter.html('').select2({data: null});
30
+ $filter.prop('disabled', true);
31
+ handleSelectChange($filter, true);
32
+ }
33
+
34
+ function updateDependentSelect($filter, dependencies) {
35
+ var values = dependencies.map(dependencyValue);
36
+ var options = $filter.data('options')[values.join('_!_')];
37
+ var currentValue = $filter.data('currentValue');
38
+
39
+ if (typeof options == 'undefined') {
40
+ $filter.html('').select2({data: null});
41
+ $filter.prop('disabled', true);
42
+ return;
43
+ }
44
+
45
+ $filter.prop('disabled', false);
46
+
47
+ options = options.map(function(option) {
48
+ if (typeof option == 'object' && option.length == 2 && typeof option[1] != 'undefined') {
49
+ return { id: option[1] || '', text: option[0] }
50
+ } else {
51
+ return { id: option, text: option }
52
+ }
53
+ });
54
+
55
+ var selectOptions = { data: options };
56
+ var includeBlank = $filter.data('includeBlank');
57
+
58
+ if (includeBlank != null && typeof includeBlank != 'undefined') {
59
+ options.unshift({ id: '', text: '' });
60
+
61
+ selectOptions.allowClear = true;
62
+ selectOptions.placeholder = $filter.data('includeBlank')
63
+ }
64
+
65
+ $filter.html('').select2(selectOptions);
66
+ handleSelectChange($filter, false);
67
+
68
+ if (currentValue != null && typeof currentValue != 'undefined') {
69
+ $filter.val(currentValue).trigger('change');
70
+ }
71
+ }
72
+
73
+ $(function() {
74
+ $('select.noventius-filter').each(function() {
75
+ var $this = $(this);
76
+
77
+ var selectOptions = {};
78
+ var includeBlank = $this.data('includeBlank');
79
+ if (includeBlank != null && includeBlank != 'undefined') {
80
+ selectOptions.allowClear = true;
81
+ selectOptions.placeholder = $this.data('includeBlank')
82
+ }
83
+
84
+ $(this).select2(selectOptions)
85
+ .on('select2:select', function() { handleSelectChange(this, false) })
86
+ .on('select2:unselect', function() { handleSelectChange(this, true) });
87
+ handleSelectChange(this, false);
88
+ })
89
+
90
+ });
91
+
92
+ })();
@@ -0,0 +1,39 @@
1
+ (function(){
2
+
3
+ var FORM_SELECTOR = '#filter-form';
4
+
5
+ function submitWithFormat(form, event, format) {
6
+ event.preventDefault();
7
+ event.stopPropagation();
8
+
9
+ form.find('input[name=format]').val(format);
10
+ form.submit();
11
+ }
12
+
13
+ $(function() {
14
+ var $form = $(FORM_SELECTOR);
15
+ if ($form.length > 0) {
16
+ $form.validate({
17
+ errorClass: 'has-error has-feedback',
18
+ validClass: 'has-success has-feedback',
19
+ errorPlacement: function(error, element) {
20
+ $error = $(error);
21
+ $element = $(element);
22
+ $(error).addClass('control-label');
23
+ $element.closest('.form-group').append(error);
24
+ },
25
+ rules: VALIDATIONS['rules'],
26
+ messages: VALIDATIONS['messages']
27
+ });
28
+
29
+ $form.on('click', 'input[name=commit]', function(e) {
30
+ submitWithFormat($form, e, 'html');
31
+ });
32
+
33
+ $form.on('click', '.download', function(e) {
34
+ submitWithFormat($form, e, 'csv');
35
+ });
36
+ }
37
+ });
38
+
39
+ })();
@@ -0,0 +1,29 @@
1
+ (function(){
2
+
3
+ $(function() {
4
+ $('table').on('click', 'tr[data-nested]', function() {
5
+ var $this = $(this);
6
+ var nested = $this.data('nested');
7
+
8
+ if ($this.next('tr.nested-container').length) {
9
+ $this.siblings('tr.nested-container').remove();
10
+ return;
11
+ }
12
+
13
+ var td = $('<td>').attr('colspan', $this.find('td').length);
14
+ var tr = $('<tr>').append(td).addClass('nested-container');
15
+
16
+ $this.siblings('tr.nested-container').remove();
17
+
18
+ $this.after(tr);
19
+
20
+ var data = nested.filters;
21
+ data.row = nested.row;
22
+ $.get(nested.url, data, function(table) {
23
+ td.append(table);
24
+ addColumnsSorting(td.find('table'));
25
+ });
26
+ });
27
+ });
28
+
29
+ })();
@@ -1,7 +1,7 @@
1
1
  // Place all the behaviors and hooks related to the matching controller here.
2
2
  // All this logic will automatically be available in application.js.
3
- //= require nuntius/filters
4
- //= require nuntius/forms
5
- //= require nuntius/columns
6
- //= require nuntius/nested
3
+ //= require noventius/filters
4
+ //= require noventius/forms
5
+ //= require noventius/columns
6
+ //= require noventius/nested
7
7
  //= require_tree ./filters
@@ -10,13 +10,14 @@
10
10
  * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
11
  * file per style scope.
12
12
  *
13
- *= require bootstrap/dist/css/bootstrap.min
14
- *= require eonasdan-bootstrap-datetimepicker/build/css/bootstrap-datetimepicker.min
15
- *= require select2-dist/dist/css/select2
13
+ *= require twitter-bootstrap-static/bootstrap
14
+ *= require twitter-bootstrap-static/sprites
15
+ *= require bootstrap-datetimepicker
16
+ *= require select2/select2
16
17
  *= require jquery-tablesorter/theme.bootstrap
17
18
  *= require_self
18
- *= require nuntius/reports
19
- *= require nuntius/nested
19
+ *= require noventius/reports
20
+ *= require noventius/nested
20
21
  */
21
22
 
22
23
  .navbar {
@@ -12,6 +12,6 @@
12
12
  width: 14em;
13
13
  }
14
14
 
15
- select.nuntius-filter {
15
+ select.noventius-filter {
16
16
  width: 100%;
17
17
  }
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module FilterParams
4
4
 
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  class ApplicationController < ActionController::Base
4
4
 
@@ -9,7 +9,7 @@ module Nuntius
9
9
  protect_from_forgery with: :exception
10
10
 
11
11
  def reports
12
- @reports ||= Report.all
12
+ @reports ||= Report.visibles
13
13
  end
14
14
 
15
15
  end
@@ -1,6 +1,6 @@
1
- require_dependency 'nuntius/application_controller'
1
+ require_dependency 'noventius/application_controller'
2
2
 
3
- module Nuntius
3
+ module Noventius
4
4
 
5
5
  class ReportsController < ApplicationController
6
6
 
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module FilterWrappers
4
4
 
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module AlertsHelper
4
4
 
@@ -1,8 +1,8 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module ApplicationHelper
4
4
 
5
- SCOPE_KEY = Nuntius::FilterParams::SCOPE_KEY
5
+ SCOPE_KEY = Noventius::FilterParams::SCOPE_KEY
6
6
 
7
7
  def scope_name(name)
8
8
  "#{SCOPE_KEY}[#{name}]"
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module CellsHelper
4
4
 
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module ColumnsHelper
4
4
 
@@ -1,9 +1,9 @@
1
1
  # rubocop:disable all
2
- module Nuntius
2
+ module Noventius
3
3
 
4
4
  module FiltersHelper
5
5
 
6
- include Nuntius::FilterWrappers
6
+ include Noventius::FilterWrappers
7
7
 
8
8
  RESERVED_OPTIONS = [:dependent]
9
9
 
@@ -26,7 +26,7 @@ module Nuntius
26
26
  end
27
27
 
28
28
  def class_for_filter(filter)
29
- classes = ['nuntius-filter']
29
+ classes = ['noventius-filter']
30
30
 
31
31
  unless filter.type == :select
32
32
  classes << 'form-control'
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module FormsHelper
4
4
 
@@ -1,4 +1,4 @@
1
- module Nuntius
1
+ module Noventius
2
2
 
3
3
  module RowsHelper
4
4
 
@@ -1,13 +1,13 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Nuntius</title>
5
- <%= stylesheet_link_tag "nuntius/application", media: "all" %>
4
+ <title>Noventius</title>
5
+ <%= stylesheet_link_tag "noventius/application", media: "all" %>
6
6
  <%= csrf_meta_tags %>
7
7
  </head>
8
8
  <body>
9
9
  <header>
10
- <%= render partial: 'shared/nuntius/header' %>
10
+ <%= render partial: 'shared/noventius/header' %>
11
11
  </header>
12
12
  <main>
13
13
  <div class='container-fluid'>
@@ -16,6 +16,6 @@
16
16
  </div>
17
17
  </main>
18
18
  <footer></footer>
19
- <%= javascript_include_tag 'nuntius/application' %>
19
+ <%= javascript_include_tag 'noventius/application' %>
20
20
  </body>
21
21
  </html>