diff --git a/model.js b/model.js index 453fa110..b2cbb8f7 100644 --- a/model.js +++ b/model.js @@ -411,3 +411,15 @@ function parseJSONValue(value) { } return value; } + +function collapseComponent(el) { + let path = getPath(el); + let field = path.pop(); + let node = getNode(path); + if (node[field]._collapse) { + delete node[field]._collapse + } else { + node[field]._collapse = true; + } + invalidated(); +} diff --git a/schemas/1.14.json b/schemas/1.14.json index 6c05a73b..b35b1e23 100644 --- a/schemas/1.14.json +++ b/schemas/1.14.json @@ -404,35 +404,47 @@ ] }, { - "id": "parameters.bonusMultiplier", - "type": "float", - "translate": "$function.bonusMultiplier", + "id": "parameters", + "type": "object", + "translate": "$function.parameters", + "color": "secondary", + "card": false, "require": [ { "function": "minecraft:apply_bonus", "formula": "minecraft:uniform_bonus_count" } + ], + "fields": [ + { + "id": "bonusMultiplier", + "type": "float", + "translate": "$function.bonusMultiplier" + } ] }, { - "id": "parameters.extra", - "type": "int", - "translate": "$function.extra", + "id": "parameters", + "type": "object", + "translate": "$function.parameters", + "color": "secondary", + "card": false, "require": [ { "function": "minecraft:apply_bonus", "formula": "minecraft:binomial_with_bonus_count" } - ] - }, - { - "id": "parameters.probability", - "type": "float", - "translate": "$function.probability", - "require": [ + ], + "fields": [ { - "function": "minecraft:apply_bonus", - "formula": "minecraft:binomial_with_bonus_count" + "id": "extra", + "type": "int", + "translate": "$function.extra" + }, + { + "id": "probability", + "type": "float", + "translate": "$function.probability" } ] }, diff --git a/view.js b/view.js index 3b539309..7062ab23 100644 --- a/view.js +++ b/view.js @@ -28,37 +28,41 @@ function changeVersion(version) { function updateView() { if (structure) { - generateTable(); + let {out: tableOut, component: $table} = generateTable(table, structure); + $('#structure').append($table); if (i18next.isInitialized) { $('html').localize(); } + $('#source').val(JSON.stringify(tableOut, null, indentation)); } - $('#source').val(JSON.stringify(table, null, indentation)); } -function generateTable() { +function generateTable(data, struct) { + let out = {}; + let $el = $('
'); $('#structure').removeClass('d-none').html(''); - let type = structure.fields.find(e => e.id === 'type'); + let type = struct.fields.find(e => e.id === 'type'); if (type) { $('.table-type').removeClass('d-none'); $('#tableType').html(''); for (let option of type.values) { $('#tableType').append(setValueAndName($('