Skip to content
Snippets Groups Projects
Commit c481c79f authored by deepak-srivastava's avatar deepak-srivastava
Browse files

Merge pull request #1032 from ravishnair/CRM-12823

-- CRM-12823 created a popup for "Add New Record"
parents 1f5849cb 591e7c66
Branches
Tags
No related merge requests found
......@@ -28,13 +28,14 @@
{if ($context eq 'multiProfileDialog')}
{literal}
<script type="text/javascript">
cj(function() {
cj(function($) {
$('#profile-dialog .crm-container-snippet #Edit').validate(CRM.validate.params);
var formOptions = {
beforeSubmit: proccessMultiRecordForm //pre-submit callback
};
//binding the callback to snippet profile form
cj('.crm-container-snippet #Edit').ajaxForm(formOptions);
$('.crm-container-snippet #Edit').ajaxForm(formOptions);
});
// pre-submit callback
......@@ -55,10 +56,7 @@ function proccessMultiRecordForm(formData, jqForm, options) {
//if there is any form error show the dialog
//else redirect to post url
if (cj(response).find('.crm-error').html()) {
cj('#profile-dialog').show().html(response);
}
else {
if (!cj(response).find('.crm-error').html()) {
window.location = '{/literal}{$postUrl}{literal}';
}
......@@ -69,6 +67,7 @@ function proccessMultiRecordForm(formData, jqForm, options) {
}
</script>
{/literal}
{include file="CRM/Form/validate.tpl"}
{/if}
{if $deleteRecord}
<div class="messages status no-popup">
......
......@@ -52,44 +52,6 @@
</div>
</div>
<div id='profile-dialog' class="hiddenElement"></div>
{literal}
<script type='text/javascript'>
cj(function () {
function formDialog(dataURL, dialogTitle) {
cj.ajax({
url: dataURL,
success: function (content) {
cj('#profile-dialog').show().html(content).dialog({
title: dialogTitle,
modal: true,
width: 680,
overlay: {
opacity: 0.5,
background: "black"
},
close: function (event, ui) {
cj('#profile-dialog').html('');
}
});
cj('.action-link').hide();
cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
}});
}
cj('.action-item').each(function () {
cj(this).attr('jshref', cj(this).attr('href'));
cj(this).attr('href', '#browseValues');
});
cj(".action-item").click(function () {
dataURL = cj(this).attr('jshref');
dialogTitle = cj(this).attr('title');
formDialog(dataURL, dialogTitle);
});
});
</script>
{/literal}
{elseif !$records}
<div class="messages status no-popup">
<div class="icon inform-icon"></div>
......@@ -100,10 +62,49 @@
{ts}No multi-record entries found. Note: check is Include in multi-record listing property of the fields you want to display in listings{/ts}
{/if}
</div>
<div id='profile-dialog' class="hiddenElement"></div>
{/if}
{if !$reachedMax}
<a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="id=`$contactId`&multiRecord=add&gid=`$gid`"}"
class="button"><span><div class="icon add-icon"></div>{ts}Add New Record{/ts}</span></a>
<a accesskey="N" href="{crmURL p='civicrm/profile/edit' q="id=`$contactId`&multiRecord=add&gid=`$gid`&snippet=1&context=multiProfileDialog"}"
class="button action-item"><span><div class="icon add-icon"></div>{ts}Add New Record{/ts}</span></a>
{/if}
{/if}
{literal}
<script type='text/javascript'>
cj(function () {
function formDialog(dataURL, dialogTitle) {
cj.ajax({
url: dataURL,
success: function (content) {
cj('#profile-dialog').show().html(content).dialog({
title: dialogTitle,
modal: true,
width: 680,
overlay: {
opacity: 0.5,
background: "black"
},
close: function (event, ui) {
cj('#profile-dialog').html('');
}
});
cj('.action-link').hide();
cj('#profile-dialog #crm-profile-block .edit-value label').css('display', 'inline');
}});
}
cj('.action-item').each(function () {
cj(this).attr('jshref', cj(this).attr('href'));
cj(this).attr('href', '#browseValues');
});
cj(".action-item").click(function () {
dataURL = cj(this).attr('jshref');
dialogTitle = cj(this).attr('title');
formDialog(dataURL, dialogTitle);
});
});
</script>
{/literal}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment