Skip to content
This repository has been archived by the owner on Jan 20, 2024. It is now read-only.

Fixed the Do Not Map option for Accounts, Contacts and Leads #3

Open
wants to merge 2 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
178 changes: 89 additions & 89 deletions src/staticresources/fixedTHeader.resource
Original file line number Diff line number Diff line change
@@ -1,90 +1,90 @@
(function($)
{
$.fn.freezeHeaders = function(options) {
var index = 0;
var defaults = {
headerId : "header",
contentId : "content"
};
var options = $.extend(defaults, options);
return this.each(function() {
var obj = $(this);
var hasThead = obj.find("thead").size() > 0;
var hasTbody = obj.find("thead").size() > 0;
if(obj.is("table") && hasThead && hasTbody) {
var widths = [];
// capture widths before rearranging
obj.find("thead td").each(function(i) {
widths.push($(this).width());
});
var id1 = false, id2 = false;
var attrId = obj.attr("id");
if(attrId) {
id1 = attrId + "_header";
id2 = attrId + "_content";
}
var headerId = (id1 || options.headerId) + index;
var contentId = (id2 || options.contentId) + index++;
// insert header after the current table
var header = $("<div><table></table></div>").attr("id",headerId).css("display","none").css("overflow","hidden").insertAfter(obj);
// insert content after the header
var content = $("<div><table></table></div>").attr("id",contentId).css("display","none").css("overflow-y","auto").insertAfter(header);
// set the options
content.height(options.height);
content.width(options.width);
var headerTable = header.find("table");
var contentTable = content.find("table");
obj.find("thead").appendTo(headerTable);
obj.find("tbody").appendTo(contentTable);
header.css("display", "block");
content.css("display", "block");
headerTable.width(contentTable.width());
copyAttributes(obj.get(0), headerTable, contentTable);
var rowId = 0;
// find the first possible row, which has the same number
// of columns as the header. This step is to avoid rows containing
// columns that span across multiple columns.
contentTable.find("tr").each(function(i) {
if($(this).children().size() == widths.length) {
rowId = i;
return false;
}
});
headerTable.find("td").each(function(i) {
var selector = "#" + contentId + " tr:eq(" + rowId + ") td:eq("+ i +")";
$(selector).wrapInner("<div></div>");
$(selector + " div").width(widths[i]);
$(this).wrapInner('<div style="width:' + widths[i] + ';"></div>');
});
}
});
function copyAttributes(elem, headerTable, contentTable) {
for (var i = 0; i < elem.attributes.length; i++) {
var attrib = elem.attributes[i];
if (attrib.specified && attrib.name != "id") {
headerTable.attr(attrib.name,attrib.value);
contentTable.attr(attrib.name,attrib.value);
}
}
}
}
(function($)
{
$.fn.freezeHeaders = function(options) {
var index = 0;

var defaults = {
headerId : "header",
contentId : "content"
};

var options = $.extend(defaults, options);

return this.each(function() {
var obj = $(this);

var hasThead = obj.find("thead").size() > 0;
var hasTbody = obj.find("thead").size() > 0;

if(obj.is("table") && hasThead && hasTbody) {
var widths = [];

// capture widths before rearranging
obj.find("thead td").each(function(i) {
widths.push($(this).width());
});

var id1 = false, id2 = false;
var attrId = obj.attr("id");

if(attrId) {
id1 = attrId + "_header";
id2 = attrId + "_content";
}

var headerId = (id1 || options.headerId) + index;
var contentId = (id2 || options.contentId) + index++;

// insert header after the current table
var header = $("<div><table></table></div>").attr("id",headerId).css("display","none").css("overflow","hidden").insertAfter(obj);
// insert content after the header
var content = $("<div><table></table></div>").attr("id",contentId).css("display","none").css("overflow-y","auto").insertAfter(header);

// set the options
content.height(options.height);
content.width(options.width);

var headerTable = header.find("table");
var contentTable = content.find("table");

obj.find("thead").appendTo(headerTable);
obj.find("tbody").appendTo(contentTable);
header.css("display", "block");
content.css("display", "block");

headerTable.width(contentTable.width());

copyAttributes(obj.get(0), headerTable, contentTable);

var rowId = 0;
// find the first possible row, which has the same number
// of columns as the header. This step is to avoid rows containing
// columns that span across multiple columns.
contentTable.find("tr").each(function(i) {
if($(this).children().size() == widths.length) {
rowId = i;
return false;
}
});

headerTable.find("td").each(function(i) {
var selector = "#" + contentId + " tr:eq(" + rowId + ") td:eq("+ i +")";
$(selector).wrapInner("<div></div>");
$(selector + " div").width(widths[i]);
$(this).wrapInner('<div style="width:' + widths[i] + ';"></div>');
});
}
});

function copyAttributes(elem, headerTable, contentTable) {
for (var i = 0; i < elem.attributes.length; i++) {
var attrib = elem.attributes[i];
if (attrib.specified && attrib.name != "id") {
headerTable.attr(attrib.name,attrib.value);
contentTable.attr(attrib.name,attrib.value);
}
}
}
}

})(jQuery);
7 changes: 7 additions & 0 deletions src/triggers/FindNearby_2010_Account_Tidy.trigger
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ trigger FindNearby_2010_Account_Tidy on Account (before update) {
reset = true;
}
}
// Added else if below to make Do Not Map selection able to be saved
else if (Trigger.new[k].Which_Address__c == 'Do Not Map')
{
Trigger.new[k].Which_Address__c = 'Do Not Map';
reset=true;
}
// End edit
else{
Trigger.new[k].Which_Address__c = 'Billing';
reset = true;
Expand Down
7 changes: 7 additions & 0 deletions src/triggers/FindNearby_2010_Contact_Tidy.trigger
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,13 @@ trigger FindNearby_2010_Contact_Tidy on Contact (before update) {
reset = true;
}
}
// Added else if below to make Do Not Map selection able to be saved
else if (Trigger.new[k].Mapping_Address__c == 'Do Not Map')
{
Trigger.new[k].Mapping_Address__c = 'Do Not Map';
reset=true;
}
// End edit
else{
Trigger.new[k].Mapping_Address__c = 'Mailing';
reset = true;
Expand Down
10 changes: 9 additions & 1 deletion src/triggers/FindNearby_2010_Lead_Tidy.trigger
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,15 @@ trigger FindNearby_2010_Lead_Tidy on Lead (before update) {
Trigger.new[k].Lat__c = null;
Trigger.new[k].Lon__c = null;
}

// Added code to make Do Not Map checkbox work
if(Trigger.new[k].Do_Not_Map__c == true)
{
reset = true;
} else
{
Trigger.new[k].Do_Not_Map__c = false;
}
// End edit
if(reset){
Trigger.new[k].Mapping_Status__c = 'Not Located Yet';
Trigger.new[k].Lat__c = null;
Expand Down