Permalink
Browse files

Fix issue with missing field values.

  • Loading branch information...
1 parent 27b8440 commit 9c8c57042cbc5f200ca5146b2184213147e20a87 Robert Jackson committed Apr 6, 2012
Showing with 36 additions and 12 deletions.
  1. +17 −5 pivot.js
  2. +1 −1 pivot.min.js
  3. +1 −1 spec/pivotjs_spec.js
  4. +15 −0 src/fields.js
  5. +2 −5 src/init.js
View
@@ -28,12 +28,9 @@ function reset(){
};
function config(){
- var fieldsOutput = getFields(), i = -1, m = fieldsOutput.length;
- while (++i < m){
- delete fieldsOutput[i].values;
- }
- return { fields: fieldsOutput,
+
+ return { fields: cloneFields(),
filters: filters,
rowLabels: objectKeys(displayFields.rowLabels),
columnLabels: objectKeys(displayFields.columnLabels),
@@ -374,6 +371,7 @@ function pivotFields(type){
summarizable: restrictFields('summarizable'),
filterable: restrictFields('filterable'),
pseudo: restrictFields('pseudo'),
+ clone: cloneFields,
add: appendField,
all: getFields,
set: setFields,
@@ -395,6 +393,20 @@ function pivotFields(type){
}
};
+ function cloneFields(){
+ var fieldsOutput = [];
+ for (var field in fields){
+ var newField = {};
+ for (var key in fields[field]){
+ if (fields[field].hasOwnProperty(key) && key !== 'values')
+ newField[key] = fields[field][key];
+ }
+ fieldsOutput.push(newField);
+ }
+
+ return fieldsOutput;
+ }
+
function getFields(){
var retFields = [];
for (var key in fields) {
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -40,7 +40,7 @@ describe('pivot', function () {
initialColumnLabels = pivot.utils().objectKeys(pivot.display().columnLabels().get),
initialSummaries = pivot.utils().objectKeys(pivot.display().summaries().get),
initialFilters = pivot.filters().all(),
- initialFields = pivot.fields().all();
+ initialFields = pivot.fields().clone();
expect(pivot.config()).toEqual({ fields: initialFields,
filters: initialFilters,
View
@@ -5,6 +5,7 @@ function pivotFields(type){
summarizable: restrictFields('summarizable'),
filterable: restrictFields('filterable'),
pseudo: restrictFields('pseudo'),
+ clone: cloneFields,
add: appendField,
all: getFields,
set: setFields,
@@ -26,6 +27,20 @@ function pivotFields(type){
}
};
+ function cloneFields(){
+ var fieldsOutput = [];
+ for (var field in fields){
+ var newField = {};
+ for (var key in fields[field]){
+ if (fields[field].hasOwnProperty(key) && key !== 'values')
+ newField[key] = fields[field][key];
+ }
+ fieldsOutput.push(newField);
+ }
+
+ return fieldsOutput;
+ }
+
function getFields(){
var retFields = [];
for (var key in fields) {
View
@@ -27,12 +27,9 @@ function reset(){
};
function config(){
- var fieldsOutput = getFields(), i = -1, m = fieldsOutput.length;
- while (++i < m){
- delete fieldsOutput[i].values;
- }
- return { fields: fieldsOutput,
+
+ return { fields: cloneFields(),
filters: filters,
rowLabels: objectKeys(displayFields.rowLabels),
columnLabels: objectKeys(displayFields.columnLabels),

0 comments on commit 9c8c570

Please sign in to comment.