Case view improvements
authorColeman Watts <coleman@civicrm.org>
Fri, 5 Sep 2014 22:35:30 +0000 (18:35 -0400)
committerColeman Watts <coleman@civicrm.org>
Fri, 5 Sep 2014 22:35:30 +0000 (18:35 -0400)
templates/CRM/Case/Form/CaseView.js
templates/CRM/Case/Form/CaseView.tpl

index 9e92797d47d27cebf586187df56caac4510c7cec..34e74f1c95ff7dfdd4350e3a5e210d514fc76193 100644 (file)
       }
     },
     '#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(),
         $('[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);
     },
     '#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;
       }
           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');
           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();
index 3eb79817f27c6a2be46e41296b34850bbf21e04e..010778b3aec62b1f363d07033702c1bab55b1c61 100644 (file)
       </a>
     </div>
     <div id="addMembersToGroupDialog" class="hiddenElement">
-      <input name="add_member_to_group_contact_id" placeholder="{ts}- select contact -{/ts}" class="huge" />
+      <input name="add_member_to_group_contact_id" placeholder="{ts}- select contacts -{/ts}" class="huge" />
     </div>
     <table id="globalRelationships-selector-{$caseId}"  class="report-layout">
       <thead><tr>