Skip to content

Commit e422c8f

Browse files
author
Tim Berners-Lee
committed
eslint tsc
1 parent 8e499cc commit e422c8f

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

src/widgets/error.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99

1010
export function errorMessageBlock (dom: HTMLDocument, err: string | Error, backgroundColor?: string): HTMLDivElement {
1111
const div = dom.createElement('div')
12-
if (err instanceof Error && err.stack) {
13-
console.error(`errorMessageBlock: Error ${err} at: ${err.stack}`, err) // @@ pick one
12+
if (err instanceof Error) {
13+
console.error(`errorMessageBlock: Error ${err} at: ${err.stack || '??'}`, err) // @@ pick one
14+
div.textContent = err.message
15+
} else {
16+
div.textContent = err
1417
}
1518
div.setAttribute(
1619
'style',
1720
'margin: 0.1em; padding: 0.5em; border: 0.05em solid gray; background-color: ' +
1821
(backgroundColor || '#fee') +
1922
'; color:black;'
2023
)
21-
div.textContent = err
2224
return div
2325
}

src/widgets/forms/autocomplete/autocompleteField.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ export function autocompleteField (
4242
callbackFunction: (_ok: boolean, _errorMessage: string) => void
4343
): HTMLElement {
4444
async function addOneIdAndRefresh (result, name) {
45-
const originals = kb.each(subject, property as any, null, doc)
46-
const deletables = []
47-
originals.forEach(x => { // Clean up multiple if there were any
48-
deletables.concat(kb.statementsMatching(subject, property as any, x, doc)) // @@ concat does right
49-
deletables.concat(kb.statementsMatching(x, labelProperty as any, null, doc))
50-
})
45+
const oldValue = kb.the(subject, property as any, null, doc)
46+
const deletables = oldValue
47+
? kb.statementsMatching(subject, property as any, oldValue, doc)
48+
.concat(kb.statementsMatching(oldValue as any, labelProperty as any, null, doc))
49+
: []
50+
5151
const insertables = [st(subject, property as any, result, doc),
5252
st(result, labelProperty as any, name, doc)] // @@ track the language of the name too!
5353
try {

src/widgets/forms/autocomplete/autocompletePicker.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export type AutocompleteDecoration = {
4242
editButton?: HTMLElement
4343
}
4444
export type AutocompleteOptions = {
45-
targetClass: NamedNode,
45+
targetClass?: NamedNode,
4646
currentObject?: NamedNode,
4747
currentName?: string,
4848
queryParams: QueryParameters
@@ -193,7 +193,7 @@ export async function renderAutoComplete (dom: HTMLDocument,
193193
}
194194
let bindings
195195
try {
196-
bindings = await queryPublicDataByName(filter, OrgClass, languagePrefs, options.queryParams)
196+
bindings = await queryPublicDataByName(filter, targetClass as any, languagePrefs, options.queryParams) // @@ any
197197
// bindings = await queryDbpedia(sparql)
198198
} catch (err) {
199199
complain('Error querying db of organizations: ' + err)
@@ -237,7 +237,8 @@ export async function renderAutoComplete (dom: HTMLDocument,
237237
} // refreshList
238238

239239
// const queryParams: QueryParameters = options.queryParams
240-
const OrgClass = options.targetClass // kb.sym('http://umbel.org/umbel/rc/EducationalOrganization') // @@@ other
240+
const targetClass = options.targetClass
241+
if (!targetClass) throw new Error('need class')
241242
if (decoration.acceptButton) {
242243
decoration.acceptButton.addEventListener('click', acceptButtonHandler, false)
243244
}

0 commit comments

Comments
 (0)