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.
Files changed (51) hide show
  1. package/.eslintrc +3 -1
  2. package/.github/workflows/ci.yml +74 -0
  3. package/.nvmrc +1 -1
  4. package/LICENSE.md +0 -0
  5. package/Makefile +0 -0
  6. package/README.md +0 -0
  7. package/__tests__/unit/data-reformat-test.js +166 -0
  8. package/__tests__/unit/data-reformat-test.ts +185 -0
  9. package/__tests__/unit/setup.js +74 -0
  10. package/__tests__/unit/setup.ts +77 -0
  11. package/babel.config.js +13 -0
  12. package/card.ai +0 -0
  13. package/card.png +0 -0
  14. package/contactLogic.js +84 -7
  15. package/contactsPane.js +64 -20
  16. package/diff.txt +0 -0
  17. package/exampleOfOpenData/mit-wikidata-details.ttl +0 -0
  18. package/exampleOfOpenData/mit-wikidata-query.sparql +0 -0
  19. package/exampleOfOpenData/wikidata-get.json +0 -0
  20. package/groupMembershipControl.js +56 -13
  21. package/individual.js +3 -2
  22. package/individualForm.js +0 -0
  23. package/jest.config.js +11 -0
  24. package/jest.setup.ts +10 -0
  25. package/lib/autocompleteBar.js +99 -0
  26. package/lib/autocompleteBar.js.map +1 -0
  27. package/lib/autocompleteField.js +157 -0
  28. package/lib/autocompleteField.js.map +1 -0
  29. package/lib/autocompletePicker.js +240 -0
  30. package/lib/autocompletePicker.js.map +1 -0
  31. package/lib/forms.js +315 -0
  32. package/lib/instituteDetailsQuery.js +38 -0
  33. package/lib/publicData.js +387 -0
  34. package/lib/publicData.js.map +1 -0
  35. package/lib/vcard.js +916 -0
  36. package/mintNewAddressBook.js +5 -4
  37. package/mugshotGallery.js +16 -4
  38. package/organizationForm.js +0 -0
  39. package/organizationForm.ttl +0 -0
  40. package/package.json +26 -13
  41. package/shapes/contacts-shapes.ttl +0 -0
  42. package/src/autocompleteBar.ts +92 -0
  43. package/src/autocompleteField.ts +180 -0
  44. package/src/autocompletePicker.ts +253 -0
  45. package/src/forms.ttl +1 -1
  46. package/src/instituteDetailsQuery.sparql +0 -0
  47. package/src/publicData.ts +385 -0
  48. package/src/vcard.ttl +0 -0
  49. package/toolsPane.js +70 -19
  50. package/tsconfig.json +16 -0
  51. 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 = UI.store
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
- await kb.updater.update([], insertables)
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
- var profileIsVisible = true
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 widgets.renderAutocompleteControl(dom, person, options, addOneIdAndRefresh))
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()