Skip to content

Commit 7cef62a

Browse files
authored
Merge pull request #86 from solid/dev
Dev branch
2 parents 91ba4d0 + df69280 commit 7cef62a

File tree

10 files changed

+324
-355
lines changed

10 files changed

+324
-355
lines changed

package-lock.json

Lines changed: 240 additions & 288 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "solid-ui",
3-
"version": "0.12.5",
3+
"version": "0.12.8-2",
44
"description": "UI library for writing Solid read-write-web applications",
55
"main": "./lib/index.js",
66
"files": [
@@ -44,7 +44,7 @@
4444
"escape-html": "^1.0.3",
4545
"mime-types": "^2.1.20",
4646
"node-uuid": "^1.4.7",
47-
"rdflib": ">=0.20.1",
47+
"rdflib": "^0.21.1",
4848
"solid-auth-client": "^2.2.13",
4949
"solid-auth-tls": "^0.1.2",
5050
"solid-namespace": "0.2.0"

src/acl-control.js

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,8 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
544544
} else {
545545
box.isContainer = targetDoc.uri.slice(-1) === '/' // Give default for all directories
546546
if (defa) {
547-
var defaults = kb.each(undefined, ACL('defaultForNew'), defaultHolder, defaultACLDoc)
547+
var defaults = kb.each(undefined, ACL('default'), defaultHolder, defaultACLDoc)
548+
.concat(kb.each(undefined, ACL('defaultForNew'), defaultHolder, defaultACLDoc))
548549
if (!defaults.length) {
549550
statusBlock.textContent += ' (No defaults given.)'
550551
} else {
@@ -561,21 +562,23 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
561562
editPlease.textContent = 'Set specific sharing\nfor this ' + noun
562563
editPlease.style.cssText = bigButtonStyle
563564
editPlease.addEventListener('click', async function (event) {
564-
kb2.forEach(st => {
565+
kb2.statements.forEach(st => {
565566
kb.add(st.subject, st.predicate, st.object, targetACLDoc)
566567
})
567568
try {
568-
fetcher.putBack(targetACLDoc)
569+
kb.fetcher.putBack(targetACLDoc)
570+
.then(function () {
571+
statusBlock.textContent = ' (Now editing specific access for this ' + noun + ')'
572+
bottomRightCell.removeChild(editPlease)
573+
renderBox()
574+
})
569575
} catch (e) {
570576
let msg = ' Error writing back access control file! ' + e
571577
console.error(msg)
572578
statusBlock.textContent += msg
573579
return
574580
}
575-
kb.fetcher.requested[targetACLDoc.uri] = 'done' // cheat - say cache is now in sync
576-
statusBlock.textContent = ' (Now editing specific access for this ' + noun + ')'
577-
bottomRightCell.removeChild(editPlease)
578-
renderBox()
581+
// kb.fetcher.requested[targetACLDoc.uri] = 'done' // cheat - say cache is now in sync
579582
})
580583
} // defaults.length
581584
} else { // Not using defaults
@@ -592,8 +595,9 @@ UI.aclControl.ACLControlBox5 = function (subject, dom, noun, kb, callback) {
592595
kb.fetcher.delete(targetACLDoc.uri)
593596
.then(function () {
594597
statusBlock.textContent = ' The sharing for this ' + noun + ' is now the default.'
595-
bottomRow.removeChild(useDefault)
598+
bottomRightCell.removeChild(useDefault)
596599
box.style.cssText = 'color: #777;'
600+
bottomLeftCell.innerHTML = ''
597601
renderBox()
598602
})
599603
.catch(function (e) {

src/acl.js

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,9 @@ UI.acl.getACLorDefault = function (doc, callbackFunction) {
337337
}
338338
var right = uri.lastIndexOf('/')
339339
var left = uri.indexOf('/', uri.indexOf('//') + 2)
340+
if (left >= right) {
341+
return callbackFunction(false, true, 404, 'Found no ACL resource')
342+
}
340343
uri = uri.slice(0, right + 1)
341344
var doc2 = $rdf.sym(uri)
342345
UI.acl.getACL(doc2, function (ok, status, defaultACLDoc) {
@@ -345,24 +348,19 @@ UI.acl.getACLorDefault = function (doc, callbackFunction) {
345348
} else if (status === 403) {
346349
return callbackFunction(false, true, status, '( default ACL file FORBIDDEN. Stop.' + uri + ')')
347350
} else if (status === 404) {
348-
if (left >= right) {
349-
return callbackFunction(false, true, 499, 'Nothing to hold a default')
350-
} else {
351-
tryParent(uri)
352-
}
351+
return tryParent(uri)
353352
} else if (status !== 200) {
354353
return callbackFunction(false, true, status, "Error status '" + status + "' searching for default for " + doc2)
355-
} else { // 200
356-
// statusBlock.textContent += (" ACCESS set at " + uri + ". End search.")
357-
var defaults = kb.each(undefined, ACL('default'), kb.sym(uri), defaultACLDoc)
358-
.concat(kb.each(undefined, ACL('defaultForNew'), kb.sym(uri), defaultACLDoc))
359-
if (!defaults.length) {
360-
tryParent(uri) // Keep searching
361-
} else {
362-
var defaultHolder = kb.sym(uri)
363-
callbackFunction(true, false, doc, aclDoc, defaultHolder, defaultACLDoc)
364-
}
365354
}
355+
// 200
356+
// statusBlock.textContent += (" ACCESS set at " + uri + ". End search.")
357+
var defaults = kb.each(undefined, ACL('default'), kb.sym(uri), defaultACLDoc)
358+
.concat(kb.each(undefined, ACL('defaultForNew'), kb.sym(uri), defaultACLDoc))
359+
if (!defaults.length) {
360+
return tryParent(uri) // Keep searching
361+
}
362+
var defaultHolder = kb.sym(uri)
363+
return callbackFunction(true, false, doc, aclDoc, defaultHolder, defaultACLDoc)
366364
})
367365
} // tryParent
368366

src/create.js

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -144,42 +144,43 @@ function newThingUI (context, thePanes) {
144144
)
145145
} // makeNewAppInstance
146146

147-
var iconArray = []
148-
for (var pn in thePanes) {
149-
var pane = thePanes[pn]
150-
if (pane.mintNew) {
151-
var icon = context.div.appendChild(dom.createElement('img'))
152-
icon.setAttribute('src', pane.icon)
153-
var noun = pane.mintClass ? UI.utils.label(pane.mintClass) : (pane.name + ' @@')
154-
icon.setAttribute('title', 'Make new ' + noun)
155-
icon.setAttribute('style', iconStyle + 'display: none;')
156-
iconArray.push(icon)
157-
var foo = function (pane, icon, noun) {
158-
var iconEle = icon
159-
var thisPane = pane
160-
var thisNoun = noun
161-
if (!icon.disabled) {
162-
icon.addEventListener('click', function (e) {
163-
selectTool(iconEle)
164-
var options = {
165-
event: e,
166-
folder: context.folder,
167-
iconEle: iconEle,
168-
pane: thisPane,
169-
noun: thisNoun,
170-
noIndexHTML: true, // do NOT @@ for now write a HTML file
171-
div: context.div,
172-
me: context.me,
173-
dom: context.dom,
174-
refreshTarget: context.refreshTarget
175-
}
176-
makeNewAppInstance(options)
177-
})
178-
}
179-
} // foo
180-
foo(pane, icon, noun)
147+
const iconArray = []
148+
const mintingPanes = Object.values(thePanes).filter(pane => pane.mintNew)
149+
const mintingClassMap = mintingPanes.reduce((classMap, pane) => {
150+
if (pane.mintClass) {
151+
classMap[pane.mintClass] = (classMap[pane.mintClass] || 0) + 1
181152
}
182-
}
153+
return classMap
154+
}, {})
155+
mintingPanes.forEach(pane => {
156+
const icon = context.div.appendChild(dom.createElement('img'))
157+
icon.setAttribute('src', pane.icon)
158+
const noun = pane.mintClass
159+
? (mintingClassMap[pane.mintClass] > 1
160+
? `${UI.utils.label(pane.mintClass)} (using ${pane.name} pane)`
161+
: UI.utils.label(pane.mintClass))
162+
: (pane.name + ' @@')
163+
icon.setAttribute('title', 'Make new ' + noun)
164+
icon.setAttribute('style', iconStyle + 'display: none;')
165+
iconArray.push(icon)
166+
if (!icon.disabled) {
167+
icon.addEventListener('click', function (e) {
168+
selectTool(icon)
169+
makeNewAppInstance({
170+
event: e,
171+
folder: context.folder,
172+
iconEle: icon,
173+
pane,
174+
noun,
175+
noIndexHTML: true, // do NOT @@ for now write a HTML file
176+
div: context.div,
177+
me: context.me,
178+
dom: context.dom,
179+
refreshTarget: context.refreshTarget
180+
})
181+
})
182+
}
183+
})
183184

184185
var styleTheIcons = function (style) {
185186
for (var i = 0; i < iconArray.length; i++) {

src/icons/noun_Cabinet_251723.svg

Lines changed: 1 addition & 0 deletions
Loading

src/signin.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,6 +776,7 @@ function genACLText (docURI, me, aclURI, options = {}) {
776776
g.add(a, UI.ns.rdf('type'), auth('Authorization'), acl)
777777
g.add(a, auth('accessTo'), doc, acl)
778778
if (options.defaultForNew) {
779+
// TODO: Should this be auth('default') instead?
779780
g.add(a, auth('defaultForNew'), doc, acl)
780781
}
781782
g.add(a, auth('agent'), me, acl)

src/style.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ module.exports = {
99
buttonStyle: 'background-color: #fff; padding: 0.5em; border: .01em solid white; font-size: 100%;', // 'background-color: #eef;
1010
// The width of the text field must bot be 100% or it switches to overlapping
1111
messageBodyStyle: 'white-space: pre-wrap; width: 99%; font-size:100%; border: 0.07em solid #eee; padding: .3em 0.5em; margin: 0.1em;',
12-
pendingeditModifier: 'color: #bbb;'
12+
pendingeditModifier: 'color: #bbb;',
13+
highlightColor: '#7C4DFF' // Solid lavendar https://design.inrupt.com/atomic-core/?cat=Core
1314

1415
}

src/tabs.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,21 @@ UI.tabs.tabWidget = function (options) {
292292
box.refresh = sync
293293
sync()
294294

295-
if (!options.startEmpty && tabContainer.children.length) {
295+
// From select-tabs branch by hand
296+
if (!options.startEmpty && tabContainer.children.length && options.selectedTab) {
297+
var tab
298+
var found = false
299+
for (var i = 0; i < tabContainer.children.length; i++) {
300+
tab = tabContainer.children[i]
301+
if (tab.firstChild && tab.firstChild.dataset.name === options.selectedTab) {
302+
tab.firstChild.click()
303+
found = true
304+
}
305+
}
306+
if (!found) {
307+
tabContainer.children[0].firstChild.click() // Open first tab
308+
}
309+
} else if (!options.startEmpty && tabContainer.children.length) {
296310
tabContainer.children[0].firstChild.click() // Open first tab
297311
}
298312
return box

src/widgets/index.js

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -904,11 +904,8 @@ UI.widgets.field[UI.ns.ui('PhoneField').uri] =
904904

905905
store = store || UI.widgets.fieldStore(subject, property, store)
906906

907-
var obj = kb.any(subject, property, undefined, store)
908-
if (!obj) {
909-
obj = kb.any(form, ui('default'))
910-
if (obj) kb.add(subject, property, obj, store)
911-
}
907+
var obj = kb.any(subject, property, undefined, store) ||
908+
kb.any(form, ui('default'))
912909
if (obj && obj.uri && params.uriPrefix) { // eg tel: or mailto:
913910
field.value = decodeURIComponent(obj.uri.replace(params.uriPrefix, '')) // should have no spaces but in case
914911
.replace(/ /g, '')

0 commit comments

Comments
 (0)