contacts-pane 2.6.4-fa583353 → 2.6.4-ffd7d417

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.
@@ -15,7 +15,18 @@ export async function renderGroupMemberships (person, context) {
15
15
  async function removeFromGroup (thing, group) {
16
16
  const pname = kb.any(thing, ns.vcard('fn'))
17
17
  const gname = kb.any(group, ns.vcard('fn'))
18
- const groups = kb.each(null, ns.vcard('hasMember'), thing)
18
+ // find all webids of thing
19
+ const thingwebids = kb.each(null, ns.owl('sameAs'), thing, group.doc())
20
+ // webid can be deleted only if not used in a other thing
21
+ let webids = []
22
+ thingwebids.map(webid => {
23
+ if (kb.any(webid, ns.owl('sameAs'), thing, group.doc()).length = 1 ) webids = webids.concat(webid)
24
+ }
25
+ )
26
+ // const webids = kb.any(webid, ns.owl('sameAs'))
27
+ let thingOrWebid = thing
28
+ if (webids.length > 0) thingOrWebid = kb.sym(webids[0])
29
+ const groups = kb.each(null, ns.vcard('hasMember'), thingOrWebid)
19
30
  if (groups.length < 2) {
20
31
  alert(
21
32
  'Must be a member of at least one group. Add to another group first.'
@@ -24,9 +35,10 @@ export async function renderGroupMemberships (person, context) {
24
35
  }
25
36
  const message = 'Remove ' + pname + ' from group ' + gname + '?'
26
37
  if (confirm(message)) {
27
- const del = kb
38
+ let del = kb
28
39
  .statementsMatching(person, undefined, undefined, group.doc())
29
40
  .concat(kb.statementsMatching(undefined, undefined, person, group.doc()))
41
+ webids.map(webid => del.concat(kb.statementsMatching(undefined,undefined, webid, group.doc())))
30
42
  kb.updater.update(del, [], function (uri, ok, err) {
31
43
  if (!ok) {
32
44
  const message = 'Error removing member from group ' + group + ': ' + err
@@ -52,9 +64,11 @@ export async function renderGroupMemberships (person, context) {
52
64
  return tr
53
65
  }
54
66
 
67
+ // find all documents where person ns.vcard('fn')
55
68
  function syncGroupList () {
56
- const groups = kb.each(null, ns.vcard('hasMember'), person)
57
-
69
+ // to be changed person and or webids
70
+ // const groups = kb.each(null, ns.vcard('hasMember'), person)
71
+ const groups = kb.each(person, ns.vcard('fn'), undefined) // non il faut acceder a la liste des group.doc()
58
72
  utils.syncTableToArray(groupList, groups, newRowForGroup)
59
73
  }
60
74
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contacts-pane",
3
- "version": "2.6.4-fa583353",
3
+ "version": "2.6.4-ffd7d417",
4
4
  "description": "Contacts Pane: Contacts manager for Address Book, Groups, and Individuals.",
5
5
  "main": "./contactsPane.js",
6
6
  "scripts": {
package/webidControl.js CHANGED
@@ -51,12 +51,18 @@ export async function addWebIDToContacts (person, webid, urlType, kb) {
51
51
  $rdf.st(vcardURLThing, ns.rdf('type'), urlType, person.doc()),
52
52
  $rdf.st(vcardURLThing, ns.vcard('value'), webid, person.doc())
53
53
  ]
54
+ // insert webID in groups
55
+ // replace person with webId in vcard:hasMember (webId may already exist)
56
+ // insert owl:sameAs
54
57
  const groups = kb.each(null, ns.vcard('hasMember'), person)
58
+ const deletables = []
55
59
  groups.forEach(group => {
60
+ deletables.push($rdf.st(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 ?
56
62
  insertables.push($rdf.st(person, ns.owl('sameAs'), kb.sym(webid), group.doc()))
57
63
  })
58
64
  try {
59
- await updateMany([], insertables)
65
+ await updateMany(deletables, insertables)
60
66
  } catch (err) { throw new Error(`Could not create webId ${WEBID_NOUN}: ${webid}.`) }
61
67
  }
62
68
 
@@ -79,12 +85,17 @@ export async function removeWebIDFromContacts (person, webid, urlType, kb) {
79
85
  await kb.updater.update(deletables, [])
80
86
 
81
87
  // remove webIDs from groups
82
- const groups = kb.each(null, ns.vcard('hasMember'), person)
88
+ const groups = kb.each(null, ns.vcard('hasMember'), kb.sym(webid))
83
89
  const removeFromGroups = []
90
+ const insertInGroups = []
84
91
  groups.forEach(group => {
85
92
  removeFromGroups.push($rdf.st(person, ns.owl('sameAs'), kb.sym(webid), group.doc()))
93
+ if (kb.each(null, ns.owl('sameAs'), kb.sym(webid), group.doc()).length = 1) {
94
+ removeFromGroups.push($rdf.st(group, ns.vcard('hasMember'), kb.sym(webid)), group.doc())
95
+ insertInGroups.push($rdf.st(group, ns.vcard('hasMember'), person, group.doc()))
96
+ }
86
97
  })
87
- await updateMany(removeFromGroups)
98
+ await updateMany(removeFromGroups, insertInGroups)
88
99
  }
89
100
 
90
101
  // Trace things the same as this - other IDs for same thing