@@ -52,6 +52,18 @@ UI.aclControl.preventBrowserDropEvents = function (document) {
5252 document . addEventListener ( 'dragover' , preventDrag , false )
5353}
5454
55+ UI . aclControl . shortNameForFolder = function ( x ) {
56+ var str = x . uri
57+ if ( str . slice ( - 1 ) === '/' ) {
58+ str = str . slice ( 0 , - 1 )
59+ }
60+ var slash = str . lastIndexOf ( '/' )
61+ if ( slash >= 0 ) {
62+ str = str . slice ( slash + 1 )
63+ }
64+ return str || '/'
65+ }
66+
5567UI . aclControl . ACLControlBox5 = function ( subject , dom , noun , kb , callback ) {
5668 var updater = kb . updater || new $rdf . UpdateManager ( kb )
5769 var ACL = UI . ns . acl
@@ -163,7 +175,7 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
163175 } else { // Linked controls
164176 UI . acl . makeACLGraphbyCombo ( kb2 , doc , box . mainByCombo , aclDoc , true , true )
165177 }
166- var updater = kb2 . updater || new $rdf . UpdateManager ( kb )
178+ var updater = kb2 . updater || new $rdf . UpdateManager ( kb2 )
167179 updater . put ( aclDoc , kb2 . statementsMatching ( undefined , undefined , undefined , aclDoc ) ,
168180 'text/turtle' , function ( uri , ok , message ) {
169181 if ( ! ok ) {
@@ -316,23 +328,40 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
316328 console . log ( 'Dropped URI list (2): ' + uris )
317329 if ( uris ) {
318330 uris . map ( function ( u ) {
331+ var saveAndRestoreUI = function ( ) {
332+ if ( ! ( combo in byCombo ) ) {
333+ byCombo [ combo ] = [ ]
334+ }
335+ removeAgentFromCombos ( u ) // Combos are mutually distinct
336+ byCombo [ combo ] . push ( [ res . pred , res . obj . uri ] )
337+ console . log ( 'ACL: setting access to ' + subject + ' by ' + res . pred + ': ' + res . obj )
338+ box . saveBack ( function ( ok ) {
339+ if ( ok ) {
340+ thisEle . style . backgroundColor = 'white' // restore look to before drag
341+ syncPanel ( )
342+ }
343+ } )
344+ }
345+
319346 var res = agentTriage ( u ) // eg 'agent', 'origin', agentClass'
320347 if ( ! res ) {
321- console . log ( 'Error: Drop fails to drop appropriate thing! ' + u )
348+ console . log ( ' looking up dropped thing ' + u )
349+ kb . fetcher . nowOrWhenFetched ( u , function ( ok , mess ) {
350+ if ( ! ok ) {
351+ console . log ( 'Error looking up dropped thing ' + u + ': ' + mess )
352+ } else {
353+ var res = agentTriage ( u )
354+ if ( ! res ) {
355+ console . log ( 'Error: Drop fails to drop appropriate thing! ' + u )
356+ } else {
357+ saveAndRestoreUI ( )
358+ }
359+ }
360+ } )
322361 return
362+ } else {
363+ saveAndRestoreUI ( )
323364 }
324- if ( ! ( combo in byCombo ) ) {
325- byCombo [ combo ] = [ ]
326- }
327- removeAgentFromCombos ( u ) // Combos are mutually distinct
328- byCombo [ combo ] . push ( [ res . pred , res . obj . uri ] )
329- console . log ( 'ACL: setting access to ' + subject + ' by ' + res . pred + ': ' + res . obj )
330- box . saveBack ( function ( ok ) {
331- if ( ok ) {
332- thisEle . style . backgroundColor = 'white' // restore look to before drag
333- syncPanel ( )
334- }
335- } )
336365 } )
337366 }
338367 return false
@@ -371,8 +400,11 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
371400 if ( ! defaults . length ) {
372401 statusBlock . textContent += ' (No defaults given.)'
373402 } else {
374- statusBlock . innerHTML = 'The sharing for this ' + noun + " is the default for folder <a href='" + defaultHolder . uri + "'>" +
375- ( defaultHolder ) + '</a>.'
403+ statusBlock . innerHTML = ''
404+ statusBlock . textContent = 'The sharing for this ' + noun + ' is the default for folder '
405+ var a = statusBlock . appendChild ( dom . createElement ( 'a' ) )
406+ a . setAttribute ( 'href' , defaultHolder . uri )
407+ a . textContent = UI . aclControl . shortNameForFolder ( defaultHolder )
376408 var kb2 = UI . acl . adoptACLDefault ( doc , targetACLDoc , defaultHolder , defaultACLDoc )
377409 ACLControlEditable ( box , doc , targetACLDoc , kb2 , { modify : false } ) // Add btton to save them as actual
378410 box . style = 'color: #777;'
0 commit comments