From: Coleman Watts Date: Sun, 2 Mar 2014 21:25:21 +0000 (-0500) Subject: CRM-13966 - Cleanup profile dialog X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=f90f3ac1fdabdb22206a9c53ecea25b5ce864426;p=civicrm-core.git CRM-13966 - Cleanup profile dialog --- diff --git a/CRM/Core/BAO/UFGroup.php b/CRM/Core/BAO/UFGroup.php index f61e682c29..d389744fe2 100644 --- a/CRM/Core/BAO/UFGroup.php +++ b/CRM/Core/BAO/UFGroup.php @@ -3223,7 +3223,7 @@ AND ( entity_id IS NULL OR entity_id <= 0 ) if (in_array($profile['name'], $profiles)) { $links[] = array( 'label' => $profile['title'], - 'url' => CRM_Utils_System::url('civicrm/profile/create', 'reset=1&gid=' . $id), + 'url' => CRM_Utils_System::url('civicrm/profile/create', 'reset=1&context=dialog&&gid=' . $id), 'name' => $profile['name'], ); } diff --git a/CRM/Profile/Form/Edit.php b/CRM/Profile/Form/Edit.php index 6921534bd0..3f47c8c93f 100644 --- a/CRM/Profile/Form/Edit.php +++ b/CRM/Profile/Form/Edit.php @@ -282,13 +282,11 @@ SELECT module 'isDefault' => TRUE, ); - if ($this->_context != 'dialog') { - $buttons[] = array( - 'type' => 'cancel', - 'name' => ts('Cancel'), - 'isDefault' => TRUE, - ); - } + $buttons[] = array( + 'type' => 'cancel', + 'name' => ts('Cancel'), + 'isDefault' => TRUE, + ); $this->addButtons($buttons); @@ -309,26 +307,8 @@ SELECT module $sortName = CRM_Core_DAO::getFieldValue('CRM_Contact_DAO_Contact', $this->_id, 'sort_name'); $this->ajaxResponse['label'] = $sortName; - // this is special case when we create contact using Dialog box - if ($this->_context == 'dialog') { - //replace the session stack for redirecting user to contact summary if new contact is created. - $contactViewURL = CRM_Utils_System::url('civicrm/contact/view', "reset=1&cid={$this->_id}", FALSE, NULL, FALSE); - $session = CRM_Core_Session::singleton(); - $session->replaceUserContext($contactViewURL); - - $returnArray = array( - 'contactID' => $this->_id, - 'displayName' => $displayName, - 'sortName' => $sortName, - 'newContactSuccess' => TRUE, - ); - - echo json_encode($returnArray); - CRM_Utils_System::civiExit(); - } - - //for delete record handling - if (empty($_POST[$this->_deleteButtonName])) { + // When saving (not deleting) and not in an ajax popup + if (empty($_POST[$this->_deleteButtonName]) && $this->_context != 'dialog') { CRM_Core_Session::setStatus(ts('Your information has been saved.'), ts('Thank you.'), 'success'); } diff --git a/templates/CRM/Profile/Form/Dynamic.tpl b/templates/CRM/Profile/Form/Dynamic.tpl index 7d28acde8a..67fcf6e423 100644 --- a/templates/CRM/Profile/Form/Dynamic.tpl +++ b/templates/CRM/Profile/Form/Dynamic.tpl @@ -295,58 +295,7 @@ cj(document).ready(function(){ cj('#selector tr:odd ').addClass('even-row'); }); {/literal} -{if $context eq 'dialog'} -{literal} - var options = { - beforeSubmit: showRequest - }; - - // bind form using 'ajaxForm' - cj('#Edit').ajaxForm( options ); - - // FIXME - this is improper use of jquery.form - // Do not use this code as an example - function showRequest(formData, jqForm, options) { - // formData is an array; here we use $.param to convert it to a string to display it - // but the form plugin does this for you automatically when it submits the data - var queryString = cj.param(formData); - queryString = queryString + '&snippet=5&gid=' + {/literal}"{$profileID}"{literal}; - var postUrl = {/literal}"{crmURL p='civicrm/profile/create' h=0 }"{literal}; - var blockNo = {/literal}{if $blockNo}{$blockNo}{else}null{/if}{literal}; - var prefix = {/literal}"{$prefix}"{literal}; - var response = cj.ajax({ - type: "POST", - url: postUrl, - async: false, // FIXME - data: queryString, - dataType: "json", - success: function( response ) { - if ( response.newContactSuccess ) { - cj('#' + prefix + 'contact_' + blockNo ).val( response.sortName ).focus( ); - if ( typeof(allowMultiClient) != "undefined" ) { - if ( allowMultiClient ) { - cj('#' + prefix + 'contact_' + blockNo).tokenInput("add", {id: response.contactID, name: response.sortName }); - } - } - cj('input[name="' + prefix + 'contact_select_id[' + blockNo +']"]').val( response.contactID ); - CRM.alert(response.displayName + {/literal}'{ts escape="js"} has been created.{/ts}', '{ts escape="js"}Contact Saved{/ts}'{literal}, 'success'); - cj('#contact-dialog-' + prefix + blockNo ).dialog('close'); - } - } - }).responseText; - - cj('#contact-dialog-' + prefix + blockNo).html( response ); - - // FIXME - we have used jquery.form very incorrectly - // and are now preventing it from doing what it's supposed to do - return false; - } - -{/literal} -{/if} -{literal} -{/literal} {/crmRegion} {* end crm-profile-NAME *}