mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 00:16:51 +00:00
Revert reset button for map types
This commit is contained in:
@@ -199,12 +199,9 @@ const renderHtml: RenderHook = {
|
||||
return [null, suffix, body]
|
||||
},
|
||||
|
||||
map({ children, keys, config, node }, path, value, lang, version, states, ctx) {
|
||||
map({ children, keys, config }, path, value, lang, version, states, ctx) {
|
||||
const { expand, collapse, isToggled } = useToggles()
|
||||
|
||||
let suffix: JSX.Element | null = null
|
||||
let body: JSX.Element | null = null
|
||||
|
||||
const keyPath = new ModelPath(keysModel, new Path([hashString(path.toString())], path.contextArr))
|
||||
const onAdd = () => {
|
||||
const key = keyPath.get()
|
||||
@@ -230,14 +227,12 @@ const renderHtml: RenderHook = {
|
||||
})
|
||||
return ObjectNode(Object.fromEntries(properties)).hook(this, path, value, lang, version, states, ctx)
|
||||
}
|
||||
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
suffix = <>
|
||||
{suffix}
|
||||
{keysSchema.hook(this, keyPath, keyPath.get() ?? '', lang, version, states, ctx)[1]}
|
||||
<button class="add tooltipped tip-se" aria-label={localize(lang, 'add')} onClick={onAdd}>{Octicon.plus_circle}</button>
|
||||
</>
|
||||
body = <>{Object.entries(value).map(([key, cValue]) => {
|
||||
const suffix = <>
|
||||
{keysSchema.hook(this, keyPath, keyPath.get() ?? '', lang, version, states, ctx)[1]}
|
||||
<button class="add tooltipped tip-se" aria-label={localize(lang, 'add')} onClick={onAdd}>{Octicon.plus_circle}</button>
|
||||
</>
|
||||
const body = <>
|
||||
{typeof value === 'object' && Object.entries(value).map(([key, cValue]) => {
|
||||
const pathWithContext = (config?.context) ? new ModelPath(path.getModel(), new Path(path.getArray(), [config.context])) : path
|
||||
const cPath = pathWithContext.modelPush(key)
|
||||
const canToggle = children.type(cPath) === 'object'
|
||||
@@ -262,11 +257,8 @@ const renderHtml: RenderHook = {
|
||||
{canToggle && <button class="toggle tooltipped tip-se" aria-label={`${localize(lang, 'collapse')}\n${localize(lang, 'collapse_all', 'Ctrl')}`} onClick={collapse(key)}>{Octicon.chevron_down}</button>}
|
||||
<button class="remove tooltipped tip-se" aria-label={localize(lang, 'remove')} onClick={onRemove}>{Octicon.trashcan}</button>
|
||||
</MemoedTreeNode>
|
||||
})}</>
|
||||
} else {
|
||||
const onReset = () => path.set(DataModel.wrapLists(node.default()))
|
||||
suffix = <>{suffix}<button class="add tooltipped tip-se" aria-label={localize(lang, 'reset')} onClick={onReset}>{Octicon.history}</button></>
|
||||
}
|
||||
})}
|
||||
</>
|
||||
return [null, suffix, body]
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user