Skip to content
This repository has been archived by the owner on May 2, 2023. It is now read-only.

Search column join groups and labels #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion lib/saved_search.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,35 @@ this.SavedSearch = (function() {
* @return {null}
*/
SavedSearch.prototype.appendResults = function(resultsBlock) {
this.results = this.results.concat(resultsBlock);
var newResultsBlock = [];
for ( var i = 0; resultsBlock != null && i < resultsBlock.length; i++ )
{
var newResult = {"id":resultsBlock[i].getId(), "recordtype":resultsBlock[i].getRecordType(), "columns":{}};
var result = resultsBlock[i];
var columns = result.getAllColumns();
var columnLen = columns.length;

for (x = 0; x < columnLen; x++)
{
var column = columns[x];
var name = column.getName();
var label = column.getLabel();
var join = column.getJoin();
var value = result.getValue(column);
var text = result.getText(column);
var joinTitle = join + 'Join';
var columnTitle = (label ? label : name);
if(text && (text !== value))var columnData = {'name':text, 'internalId':value};
else columnData = value;
if(join && !label){
if(!(joinTitle in newResult.columns))newResult.columns[joinTitle] = {};
newResult.columns[joinTitle][columnTitle] = columnData;
}
else newResult.columns[columnTitle] = columnData;
}
newResultsBlock.push(newResult);
}
this.results = this.results.concat(newResultsBlock);
}

/**
Expand Down
30 changes: 29 additions & 1 deletion lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,35 @@ this.Searcher = (function() {
* @return {null}
*/
Searcher.prototype.appendResults = function(resultsBlock) {
this.results = this.results.concat(resultsBlock);
var newResultsBlock = [];
for ( var i = 0; resultsBlock != null && i < resultsBlock.length; i++ )
{
var newResult = {"id":resultsBlock[i].getId(), "recordtype":resultsBlock[i].getRecordType(), "columns":{}};
var result = resultsBlock[i];
var columns = result.getAllColumns();
var columnLen = columns.length;

for (x = 0; x < columnLen; x++)
{
var column = columns[x];
var name = column.getName();
var label = column.getLabel();
var join = column.getJoin();
var value = result.getValue(column);
var text = result.getText(column);
var joinTitle = join + 'Join';
var columnTitle = (label ? label : name);
if(text && (text !== value))var columnData = {'name':text, 'internalId':value};
else columnData = value;
if(join && !label){
if(!(joinTitle in newResult.columns))newResult.columns[joinTitle] = {};
newResult.columns[joinTitle][columnTitle] = columnData;
}
else newResult.columns[columnTitle] = columnData;
}
newResultsBlock.push(newResult);
}
this.results = this.results.concat(newResultsBlock);
}

/**
Expand Down