tabulatr2 0.9.0 → 0.9.1

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 33bcdd2d48f79be42e48d96f15856c24731b6543
4
- data.tar.gz: db9ecdc0fb072cd452233d3a181bf1524cc0e6d1
3
+ metadata.gz: 3a100eb6202380170c5e957e104a93d5b359f3ba
4
+ data.tar.gz: 65259c8ffd88e967eaf1d51dcd888d4446f379e7
5
5
  SHA512:
6
- metadata.gz: b88025d3af65dd7cceaa36ab28512767de961cd4bbd35878ec5be326456112aaf2ef7ed695ad9f8d8a7b87118c0330f0df1f09ee96aa79986048fd3946754725
7
- data.tar.gz: 695b0ee5be5f34b8c6464b014ce11e5c4a814ec817469f6100f8f76bc7ec77a9c41190c4da675a7a9c2753c1500993209bd02ab74cefebd73790499001e8fee2
6
+ metadata.gz: f9516e1047006e55ba663b9a86d6f31bff0d45733e0da4ae78fb0c0cf13d562b8dcf4d5bfbc88daaed98613633d29c3061ba532dcff1b93fb12c670abb2615a9
7
+ data.tar.gz: ebb911b6ce9d4abcf4003abc1898745a03b4f9167b082516ef023c0592bfd12a76dbea9d7998b76390d4d579d43887a0fd950d9c07752486be6f93a40261d911
data/CHANGELOG.md CHANGED
@@ -1,3 +1,17 @@
1
+ ## 0.9.1
2
+
3
+ * Show spinner when data is loading. Type of spinner can be overriden via
4
+ `Tabulatr.spinner` option. Possible values are :standard and :pacman.
5
+
6
+ Example:
7
+ ```
8
+ Tabulatr.config do |tc|
9
+ tc.spinner = :pacman
10
+ end
11
+ ```
12
+
13
+ * does not complain when no id is manually provided in TabulatrData
14
+
1
15
  ## 0.9
2
16
 
3
17
  * Added `row` to the TabulatrData DSL to provide HTML attributes for the
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Tabulatr2 - Index Tables made easy
2
2
  [![Code Climate](https://codeclimate.com/github/provideal/tabulatr2.png)](https://codeclimate.com/github/provideal/tabulatr2)
3
-
3
+ [![Gem Version](https://badge.fury.io/rb/tabulatr2.png)](http://badge.fury.io/rb/tabulatr2)
4
4
  **WARNING: Tabulatr2 is not production ready yet!**
5
5
 
6
6
  ## Installation
Binary file
@@ -98,7 +98,7 @@ Tabulatr.prototype = {
98
98
  var $table = $('#'+ this.id);
99
99
  if(hash.page !== undefined && !forceReload){
100
100
  //old page should be stored
101
- Tabulatr.storePage = true;
101
+ this.storePage = true;
102
102
  // check if this page was already loaded
103
103
  if($table.find('tbody tr[data-page='+ hash.page +']').length > 0){
104
104
  $table.find('tbody tr').hide();
@@ -115,12 +115,14 @@ Tabulatr.prototype = {
115
115
  if(this.locked){ return; }
116
116
  this.locked = true;
117
117
  var curTable = this;
118
+ this.showLoadingSpinner();
118
119
  $.ajax({
119
120
  context: this,
120
121
  type: 'GET',
121
122
  url: $('table#'+ this.id).data('path') + '.json',
122
123
  data: this.createParameterString(hash, this.id),
123
- success: this.handleResponse
124
+ success: this.handleResponse,
125
+ complete: this.hideLoadingSpinner
124
126
  });
125
127
  },
126
128
 
@@ -241,6 +243,14 @@ Tabulatr.prototype = {
241
243
 
242
244
  localDate: function(value, $td, $tr, obj){
243
245
  return new Date(value).toLocaleString();
246
+ },
247
+
248
+ showLoadingSpinner: function(){
249
+ $('.tabulatr-spinner-box[data-table='+ this.id +']').show();
250
+ },
251
+
252
+ hideLoadingSpinner: function(){
253
+ $('.tabulatr-spinner-box[data-table='+ this.id +']').hide();
244
254
  }
245
255
 
246
256
  }
@@ -155,3 +155,11 @@ table.tabulatr_table {
155
155
  }
156
156
  }
157
157
 
158
+ .tabulatr-spinner-box{
159
+ width: 100%;
160
+ height: 50px;
161
+ display: none;
162
+ position: relative;
163
+ text-align: center;
164
+ }
165
+
@@ -35,5 +35,7 @@ table.table.tabulatr_table id=table_id data-path=table_options[:path] data-pages
35
35
  - classes = column.sortable ? ['tabulatr-sortable'] : []
36
36
  - classes = [classes, column.classes].flatten.compact.join(' ')
37
37
  td data-tabulatr-column-name=column.full_name data-tabulatr-type=column.coltype style=column.cell_style class=classes
38
+ .tabulatr-spinner-box data-table=table_id
39
+ = image_tag "#{Tabulatr.spinner}-loader.gif"
38
40
  span.pagination_trigger data-table="#{table_id}"
39
41
 
@@ -29,7 +29,6 @@ module Tabulatr::JsonBuilder
29
29
  each_serializer: klass
30
30
  }).as_json
31
31
  else
32
- id_included = false
33
32
  attrs = build_hash_from requested_attributes, id
34
33
  result = []
35
34
  data.each do |f|
@@ -77,7 +76,7 @@ module Tabulatr::JsonBuilder
77
76
  # end
78
77
  begin
79
78
  raise Tabulatr::RequestDataNotIncludedError.raise_error(rel, f) if !f.has_key?(rel)
80
- raise Tabulatr::RequestDataNotIncludedError.raise_error(action, rel) if !f[rel].has_key?(action)
79
+ raise Tabulatr::RequestDataNotIncludedError.raise_error(action, rel) if !f[rel].has_key?(action) && action != :id
81
80
  r["#{at[:relation]}:#{at[:action]}"] = f[rel][action]
82
81
  rescue TypeError, NoMethodError => e
83
82
  Tabulatr::RequestDataNotIncludedError.raise_error(at[:action], at[:relation])
@@ -85,7 +84,7 @@ module Tabulatr::JsonBuilder
85
84
  else
86
85
  begin
87
86
  action = at[:action].to_sym
88
- raise Tabulatr::RequestDataNotIncludedError.raise_error(action, f) if !f.has_key?(action) && action != :checkbox
87
+ raise Tabulatr::RequestDataNotIncludedError.raise_error(action, f) if !f.has_key?(action) && [:checkbox, :id].exclude?(action)
89
88
  r[at[:action]] = f[action]
90
89
  rescue TypeError, NoMethodError => e
91
90
  raise Tabulatr::RequestDataNotIncludedError.raise_error(action, f)
@@ -22,5 +22,5 @@
22
22
  #++
23
23
 
24
24
  module Tabulatr
25
- VERSION = "0.9.0"
25
+ VERSION = "0.9.1"
26
26
  end
data/lib/tabulatr.rb CHANGED
@@ -25,6 +25,10 @@ module Tabulatr
25
25
  def self.config &block
26
26
  yield self
27
27
  end
28
+
29
+ mattr_accessor :spinner
30
+
31
+ self.spinner = :standard
28
32
  end
29
33
 
30
34
  require 'tabulatr/engine'
@@ -0,0 +1,16 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tabulatr::JsonBuilder do
4
+
5
+ it "does not complain when no id is manually provided" do
6
+ attribute = {action: :id}
7
+ data = {title: 'test', price: '7.0 EUR'}
8
+ expect{Tabulatr::JsonBuilder.insert_attribute_in_hash(attribute, data)}.to_not raise_error
9
+ end
10
+
11
+ it "complains when a non given attribute other than id is requested" do
12
+ attribute = {action: :bar}
13
+ data = {title: 'test', price: '7.0 EUR'}
14
+ expect{Tabulatr::JsonBuilder.insert_attribute_in_hash(attribute, data)}.to raise_error
15
+ end
16
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tabulatr2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.0
4
+ version: 0.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Horn
@@ -70,6 +70,8 @@ files:
70
70
  - LICENSE
71
71
  - README.md
72
72
  - Rakefile
73
+ - app/assets/images/pacman-loader.gif
74
+ - app/assets/images/standard-loader.gif
73
75
  - app/assets/javascripts/tabulatr.js
74
76
  - app/assets/javascripts/tabulatr/application.js
75
77
  - app/assets/javascripts/tabulatr/jquery.inview.min.js
@@ -178,6 +180,7 @@ files:
178
180
  - spec/dummy/public/favicon.ico
179
181
  - spec/features/tabulatrs_spec.rb
180
182
  - spec/lib/tabulatr/data/data_spec.rb
183
+ - spec/lib/tabulatr/json_builder_spec.rb
181
184
  - spec/spec_helper.rb
182
185
  - tabulatr.gemspec
183
186
  homepage: http://github.com/provideal/tabulatr2
@@ -267,5 +270,6 @@ test_files:
267
270
  - spec/dummy/public/favicon.ico
268
271
  - spec/features/tabulatrs_spec.rb
269
272
  - spec/lib/tabulatr/data/data_spec.rb
273
+ - spec/lib/tabulatr/json_builder_spec.rb
270
274
  - spec/spec_helper.rb
271
275
  has_rdoc: