Skip to content
Snippets Groups Projects
Commit 988d63ba authored by Jaden Diefenbaugh's avatar Jaden Diefenbaugh
Browse files

fix tablefield generation using startswith instead of actual matching, #21

parent 74c7a43b
No related branches found
No related tags found
1 merge request!223Reports overhaul
......@@ -63,7 +63,9 @@ angular.module('reportApp')
// converting to and from a Set is a simple way of
// removing dups
return Array.from(new Set(fieldArr));
const arr = Array.from(new Set(fieldArr));
return arr;
};
// has this fieldName already been processed?
......@@ -101,12 +103,28 @@ angular.module('reportApp')
.filter(f => f.includes('.'))
.map(f => f.split('.')[0]);
return Array.from(new Set(groupNames)).sort((a, b) => groupNames.indexOf(a) - groupNames.indexOf(b));
const sorted = Array.from(new Set(groupNames))
.sort((a, b) => groupNames.indexOf(a) - groupNames.indexOf(b))
return sorted;
};
// finds the actual field name whether its in a field group or not
scope.groupName = (field) => field.includes('.') ? field.split('.')[0] : field;
// finds the actual field name whether its in a field group or not
scope.subfieldName = (field) => field.includes('.') ? field.split('.').slice(1).join('.') : field;
scope.shouldShowField = (fName, gName) => {
const isUnique = scope.isUniqueTableable(fName);
const isInGroup = scope.groupName(fName) == gName;
// console.log(`for field "${fName}" and group "${gName}":`);
// console.log(`isUnique: ${isUnique}; isInGroup: ${isInGroup}`);
return isUnique && isInGroup;
}
// toggle the selection of a field
scope.toggleField = (fName) => {
let idx = scope.colsSelected.indexOf(fName);
......@@ -145,7 +163,7 @@ angular.module('reportApp')
<h4>{{ gName }}</h4>
<div
ng-repeat='fName in tableables()'
ng-if='isUniqueTableable(fName) && fName.startsWith(gName)'>
ng-if='shouldShowField(fName, gName)'>
<label>
<input
type='checkbox'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment