Skip to content
Snippets Groups Projects
Commit f58325af authored by mattwire's avatar mattwire
Browse files

Add rule ID to rules view, improve layout of filter, fix html errors

parent 37625016
No related branches found
No related tags found
No related merge requests found
......@@ -39,7 +39,7 @@ class CRM_Civirules_Form_RuleView extends CRM_Core_Form {
'class' => 'crm-select2',
'placeholder' => E::ts('- Select Trigger -'),
]);
$this->add('text', 'desc_contains', E::ts('Description Contains'), [], FALSE);
$this->add('text', 'desc_contains', E::ts('Description Contains'), ['size' => 40], FALSE);
$this->addYesNo('include_disabled', E::ts('Show disabled Rules?'), [], FALSE);
$this->addButtons([
['type' => 'submit', 'name' => E::ts('Filter'), 'isDefault' => TRUE],
......@@ -93,7 +93,7 @@ class CRM_Civirules_Form_RuleView extends CRM_Core_Form {
* Method to generate the query and query parameters to get the rules
*/
private function generateRuleQuery() {
$select = "SELECT DISTINCT(cr.id) AS rule_id, cr.label, ct.label AS trigger_label, cr.is_active, cr.description, cr.help_text,
$select = "SELECT DISTINCT(cr.id) AS rule_id, cr.label, ct.label AS trigger_label, cr.is_active, cr.description, cr.help_text,
cr.created_date, cr.created_user_id, cc.sort_name AS created_by";
$from = "FROM civirule_rule AS cr JOIN civirule_trigger AS ct ON cr.trigger_id = ct.id
LEFT JOIN civicrm_contact AS cc ON cr.created_user_id = cc.id
......
......@@ -2,7 +2,7 @@
{ts}The existing CiviRules are listed below. You can manage, delete, disable/enable or add a rule. You can filther the list of CiviRules with the Filter Criteria{/ts}
</div>
<div class="crm-block crm-form-block crm-civirule-rule_view-block">
{* dialog for rule help text *}
{* dialog for rule help text *}
<div class="crm-accordion-wrapper civirule-view-wrapper">
<div class="crm-accordion-header crm-master-accordion-header">Filter Criteria</div>
<div class="crm-accordion-body">
......@@ -12,14 +12,15 @@
<td class="content civirule_view_trigger_id">{$form.trigger_id.html}</td>
<td class="label civirule_view_tag_id_label">{$form.tag_id.label}</td>
<td class="content civirule_view_tag_id">{$form.tag_id.html}</td>
<td class="label civirule_view_tag_id_label">{$form.desc_contains.label}</td>
<td class="content civirule_view_tag_id">{$form.desc_contains.html}</td>
</tr><tr>
<td class="label civirule_view_include_disabled_label">{$form.include_disabled.label}</td>
<td class="content civirule_view_include_disabled">{$form.include_disabled.html}</td>
<td><div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div></td>
<td class="label civirule_view_tag_id_label">{$form.desc_contains.label}</td>
<td class="content civirule_view_tag_id">{$form.desc_contains.html}</td>
</tr>
</table>
<div class="crm-submit-buttons">{include file="CRM/common/formButtons.tpl"}</div>
</div>
</div>
{include file="CRM/Civirules/Page/RuleViewList.tpl"}
{include file="CRM/Civirules/Page/RuleViewList.tpl"}
</div>
<div class="crm-content-block crm-block">
</div>
<div class="action-link">
<a class="button new-option civirule-add-new" href="{$add_url}">
<span><i class="crm-i fa-plus-circle"></i> {ts}Add CiviRule{/ts}</span>
</a>
</div>
<div id="civirule_wrapper" class="dataTables_wrapper">
{include file="CRM/common/jsortable.tpl"}
{include file="CRM/common/enableDisableApi.tpl"}
<table id="civirule-table" class="display">
<thead>
<tr>
<th id="sortable">{ts}Rule Label{/ts}</th>
<th id="sortable">{ts}Trigger{/ts}</th>
<th id="sortable">{ts}Tag(s){/ts}</th>
<th id="nosort">{ts}Description{/ts}</th>
<th id="sortable">{ts}Active?{/ts}</th>
<th id="sortable">{ts}Date Created{/ts}</th>
<th id="sortable">{ts}Created By{/ts}</th>
<th id="nosort"></th>
</tr>
</thead>
<tbody>
{assign var="row_class" value="odd-row"}
{foreach from=$rules key=rule_id item=row}
<tr id="row_{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}{if NOT $row.is_active} disabled{/if}">
<td hidden="1">{$row.id}</td>
<td>{$row.label}</td>
<td>{$row.trigger_label}</td>
<td>{$row.tags}</td>
<td>{$row.description}
{if (!empty($row.help_text))}
<a id="civirule_help_text_icon" class="crm-popup medium-popup helpicon" onclick="showRuleHelp({$row.id})" href="#"></a>
{/if}
<td>{$row.is_active}</td>
</td>
<td>{$row.created_date|crmDate}</td>
<td>{$row.created_contact_name}</td>
<td>
</div>
<div class="action-link">
<a class="button new-option civirule-add-new" href="{$add_url}">
<span><i class="crm-i fa-plus-circle"></i> {ts}Add CiviRule{/ts}</span>
</a>
</div>
<div id="civirule_wrapper" class="dataTables_wrapper">
{include file="CRM/common/jsortable.tpl"}
{include file="CRM/common/enableDisableApi.tpl"}
<table id="civirule-table" class="display">
<thead>
<tr>
<th id="sortable">{ts}ID{/ts}</th>
<th id="sortable">{ts}Rule Label{/ts}</th>
<th id="sortable">{ts}Trigger{/ts}</th>
<th id="sortable">{ts}Tag(s){/ts}</th>
<th id="nosort">{ts}Description{/ts}</th>
<th id="sortable">{ts}Active?{/ts}</th>
<th id="sortable">{ts}Date Created{/ts}</th>
<th id="sortable">{ts}Created By{/ts}</th>
<th id="nosort"></th>
</tr>
</thead>
<tbody>
{assign var="row_class" value="odd-row"}
{foreach from=$rules key=rule_id item=row}
<tr id="row_{$rule_id}" class="crm-entity {cycle values="odd-row,even-row"}{if NOT $row.is_active} disabled{/if}">
<td>{$rule_id}</td>
<td>{$row.label}</td>
<td>{$row.trigger_label}</td>
<td>{$row.tags}</td>
<td>{$row.description}
{if (!empty($row.help_text))}
<a id="civirule_help_text_icon" class="crm-popup medium-popup helpicon" onclick="showRuleHelp({$rule_id})" href="#"></a>
{/if}
</td>
<td>{$row.is_active}</td>
<td>{$row.created_date|crmDate}</td>
<td>{$row.created_contact_name}</td>
<td>
<span>
{foreach from=$row.actions item=action_link}
{$action_link}
{/foreach}
</span>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="action-link">
<a class="button new-option civirule-add-new" href="{$add_url}">
<span><i class="crm-i fa-plus-circle"></i> {ts}Add CiviRule{/ts}</span>
</a>
</div>
</td>
</tr>
{/foreach}
</tbody>
</table>
</div>
<div class="action-link">
<a class="button new-option civirule-add-new" href="{$add_url}">
<span><i class="crm-i fa-plus-circle"></i> {ts}Add CiviRule{/ts}</span>
</a>
</div>
{literal}
......@@ -61,41 +61,41 @@
function showRuleHelp(ruleId) {
console.log('rule id is ' + ruleId);
CRM.api3('CiviRuleRule', 'getsingle', {"id": ruleId})
.done(function(result) {
cj("#civirule_helptext_dialog-block").dialog({
width: 600,
height: 300,
title: "Help for Rule " + result.label,
buttons: {
"Done": function() {
cj(this).dialog("close");
}
}
});
cj("#civirule_helptext_dialog-block").html(result.help_text);
});
.done(function(result) {
cj("#civirule_helptext_dialog-block").dialog({
width: 600,
height: 300,
title: "Help for Rule " + result.label,
buttons: {
"Done": function() {
cj(this).dialog("close");
}
}
});
cj("#civirule_helptext_dialog-block").html(result.help_text);
});
}
function civiruleEnableDisable(ruleId, action) {
if (action === 1) {
CRM.api3('CiviRuleRule', 'getClones', {"id": ruleId})
.done(function (result) {
if (result.count > 0) {
location.href = CRM.url('civicrm/civirule/form/ruleenable', {"id": ruleId});
}
else {
CRM.api3('CiviRuleRule', 'create', {"id": ruleId, "is_active": action})
.done(function (result) {
location.reload(true);
});
}
});
.done(function (result) {
if (result.count > 0) {
location.href = CRM.url('civicrm/civirule/form/ruleenable', {"id": ruleId});
}
else {
CRM.api3('CiviRuleRule', 'create', {"id": ruleId, "is_active": action})
.done(function (result) {
location.reload(true);
});
}
});
}
else {
CRM.api3('CiviRuleRule', 'create', {"id": ruleId, "is_active": action})
.done(function (result) {
location.reload(true);
});
.done(function (result) {
location.reload(true);
});
}
}
</script>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment