Skip to content

Commit

Permalink
Move formFields klass from an argument to a state variable
Browse files Browse the repository at this point in the history
(maybe needed in case render can get called different ways)
  • Loading branch information
bhousel committed Jan 11, 2019
1 parent 6c9a57f commit b575ee8
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 15 deletions.
32 changes: 19 additions & 13 deletions modules/ui/form_fields.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ import { utilGetSetValue, utilNoAuto } from '../util';

export function uiFormFields(context) {
var moreCombo = uiCombobox(context, 'more-fields').minItems(1);
var _selection = d3_select(null);
var _fieldsArr = [];
var _state = '';
var _fieldsArr;
var _klass = '';


function formFields(selection, klass) {
render(selection, klass);
function formFields(selection) {
_selection = selection
.call(render);
}

formFields.tagsChanged = function() {
_selection
.call(render);
};

formFields.tagsChanged = function() {};

function render(selection, klass) {

formFields.tagsChanged = function() {
render(selection, klass);
};

function render(selection) {
var allowedFields = _fieldsArr.filter(function(field) { return field.isAllowed(); });

var shown = allowedFields.filter(function(field) { return field.isShown(); });
var notShown = allowedFields.filter(function(field) { return !field.isShown(); });

Expand All @@ -34,7 +34,7 @@ export function uiFormFields(context) {

container = container.enter()
.append('div')
.attr('class', 'form-fields-container ' + (klass || ''))
.attr('class', 'form-fields-container ' + (_klass || ''))
.merge(container);


Expand Down Expand Up @@ -122,7 +122,7 @@ export function uiFormFields(context) {

formFields.fieldsArr = function(val) {
if (!arguments.length) return _fieldsArr;
_fieldsArr = val;
_fieldsArr = val || [];
return formFields;
};

Expand All @@ -132,6 +132,12 @@ export function uiFormFields(context) {
return formFields;
};

formFields.klass = function(val) {
if (!arguments.length) return _klass;
_klass = val;
return formFields;
};


return formFields;
}
5 changes: 3 additions & 2 deletions modules/ui/preset_editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,9 @@ export function uiPresetEditor(context) {
selection
.call(formFields
.fieldsArr(_fieldsArr)
.state(_state),
'inspector-inner fillL3');
.state(_state)
.klass('inspector-inner fillL3')
);


selection.selectAll('.wrap-form-field input')
Expand Down

0 comments on commit b575ee8

Please sign in to comment.