// query to list mergable tags
$query = "
-SELECT t1.name, t1.id, t1.used_for, t2.name as parent
+SELECT t1.name, t1.id, t1.used_for, t1.color, t2.name as parent
FROM civicrm_tag t1
LEFT JOIN civicrm_tag t2 ON t1.parent_id = t2.id
WHERE t1.id <> {$fromId} AND
$row = array(
'id' => $dao->id,
'text' => ($dao->parent ? "{$dao->parent} :: " : '') . $dao->name,
+ 'color' => isset($dao->color) ? $dao->color : NULL,
);
// Add warning about used_for types
if (!empty($dao->used_for)) {
'page_num' => 1,
'input' => '',
'image_field' => NULL,
+ 'color_field' => isset($fields['color']) ? 'color' : NULL,
'id_field' => $entity == 'option_value' ? 'value' : 'id',
'description_field' => array(),
'params' => array(),
if (!empty($request['image_field'])) {
$fieldsToReturn[] = $request['image_field'];
}
+ if (!empty($request['color_field'])) {
+ $fieldsToReturn[] = $request['color_field'];
+ }
if (!empty($request['description_field'])) {
$fieldsToReturn = array_merge($fieldsToReturn, (array) $request['description_field']);
}
if (!empty($request['image_field'])) {
$data['image'] = isset($row[$request['image_field']]) ? $row[$request['image_field']] : '';
}
+ if (isset($row[$request['color_field']])) {
+ $data['color'] = $row[$request['color_field']];
+ }
$output[] = $data;
}
}
},
minimumInputLength: 1,
formatResult: CRM.utils.formatSelect2Result,
- formatSelection: function(row) {
- return _.escape((row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : ''));
- },
+ formatSelection: formatEntityRefSelection,
escapeMarkup: _.identity,
initSelection: function($el, callback) {
var
markup += '<div class="crm-select2-icon"><div class="crm-icon ' + row.icon_class + '-icon"></div></div>';
}
markup += '<div><div class="crm-select2-row-label '+(row.label_class || '')+'">' +
+ (row.color ? '<span class="crm-select-item-color" style="background-color: ' + row.color + '"></span> ' : '') +
_.escape((row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : '')) +
'</div>' +
'<div class="crm-select2-row-description">';
return markup;
};
+ function formatEntityRefSelection(row) {
+ return (row.color ? '<span class="crm-select-item-color" style="background-color: ' + row.color + '"></span> ' : '') +
+ _.escape((row.prefix !== undefined ? row.prefix + ' ' : '') + row.label + (row.suffix !== undefined ? ' ' + row.suffix : ''));
+ }
+
function renderEntityRefCreateLinks($el) {
var
createLinks = $el.data('create-links'),