diff --git a/src/tabs.ts b/src/tabs.ts index 184614d8..7953300a 100644 --- a/src/tabs.ts +++ b/src/tabs.ts @@ -178,7 +178,7 @@ export function tabWidget (options: TabWidgetOptions) { const onClose = options.onClose const [selectedColor, color] = getColors(backgroundColor) - const bodyMainStyle = `flex: 2; width: auto; height: 100%; border: 0.1em; border-style: solid; border-color: ${selectedColor}; padding: 1em;` + const bodyMainStyle = `display: grid; width: auto; height: 100%; border: 0.1em; border-style: solid; border-color: ${selectedColor}; padding: 1em;` const rootElement: TabWidgetElement = dom.createElement('div') // 20200117a rootElement.setAttribute('style', style.tabsRootElement) diff --git a/src/widgets/forms.js b/src/widgets/forms.js index 4c69ecd0..0cfd3994 100644 --- a/src/widgets/forms.js +++ b/src/widgets/forms.js @@ -712,7 +712,19 @@ field[ns.ui('Classifier').uri] = function ( if (!ok) return callbackFunction(ok, body) return callbackFunction(ok, body) } - const box = makeSelectForNestedCategory( + // Create container for label and select + const outerBox = dom.createElement('div') + outerBox.setAttribute('class', 'classifierBox') + // Render label + const labelDiv = dom.createElement('div') + labelDiv.setAttribute('class', 'formFieldName classifierBox-label') + // Use fieldLabel to render ui:label if present + labelDiv.appendChild(fieldLabel(dom, category, form)) + outerBox.appendChild(labelDiv) + // Render select + const selectBox = dom.createElement('div') + selectBox.setAttribute('class', 'formFieldValue classifierBox-selectBox') + const selectElement = makeSelectForNestedCategory( dom, kb, subject, @@ -720,8 +732,18 @@ field[ns.ui('Classifier').uri] = function ( dataDoc, checkOptions ) - if (container) container.appendChild(box) - return box + // Set readonly if not editable + if (selectElement && selectElement.querySelector && selectElement.querySelector('select')) { + const select = selectElement.querySelector('select'); + if (select && !kb.updater.editable(dataDoc.uri)) { + select.readOnly = true; + select.style = style.textInputStyleUneditable; + } + } + selectBox.appendChild(selectElement) + outerBox.appendChild(selectBox) + if (container) container.appendChild(outerBox) + return outerBox } /** Choice field diff --git a/test/unit/__snapshots__/tabs.test.ts.snap b/test/unit/__snapshots__/tabs.test.ts.snap index f3778241..7db32e8d 100644 --- a/test/unit/__snapshots__/tabs.test.ts.snap +++ b/test/unit/__snapshots__/tabs.test.ts.snap @@ -8,7 +8,7 @@ exports[`tabWidget minimal setup of options renders content for first tab 1`] = style="height: 100%; width: 100%;" >