if ($this->_gid) {
$this->_title = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'title');
CRM_Utils_System::setTitle($this->_title . ' - ' . ($this->_id ? ts('Edit Field') : ts('Add Field')));
+ $this->assign('gid', $this->_gid);
}
// lets trim all the whitespace
*/
function run() {
- // get the group id
- $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive',
- $this
+
+ $id = CRM_Utils_Request::retrieve('id', 'Positive',
+ $this, FALSE, 0
);
+ if ($id) {
+ $values = civicrm_api3('custom_field', 'getsingle', array('id' => $id));
+ $this->_gid = $values['custom_group_id'];
+ }
+ // get the group id
+ else {
+ $this->_gid = CRM_Utils_Request::retrieve('gid', 'Positive',
+ $this
+ );
+ }
+
if ($isReserved = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_CustomGroup', $this->_gid, 'is_reserved', 'id')) {
CRM_Core_Error::fatal("You cannot add or edit fields in a reserved custom field-set.");
}
// assign vars to templates
$this->assign('action', $action);
- $id = CRM_Utils_Request::retrieve('id', 'Positive',
- $this, FALSE, 0
- );
-
// what action to take ?
if ($action & (CRM_Core_Action::UPDATE | CRM_Core_Action::ADD)) {
// no browse for edit/update/view
border-left: none;
/* last action item should not have right hand border */}
+
+/* theming for panel and context menus */
+.crm-container td ul.panel li {
+ background-color: #2F2F2E;
+}
+
+.crm-container .panel li a {
+ color: #DFDFDF;
+}
+
+.crm-container .panel li a:hover,
+.crm-container .crm-participant-list-inner li a:hover,
+.crm-container .crm-event-links-list-inner li a:hover,
+.crm-container .crm-contribpage-links-list-inner li a:hover {
+ color: #3e3e3e;
+ background-color: #F5F6F1;
+ text-decoration: none;
+}
+
.crm-container .panel {
display: none;
z-index: 9999;
background: white url('../i/loading.gif') no-repeat right center;
}
-/* theming for panel and context menus */
-#crm-container td ul.panel li {
- background-color: #2F2F2E;
-}
-
-#crm-container .panel li a {
- color: #DFDFDF;
-}
-
-#crm-container .panel li a:hover,
-#crm-container .crm-participant-list-inner li a:hover,
-#crm-container .crm-event-links-list-inner li a:hover,
-#crm-container .crm-contribpage-links-list-inner li a:hover {
- color: #3e3e3e;
- background-color: #F5F6F1;
- text-decoration: none;
-}
-
/* Special styling for specific form buttons */
#crm-container span.crm-button_qf_Main_upload input,
#crm-container span.crm-button_qf_Confirm_next input,
box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3);
}
-.crm-designer .crm-designer-palette-add button {
+.crm-designer .crm-designer-palette-tree button {
font-size: .8em;
}
right: 5px;
top: 35px;
font-size: .8em;
+ border: 1px solid #CFCEC3;
}
button#crm-designer-add-custom-set {
}
.crm-designer-row-label {
- padding: 0.5em 0px;
+ padding: 0.5em 0;
}
.crm-designer-label {
}
.crm-designer-dialog .description {
- margin: 0px 2em 0px 0px;
+ margin: 0 2em 0 0;
}
.crm-designer-dialog .disabled .description {
}
target.toggleClass('crm-row-selected', $(this).is(':checked'));
});
- $('#crm-container').live('click', function (event) {
+ $('body').live('click', function (event) {
if ($(event.target).is('.btn-slide')) {
var currentActive = $('#crm-container .btn-slide-active');
currentActive.children().hide();
block: true,
crmForm: null
},
+ _originalUrl: null,
+ isOriginalUrl: function() {
+ var args = {}, same = true;
+ // Compare path
+ if (this.options.url.split('?')[0] !== this._originalUrl.split('?')[0]) {
+ return false;
+ }
+ // Compare arguments
+ $.each(this.options.url.split('?')[1].split('&'), function(k, v) {
+ var arg = v.split('=');
+ args[arg[0]] = arg[1];
+ });
+ $.each(this._originalUrl.split('?')[1].split('&'), function(k, v) {
+ var arg = v.split('=');
+ if (args[arg[0]] !== undefined && arg[1] !== args[arg[0]]) {
+ same = false;
+ }
+ });
+ return same;
+ },
+ resetUrl: function() {
+ this.options.url = this._originalUrl;
+ },
_create: function() {
this.element.addClass('crm-ajax-container');
if (!this.element.is('.crm-container *')) {
this.element.addClass('crm-container');
}
this.options.url ? this.refresh() : this.options.url = document.location.href;
+ this._originalUrl = this.options.url;
},
_onFailure: function(data) {
this.options.block && this.element.unblock();
var returnVal = settings.onCancel.call($el, event);
if (returnVal !== false) {
$el.trigger('crmFormCancel', event);
- $el.data('dialog') && settings.autoClose && $el.dialog('close');
+ if ($el.data('dialog') && settings.autoClose) {
+ $el.dialog('close');
+ }
+ else if (!settings.autoClose) {
+ $el.crmSnippet('resetUrl').crmSnippet('refresh');
+ }
}
return returnVal === false;
});
- settings.openInline && $(settings.openInline, this).click(function(event) {
- $el.crmSnippet('option', 'url', this.href).crmSnippet('refresh');
- return false;
- });
if (settings.validate) {
$("form", this).validate(typeof(settings.validate) == 'object' ? settings.validate : CRM.validate.params);
}
$("form", this).ajaxForm($.extend({
- url: data.url,
+ url: data.url.replace(/reset=1[&]?/, ''),
dataType: 'json',
success: function(response) {
if (response.status == 'success') {
$el.crmSnippet('option', 'block') && $el.unblock();
$el.trigger('crmFormSuccess', response);
// Reset form for e.g. "save and new"
- if (settings.refreshAction && $.inArray(response.buttonName, settings.refreshAction) >= 0) {
+ if (response.userContext && (!settings.autoClose ||
+ (settings.refreshAction && $.inArray(response.buttonName, settings.refreshAction) >= 0)))
+ {
$el.crmSnippet('option', 'url', response.userContext).crmSnippet('refresh');
}
else if ($el.data('dialog') && settings.autoClose) {
$el.trigger('crmFormSubmit', submission);
}
}, settings.ajaxForm));
+ if (settings.openInline) {
+ settings.autoClose = $el.crmSnippet('isOriginalUrl');
+ $(settings.openInline, this).click(function(event) {
+ $el.crmSnippet('option', 'url', $(this).attr('href')).crmSnippet('refresh');
+ return false;
+ });
+ }
});
return widget;
};
}
});
if (this.model.get('field_name').split('_')[0] == 'custom') {
- this.$('.crm-designer-field-summary > div').append('<button class="crm-designer-edit-custom">' + ts('Edit Custom Field') + '</button>');
- this.$('button.crm-designer-edit-custom').button();
+ this.$('.crm-designer-field-summary > div').append('<button class="crm-designer-edit-custom">» ' + ts('Edit Custom Field') + '</button>');
+ this.$('button.crm-designer-edit-custom').button().attr('title', ts('Edit global settings for this custom field.'));
}
}
},
doEditCustomField: function() {
- CRM.loadForm(CRM.url('civicrm/admin/custom/group/field/update', {
+ var url = CRM.url('civicrm/admin/custom/group/field/update', {
action: 'update',
reset: 1,
id: this.model.get('field_name').split('_')[1]
- })).on('crmFormLoad', function() {
+ });
+ var form1 = CRM.loadForm(url, {openInline: '.crm-custom-field-form-block-data_type a'})
+ .on('crmFormLoad', function() {
$(this).prepend('<div class="messages status"><div class="icon inform-icon"></div>' + ts('Note: This will modify the field system-wide, not just in this profile form.') + '</div>');
- });
+ var $link = $('.action-link a', this);
+ if ($link.length) {
+ $link.detach();
+ var buttons = {};
+ buttons[$link.text()] = function() {
+ var form2 = CRM.loadForm($link.attr('href'), {
+ cancelButton: '.cancel.form-submit, #done',
+ openInline: 'a.action-item:not(".enable-action, .disable-action")',
+ dialog: {
+ width: '60%',
+ height: parseInt($(window).height() * .8)
+ }
+ }).on('crmLoad', function() {
+ $('#done', this).removeAttr('onclick');
+ });
+ }
+ $(this).dialog('option', 'buttons', buttons);
+ }
+ })
return false;
},
onChangeIsDuplicate: function(model, value, options) {
{/strip}
<div class="action-link">
- <a href="{crmURL q="reset=1&action=add&fid=$fid&gid=$gid"}" class="button"><span><div class="icon add-icon"></div> {ts 1=$fieldTitle}Add Option for '%1'{/ts}</span></a>
+ <a href="{crmURL q="reset=1&action=add&fid=$fid&gid=$gid"}" class="button action-item"><span><div class="icon add-icon"></div> {ts 1=$fieldTitle}Add Option for '%1'{/ts}</span></a>
</div>
</div>
</div>
{if $action eq 16}
<div class="messages status no-popup">
<img src="{$config->resourceBase}i/Inform.gif" alt="{ts}status{/ts}"/>
- {capture assign=crmURL}{crmURL p='civicrm/admin/custom/group/field/option' q="action=add&fid=$fid&gid=$gid"}{/capture}{ts 1=$fieldTitle 2=$crmURL}There are no multiple choice options for the custom field '%1', <a href='%2'>add one</a>.{/ts}
+ {capture assign=crmURL}{crmURL p='civicrm/admin/custom/group/field/option' q="action=add&fid=$fid&gid=$gid"}{/capture}{ts 1=$fieldTitle 2=$crmURL}There are no multiple choice options for the custom field '%1', <a href='%2' class="action-item">add one</a>.{/ts}
</div>
{/if}
{/if}