caboose-cms 0.8.60 → 0.8.61

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f5c5ba850878fe90aaad10b85a49a22fb7ac6315
4
- data.tar.gz: a23f403479820953621d16ba00f98fe3d850525e
3
+ metadata.gz: f36c7fdecc5fc40895fc8cf1cbfa7c0af91b7e10
4
+ data.tar.gz: d76ad213171289b7f79ba6260c657dfbd37e6f00
5
5
  SHA512:
6
- metadata.gz: 88908188c6d4f53c82b59e1761d477b61fe88b3040208bf53fcd5184a37af738169accf690a7d242da7e82731f9e0c8244e62da784e0d65918a23da6833a4da0
7
- data.tar.gz: 648a6468d05c068df994709e6f2fb38069d9683e08c761e753773a5487e0dfdb8cecd9f0f604c7ad93ce08d265eaa2b27e42300ebe0e06e2704587e6221ff154
6
+ metadata.gz: 25b912cdbafbedbe3c6e420ca5af6a2e47157274a56151902e2336c25a166a6fe5be288fc7f67015690eb66a8aebcd9cbb835504f222f0d02c7397abc40fdd45
7
+ data.tar.gz: 3ebe5da2b93ccb8ae12d8dc8bd172dd88441dac80b53618ff44e6e705aa28659bdf4290df51bfd967d76ac3568331ebd9d470c644d68381d04e95aacdd07f82f
@@ -90,7 +90,16 @@ IndexTable.prototype = {
90
90
  after_print: false,
91
91
  table_class: 'data',
92
92
  allow_export: false,
93
- export_urls: false,
93
+ export_urls: false, // Example:
94
+ // [
95
+ // {
96
+ // name: 'My Export',
97
+ // url: '<url that starts export process>',
98
+ // wait_for_processing: true,
99
+ // status_url: function(resp) { return resp.status_url; },
100
+ // ready: function(resp) { return resp.redirect_url; }
101
+ // }
102
+ // ]
94
103
 
95
104
  //============================================================================
96
105
  // End of parameters
@@ -693,31 +702,71 @@ IndexTable.prototype = {
693
702
  },
694
703
 
695
704
  csv_export: function()
705
+ {
706
+ var that = this;
707
+
708
+ var defaults = {
709
+ name: "Export",
710
+ url: that.base_url + '/export.csv',
711
+ type: 'get',
712
+ wait_for_processing: false,
713
+ status_url: function(resp) { return resp.status_url; },
714
+ ready: function(resp) { return resp.redirect_url.length > 0; },
715
+ final_url: function(resp) { return resp.redirect_url; }
716
+ };
717
+
718
+ var p = $('<p/>');
719
+ $.each(that.export_urls, function(i, h) {
720
+ that.export_urls[i] = $.extend({}, defaults, h);
721
+ p.append($('<input/>').attr('type', 'button').val(that.export_urls[i].name).click(function(e) { that.csv_export_start($(this).val()); })).append(' ');
722
+ });
723
+
724
+ var div = $('<div/>').addClass('note')
725
+ .append($('<p/>').append('Which export would you like to run?'))
726
+ .append(p)
727
+ .append($('<div/>').attr('id', 'export_message'))
728
+ .append($('<p/>').append($('<input/>').attr('type', 'button').val('Cancel').click(function(e) { that.hide_message(); })));
729
+ that.show_message(div);
730
+ },
731
+
732
+ csv_export_start: function(name)
696
733
  {
697
734
  var that = this;
698
- var p = this.pager_params();
699
- var qs = [];
700
- $.each(p, function(k,v) {
701
- if (k != '[object Object]') qs.push('' + k + '=' + encodeURIComponent(v));
735
+ var p = that.pager_params();
736
+
737
+ var h = false;
738
+ $.each(that.export_urls, function(i, h2) {
739
+ if (h2.name == name) { h = h2; return false; }
702
740
  });
703
- //var url = that.export_url ? that.export_url : that.base_url + '/export.csv';
704
741
 
705
- var urls = that.export_urls ? that.export_urls : { "Export": that.base_url + '/export.csv' };
706
-
707
- if (urls.length == 1)
708
- window.location = url + '?' + qs.join('&');
709
- else
742
+ if (!h.wait_for_processing)
710
743
  {
711
- var div = $('<div/>').addClass('note')
712
- .append($('<p/>').append('Which export would you like to run?'));
713
- var p = $('<p/>');
714
- $.each(urls, function(name, url) {
715
- p.append($('<input/>').attr('type', 'button').val(name).click(function(e) { window.location = url + '?' + qs.join('&'); })).append(' ');
716
- });
717
- div.append(p);
718
- div.append($('<p/>').append($('<input/>').attr('type', 'button').val('Cancel').click(function(e) { that.hide_message(); })));
719
- that.show_message(div);
720
- }
744
+ var qs = [];
745
+ $.each(p, function(k,v) { if (k != '[object Object]') qs.push('' + k + '=' + encodeURIComponent(v)); });
746
+ window.location = h.url + '?' + qs.join('&');
747
+ return;
748
+ }
749
+
750
+ $('#export_message').html("<p class='loading'>Creating export...</p>");
751
+ var qs = {};
752
+ $.each(p, function(k,v) { if (k != '[object Object]') qs[k] = v; });
753
+ $.ajax({ url: h.url, type: h.type, data: qs, success: function(resp) { h.status_url = h.status_url(resp); }, async: false });
754
+ setTimeout(function() { that.csv_export_status(h); }, 1000);
755
+ },
756
+
757
+ csv_export_status: function(h)
758
+ {
759
+ var that = this;
760
+ $.ajax({
761
+ url: h.status_url,
762
+ type: 'get',
763
+ success: function(resp) {
764
+ if (h.ready(resp))
765
+ window.location = h.final_url(resp);
766
+ else
767
+ setTimeout(function() { that.csv_export_status(h); }, 1000);
768
+ }
769
+ });
721
770
  },
722
771
 
723
772
  pager_div: function(summary)
@@ -1,3 +1,3 @@
1
1
  module Caboose
2
- VERSION = '0.8.60'
2
+ VERSION = '0.8.61'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: caboose-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.60
4
+ version: 0.8.61
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Barry