-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Bugfix: ensure there are field for clearFields action and update demo #245
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -355,30 +355,6 @@ | |
$field.html(typeLabel).appendTo($cbUL); | ||
} | ||
|
||
let viewDataText = opts.dataType === 'xml' ? opts.messages.viewXML : opts.messages.viewJSON; | ||
|
||
if (opts.showActionButtons) { | ||
// Build our headers and action links | ||
var viewData = utils.markup('button', viewDataText, { | ||
id: frmbID + '-view-data', | ||
type: 'button', | ||
className: 'view-data btn btn-default' | ||
}), | ||
clearAll = utils.markup('button', opts.messages.clearAll, { | ||
id: frmbID + '-clear-all', | ||
type: 'button', | ||
className: 'clear-all btn btn-default' | ||
}), | ||
saveAll = utils.markup('button', opts.messages.save, { | ||
className: `btn btn-primary ${opts.prefix}save`, | ||
id: frmbID + '-save', | ||
type: 'button' | ||
}), | ||
formActions = utils.markup('div', [clearAll, viewData, saveAll], { | ||
className: 'form-actions btn-group' | ||
}); | ||
} | ||
|
||
// Sortable fields | ||
$sortableFields.sortable({ | ||
cursor: 'move', | ||
|
@@ -432,7 +408,32 @@ | |
var cbWrap = $('<div/>', { | ||
id: frmbID + '-cb-wrap', | ||
'class': 'cb-wrap ' + formBuilder.layout.controls | ||
}).append($cbUL[0], formActions); | ||
}).append($cbUL[0]); | ||
|
||
if (opts.showActionButtons) { | ||
// Build our headers and action links | ||
let viewDataText = opts.dataType === 'xml' ? opts.messages.viewXML : opts.messages.viewJSON, | ||
viewData = utils.markup('button', viewDataText, { | ||
id: frmbID + '-view-data', | ||
type: 'button', | ||
className: 'view-data btn btn-default' | ||
}), | ||
clearAll = utils.markup('button', opts.messages.clearAll, { | ||
id: frmbID + '-clear-all', | ||
type: 'button', | ||
className: 'clear-all btn btn-default' | ||
}), | ||
saveAll = utils.markup('button', opts.messages.save, { | ||
className: `btn btn-primary ${opts.prefix}save`, | ||
id: frmbID + '-save', | ||
type: 'button' | ||
}), | ||
formActions = utils.markup('div', [clearAll, viewData, saveAll], { | ||
className: 'form-actions btn-group' | ||
}); | ||
|
||
cbWrap.append(formActions); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This ensures |
||
} | ||
|
||
$stageWrap.append($sortableFields, cbWrap); | ||
$stageWrap.before($formWrap); | ||
|
@@ -1209,7 +1210,7 @@ | |
}); | ||
|
||
|
||
if(opts.showActionButtons) { | ||
if (opts.showActionButtons) { | ||
// View XML | ||
var xmlButton = $(document.getElementById(frmbID + '-view-data')); | ||
xmlButton.click(function(e) { | ||
|
@@ -1259,7 +1260,7 @@ | |
|
||
document.dispatchEvent(formBuilder.events.loaded); | ||
|
||
// Make some actions accessible | ||
// Make actions accessible | ||
formBuilder.actions = { | ||
clearFields: _helpers.removeAllfields, | ||
showData: _helpers.showData, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -791,6 +791,10 @@ function formBuilderHelpersFn(opts, formBuilder) { | |
var $fields = $(fields); | ||
var markEmptyArray = []; | ||
|
||
if (!fields.length) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. dump out of the function if there are no fields to clear |
||
return false; | ||
} | ||
|
||
if (opts.prepend) { | ||
markEmptyArray.push(true); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
give developers quick view of available actions, data etc