From 326af9453aef093804e6ced86259d01bd326a48a Mon Sep 17 00:00:00 2001 From: Misode Date: Sat, 28 Dec 2019 14:14:35 +0100 Subject: [PATCH] Add help tooltip for display object --- locales/en.json | 1 + schemas/1.15.json | 1 + view.js | 11 ++++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/locales/en.json b/locales/en.json index 373abb92..2bd7b637 100644 --- a/locales/en.json +++ b/locales/en.json @@ -244,6 +244,7 @@ "gamemode.spectator": "Spectator", "gamemode.survival": "Survival", "help.condition.time_period": "If present, time will be modulo-divided by this value. For example, if set to 24000, value will operate on a time period of days.", + "help.display": "If present, advancement will be visible in the advancement tabs.", "help.entry.expand": "If false, entry will return all contents of tag, otherwise entry will behave as multiple item entries", "help.entry.type.alternatives": "Tests conditions of the child entries and executes the first that can run", "help.entry.type.dynamic": "Gets block specific drops", diff --git a/schemas/1.15.json b/schemas/1.15.json index 75351eee..f983255d 100644 --- a/schemas/1.15.json +++ b/schemas/1.15.json @@ -47,6 +47,7 @@ "translate": "display", "type": "object", "collapse": true, + "help": true, "color": "dark", "fields": [ { diff --git a/view.js b/view.js index 67a0bef8..fe92ecfc 100644 --- a/view.js +++ b/view.js @@ -70,7 +70,9 @@ function generateSourceAndView(data, struct) { $('#structure').attr('data-index', 'pools'); return generateTable(data, struct); } else { - return generateObject(data, struct, false); + let {out: sourceOut, component: $component} = generateObject(data, struct, false); + $component.removeClass('mt-3'); + return {out: sourceOut, component: $component}; } } @@ -406,9 +408,12 @@ function generateObject(data, struct, header) { } for (let field of struct.fields) { if (field.collapse) { - let hasNoValue = data[field.id] === undefined + let hasNoValue = data[field.id] === undefined; let arrowDirection = hasNoValue ? 'dropright' : 'dropdown' - $body.append(''); + $body.append(''); + if (field.help) { + $body.find('span').append(generateTooltip(field.translate)); + } if (hasNoValue) { $body.append('
'); continue;