Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crm 12048 #105

Merged
merged 1 commit into from
Mar 9, 2013
Merged
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
89 changes: 19 additions & 70 deletions templates/CRM/common/highLightImport.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -23,76 +23,25 @@
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
*}
{* Highlight the required field during import (included within a <script>)*}
{literal}
//Highlight the required field during import
paramsArray = new Array();

//build the an array of highlighted elements
{/literal}
{foreach from=$highlightedFields item=paramName}
paramsArray["{$paramName}"] = "1";
{/foreach}
{literal}

//get select object of first element
selObj = document.getElementById("mapper\[0\]\[0\]");

for ( i = 0; i < selObj.options.length; i++ ) {
//check value is exist in array
if (selObj.options[i].value in paramsArray) {
//change background Color of all element whose ids start with mapper and end with [0];
cj('select[id^="mapper"][id$="[0]"]').each( function( ) {
cj(this.options[i]).append(' *').css({"color":"#FF0000"});
});
}
}

{/literal}{if $relationship}{literal}

//Highlight the required field during import (Relationship fields*)
paramsArrayRel = new Array();

//build the an array of highlighted elements
{/literal}
{foreach from=$highlightedRelFields key=relId item=paramsRel}
{literal}
paramsArrayRel["{/literal}{$relId}{literal}"] = new Array();
{/literal}
{foreach from=$paramsRel item=paramNameRel}
paramsArrayRel["{$relId}"]["{$paramNameRel}"] = "1";
{/foreach}
{/foreach}
{literal}

var object = 'select[id^="mapper"][id$="[0]"]';
cj(object).bind( 'change', function(){highlight(this);});
cj('div#map-field').one( 'mouseenter', function(){highlight(object);});

function highlight(obj){
cj(obj).each(function(){
// get selected element id
var currentId = this.id;

// create relationship related field ID ( replace last [0] with [1] )
var newId = currentId.replace(/\[0\]$/, "\[1\]");

// get the option value
var selected = cj(this).val();

// get obeject of select field
selObjRel = document.getElementById(newId);

if ( paramsArrayRel[selected] != undefined ) {
for ( i = 0; i < selObjRel.options.length; i++ ) {
//check value is exist in array
if (selObjRel.options[i].value in paramsArrayRel[selected]) {
cj(selObjRel).each( function( ) {
cj(selObjRel.options[i]).append(' *').css({"color":"#FF0000"});
});
}
}
}
});
cj(function($) {
var highlightedFields = ["{/literal}{'","'|implode:$highlightedFields}{literal}"];
$.each(highlightedFields, function() {
$('select[id^="mapper"][id$="_0"] option[value='+ this + ']').append(' *').css({"color":"#FF0000"});
});
{/literal}{if $relationship}{literal}
var highlightedRelFields = {/literal}{$highlightedRelFields|@json_encode}{literal};
function highlight() {
var select, fields = highlightedRelFields[$(this).val()];
if (fields) {
select = $(this).next();
$.each(fields, function() {
$('option[value='+ this + ']', select).append(' *').css({"color":"#FF0000"});
});
}
}
$('select[id^="mapper"][id$="_0"]').each(highlight).click(highlight);
{/literal}{/if}{literal}
});
{/literal}
{/if}