From e871d6ebd13d3861b3a73f0bb7dbb3e987df946f Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Sun, 17 Nov 2013 21:13:32 -0800 Subject: [PATCH] CRM-13783 - ProfileBuilder - Maintain jstree state during refresh, other tweaks --- css/crm.designer.css | 10 ++++++- js/view/crm.designer.js | 59 +++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 24 deletions(-) diff --git a/css/crm.designer.css b/css/crm.designer.css index 1fdb3f06e1..894f0135bd 100644 --- a/css/crm.designer.css +++ b/css/crm.designer.css @@ -36,7 +36,7 @@ height: 20em; } -.crm-designer-palette-tree > ul > li > a { +.crm-designer-palette-section > a { font-weight: bold; } @@ -145,6 +145,14 @@ box-shadow: 1px 1px 2px rgba(0, 0, 0, 0.3); } +.crm-designer .crm-designer-palette-add button { + font-size: .8em; +} + +.crm-designer .crm-designer-palette-add span.ui-button-text { + padding: 0.4em; +} + .ui-sortable-helper > .crm-designer-row { box-shadow: 2px 2px 5px rgba(0, 0, 0, 0.2); opacity: 0.75; diff --git a/js/view/crm.designer.js b/js/view/crm.designer.js index 6c33665f97..51e1ec739b 100644 --- a/js/view/crm.designer.js +++ b/js/view/crm.designer.js @@ -290,10 +290,13 @@ serializeData: extendedSerializeData, template: '#palette_template', el: '
', + openTreeNodes: [], events: { 'keyup .crm-designer-palette-search input': 'doSearch', 'click .crm-designer-palette-clear-search': 'clearSearch', - 'click .crm-designer-palette-toggle': 'toggleAll' + 'click .crm-designer-palette-toggle': 'toggleAll', + 'click .crm-designer-palette-add button': 'doNewCustomFieldDialog', + 'dblclick .crm-designer-palette-field': 'doAddToCanvas' }, initialize: function() { this.model.getRel('ufFieldCollection') @@ -328,10 +331,19 @@ }); } if (section.is_addable) { - items.push({data: 'placeholder', attr: {'class': 'crm-designer-palette-add', 'data-entity': ufEntityModel.get('entity_name'), 'data-section': sectionKey}}); + items.push({data: ts('+ Add New Field'), attr: {'class': 'crm-designer-palette-add'}}); } if (items.length > 0) { - treeData.push({data: section.title, children: items}); + treeData.push({ + data: section.title, + children: items, + state: _.contains(paletteView.openTreeNodes, sectionKey) ? 'open' : 'closed', + attr: { + 'class': 'crm-designer-palette-section', + 'data-section': sectionKey, + 'data-entity': ufEntityModel.get('entity_name') + } + }); } }) }); @@ -356,26 +368,11 @@ helper: 'clone', connectToSortable: '.crm-designer-fields' // FIXME: tight canvas/palette coupling }); - $('.crm-designer-palette-field', this).dblclick(function(event){ - var paletteFieldModel = paletteView.model.getRel('paletteFieldCollection').get($(event.currentTarget).attr('data-plm-cid')); - paletteFieldModel.addToUFCollection(paletteView.model.getRel('ufFieldCollection')); - event.stopPropagation(); - }); paletteView.model.getRel('ufFieldCollection').each(function(ufFieldModel) { paletteView.toggleActive(ufFieldModel, paletteView.model.getRel('ufFieldCollection')) }); - paletteView.$('.crm-designer-palette-add a').remove(); - paletteView.$('.crm-designer-palette-add').append(''); - paletteView.$('.crm-designer-palette-add button').button() - .click(function(event){ - var entityKey = $(event.currentTarget).closest('.crm-designer-palette-add').attr('data-entity'); - var sectionKey = $(event.currentTarget).closest('.crm-designer-palette-add').attr('data-section'); - var ufEntityModel = paletteView.model.getRel('ufEntityCollection').getByName(entityKey); - var sections = ufEntityModel.getSections(); - paletteView.doAddField(sections[sectionKey]); - event.stopPropagation(); - }) - ; + paletteView.$('.crm-designer-palette-add a').replaceWith('