oilsRpt.name = n;
oilsRptDisplaySelector = DOM.oils_rpt_display_selector;
oilsRptFilterSelector = DOM.oils_rpt_filter_selector;
+ oilsRptAggFilterSelector= DOM.oils_rpt_agg_filter_selector;
removeChildren(oilsRptDisplaySelector);
removeChildren(oilsRptFilterSelector);
+ removeChildren(oilsRptAggFilterSelector);
oilsRptDebug();
oilsRptResetParams();
}
} else {
for( var j = 0; j < list.length; j++ )
- /* if there are no items left in the "select" clause for the given
- relation, trim this relation from the "from" clause */
- if(!grep(oilsRpt.def.select,
- function(i){ return (i.relation == oilsRptPathRel(list[j])); }))
- oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+ /* if there are no items left in the "select", "where", or "having" clauses
+ for the given relation, trim this relation from the "from" clause */
+ if( !grep(oilsRpt.def.select,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ && !grep(oilsRpt.def.where,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ && !grep(oilsRpt.def.having,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
}
oilsRptDebug();
/* removes selected items from the display window */
function oilsDelSelectedFilterItems() {
- oilsDelSelectedItems(oilsRptFilterSelector);
+ var list = oilsDelSelectedItems(oilsRptFilterSelector);
+
+ /* remove the de-selected columns from the report output */
+ oilsRpt.def.where = grep( oilsRpt.def.where,
+ function(i) {
+ for( var j = 0; j < list.length; j++ ) {
+ var d = list[j];
+ var col = i.column;
+
+ /* if this columsn has a transform,
+ it will be an object { tform => column } */
+ if( typeof col != 'string' )
+ for( var c in col ) col = col[c];
+
+ /* if this transform requires params, the column
+ will be the first item in the param set array */
+ if( typeof col != 'string' ) col = col[0];
+
+ if( oilsRptPathRel(d) == i.relation && oilsRptPathCol(d) == col ) {
+ var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
+ if( param ) delete oilsRpt.params[param];
+ return false;
+ }
+ }
+ return true;
+ }
+ );
+
+ if(!oilsRpt.def.where) {
+ oilsRpt.def.where = [];
+ oilsReportBuilderReset();
+
+ } else {
+ for( var j = 0; j < list.length; j++ )
+ /* if there are no items left in the "select", "where", or "having" clauses
+ for the given relation, trim this relation from the "from" clause */
+ if( !grep(oilsRpt.def.select,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ && !grep(oilsRpt.def.where,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ && !grep(oilsRpt.def.having,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+ }
+
+ oilsRptDebug();
+}
+
+/* adds an item to the display window */
+function oilsAddRptAggFilterItem(val) {
+ oilsAddSelectorItem(oilsRptAggFilterSelector, val);
+}
+
+/* removes a specific item from the display window */
+function oilsDelAggFilterItem(val) {
+ oilsDelSelectorItem(oilsRptAggFilterSelector, val);
+}
+
+/* removes selected items from the display window */
+function oilsDelSelectedAggFilterItems() {
+ var list = oilsDelSelectedItems(oilsRptAggFilterSelector);
+
+ /* remove the de-selected columns from the report output */
+ oilsRpt.def.having = grep( oilsRpt.def.having,
+ function(i) {
+ for( var j = 0; j < list.length; j++ ) {
+ var d = list[j];
+ var col = i.column;
+
+ /* if this columsn has a transform,
+ it will be an object { tform => column } */
+ if( typeof col != 'string' )
+ for( var c in col ) col = col[c];
+
+ /* if this transform requires params, the column
+ will be the first item in the param set array */
+ if( typeof col != 'string' ) col = col[0];
+
+ if( oilsRptPathRel(d) == i.relation && oilsRptPathCol(d) == col ) {
+ var param = (i.alias) ? i.alias.match(/::PARAM\d*/) : null;
+ if( param ) delete oilsRpt.params[param];
+ return false;
+ }
+ }
+ return true;
+ }
+ );
+
+ if(!oilsRpt.def.having) {
+ oilsRpt.def.having = [];
+ oilsReportBuilderReset();
+
+ } else {
+ for( var j = 0; j < list.length; j++ )
+ /* if there are no items left in the "select", "where", or "having" clauses
+ for the given relation, trim this relation from the "from" clause */
+ if( !grep(oilsRpt.def.select,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ && !grep(oilsRpt.def.where,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ && !grep(oilsRpt.def.having,
+ function(i){ return (i.relation == oilsRptPathRel(list[j])); })
+ ) oilsRptPruneFromClause(oilsRptPathRel(list[j]));
+ }
+
+ oilsRptDebug();
}
<!-- generic transforms -->
<option value='Bare' selected='selected'>Raw Data</option>
- <option value='count' aggregate='1'>Count</option>
- <option value='count distinct' aggregate='1'>Count Distinct</option>
- <option value='min' aggregate='1'>Min</option>
- <option value='max' aggregate='1'>Max</option>
+ <option value='first'>First Value</option>
+ <option value='last'>Last Value</option>
<!-- string transforms -->
+ <option value='count' datatype='string' aggregate='1'>Count</option>
+ <option value='count_distinct' datatype='string' aggregate='1'>Count Distinct</option>
+ <option value='min' datatype='string' aggregate='1'>Min</option>
+ <option value='max' datatype='string' aggregate='1'>Max</option>
<option value='substring' datatype='string' widget='string_substring_widget' >Substring</option>
<option value='lower' datatype='string'>Lower case</option>
<option value='upper' datatype='string'>Upper Case</option>
<!-- timestamp transforms -->
+ <option value='count' datatype='timestamp' aggregate='1'>Count</option>
+ <option value='count_distinct' datatype='timestamp' aggregate='1'>Count Distinct</option>
+ <option value='min' datatype='timestamp' aggregate='1'>Min</option>
+ <option value='max' datatype='timestamp' aggregate='1'>Max</option>
<option value='dow' datatype='timestamp'>Day of Week</option>
<option value='dom' datatype='timestamp'>Day of Month</option>
<option value='doy' datatype='timestamp'>Day of Year</option>
<option value='day_name' datatype='timestamp'>Day Name</option>
<option value='month_name' datatype='timestamp'>Month Name</option>
- <!-- numeric transforms -->
- <option value='round' datatype='numeric' >Round</option>
- <option value='int' datatype='numeric' >Drop trailing decimals</option>
+ <!-- int transforms -->
+ <option value='count' datatype='int' aggregate='1'>Count</option>
+ <option value='count_distinct' datatype='int' aggregate='1'>Count</option>
+ <option value='min' datatype='int' aggregate='1'>Min</option>
+ <option value='max' datatype='int' aggregate='1'>Max</option>
+ <option value='sum' datatype='int' aggregate='1'>Sum</option>
+ <option value='average' datatype='int' aggregate='1'>Average</option>
+
+ <!-- float transforms -->
+ <option value='count' datatype='float' aggregate='1'>Count</option>
+ <option value='count_distinct' datatype='float' aggregate='1'>Count</option>
+ <option value='min' datatype='float' aggregate='1'>Min</option>
+ <option value='max' datatype='float' aggregate='1'>Max</option>
+ <option value='sum' datatype='float' aggregate='1'>Sum</option>
+ <option value='average' datatype='int' aggregate='1'>Average</option>
+ <option value='round' datatype='float' >Round</option>
+ <option value='int' datatype='float' >Drop trailing decimals</option>
</select>
</td>