}
$surveysData[$sid]['isActive'] = $isActive;
- $surveysData[$sid]['is_default'] = self::crmIcon('fa-check', ts('Default'), $surveysData[$sid]['is_default']);
+ // For some reason, 'is_default' is coming as a string.
+ $surveysData[$sid]['is_default'] = boolval($surveysData[$sid]['is_default']);
if ($surveysData[$sid]['result_id']) {
$resultSet = '<a href= "javascript:displayResultSet( ' . $sid . ',' . "'" . $surveysData[$sid]['title'] . "'" . ', ' . $surveysData[$sid]['result_id'] . ' )" title="' . ts('view result set') . '">' . ts('Result Set') . '</a>';
$isActive = ts('Yes');
}
$petitionsData[$pid]['isActive'] = $isActive;
- $petitionsData[$pid]['is_default'] = self::crmIcon('fa-check', ts('Default'), $petitionsData[$pid]['is_default']);
+
+ // For some reason, 'is_default' is coming as a string.
+ $petitionsData[$pid]['is_default'] = boolval($petitionsData[$pid]['is_default']);
$petitionsData[$pid]['action'] = CRM_Core_Action::formLink(self::petitionActionLinks(),
$action,
}
if (in_array($field->html_type, ['CheckBox', 'Multi-Select'])) {
- $isDefault = (isset($defVal) && in_array($dao->value, $defVal));
+ $options[$dao->id]['is_default'] = (isset($defVal) && in_array($dao->value, $defVal));
}
else {
- $isDefault = ($field->default_value == $dao->value);
+ $options[$dao->id]['is_default'] = ($field->default_value == $dao->value);
}
- $options[$dao->id]['is_default'] = CRM_Core_Page::crmIcon('fa-check', ts('Default'), $isDefault);
$options[$dao->id]['description'] = $dao->description;
$options[$dao->id]['class'] = $dao->id . ',' . $class;
$options[$dao->id]['is_active'] = empty($dao->is_active) ? ts('No') : ts('Yes');
$action -= CRM_Core_Action::DISABLE;
}
}
- $customOption[$id]['is_default'] = CRM_Core_Page::crmIcon('fa-check', ts('Default'), !empty($customOption[$id]['is_default']));
$customOption[$id]['order'] = $customOption[$id]['weight'];
$customOption[$id]['action'] = CRM_Core_Action::formLink(self::actionLinks(), $action,
[
return ret + _.escape(row.text) + (description ? '<div class="crm-select2-row-description"><p>' + _.escape(description) + '</p></div>' : '');
}
+ /**
+ * Helper to generate an icon with alt text.
+ *
+ * See also smarty `{icon}` and CRM_Core_Page::crmIcon() functions
+ *
+ * @param string icon
+ * The Font Awesome icon class to use.
+ * @param string text
+ * Alt text to display.
+ * @param mixed condition
+ * This will only display if this is truthy.
+ *
+ * @return string
+ * The formatted icon markup.
+ */
+ CRM.utils.formatConditionalIcon = function (icon, text, condition) {
+ if (!condition) {
+ return '';
+ }
+ var title = '';
+ var sr = '';
+ if (text) {
+ title = ' title="' + text + '"';
+ sr = '<span class="sr-only">' + text + '</span>';
+ }
+ return '<i class="crm-i ' + icon + '"' + title + '></i>' + sr;
+ };
+
/**
* Wrapper for select2 initialization function; supplies defaults
* @param options object
//add id for yes/no column.
CRM.$(nRow).children().eq(8).attr( 'id', rowId + '_status' );
+ CRM.$(nRow).children().eq(6).html(CRM.utils.formatConditionalIcon('fa-check', ts('Default'), nRow.cells[6].innerText));
return nRow;
},
//add id for yes/no column.
CRM.$(nRow).children().eq(11).attr( 'id', rowId + '_status' );
+ CRM.$(nRow).children().eq(9).html(CRM.utils.formatConditionalIcon('fa-check', ts('Default'), nRow.cells[9].innerText));
return nRow;
},
"aoColumns" : [
{sClass:'crm-custom_option-label'},
{sClass:'crm-custom_option-value'},
+ {sClass:'crm-custom_option-description'},
{sClass:'crm-custom_option-default_value'},
- {sClass:'crm-custom_option-default_description'},
{sClass:'crm-custom_option-is_active'},
{sClass:'crm-custom_option-links'},
{sClass:'hiddenElement'}
$(nRow).addClass(cl).attr({id: 'OptionValue-' + id});
$('td:eq(0)', nRow).wrapInner('<span class="crm-editable crmf-label" />');
$('td:eq(0)', nRow).prepend('<span class="crm-i fa-arrows crm-grip" />');
- $('td:eq(2)', nRow).addClass('crmf-default_value');
+ $('td:eq(3)', nRow).addClass('crmf-default_value').html(CRM.utils.formatConditionalIcon('fa-check', ts('Default'), nRow.cells[3].innerText));
return nRow;
},
"fnDrawCallback": function() {