1- /* Manage a UI for the particpation of a person in any thing
1+ /* Manage a UI for the participation of a person in any thing
22*/
33
44// import { currentUser } from './authn/authn'
@@ -9,6 +9,7 @@ import { personTR, newThing, errorMessageBlock } from './widgets'
99import { syncTableToArray } from './utils'
1010import { lightColorHash } from './pad'
1111import { log } from './debug'
12+ import * as style from './style'
1213import { solidLogicSingleton , authn } from 'solid-logic'
1314
1415type ParticipationOptions = {
@@ -31,10 +32,10 @@ const store = solidLogicSingleton.store as LiveStore
3132* @param {NamedNode } unused2/me - user that is logged into the pod (this argument is no longer used, but left in for backwards compatibility)
3233* @param {ParticipationOptions } options - the options that can be passed in are deleteFunction, link, and draggable these are used by the personTR button
3334*/
34- export function renderPartipants ( dom : HTMLDocument , table : ParticipationTableElement , unused1 : NamedNode , subject : NamedNode , unused2 : NamedNode , options : ParticipationOptions ) {
35- table . setAttribute ( 'style' , 'margin: 0.8em;' )
35+ export function renderParticipants ( dom : HTMLDocument , table : ParticipationTableElement , unused1 : NamedNode , subject : NamedNode , unused2 : NamedNode , options : ParticipationOptions ) {
36+ table . setAttribute ( 'style' , style . participantsStyle )
3637
37- const newRowForParticpation = function ( parp ) {
38+ const newRowForParticipation = function ( parp ) {
3839 const person = store . any ( parp , ns . wf ( 'participant' ) )
3940
4041 let tr
@@ -47,14 +48,13 @@ export function renderPartipants (dom: HTMLDocument, table: ParticipationTableEl
4748
4849 const block = dom . createElement ( 'div' )
4950 block . setAttribute (
50- 'style' ,
51- 'height: 1.5em; width: 1.5em; margin: 0.3em; border 0.01em solid #888; background-color: ' +
52- bg
53- )
51+ 'style' , style . participantsBlock )
52+ block . style . backgroundColor = bg
53+
5454 tr = personTR ( dom , null , person , options )
5555 table . appendChild ( tr )
5656 const td = dom . createElement ( 'td' )
57- td . setAttribute ( 'style' , 'vertical-align: middle;' )
57+ td . setAttribute ( 'style' , style . personTableTD )
5858 td . appendChild ( block )
5959 tr . insertBefore ( td , tr . firstChild )
6060 return tr
@@ -69,16 +69,16 @@ export function renderPartipants (dom: HTMLDocument, table: ParticipationTableEl
6969 const participations = parps . map ( function ( p ) {
7070 return p [ 1 ]
7171 } )
72- syncTableToArray ( table , participations , newRowForParticpation )
72+ syncTableToArray ( table , participations , newRowForParticipation )
7373 }
7474 table . refresh = syncTable
7575 syncTable ( )
7676 return table
7777}
7878
79- /** Record, or find old, Particpation object
79+ /** Record, or find old, Participation object
8080 *
81- * A particpaption object is a place to record things specifically about
81+ * A participation object is a place to record things specifically about
8282 * subject and the user, such as preferences, start of membership, etc
8383 * @param {NamedNode } subject - the thing in which the participation is happening
8484 * @param {NamedNode } document - where to record the data
@@ -104,13 +104,13 @@ export function participationObject (subject: NamedNode, padDoc: NamedNode, me:
104104 }
105105 candidates . sort ( ) // Pick the earliest
106106 // @@ Possibly, for extra credit, delete the others, if we have write access
107- debug . warn ( 'Multiple particpation objects, picking earliest, in ' + padDoc )
107+ debug . warn ( 'Multiple participation objects, picking earliest, in ' + padDoc )
108108 resolve ( candidates [ 0 ] [ 1 ] )
109109 // throw new Error('Multiple records of your participation')
110110 }
111111 if ( parps . length ) {
112112 // If I am not already recorded
113- resolve ( parps [ 0 ] ) // returns the particpation object
113+ resolve ( parps [ 0 ] ) // returns the participation object
114114 } else {
115115 const participation = newThing ( padDoc )
116116 const ins = [
@@ -127,7 +127,7 @@ export function participationObject (subject: NamedNode, padDoc: NamedNode, me:
127127 ] ;
128128 ( store . updater as UpdateManager ) . update ( [ ] , ins , function ( uri : string | null | undefined , ok : boolean , errorMessage ?: string ) {
129129 if ( ! ok ) {
130- reject ( new Error ( 'Error recording your partipation : ' + errorMessage ) )
130+ reject ( new Error ( 'Error recording your participation : ' + errorMessage ) )
131131 } else {
132132 resolve ( participation )
133133 }
@@ -140,7 +140,7 @@ export function participationObject (subject: NamedNode, padDoc: NamedNode, me:
140140/** Record my participation and display participants
141141 *
142142 * @param {NamedNode } subject - the thing in which participation is happening
143- * @param {NamedNode } padDoc - the document into which the particpation should be recorded
143+ * @param {NamedNode } padDoc - the document into which the participation should be recorded
144144 * @param {DOMNode } refreshable - a DOM element whose refresh() is to be called if the change works
145145 *
146146 */
@@ -156,10 +156,10 @@ export function recordParticipation (subject: NamedNode, padDoc: NamedNode, refr
156156 }
157157 if ( parps . length ) {
158158 // If I am not already recorded
159- return parps [ 0 ] // returns the particpation object
159+ return parps [ 0 ] // returns the participation object
160160 } else {
161161 if ( ! ( store . updater as UpdateManager ) . editable ( padDoc ) ) {
162- debug . log ( 'Not recording participation, as no write acesss as ' + me + ' to ' + padDoc )
162+ debug . log ( 'Not recording participation, as no write access as ' + me + ' to ' + padDoc )
163163 return null
164164 }
165165 const participation = newThing ( padDoc )
@@ -177,12 +177,11 @@ export function recordParticipation (subject: NamedNode, padDoc: NamedNode, refr
177177 ] ;
178178 ( store . updater as UpdateManager ) . update ( [ ] , ins , function ( uri : string | null | undefined , ok : boolean , errorMessage ?: string ) {
179179 if ( ! ok ) {
180- throw new Error ( 'Error recording your partipation : ' + errorMessage )
180+ throw new Error ( 'Error recording your participation : ' + errorMessage )
181181 }
182182 if ( refreshable && refreshable . refresh ) {
183183 refreshable . refresh ( )
184184 }
185- // UI.pad.renderPartipants(dom, table, padDoc, subject, me, options)
186185 } )
187186 return participation
188187 }
@@ -192,7 +191,7 @@ export function recordParticipation (subject: NamedNode, padDoc: NamedNode, refr
192191*
193192* @param {Document } dom - the web page loaded into the browser
194193* @param {HTMLDivElement } container - the container element where the participants should be displayed
195- * @param {NamedNode } document - the document into which the particpation should be shown
194+ * @param {NamedNode } document - the document into which the participation should be shown
196195* @param {NamedNode } subject - the thing in which participation is happening
197196* @param {NamedNode } me - the logged in user
198197* @param {ParticipationOptions } options - the options that can be passed in are deleteFunction, link, and draggable these are used by the personTR button
@@ -208,15 +207,15 @@ export function manageParticipation (
208207) {
209208 const table = dom . createElement ( 'table' )
210209 container . appendChild ( table )
211- renderPartipants ( dom , table , padDoc , subject , me , options )
210+ renderParticipants ( dom , table , padDoc , subject , me , options )
212211 let _participation
213212 try {
214213 _participation = recordParticipation ( subject , padDoc , table )
215214 } catch ( e ) {
216215 container . appendChild (
217216 errorMessageBlock (
218217 dom ,
219- 'Error recording your partipation : ' + e
218+ 'Error recording your participation : ' + e
220219 )
221220 ) // Clean up?
222221 }
0 commit comments