post an empty array to remove an array from settings

This commit is contained in:
Stephen Birarda 2014-10-09 09:47:53 -07:00
parent 188320a7b7
commit 90c73dc9e1
2 changed files with 11 additions and 2 deletions

View file

@ -102,8 +102,15 @@ $(document).ready(function(){
row.empty()
row.html("<input type='hidden' class='form-control' name='" + row.attr("name") + "' data-changed='true' value=''>");
} else {
// just remove this row completely - the removal of the hidden input will remove it from the array on post
row.remove()
if (table.children('tr.row-data').length) {
// this isn't the last row - we can just remove it
row.remove()
} else {
// this is the last row, we can't remove it completely since we need to post an empty array
row.empty()
row.html("<input type='hidden' class='form-control' name='" + table.attr("name").replace('[]', '')
+ "' data-changed='true' value=''>");
}
// we need to fire a change event on one of the remaining inputs so that the sidebar badge is updated
badgeSidebarForDifferences($(table))

View file

@ -295,6 +295,8 @@ void DomainServerSettingsManager::updateSetting(const QString& key, const QJsonV
void DomainServerSettingsManager::recurseJSONObjectAndOverwriteSettings(const QJsonObject& postedObject,
QVariantMap& settingsVariant,
const QJsonArray& descriptionArray) {
qDebug() << postedObject;
// Iterate on the setting groups
foreach(const QString& groupKey, postedObject.keys()) {
QJsonValue groupValue = postedObject[groupKey];