Skip to content

Commit 7b95a13

Browse files
committed
try catch widgets forms
1 parent 210456b commit 7b95a13

1 file changed

Lines changed: 38 additions & 32 deletions

File tree

src/widgets/forms.js

Lines changed: 38 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -119,40 +119,46 @@ 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-
if (!parts) {
123-
return box.appendChild(errorMessageBlock(dom, 'No parts to form! '))
124-
}
125-
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))
137-
}
138-
return box
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+
}
139141
}
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
140152

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,
153+
input.state = input.newState
154+
resetButton()
155+
refresh()
156+
})
157+
} catch (error) {
158+
isUpdating = false
159+
input.disabled = false
160+
throw error
161+
}
156162
container,
157163
already,
158164
subject,

0 commit comments

Comments
 (0)