Skip to content

Commit cc4ae9a

Browse files
author
Danish, Joshua Adam
committed
Display help text inline when in edit more on attributes. TODO: need to un-center the text on edges.
1 parent 83b1785 commit cc4ae9a

File tree

1 file changed

+43
-33
lines changed

1 file changed

+43
-33
lines changed

app/view/netcreate/nc-ui.js

Lines changed: 43 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -122,9 +122,10 @@ function RenderAttributesTabEdit(state, defs, onchange) {
122122
items.push(RenderLabel(k, defs[k].displayLabel));
123123
const type = defs[k].type;
124124
const value = attributes[k] || ''; // catch `undefined` or React will complain about changing from uncontrolled to controlled
125+
const helpText = defs[k].help;
125126
switch (type) {
126127
case 'string':
127-
items.push(RenderStringInput(k, value, onchange));
128+
items.push(RenderStringInput(k, value, onchange, helpText));
128129
break;
129130
case 'number':
130131
items.push(m_RenderNumberInput(k, value, onchange));
@@ -207,19 +208,22 @@ function RenderStringValue(key, value) {
207208
* @param {function} cb
208209
* @returns
209210
*/
210-
function RenderStringInput(key, value, cb) {
211+
function RenderStringInput(key, value, cb, helpText) {
211212
const rows = String(value).length > 35 ? 3 : 1;
212213
return (
213-
<textarea
214-
id={key}
215-
key={`${key}input`}
216-
type="string"
217-
value={value}
218-
onChange={event => m_UIStringInputUpdate(event, cb)}
219-
autoComplete="off" // turn off Chrome's default autocomplete, which conflicts
220-
className={rows > 1 ? `long` : ''}
221-
rows={rows}
222-
/>
214+
<div key={`${key}div`}>
215+
{helpText}
216+
<textarea
217+
id={key}
218+
key={`${key}input`}
219+
type="string"
220+
value={value}
221+
onChange={event => m_UIStringInputUpdate(event, cb)}
222+
autoComplete="off" // turn off Chrome's default autocomplete, which conflicts
223+
className={rows > 1 ? `long` : ''}
224+
rows={rows}
225+
/>
226+
</div>
223227
);
224228
}
225229
/**
@@ -231,15 +235,18 @@ function RenderStringInput(key, value, cb) {
231235
* @param {function} cb
232236
* @returns
233237
*/
234-
function m_RenderNumberInput(key, value, cb) {
238+
function m_RenderNumberInput(key, value, cb, helpText) {
235239
return (
236-
<input
237-
id={key}
238-
key={`${key}input`}
239-
value={value}
240-
type="number"
241-
onChange={event => m_UINumberInputUpdate(event, cb)}
242-
/>
240+
<div key={`${key}div`}>
241+
{helpText}
242+
<input
243+
id={key}
244+
key={`${key}input`}
245+
value={value}
246+
type="number"
247+
onChange={event => m_UINumberInputUpdate(event, cb)}
248+
/>
249+
</div>
243250
);
244251
}
245252
/**
@@ -251,21 +258,24 @@ function m_RenderNumberInput(key, value, cb) {
251258
* @param {function} cb
252259
* @returns
253260
*/
254-
function m_RenderOptionsInput(key, value, defs, cb) {
261+
function m_RenderOptionsInput(key, value, defs, cb, helpText) {
255262
const options = defs[key].options;
256263
return (
257-
<select
258-
id={key}
259-
key={`${key}select`}
260-
value={value}
261-
onChange={event => m_UISelectInputUpdate(event, cb)}
262-
>
263-
{options.map(o => (
264-
<option key={o.label} value={o.label}>
265-
{o.label}
266-
</option>
267-
))}
268-
</select>
264+
<div key={`${key}div`}>
265+
{helpText}
266+
<select
267+
id={key}
268+
key={`${key}select`}
269+
value={value}
270+
onChange={event => m_UISelectInputUpdate(event, cb)}
271+
>
272+
{options.map(o => (
273+
<option key={o.label} value={o.label}>
274+
{o.label}
275+
</option>
276+
))}
277+
</select>
278+
</div>
269279
);
270280
}
271281

0 commit comments

Comments
 (0)