contacts-pane 2.4.8 → 2.4.12-beta4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +3 -1
- package/.github/workflows/ci.yml +74 -0
- package/.nvmrc +1 -1
- package/LICENSE.md +0 -0
- package/Makefile +0 -0
- package/README.md +0 -0
- package/__tests__/unit/data-reformat-test.js +166 -0
- package/__tests__/unit/data-reformat-test.ts +185 -0
- package/__tests__/unit/setup.js +74 -0
- package/__tests__/unit/setup.ts +77 -0
- package/babel.config.js +13 -0
- package/card.ai +0 -0
- package/card.png +0 -0
- package/contactLogic.js +84 -7
- package/contactsPane.js +64 -20
- package/diff.txt +0 -0
- package/exampleOfOpenData/mit-wikidata-details.ttl +0 -0
- package/exampleOfOpenData/mit-wikidata-query.sparql +0 -0
- package/exampleOfOpenData/wikidata-get.json +0 -0
- package/groupMembershipControl.js +56 -13
- package/individual.js +3 -2
- package/individualForm.js +0 -0
- package/jest.config.js +11 -0
- package/jest.setup.ts +10 -0
- package/lib/autocompleteBar.js +99 -0
- package/lib/autocompleteBar.js.map +1 -0
- package/lib/autocompleteField.js +157 -0
- package/lib/autocompleteField.js.map +1 -0
- package/lib/autocompletePicker.js +240 -0
- package/lib/autocompletePicker.js.map +1 -0
- package/lib/forms.js +315 -0
- package/lib/instituteDetailsQuery.js +38 -0
- package/lib/publicData.js +387 -0
- package/lib/publicData.js.map +1 -0
- package/lib/vcard.js +916 -0
- package/mintNewAddressBook.js +5 -4
- package/mugshotGallery.js +16 -4
- package/organizationForm.js +0 -0
- package/organizationForm.ttl +0 -0
- package/package.json +26 -13
- package/shapes/contacts-shapes.ttl +0 -0
- package/src/autocompleteBar.ts +92 -0
- package/src/autocompleteField.ts +180 -0
- package/src/autocompletePicker.ts +253 -0
- package/src/forms.ttl +1 -1
- package/src/instituteDetailsQuery.sparql +0 -0
- package/src/publicData.ts +385 -0
- package/src/vcard.ttl +0 -0
- package/toolsPane.js +70 -19
- package/tsconfig.json +16 -0
- package/webidControl.js +49 -4
package/webidControl.js
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
// Render a control to record the webids we have for this agent
|
|
2
2
|
/* eslint-disable multiline-ternary */
|
|
3
3
|
import * as UI from 'solid-ui'
|
|
4
|
+
import { store } from 'solid-logic'
|
|
5
|
+
import { updateMany } from './contactLogic'
|
|
6
|
+
// import { renderAutoComplete } from './lib/autocompletePicker' // dbpediaParameters
|
|
7
|
+
import { renderAutocompleteControl } from './lib/autocompleteBar'
|
|
8
|
+
// import { wikidataParameters, loadPublicDataThing, wikidataClasses } from './lib/publicData' // dbpediaParameters
|
|
4
9
|
|
|
5
10
|
const $rdf = UI.rdf
|
|
6
11
|
const ns = UI.ns
|
|
7
12
|
const widgets = UI.widgets
|
|
8
13
|
const utils = UI.utils
|
|
9
|
-
const kb =
|
|
14
|
+
const kb = store
|
|
10
15
|
const style = UI.style
|
|
11
16
|
|
|
12
17
|
const wikidataClasses = widgets.publicData.wikidataClasses // @@ move to solid-logic
|
|
@@ -30,6 +35,15 @@ export async function addWebIDToContacts (person, webid, urlType, kb) {
|
|
|
30
35
|
}
|
|
31
36
|
}
|
|
32
37
|
*/
|
|
38
|
+
|
|
39
|
+
// check this is a url
|
|
40
|
+
try {
|
|
41
|
+
const _url = new URL(webid)
|
|
42
|
+
} catch (error) {
|
|
43
|
+
throw new Error(`${WEBID_NOUN}: ${webid} is not a valid url.`)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// create a person's webID
|
|
33
47
|
console.log(`Adding to ${person} a ${WEBID_NOUN}: ${webid}.`)
|
|
34
48
|
const vcardURLThing = kb.bnode()
|
|
35
49
|
const insertables = [
|
|
@@ -37,11 +51,25 @@ export async function addWebIDToContacts (person, webid, urlType, kb) {
|
|
|
37
51
|
$rdf.st(vcardURLThing, ns.rdf('type'), urlType, person.doc()),
|
|
38
52
|
$rdf.st(vcardURLThing, ns.vcard('value'), webid, person.doc())
|
|
39
53
|
]
|
|
40
|
-
|
|
54
|
+
// insert WebID in groups
|
|
55
|
+
// replace person with WebID in vcard:hasMember (WebID may already exist)
|
|
56
|
+
// insert owl:sameAs
|
|
57
|
+
const groups = kb.each(null, ns.vcard('hasMember'), person)
|
|
58
|
+
let deletables = []
|
|
59
|
+
groups.forEach(group => {
|
|
60
|
+
deletables = deletables.concat(kb.statementsMatching(group, ns.vcard('hasMember'), person, group.doc()))
|
|
61
|
+
insertables.push($rdf.st(group, ns.vcard('hasMember'), kb.sym(webid), group.doc())) // May exist; do we need to check?
|
|
62
|
+
insertables.push($rdf.st(kb.sym(webid), ns.owl('sameAs'), person, group.doc()))
|
|
63
|
+
})
|
|
64
|
+
try {
|
|
65
|
+
await updateMany(deletables, insertables)
|
|
66
|
+
} catch (err) { throw new Error(`Could not create webId ${WEBID_NOUN}: ${webid}.`) }
|
|
41
67
|
}
|
|
42
68
|
|
|
43
69
|
export async function removeWebIDFromContacts (person, webid, urlType, kb) {
|
|
44
70
|
console.log(`Removing from ${person} their ${WEBID_NOUN}: ${webid}.`)
|
|
71
|
+
|
|
72
|
+
// remove webID from card
|
|
45
73
|
const existing = kb.each(person, ns.vcard('url'), null, person.doc())
|
|
46
74
|
.filter(urlObject => kb.holds(urlObject, ns.rdf('type'), urlType, person.doc()))
|
|
47
75
|
.filter(urlObject => kb.holds(urlObject, ns.vcard('value'), webid, person.doc()))
|
|
@@ -55,6 +83,19 @@ export async function removeWebIDFromContacts (person, webid, urlType, kb) {
|
|
|
55
83
|
$rdf.st(vcardURLThing, ns.vcard('value'), webid, person.doc())
|
|
56
84
|
]
|
|
57
85
|
await kb.updater.update(deletables, [])
|
|
86
|
+
|
|
87
|
+
// remove webIDs from groups
|
|
88
|
+
const groups = kb.each(null, ns.vcard('hasMember'), kb.sym(webid))
|
|
89
|
+
let removeFromGroups = []
|
|
90
|
+
const insertInGroups = []
|
|
91
|
+
groups.forEach(async group => {
|
|
92
|
+
removeFromGroups = removeFromGroups.concat(kb.statementsMatching(kb.sym(webid), ns.owl('sameAs'), person, group.doc()))
|
|
93
|
+
insertInGroups.push($rdf.st(group, ns.vcard('hasMember'), person, group.doc()))
|
|
94
|
+
if (kb.statementsMatching(kb.sym(webid), ns.owl('sameAs'), null, group.doc()).length < 2) {
|
|
95
|
+
removeFromGroups = removeFromGroups.concat(kb.statementsMatching(group, ns.vcard('hasMember'), kb.sym(webid), group.doc()))
|
|
96
|
+
}
|
|
97
|
+
})
|
|
98
|
+
await updateMany(removeFromGroups, insertInGroups)
|
|
58
99
|
}
|
|
59
100
|
|
|
60
101
|
// Trace things the same as this - other IDs for same thing
|
|
@@ -86,6 +127,7 @@ export function getSameAs (kb, thing, doc) { // Should this recurse?
|
|
|
86
127
|
return Array.from(found).map(uri => kb.sym(uri)) // return as array of nodes
|
|
87
128
|
}
|
|
88
129
|
|
|
130
|
+
// find person webIDs
|
|
89
131
|
export function getPersonas (kb, person) {
|
|
90
132
|
const lits = vcardWebIDs(kb, person).concat(getSameAs(kb, person, person.doc()))
|
|
91
133
|
const strings = new Set(lits.map(lit => lit.value)) // remove dups
|
|
@@ -206,7 +248,7 @@ export async function renderIdControl (person, dataBrowserContext, options) {
|
|
|
206
248
|
mainCell.setAttribute('colspan', 3)
|
|
207
249
|
let main
|
|
208
250
|
|
|
209
|
-
|
|
251
|
+
let profileIsVisible = true
|
|
210
252
|
|
|
211
253
|
const rhs = nav.children[2]
|
|
212
254
|
const openButton = rhs.appendChild(widgets.button(dom, DOWN_ARROW, 'View', profileOpenHandler))
|
|
@@ -216,6 +258,7 @@ export async function renderIdControl (person, dataBrowserContext, options) {
|
|
|
216
258
|
const paneName = isOrganization(person) || isOrganization(persona) ? 'profile' : 'profile' // was default for org
|
|
217
259
|
|
|
218
260
|
widgets.publicData.loadPublicDataThing(kb, person, persona).then(_resp => {
|
|
261
|
+
// loadPublicDataThing(kb, person, persona).then(_resp => {
|
|
219
262
|
try {
|
|
220
263
|
main = renderNamedPane(dom, persona, paneName, dataBrowserContext)
|
|
221
264
|
console.log('main: ', main)
|
|
@@ -272,8 +315,10 @@ export async function renderIdControl (person, dataBrowserContext, options) {
|
|
|
272
315
|
table.style.width = '100%'
|
|
273
316
|
|
|
274
317
|
if (options.editable) { // test
|
|
318
|
+
options.manualURIEntry = true // introduced in solid-ui 2.4.2
|
|
275
319
|
options.queryParams = options.queryParams || wikidataParameters
|
|
276
|
-
div.appendChild(await
|
|
320
|
+
div.appendChild(await renderAutocompleteControl(dom, person, options, addOneIdAndRefresh))
|
|
321
|
+
// div.appendChild(await widgets.renderAutocompleteControl(dom, person, options, addOneIdAndRefresh))
|
|
277
322
|
}
|
|
278
323
|
const profileArea = div.appendChild(dom.createElement('div'))
|
|
279
324
|
await refreshWebIDTable()
|