From: Coleman Watts Date: Fri, 5 Sep 2014 22:35:30 +0000 (-0400) Subject: Case view improvements X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=ba9be71a9ddca72a33b16202979751c6c14e0ac8;p=civicrm-core.git Case view improvements --- diff --git a/templates/CRM/Case/Form/CaseView.js b/templates/CRM/Case/Form/CaseView.js index 9e92797d47..34e74f1c95 100644 --- a/templates/CRM/Case/Form/CaseView.js +++ b/templates/CRM/Case/Form/CaseView.js @@ -89,11 +89,15 @@ } }, '#editCaseRoleDialog': { - pre: function() { - $('[name=edit_role_contact_id]', this).val('').crmEntityRef({create: true, api: {params: {contact_type: 'Individual'}}}); + pre: function(data) { + var params = {create: true}; + if (data.contact_type) { + params.api = {params: {contact_type: data.contact_type}}; + } + $('[name=edit_role_contact_id]', this).val('').crmEntityRef(params); }, post: function(data) { - data.rel_contact = $('[name=edit_role_contact_id]').val(); + data.rel_contact = $('[name=edit_role_contact_id]', this).val(); if (data.rel_contact) { $.extend(data, { case_id: caseId(), @@ -109,7 +113,7 @@ $('[name=add_client_id]', this).val('').crmEntityRef({create: true}); }, post: function(data) { - data.contactID = $('[name=add_client_id]').val(); + data.contactID = $('[name=add_client_id]', this).val(); if (data.contactID) { data.caseID = caseId(); return $.post(CRM.url('civicrm/case/ajax/addclient'), data); @@ -119,12 +123,16 @@ }, '#addMembersToGroupDialog': { pre: function() { - $('[name=add_member_to_group_contact_id]', this).val('').crmEntityRef({create: true}); + $('[name=add_member_to_group_contact_id]', this).val('').crmEntityRef({create: true, select: {multiple: true}}); }, post: function(data) { - data.contact_id = $('[name=add_member_to_group_contact_id]').val(); - if (data.contact_id) { - return CRM.api3('group_contact', 'create', data); + var requests = [], + cids = $('[name=add_member_to_group_contact_id]', this).val(); + if (cids) { + $.each(cids.split(','), function (k, cid) { + requests.push(['group_contact', 'create', $.extend({contact_id: cid}, data)]); + }); + return CRM.api3(requests); } return false; } @@ -183,7 +191,7 @@ var submission = miniForms[target].post.call(dialog[0], $.extend({}, $el.data())); // Function should return a deferred object if (submission) { - dialog.parent().block(); + dialog.block(); submission.done(function(data) { dialog.dialog('close'); var table = $el.closest('table.dataTable'); @@ -208,7 +216,9 @@ title: $(this).attr('title') || $(this).text(), message: detached[target], resizable: true, - open: miniForms[target].pre + open: function() { + miniForms[target].pre && miniForms[target].pre.call(this, $el.data()); + } }) .on('dialogclose', function() { detached[target] = $(target, dialog).detach(); diff --git a/templates/CRM/Case/Form/CaseView.tpl b/templates/CRM/Case/Form/CaseView.tpl index 3eb79817f2..010778b3ae 100644 --- a/templates/CRM/Case/Form/CaseView.tpl +++ b/templates/CRM/Case/Form/CaseView.tpl @@ -340,7 +340,7 @@
- +