added JS for Delete
This commit is contained in:
parent
499efd7087
commit
334c120a35
@ -3,7 +3,7 @@
|
|||||||
class CRM_EntityTemplates_BAO_EntityTemplates extends CRM_Core_DAO_EntityTemplates {
|
class CRM_EntityTemplates_BAO_EntityTemplates extends CRM_Core_DAO_EntityTemplates {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Build Fiscal year option list.
|
* Build Entity option list.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public static function getEntityTypes() {
|
public static function getEntityTypes() {
|
||||||
@ -15,6 +15,14 @@ class CRM_EntityTemplates_BAO_EntityTemplates extends CRM_Core_DAO_EntityTemplat
|
|||||||
return array_column($result['values'], 'value', 'value');
|
return array_column($result['values'], 'value', 'value');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create Entity Template.
|
||||||
|
*
|
||||||
|
* @param array $params
|
||||||
|
*
|
||||||
|
* @throws Exception
|
||||||
|
* @return CRM_EntityTemplates_BAO_EntityTemplates|CRM_Core_Error
|
||||||
|
*/
|
||||||
public static function create($params) {
|
public static function create($params) {
|
||||||
|
|
||||||
if (empty($params['entity_table'])) {
|
if (empty($params['entity_table'])) {
|
||||||
|
@ -38,6 +38,7 @@ class CRM_EntityTemplates_Page_EntityTemplates extends CRM_Core_Page_Basic {
|
|||||||
'name' => ts('Delete'),
|
'name' => ts('Delete'),
|
||||||
'url' => 'civicrm/entity/templates',
|
'url' => 'civicrm/entity/templates',
|
||||||
'qs' => 'action=delete&id=%%id%%',
|
'qs' => 'action=delete&id=%%id%%',
|
||||||
|
'ref' => 'delete-entity-template',
|
||||||
'title' => ts('Delete template'),
|
'title' => ts('Delete template'),
|
||||||
],
|
],
|
||||||
];
|
];
|
||||||
@ -91,6 +92,7 @@ class CRM_EntityTemplates_Page_EntityTemplates extends CRM_Core_Page_Basic {
|
|||||||
$action = array_sum(array_keys($this->links()));
|
$action = array_sum(array_keys($this->links()));
|
||||||
foreach ($results['values'] as $values) {
|
foreach ($results['values'] as $values) {
|
||||||
$rows[] = [
|
$rows[] = [
|
||||||
|
'id' => $values['id'],
|
||||||
'title' => $values['title'],
|
'title' => $values['title'],
|
||||||
'links' => CRM_Core_Action::formLink(
|
'links' => CRM_Core_Action::formLink(
|
||||||
self::links(),
|
self::links(),
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
<th></th>
|
<th></th>
|
||||||
</thead>
|
</thead>
|
||||||
{foreach from=$rows item=row}
|
{foreach from=$rows item=row}
|
||||||
<tr id="EntityTemplates-{$row.title}" class="crm-entity {cycle values="odd-row,even-row"}">
|
<tr id="EntityTemplates-{$row.id}" class="crm-entity {cycle values="odd-row,even-row"}">
|
||||||
<td class='EntityTemplates-title'>{$row.title}</td>
|
<td class='EntityTemplates-title'>{$row.title}</td>
|
||||||
<td class='EntityTemplates-links'>{$row.links}</td>
|
<td class='EntityTemplates-links'>{$row.links}</td>
|
||||||
</tr>
|
</tr>
|
||||||
@ -30,6 +30,22 @@
|
|||||||
entityType: $('#entityType').val()
|
entityType: $('#entityType').val()
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
$('a.delete-entity-template').click(deleteEntity);
|
||||||
|
function deleteEntity() {
|
||||||
|
var row = $(this).closest('.crm-entity');
|
||||||
|
var entityId = row.data('id') || row[0].id.split('-')[1];
|
||||||
|
CRM.confirm({
|
||||||
|
message: ts('Are you sure you want to delete this template?'),
|
||||||
|
title: ts('Delete Template'),
|
||||||
|
options: {{/literal}yes: '{ts escape="js"}Delete{/ts}', no: '{ts escape="js"}Cancel{/ts}'{literal}},
|
||||||
|
width: 300,
|
||||||
|
height: 'auto'
|
||||||
|
})
|
||||||
|
.on('crmConfirm:yes', function() {
|
||||||
|
CRM.api3('EntityTemplates', 'delete', {id: entityId}, true).done(loadPage);
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{/literal}
|
{/literal}
|
||||||
|
Loading…
Reference in New Issue
Block a user