@@ -21,7 +21,7 @@ import ns from '../ns'
2121import kb from '../store'
2222
2323export class PeoplePicker {
24- constructor ( element , typeIndex , groupPickedCb , options ) {
24+ constructor ( element , typeIndex , groupPickedCb , options ) {
2525 this . options = options || { }
2626 this . element = element
2727 this . typeIndex = typeIndex
@@ -30,7 +30,7 @@ export class PeoplePicker {
3030 this . onSelectGroup = this . onSelectGroup . bind ( this )
3131 }
3232
33- render ( ) {
33+ render ( ) {
3434 const container = document . createElement ( 'div' )
3535 container . style . maxWidth = '350px'
3636 container . style . minHeight = '200px'
@@ -65,7 +65,7 @@ export class PeoplePicker {
6565 createNewGroupButton . textContent = escape ( 'Create a new group' )
6666 createNewGroupButton . style . margin = 'auto'
6767 createNewGroupButton . addEventListener ( 'click' , ( _event ) => {
68- createNewGroup ( book )
68+ createNewGroup ( book , this . options . defaultNewGroupName )
6969 . then ( ( { group } ) => {
7070 new GroupBuilder (
7171 this . element ,
@@ -105,21 +105,21 @@ export class PeoplePicker {
105105 return this
106106 }
107107
108- onSelectGroup ( group ) {
108+ onSelectGroup ( group ) {
109109 this . selectedgroup = group
110110 this . groupPickedCb ( group )
111111 this . render ( )
112112 }
113113}
114114
115115export class GroupPicker {
116- constructor ( element , book , onSelectGroup ) {
116+ constructor ( element , book , onSelectGroup ) {
117117 this . element = element
118118 this . book = book
119119 this . onSelectGroup = onSelectGroup
120120 }
121121
122- render ( ) {
122+ render ( ) {
123123 this . loadGroups ( )
124124 . then ( ( groups ) => {
125125 // render the groups
@@ -146,7 +146,7 @@ export class GroupPicker {
146146 return this
147147 }
148148
149- loadGroups ( ) {
149+ loadGroups ( ) {
150150 return new Promise ( ( resolve , reject ) => {
151151 const { groupIndex } = indexes ( this . book )
152152 kb . fetcher . nowOrWhenFetched ( groupIndex , ( ok , err ) => {
@@ -159,20 +159,20 @@ export class GroupPicker {
159159 } )
160160 }
161161
162- handleClickGroup ( group ) {
162+ handleClickGroup ( group ) {
163163 return ( _event ) => {
164164 this . onSelectGroup ( group )
165165 }
166166 }
167167}
168168
169169export class Group {
170- constructor ( element , group ) {
170+ constructor ( element , group ) {
171171 this . element = element
172172 this . group = group
173173 }
174174
175- render ( ) {
175+ render ( ) {
176176 const container = document . createElement ( 'div' )
177177 container . textContent = escape (
178178 // @@@@@ need to escape??
@@ -185,7 +185,7 @@ export class Group {
185185}
186186
187187export class GroupBuilder {
188- constructor ( element , book , group , doneBuildingCb , groupChangedCb ) {
188+ constructor ( element , book , group , doneBuildingCb , groupChangedCb ) {
189189 this . element = element
190190 this . book = book
191191 this . group = group
@@ -198,11 +198,11 @@ export class GroupBuilder {
198198 this . doneBuildingCb = doneBuildingCb
199199 }
200200
201- refresh ( ) {
201+ refresh ( ) {
202202 // TODO: implement
203203 }
204204
205- render ( ) {
205+ render ( ) {
206206 const dropContainer = document . createElement ( 'div' )
207207 dropContainer . style . maxWidth = '350px'
208208 dropContainer . style . minHeight = '200px'
@@ -269,7 +269,7 @@ export class GroupBuilder {
269269 return this
270270 }
271271
272- add ( webId ) {
272+ add ( webId ) {
273273 return new Promise ( ( resolve , reject ) => {
274274 kb . fetcher . nowOrWhenFetched ( webId , ( ok , err ) => {
275275 if ( ! ok ) {
@@ -303,7 +303,7 @@ export class GroupBuilder {
303303 } )
304304 }
305305
306- handleRemove ( webIdNode ) {
306+ handleRemove ( webIdNode ) {
307307 return ( _event ) => {
308308 const statement = rdf . st ( this . group , ns . vcard ( 'hasMember' ) , webIdNode )
309309 return patch ( this . group . doc ( ) . uri , { toDel : [ statement ] } )
@@ -324,7 +324,7 @@ export class GroupBuilder {
324324 }
325325 }
326326
327- setGroupName ( name ) {
327+ setGroupName ( name ) {
328328 const { groupIndex } = indexes ( this . book )
329329 const updatePromises = [ this . group . doc ( ) , groupIndex ] . map ( ( namedGraph ) => {
330330 const oldNameStatements = kb . match (
@@ -354,13 +354,13 @@ export class GroupBuilder {
354354// @@ TODO maybe I should move this down at end, but for
355355// now I will leave it where it was
356356export class Person {
357- constructor ( element , webIdNode , handleRemove ) {
357+ constructor ( element , webIdNode , handleRemove ) {
358358 this . webIdNode = webIdNode
359359 this . element = element
360360 this . handleRemove = handleRemove
361361 }
362362
363- render ( ) {
363+ render ( ) {
364364 const container = document . createElement ( 'div' )
365365 container . style . display = 'flex'
366366
@@ -406,12 +406,12 @@ export class Person {
406406 }
407407}
408408
409- function getWithDefault ( subject , predicate , defaultValue ) {
409+ function getWithDefault ( subject , predicate , defaultValue ) {
410410 const object = kb . any ( subject , predicate )
411411 return object ? object . value : defaultValue
412412}
413413
414- function patch ( url , { toDel, toIns } ) {
414+ function patch ( url , { toDel, toIns } ) {
415415 return new Promise ( ( resolve , reject ) => {
416416 kb . updater . update ( toDel , toIns , ( uri , success , errorMessage ) => {
417417 if ( ! success ) {
@@ -433,7 +433,7 @@ function patch(url, { toDel, toIns }) {
433433 // })
434434}
435435
436- function indexes ( book ) {
436+ function indexes ( book ) {
437437 return {
438438 // bookIndex: book,
439439 groupIndex : kb . any ( book , ns . vcard ( 'groupIndex' ) ) ,
@@ -442,7 +442,7 @@ function indexes(book) {
442442}
443443// Below are functions that are exported to make testing easier
444444// @ignore exporting this only for the unit test
445- export function findAddressBook ( typeIndex ) {
445+ export function findAddressBook ( typeIndex ) {
446446 return new Promise ( ( resolve , reject ) => {
447447 kb . fetcher . nowOrWhenFetched ( typeIndex , ( ok , err ) => {
448448 if ( ! ok ) {
@@ -466,22 +466,22 @@ export function findAddressBook(typeIndex) {
466466 }
467467 kb . fetcher
468468 . load ( book )
469- . then ( function ( _xhr ) {
469+ . then ( function ( _xhr ) {
470470 return resolve ( { book } )
471471 } )
472- . catch ( function ( err ) {
472+ . catch ( function ( err ) {
473473 return reject ( new Error ( 'Could not load address book ' + err ) )
474474 } )
475475 } )
476476 } )
477477}
478478
479- export function createNewGroup ( book ) {
479+ export function createNewGroup ( book , defaultNewGroupName ) {
480480 const { groupIndex, groupContainer } = indexes ( book )
481481 const group = rdf . sym (
482482 `${ groupContainer . uri } ${ uuid . v4 ( ) . slice ( 0 , 8 ) } .ttl#this`
483483 )
484- const name = this . options . defaultNewGroupName || 'Untitled Group'
484+ const name = defaultNewGroupName || 'Untitled Group'
485485
486486 // NOTE that order matters here. Unfortunately this type of update is
487487 // non-atomic in that solid requires us to send two PATCHes, either of which
0 commit comments