contactsPane.js
function (uris) {
                uris.forEach(function (u) {
                  console.log('Dropped on group: ' + u)
                  var thing = kb.sym(u)
                  var toBeFetched = [thing.doc(), group.doc()]

                  kb.fetcher.load(toBeFetched).then(function (xhrs) {
                    var types = kb.findTypeURIs(thing)
                    for (var ty in types) {
                      console.log('    drop object type includes: ' + ty) // @@ Allow email addresses and phone numbers to be dropped?
                    }
                    if (ns.vcard('Individual').uri in types || ns.vcard('Organization').uri in types) {
                      var pname = kb.any(thing, ns.vcard('fn'))
                      if (!pname) return alert('No vcard name known for ' + thing)
                      var already = kb.holds(group, ns.vcard('hasMember'), thing, group.doc())
                      if (already) return alert('ALREADY added ' + pname + ' to group ' + name)
                      var message = 'Add ' + pname + ' to group ' + name + '?'
                      if (confirm(message)) {
                        var ins = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
                          $rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
                        kb.updater.update([], ins, function (uri, ok, err) {
                          if (!ok) return complain('Error adding member to group ' + group + ': ' + err)
                          console.log('Added ' + pname + ' to group ' + name)
                          // @@ refresh UI
                        })
                      }
                    }
                  }).catch(function (e) {
                    complain('Error looking up dropped thing ' + thing + ' and group: ' + e)
                  })
                })
              }
function (uris) {
                uris.forEach(function (u) {
                  console.log('Dropped on group: ' + u)
                  var thing = kb.sym(u)
                  var toBeFetched = [thing.doc(), group.doc()]

                  kb.fetcher.load(toBeFetched).then(function (xhrs) {
                    var types = kb.findTypeURIs(thing)
                    for (var ty in types) {
                      console.log('    drop object type includes: ' + ty) // @@ Allow email addresses and phone numbers to be dropped?
                    }
                    if (ns.vcard('Individual').uri in types || ns.vcard('Organization').uri in types) {
                      var pname = kb.any(thing, ns.vcard('fn'))
                      if (!pname) return alert('No vcard name known for ' + thing)
                      var already = kb.holds(group, ns.vcard('hasMember'), thing, group.doc())
                      if (already) return alert('ALREADY added ' + pname + ' to group ' + name)
                      var message = 'Add ' + pname + ' to group ' + name + '?'
                      if (confirm(message)) {
                        var ins = [ $rdf.st(group, ns.vcard('hasMember'), thing, group.doc()),
                          $rdf.st(thing, ns.vcard('fn'), pname, group.doc())]
                        kb.updater.update([], ins, function (uri, ok, err) {
                          if (!ok) return complain('Error adding member to group ' + group + ': ' + err)
                          console.log('Added ' + pname + ' to group ' + name)
                          // @@ refresh UI
                        })
                      }
                    }
                  }).catch(function (e) {
                    complain('Error looking up dropped thing ' + thing + ' and group: ' + e)
                  })
                })
              }
function ( uris ) { uris . forEach ( function ( u ) { console . log ( 'Dropped on group: ' + u ) var thing = kb . sym ( u ) var toBeFetched = [ thing . doc ( ) , group . doc ( ) ] kb . fetcher . load ( toBeFetched ) . then ( function ( xhrs ) { var types = kb . findTypeURIs ( thing ) for ( var ty in types ) { console . log ( '    drop object type includes: ' + ty ) // @@ Allow email addresses and phone numbers to be dropped? } if ( ns . vcard ( 'Individual' ) . uri in types || ns . vcard ( 'Organization' ) . uri in types ) { var pname = kb . any ( thing , ns . vcard ( 'fn' ) ) if ( ! pname ) return alert ( 'No vcard name known for ' + thing ) var already = kb . holds ( group , ns . vcard ( 'hasMember' ) , thing , group . doc ( ) ) if ( already ) return alert ( 'ALREADY added ' + pname + ' to group ' + name ) var message = 'Add ' + pname + ' to group ' + name + '?' if ( confirm ( message ) ) { var ins = [ $rdf . st ( group , ns . vcard ( 'hasMember' ) , thing , group . doc ( ) ) , $rdf . st ( thing , ns . vcard ( 'fn' ) , pname , group . doc ( ) ) ] kb . updater . update ( [ ] , ins , function ( uri , ok , err ) { if ( ! ok ) return complain ( 'Error adding member to group ' + group + ': ' + err ) console . log ( 'Added ' + pname + ' to group ' + name ) // @@ refresh UI } ) } } } ) . catch ( function ( e ) { complain ( 'Error looking up dropped thing ' + thing + ' and group: ' + e ) } ) } ) }
Is something is dropped on a group, add people to group
Is something is dropped on a group add people to group