Skip to content

Commit 3273eef

Browse files
author
Tim Berners-Lee
committed
tweaks and bug fixes
1 parent fe583f1 commit 3273eef

3 files changed

Lines changed: 63 additions & 22 deletions

File tree

lib/acl-control.js

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
5567
UI.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;'

lib/matrix.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ module.exports.matrixForQuery = function (dom, query, vx, vy, vvalue, options, w
4646
options.cellFunction(cell, x, y, value)
4747
} else {
4848
cell.textContent = utilsModule.label(value)
49+
cell.setAttribute('style', 'padding: 0.3em')
4950
}
5051
delete cell.old
5152
}
@@ -55,12 +56,12 @@ module.exports.matrixForQuery = function (dom, query, vx, vy, vvalue, options, w
5556
if (rows[y]) return rows[y]
5657
var tr = dom.createElement('tr')
5758
var header = tr.appendChild(dom.createElement('td'))
59+
header.setAttribute('style', 'padding: 0.3em;')
60+
header.textContent = utilsModule.label(y1) // first approximation
5861
if (y1.termType = 'symbol') {
5962
kb.fetcher.nowOrWhenFetched(y1.uri.split('#')[0], undefined, function (uri, ok, body) {
6063
header.textContent = utilsModule.label(y1)
6164
})
62-
} else {
63-
header.textContent = utilsModule.label(y1)
6465
}
6566
for (var i = 0; i < columns.length; i++) {
6667
setCell(tr.appendChild(dom.createElement('td')), $rdf.fromNT(columns[i]), y1, null)

lib/tabs.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11

2-
// Code lost -- must have never checked it in :-((
3-
// 2016-05-27
2+
// SOLID-compaible Tabs widget
3+
//
4+
// - Any Orientation = top, left, bottom, right
5+
// - Selected bodies are hidden not deleted
6+
// - Multiple tab select with Alt key
7+
//
8+
// written 2016-05-27
49

510

611
var tabs = {}
@@ -32,9 +37,9 @@ UI.tabs.tabWidget = function(options){
3237
var vertical = orientation & 1
3338
var wholetable = box.appendChild(dom.createElement('table'))
3439

35-
var tabContainer, tabElement, mainDiv
40+
var tabContainer, tabElement, mainDiv, tabBar
3641
//var bodyDiv = dom.createElement('div')
37-
var bodyDivStyle = 'resize: both; margin:0; border: 0.5em; border-style: solid; border-color: #eed; padding: 1em; min-width: 30em; min-height: 20em; width:100%;'
42+
var bodyDivStyle = 'resize: both; margin:0; border: 0.5em; border-style: solid; border-color: #eed; padding: 1em; min-width: 30em; min-height: 450px; width:100%;'
3843
//bodyDiv.setAttribute('style', )
3944
if (vertical){
4045
var onlyTR = wholetable.appendChild(dom.createElement('tr'))
@@ -49,6 +54,7 @@ UI.tabs.tabWidget = function(options){
4954
}
5055
tabContainer = tabTD.appendChild(dom.createElement('table'))
5156
tabElement = 'tr'
57+
tabBar = tabTD // drop zone
5258
//mainTD.appendChild(bodyDiv)
5359

5460
} else { // horizontal
@@ -67,6 +73,8 @@ UI.tabs.tabWidget = function(options){
6773
//mainTD.appendChild(bodyDiv)
6874
}
6975
var bodyContainer = mainTD.appendChild(dom.createElement('table'))
76+
box.tabContainer = tabContainer
77+
box.bodyContainer = bodyContainer
7078

7179
var getItems = function(){
7280
if (options.ordered){

0 commit comments

Comments
 (0)