From: Coleman Watts Date: Mon, 2 Dec 2013 22:17:52 +0000 (-0800) Subject: CRM-11864 CRM-10693 - Improve multistep forms and menus in popup context X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=fa3a5fe2f0e77fb5bf2a52bc5dd3b8a61be447fc;p=civicrm-core.git CRM-11864 CRM-10693 - Improve multistep forms and menus in popup context --- diff --git a/CRM/Custom/Form/Field.php b/CRM/Custom/Form/Field.php index e4e6a8e134..b573587d9f 100644 --- a/CRM/Custom/Form/Field.php +++ b/CRM/Custom/Form/Field.php @@ -276,6 +276,7 @@ class CRM_Custom_Form_Field extends CRM_Core_Form { 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 diff --git a/CRM/Custom/Page/Field.php b/CRM/Custom/Page/Field.php index cadb99ddce..06aa1cbc52 100644 --- a/CRM/Custom/Page/Field.php +++ b/CRM/Custom/Page/Field.php @@ -230,11 +230,22 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { */ 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."); } @@ -270,10 +281,6 @@ class CRM_Custom_Page_Field extends CRM_Core_Page { // 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 diff --git a/css/civicrm.css b/css/civicrm.css index 277cf5a81d..86a0a28ecf 100644 --- a/css/civicrm.css +++ b/css/civicrm.css @@ -1708,6 +1708,25 @@ editor specific classes 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; @@ -3372,24 +3391,6 @@ div.m ul#civicrm-menu, 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, diff --git a/css/crm.designer.css b/css/crm.designer.css index 3afec0358f..1b997689c7 100644 --- a/css/crm.designer.css +++ b/css/crm.designer.css @@ -149,7 +149,7 @@ 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; } @@ -163,6 +163,7 @@ right: 5px; top: 35px; font-size: .8em; + border: 1px solid #CFCEC3; } button#crm-designer-add-custom-set { @@ -191,7 +192,7 @@ button#crm-designer-add-custom-set { } .crm-designer-row-label { - padding: 0.5em 0px; + padding: 0.5em 0; } .crm-designer-label { @@ -204,7 +205,7 @@ button#crm-designer-add-custom-set { } .crm-designer-dialog .description { - margin: 0px 2em 0px 0px; + margin: 0 2em 0 0; } .crm-designer-dialog .disabled .description { diff --git a/js/Common.js b/js/Common.js index 0db84030dd..27aa8aab0f 100644 --- a/js/Common.js +++ b/js/Common.js @@ -521,7 +521,7 @@ CRM.validate = CRM.validate || { } 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(); @@ -826,12 +826,36 @@ CRM.validate = CRM.validate || { 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(); @@ -931,26 +955,29 @@ CRM.validate = CRM.validate || { 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) { @@ -966,6 +993,13 @@ CRM.validate = CRM.validate || { $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; }; diff --git a/js/view/crm.designer.js b/js/view/crm.designer.js index 1a1c372f60..9009f8074c 100644 --- a/js/view/crm.designer.js +++ b/js/view/crm.designer.js @@ -630,19 +630,39 @@ } }); if (this.model.get('field_name').split('_')[0] == 'custom') { - this.$('.crm-designer-field-summary > div').append(''); - this.$('button.crm-designer-edit-custom').button(); + this.$('.crm-designer-field-summary > div').append(''); + 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('
' + ts('Note: This will modify the field system-wide, not just in this profile form.') + '
'); - }); + 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) { diff --git a/templates/CRM/Custom/Page/Option.tpl b/templates/CRM/Custom/Page/Option.tpl index 57a09723fb..0626703a33 100644 --- a/templates/CRM/Custom/Page/Option.tpl +++ b/templates/CRM/Custom/Page/Option.tpl @@ -63,7 +63,7 @@ {/strip} @@ -72,7 +72,7 @@ {if $action eq 16}
{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', add one.{/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', add one.{/ts}
{/if} {/if}