Skip to content

Commit db882d9

Browse files
committed
fix forms break
1 parent 0028d05 commit db882d9

1 file changed

Lines changed: 75 additions & 75 deletions

File tree

src/widgets/forms.js

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -119,46 +119,40 @@ field[ns.ui('Form').uri] = field[ns.ui('Group').uri] =
119119
parts = kb.each(form, ui('part'), null, formDoc) // Warning: unordered
120120
subfields = sortBySequence(parts)
121121
}
122-
try {
123-
kb.updater.update(toDelete, toInsert, function (
124-
uri,
125-
success,
126-
errorBody
127-
) {
128-
isUpdating = false
129-
input.disabled = false
130-
if (!success) {
131-
if (toDelete.why) {
132-
const hmmm = kb.holds(
133-
toDelete.subject,
134-
toDelete.predicate,
135-
toDelete.object,
136-
toDelete.why
137-
)
138-
if (hmmm) {
139-
debug.log(' @@@@@ weird if 409 - does hold statement')
140-
}
141-
}
142-
colorCarrier.style.color = '#000'
143-
colorCarrier.style.backgroundColor = '#fee'
144-
box.appendChild(
145-
errorMessageBlock(
146-
dom,
147-
'Error writing data: ' + errorBody,
148-
'pink'
149-
)
150-
)
151-
return
122+
if (!parts) {
123+
return box.appendChild(errorMessageBlock(dom, 'No parts to form! '))
124+
}
152125

153-
input.state = input.newState
154-
resetButton()
155-
refresh()
156-
})
157-
} catch (error) {
158-
isUpdating = false
159-
input.disabled = false
160-
throw error
126+
for (let i = 0; i < subfields.length; i++) {
127+
const field = subfields[i]
128+
const subFieldFunction = fieldFunction(dom, field) //
129+
130+
const itemChanged = function (ok, body) {
131+
if (ok && body && body.widget && body.widget === 'select') {
132+
refreshOpionsSubfieldinGroup(dom, already, subject, dataDoc, callbackFunction, box, subfields)
133+
}
134+
callbackFunction(ok, { widget: 'group', change: body })
135+
}
136+
box.appendChild(subFieldFunction(dom, null, already2, subject, field, dataDoc, itemChanged))
161137
}
138+
return box
139+
}
140+
141+
/** Options field: Select one or more cases
142+
**
143+
** @param {Document} dom The HTML Document object aka Document Object Model
144+
** @param {Element?} container If present, the created widget will be appended to this
145+
** @param {Map} already A hash table of (form, subject) kept to prevent recursive forms looping
146+
** @param {Node} subject The thing about which the form displays/edits data
147+
** @param {Node} form The form or field to be rendered
148+
** @param {Node} dataDoc The web document in which the data is
149+
** @param {function(ok, errorMessage)} callbackFunction Called when data is changed?
150+
**
151+
** @returns {Element} The HTML widget created
152+
*/
153+
154+
field[ns.ui('Options').uri] = function (
155+
dom,
162156
container,
163157
already,
164158
subject,
@@ -1932,45 +1926,51 @@ export function buildCheckboxForm (dom, kb, lab, del, ins, form, dataDoc, trista
19321926
input.newState === true ? ins : input.newState === false ? del : []
19331927
debug.log(` Deleting ${toDelete}`)
19341928
debug.log(` Inserting ${toInsert}`)
1935-
kb.updater.update(toDelete, toInsert, function (
1936-
uri,
1937-
success,
1938-
errorBody
1939-
) {
1940-
isUpdating = false
1941-
input.disabled = false
1942-
if (!success) {
1943-
if (toDelete.why) {
1944-
const hmmm = kb.holds(
1945-
toDelete.subject,
1946-
toDelete.predicate,
1947-
toDelete.object,
1948-
toDelete.why
1949-
)
1950-
if (hmmm) {
1951-
debug.log(' @@@@@ weird if 409 - does hold statement')
1929+
try {
1930+
kb.updater.update(toDelete, toInsert, function (
1931+
uri,
1932+
success,
1933+
errorBody
1934+
) {
1935+
isUpdating = false
1936+
input.disabled = false
1937+
if (!success) {
1938+
if (toDelete.why) {
1939+
const hmmm = kb.holds(
1940+
toDelete.subject,
1941+
toDelete.predicate,
1942+
toDelete.object,
1943+
toDelete.why
1944+
)
1945+
if (hmmm) {
1946+
debug.log(' @@@@@ weird if 409 - does hold statement')
1947+
}
19521948
}
1953-
}
1954-
colorCarrier.style.color = '#000'
1955-
colorCarrier.style.backgroundColor = '#fee'
1956-
box.appendChild(
1957-
errorMessageBlock(
1958-
dom,
1959-
`Checkbox: Error updating dataDoc from ${input.state} to ${
1960-
input.newState
1961-
}:\n\n${errorBody}`
1949+
colorCarrier.style.color = '#000'
1950+
colorCarrier.style.backgroundColor = '#fee'
1951+
box.appendChild(
1952+
errorMessageBlock(
1953+
dom,
1954+
`Checkbox: Error updating dataDoc from ${input.state} to ${
1955+
input.newState
1956+
}:\n\n${errorBody}`
1957+
)
19621958
)
1963-
)
1964-
} else {
1965-
colorCarrier.style.color = '#000'
1966-
input.state = input.newState
1967-
input.textContent = {
1968-
true: checkMarkCharacter,
1969-
false: cancelCharacter,
1970-
null: dashCharacter
1971-
}[input.state] // @@
1972-
}
1973-
})
1959+
} else {
1960+
colorCarrier.style.color = '#000'
1961+
input.state = input.newState
1962+
input.textContent = {
1963+
true: checkMarkCharacter,
1964+
false: cancelCharacter,
1965+
null: dashCharacter
1966+
}[input.state] // @@
1967+
}
1968+
})
1969+
} catch (error) {
1970+
isUpdating = false
1971+
input.disabled = false
1972+
throw error
1973+
}
19741974
}
19751975
input.addEventListener('click', boxHandler, false)
19761976
return box

0 commit comments

Comments
 (0)