// Provide a select drop-down for the location's location type
// eg: Home, Work...
- $js = NULL;
-
if ($blockInfo['hasLocation']) {
// Load the location options for this entity
$locationOptions = civicrm_api3($blockName, 'getoptions', array('field' => 'location_type_id'));
- // JS lookup 'main' contact's location (if there are any)
- if (!empty($locations['main'][$blockName])) {
- $js = array('onChange' => "mergeBlock('$blockName', this, $count, 'locTypeId' );");
- }
-
$thisLocId = $value['location_type_id'];
// Put this field's location type at the top of the list
"location_blocks[$blockName][$count][locTypeId]",
NULL,
$defaultLocId + $tmpIdList,
- $js,
);
// Add the relevant information to the $migrationInfo
// Provide a select drop-down for the location's type/provider
// eg websites: Google+, Facebook...
- $js = NULL;
-
if ($blockInfo['hasType']) {
// Load the type options for this entity
$typeOptions = civicrm_api3($blockName, 'getoptions', array('field' => $blockInfo['hasType']));
- // CRM-17556 Set up JS lookup of 'main' contact's value by type
- if (!empty($locations['main'][$blockName])) {
- $js = array('onChange' => "mergeBlock('$blockName', this, $count, 'typeTypeId' );");
- }
-
$thisTypeId = CRM_Utils_Array::value($blockInfo['hasType'], $value);
// Put this field's location type at the top of the list
"location_blocks[$blockName][$count][typeTypeId]",
NULL,
$defaultTypeId + $tmpIdList,
- $js,
);
// Add the information to the migrationInfo
// Look for a matching block on the main contact
var mainBlockId = 0;
var mainBlockDisplay = '';
- var mainBlock = findBlock(allBlock, blockname, locTypeId, typeTypeId);
+ var mainBlock = findBlock(blockname, locTypeId, typeTypeId);
// Create appropriate label / add new link after changing the block
if (mainBlock == false) {
* Look for a matching 'main' contact location block by entity, location and
* type
*
- * @param allBlock array
- * All location blocks on the main contact record.
* @param entName string
* The entity name to lookup.
* @param locationID int
* Returns false if no match, otherwise an object with the location ID and
* display value.
*/
- function findBlock(allBlock, entName, locationID, typeID) {
+ function findBlock(entName, locationID, typeID) {
var entityArray = allBlock[entName];
var result = false;
for (var i = 0; i < entityArray.length; i++) {
$('tr.merge-row-equal').toggle();
});
+ // Call mergeBlock whenever a location type is changed
+ jQuery('select[id^="location_blocks_"]').change(function(){
+ // All the information we need is held in the id, separated by underscores
+ var idSplit = this.id.split('_');
+ // Lookup the main value, if any are available
+ if (allBlock[idSplit[2]] != undefined) {
+ mergeBlock(idSplit[2], this, idSplit[3], idSplit[4]);
+ }
+ });
+
});
</script>