mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: allow nested properties on category page (#9601)
* feat: allow nested properties on category page * fix: remove debug * fix: remove debug
This commit is contained in:
committed by
GitHub
parent
8f00abc838
commit
cc0cf99fed
@@ -235,8 +235,27 @@ define('admin/manage/category', [
|
|||||||
} else {
|
} else {
|
||||||
value = $(el).val();
|
value = $(el).val();
|
||||||
}
|
}
|
||||||
|
var dataName = $(el).attr('data-name');
|
||||||
|
var fields = dataName.match(/[^\][.]+/g);
|
||||||
|
|
||||||
updateHash[$(el).attr('data-name')] = value;
|
function setNestedFields(obj, index) {
|
||||||
|
if (index === fields.length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
obj[fields[index]] = obj[fields[index]] || {};
|
||||||
|
if (index === fields.length - 1) {
|
||||||
|
obj[fields[index]] = value;
|
||||||
|
}
|
||||||
|
setNestedFields(obj[fields[index]], index + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fields && fields.length) {
|
||||||
|
if (fields.length === 1) { // simple field name ie data-name="name"
|
||||||
|
updateHash[fields[0]] = value;
|
||||||
|
} else if (fields.length > 1) { // nested field name ie data-name="name[sub1][sub2]"
|
||||||
|
setNestedFields(updateHash, 0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
app.flags = app.flags || {};
|
app.flags = app.flags || {};
|
||||||
app.flags._unsaved = true;
|
app.flags._unsaved = true;
|
||||||
|
|||||||
@@ -39,6 +39,7 @@
|
|||||||
<input type="color" id="cid-{category.cid}-color" placeholder="#ffffff" data-name="color" value="{category.color}" class="form-control category_color" />
|
<input type="color" id="cid-{category.cid}-color" placeholder="#ffffff" data-name="color" value="{category.color}" class="form-control category_color" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-sm-4 col-xs-12">
|
<div class="col-sm-4 col-xs-12">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="cid-{category.cid}-imageClass">
|
<label for="cid-{category.cid}-imageClass">
|
||||||
|
|||||||
Reference in New Issue
Block a user