}
},
'#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();