folder-pane 2.4.9-alpha-d9bd19aa → 2.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/folderPane.js +150 -0
- package/lib/folderPane.js.map +1 -0
- package/package.json +21 -10
- package/.eslintrc +0 -18
- package/.nvmrc +0 -1
- package/folderPane.js +0 -201
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/* Folder pane
|
|
3
|
+
**
|
|
4
|
+
** This outline pane lists the members of a folder
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
var UI = require("solid-ui");
|
|
8
|
+
module.exports = {
|
|
9
|
+
icon: UI.icons.iconBase + 'noun_973694_expanded.svg',
|
|
10
|
+
name: 'folder',
|
|
11
|
+
// Create a new folder in a Solid system,
|
|
12
|
+
mintNew: function (context, newPaneOptions) {
|
|
13
|
+
var kb = context.session.store;
|
|
14
|
+
var newInstance = newPaneOptions.newInstance || kb.sym(newPaneOptions.newBase);
|
|
15
|
+
var u = newInstance.uri;
|
|
16
|
+
if (u.endsWith('/')) {
|
|
17
|
+
u = u.slice(0, -1); // chop off trailer
|
|
18
|
+
} // { throw new Error('URI of new folder must end in "/" :' + u) }
|
|
19
|
+
newPaneOptions.newInstance = kb.sym(u + '/');
|
|
20
|
+
// @@@@ kludge until we can get the solid-client version working
|
|
21
|
+
// Force the folder by saving a dummy file inside it
|
|
22
|
+
return kb.fetcher
|
|
23
|
+
.webOperation('PUT', newInstance.uri + '.dummy', { contentType: 'application/octet-stream' })
|
|
24
|
+
.then(function () {
|
|
25
|
+
console.log('New folder created: ' + newInstance.uri);
|
|
26
|
+
return kb.fetcher.delete(newInstance.uri + '.dummy');
|
|
27
|
+
})
|
|
28
|
+
.then(function () {
|
|
29
|
+
console.log('Dummy file deleted : ' + newInstance.uri + '.dummy');
|
|
30
|
+
/*
|
|
31
|
+
return kb.fetcher.createContainer(parentURI, folderName) // Not BOTH ways
|
|
32
|
+
})
|
|
33
|
+
.then(function () {
|
|
34
|
+
*/
|
|
35
|
+
console.log('New container created: ' + newInstance.uri);
|
|
36
|
+
return newPaneOptions;
|
|
37
|
+
});
|
|
38
|
+
},
|
|
39
|
+
label: function (subject, context) {
|
|
40
|
+
var kb = context.session.store;
|
|
41
|
+
var n = kb.each(subject, UI.ns.ldp('contains')).length;
|
|
42
|
+
if (n > 0) {
|
|
43
|
+
return 'Contents (' + n + ')'; // Show how many in hover text
|
|
44
|
+
}
|
|
45
|
+
if (kb.holds(subject, UI.ns.rdf('type'), UI.ns.ldp('Container'))) {
|
|
46
|
+
// It is declared as being a container
|
|
47
|
+
return 'Container (0)';
|
|
48
|
+
}
|
|
49
|
+
return null; // Suppress pane otherwise
|
|
50
|
+
},
|
|
51
|
+
// Render a file folder in a LDP/solid system
|
|
52
|
+
render: function (subject, context) {
|
|
53
|
+
function noHiddenFiles(obj) {
|
|
54
|
+
// @@ This hiddenness should actually be server defined
|
|
55
|
+
var pathEnd = obj.uri.slice(obj.dir().uri.length);
|
|
56
|
+
return !(pathEnd.startsWith('.') ||
|
|
57
|
+
pathEnd.endsWith('.acl') ||
|
|
58
|
+
pathEnd.endsWith('~'));
|
|
59
|
+
}
|
|
60
|
+
function refresh() {
|
|
61
|
+
var objs = kb.each(subject, UI.ns.ldp('contains')).filter(noHiddenFiles);
|
|
62
|
+
objs = objs.map(function (obj) { return [UI.utils.label(obj).toLowerCase(), obj]; });
|
|
63
|
+
objs.sort(); // Sort by label case-insensitive
|
|
64
|
+
objs = objs.map(function (pair) { return pair[1]; });
|
|
65
|
+
UI.utils.syncTableToArray(mainTable, objs, function (obj) {
|
|
66
|
+
var st = kb.statementsMatching(subject, UI.ns.ldp('contains'), obj)[0];
|
|
67
|
+
var defaultpropview = outliner.VIEWAS_boring_default;
|
|
68
|
+
var tr = outliner.propertyTR(dom, st, false);
|
|
69
|
+
tr.firstChild.textContent = ''; // Was initialized to 'Contains'
|
|
70
|
+
tr.firstChild.style.cssText += 'min-width: 3em;';
|
|
71
|
+
tr.appendChild(outliner.outlineObjectTD(obj, defaultpropview, undefined, st));
|
|
72
|
+
// UI.widgets.makeDraggable(tr, obj)
|
|
73
|
+
return tr;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
var dom = context.dom;
|
|
77
|
+
var outliner = context.getOutliner(dom);
|
|
78
|
+
var kb = context.session.store;
|
|
79
|
+
var mainTable; // This is a live synced table
|
|
80
|
+
var div = dom.createElement('div');
|
|
81
|
+
div.setAttribute('class', 'instancePane');
|
|
82
|
+
var paneStyle = UI.style.folderPaneStyle || 'border-top: solid 1px #777; border-bottom: solid 1px #777; margin-top: 0.5em; margin-bottom: 0.5em;';
|
|
83
|
+
div.setAttribute('style', paneStyle);
|
|
84
|
+
var thisDir = subject.uri.endsWith('/') ? subject.uri : subject.uri + '/';
|
|
85
|
+
var indexThing = kb.sym(thisDir + 'index.ttl#this');
|
|
86
|
+
if (kb.holds(subject, UI.ns.ldp('contains'), indexThing.doc())) {
|
|
87
|
+
console.log('View of folder will be view of indexThing. Loading ' + indexThing);
|
|
88
|
+
var packageDiv_1 = div.appendChild(dom.createElement('div'));
|
|
89
|
+
packageDiv_1.style.cssText = 'border-top: 0.2em solid #ccc;'; // Separate folder views above from package views below
|
|
90
|
+
kb.fetcher.load(indexThing.doc()).then(function () {
|
|
91
|
+
mainTable = packageDiv_1.appendChild(dom.createElement('table'));
|
|
92
|
+
context
|
|
93
|
+
.getOutliner(dom)
|
|
94
|
+
.GotoSubject(indexThing, true, undefined, false, undefined, mainTable);
|
|
95
|
+
});
|
|
96
|
+
return div;
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
mainTable = div.appendChild(dom.createElement('table'));
|
|
100
|
+
mainTable.refresh = refresh;
|
|
101
|
+
refresh();
|
|
102
|
+
// addDownstreamChangeListener is a high level function which when someone else changes the resource,
|
|
103
|
+
// reloads it into the kb, then must call addDownstreamChangeListener to be able to update the folder pane.
|
|
104
|
+
kb.updater.addDownstreamChangeListener(subject, refresh); // Update store and call me if folder changes
|
|
105
|
+
}
|
|
106
|
+
// Allow user to create new things within the folder
|
|
107
|
+
var creationDiv = div.appendChild(dom.createElement('div'));
|
|
108
|
+
var me = UI.authn.currentUser(); // @@ respond to login events
|
|
109
|
+
var creationContext = {
|
|
110
|
+
folder: subject,
|
|
111
|
+
div: creationDiv,
|
|
112
|
+
dom: dom,
|
|
113
|
+
statusArea: creationDiv,
|
|
114
|
+
me: me
|
|
115
|
+
};
|
|
116
|
+
creationContext.refreshTarget = mainTable;
|
|
117
|
+
UI.authn
|
|
118
|
+
.filterAvailablePanes(context.session.paneRegistry.list)
|
|
119
|
+
.then(function (relevantPanes) {
|
|
120
|
+
UI.create.newThingUI(creationContext, context, relevantPanes); // Have to pass panes down newUI
|
|
121
|
+
UI.aclControl.preventBrowserDropEvents(dom);
|
|
122
|
+
var explictDropIcon = false;
|
|
123
|
+
var target;
|
|
124
|
+
if (explictDropIcon) {
|
|
125
|
+
var iconStyleFound = creationDiv.firstChild.style.cssText;
|
|
126
|
+
target = creationDiv.insertBefore(dom.createElement('img'), creationDiv.firstChild);
|
|
127
|
+
target.style.cssText = iconStyleFound;
|
|
128
|
+
target.setAttribute('src', UI.icons.iconBase + 'noun_748003.svg');
|
|
129
|
+
target.setAttribute('style', 'width: 2em; height: 2em'); // Safari says target.style is read-only
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
target = creationDiv.firstChild; // Overload drop target semantics onto the plus sign
|
|
133
|
+
}
|
|
134
|
+
// /////////// Allow new file to be Uploaded
|
|
135
|
+
UI.widgets.makeDropTarget(target, null, droppedFileHandler);
|
|
136
|
+
});
|
|
137
|
+
return div;
|
|
138
|
+
function droppedFileHandler(files) {
|
|
139
|
+
UI.widgets.uploadFiles(kb.fetcher, files, subject.uri, subject.uri, function (file, uri) {
|
|
140
|
+
// A file has been uploaded
|
|
141
|
+
var destination = kb.sym(uri);
|
|
142
|
+
console.log(' Upload: put OK: ' + destination);
|
|
143
|
+
kb.add(subject, UI.ns.ldp('contains'), destination, subject.doc());
|
|
144
|
+
mainTable.refresh();
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
// ends
|
|
150
|
+
//# sourceMappingURL=folderPane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"folderPane.js","sourceRoot":"","sources":["../src/folderPane.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAGH,6BAA8B;AAE9B,MAAM,CAAC,OAAO,GAAG;IACf,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,GAAG,0BAA0B;IACpD,IAAI,EAAE,QAAQ;IAEd,yCAAyC;IACzC,OAAO,EAAE,UAAU,OAAO,EAAE,cAAc;QACxC,IAAM,EAAE,GAAG,OAAO,CAAC,OAAO,CAAC,KAAK,CAAA;QAChC,IAAM,WAAW,GACf,cAAc,CAAC,WAAW,IAAI,EAAE,CAAC,GAAG,CAAC,cAAc,CAAC,OAAO,CAAC,CAAA;QAC9D,IAAI,CAAC,GAAG,WAAW,CAAC,GAAG,CAAA;QACvB,IAAI,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACnB,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA,CAAC,mBAAmB;SACvC,CAAC,iEAAiE;QACnE,cAAc,CAAC,WAAW,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,GAAG,CAAC,CAAA;QAE5C,gEAAgE;QAChE,oDAAoD;QACpD,OAAO,EAAE,CAAC,OAAO;aACd,YAAY,CAAC,KAAK,EAAE,WAAW,CAAC,GAAG,GAAG,QAAQ,EAAE,EAAE,WAAW,EAAE,0BAA0B,EAAE,CAAC;aAC5F,IAAI,CAAC;YACJ,OAAO,CAAC,GAAG,CAAC,sBAAsB,GAAG,WAAW,CAAC,GAAG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AAC,UAAU,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAA;gBAClE,SAAS,CAAC,OAAO,EAAE,CAAA;YACrB,CAAC,CACF,CAAA;QACH,CAAC;IACH,CAAC;CACF,CAAA;AACD,OAAO"}
|
package/package.json
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "folder-pane",
|
|
3
|
-
"version": "2.4.9
|
|
3
|
+
"version": "2.4.9",
|
|
4
4
|
"description": "Solid-compatible Panes: File browser",
|
|
5
|
-
"main": "./folderPane.js",
|
|
5
|
+
"main": "./lib/folderPane.js",
|
|
6
6
|
"scripts": {
|
|
7
|
-
"build": "
|
|
8
|
-
"lint": "eslint '
|
|
9
|
-
"lint-fix": "eslint '
|
|
7
|
+
"build": "tsc",
|
|
8
|
+
"lint": "eslint './src'",
|
|
9
|
+
"lint-fix": "eslint './src' --fix",
|
|
10
10
|
"test": "npm run lint",
|
|
11
|
+
"check": "npm run lint && npm run build && npm run test",
|
|
11
12
|
"prepublishOnly": "npm test",
|
|
12
13
|
"postpublish": "git push origin main --follow-tags"
|
|
13
14
|
},
|
|
15
|
+
"files": [
|
|
16
|
+
"/lib"
|
|
17
|
+
],
|
|
14
18
|
"repository": {
|
|
15
19
|
"type": "git",
|
|
16
20
|
"url": "https://github.com/solid/folder-pane"
|
|
@@ -34,13 +38,20 @@
|
|
|
34
38
|
},
|
|
35
39
|
"homepage": "https://github.com/solid/folder-pane",
|
|
36
40
|
"dependencies": {
|
|
37
|
-
"solid-ui": "^2.4.
|
|
41
|
+
"solid-ui": "^2.4.10"
|
|
38
42
|
},
|
|
39
43
|
"devDependencies": {
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
+
"@babel/core": "^7.15.8",
|
|
45
|
+
"@babel/preset-env": "^7.15.8",
|
|
46
|
+
"@babel/preset-typescript": "^7.15.0",
|
|
47
|
+
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
48
|
+
"@typescript-eslint/parser": "^5.0.0",
|
|
49
|
+
"eslint": "^7.32.0",
|
|
50
|
+
"husky": "^7.0.2",
|
|
51
|
+
"lint-staged": "^11.2.3",
|
|
52
|
+
"prettier": "^2.4.1",
|
|
53
|
+
"standard": "^16.0.4",
|
|
54
|
+
"typescript": "^4.4.4"
|
|
44
55
|
},
|
|
45
56
|
"husky": {
|
|
46
57
|
"hooks": {
|
package/.eslintrc
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"env": {
|
|
3
|
-
"browser": true,
|
|
4
|
-
"es6": true,
|
|
5
|
-
"node": true
|
|
6
|
-
},
|
|
7
|
-
"extends": "standard",
|
|
8
|
-
"globals": {
|
|
9
|
-
"Atomics": "readonly",
|
|
10
|
-
"SharedArrayBuffer": "readonly"
|
|
11
|
-
},
|
|
12
|
-
"rules": {
|
|
13
|
-
"no-unused-vars": ["warn", {
|
|
14
|
-
"argsIgnorePattern": "^_",
|
|
15
|
-
"varsIgnorePattern": "^_"
|
|
16
|
-
}]
|
|
17
|
-
}
|
|
18
|
-
}
|
package/.nvmrc
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
v12.7.0
|
package/folderPane.js
DELETED
|
@@ -1,201 +0,0 @@
|
|
|
1
|
-
/* Folder pane
|
|
2
|
-
**
|
|
3
|
-
** This outline pane lists the members of a folder
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
var UI = require('solid-ui')
|
|
7
|
-
var ns = UI.ns
|
|
8
|
-
|
|
9
|
-
const $rdf = UI.rdf
|
|
10
|
-
|
|
11
|
-
module.exports = {
|
|
12
|
-
icon: UI.icons.iconBase + 'noun_973694_expanded.svg',
|
|
13
|
-
|
|
14
|
-
name: 'folder',
|
|
15
|
-
|
|
16
|
-
// Create a new folder in a Solid system,
|
|
17
|
-
mintNew: function (context, newPaneOptions) {
|
|
18
|
-
var kb = context.session.store
|
|
19
|
-
var newInstance =
|
|
20
|
-
newPaneOptions.newInstance || kb.sym(newPaneOptions.newBase)
|
|
21
|
-
var u = newInstance.uri
|
|
22
|
-
if (u.endsWith('/')) {
|
|
23
|
-
u = u.slice(0, -1) // chop off trailer
|
|
24
|
-
} // { throw new Error('URI of new folder must end in "/" :' + u) }
|
|
25
|
-
newPaneOptions.newInstance = kb.sym(u + '/')
|
|
26
|
-
|
|
27
|
-
// @@@@ kludge until we can get the solid-client version working
|
|
28
|
-
// Force the folder by saving a dummy file inside it
|
|
29
|
-
return kb.fetcher
|
|
30
|
-
.webOperation('PUT', newInstance.uri + '.dummy', { contentType: 'application/octet-stream' })
|
|
31
|
-
.then(function () {
|
|
32
|
-
console.log('New folder created: ' + newInstance.uri)
|
|
33
|
-
|
|
34
|
-
return kb.fetcher.delete(newInstance.uri + '.dummy')
|
|
35
|
-
})
|
|
36
|
-
.then(function () {
|
|
37
|
-
console.log('Dummy file deleted : ' + newInstance.uri + '.dummy')
|
|
38
|
-
/*
|
|
39
|
-
return kb.fetcher.createContainer(parentURI, folderName) // Not BOTH ways
|
|
40
|
-
})
|
|
41
|
-
.then(function () {
|
|
42
|
-
*/
|
|
43
|
-
console.log('New container created: ' + newInstance.uri)
|
|
44
|
-
return newPaneOptions
|
|
45
|
-
})
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
label: function (subject, context) {
|
|
49
|
-
var kb = context.session.store
|
|
50
|
-
var n = kb.each(subject, ns.ldp('contains')).length
|
|
51
|
-
if (n > 0) {
|
|
52
|
-
return 'Contents (' + n + ')' // Show how many in hover text
|
|
53
|
-
}
|
|
54
|
-
if (kb.holds(subject, ns.rdf('type'), ns.ldp('Container'))) {
|
|
55
|
-
// It is declared as being a container
|
|
56
|
-
return 'Container (0)'
|
|
57
|
-
}
|
|
58
|
-
return null // Suppress pane otherwise
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
// Render a file folder in a LDP/solid system
|
|
62
|
-
|
|
63
|
-
render: function (subject, context) {
|
|
64
|
-
var dom = context.dom
|
|
65
|
-
var outliner = context.getOutliner(dom)
|
|
66
|
-
var kb = context.session.store
|
|
67
|
-
var mainTable // This is a live synced table
|
|
68
|
-
/*
|
|
69
|
-
var complain = function complain (message, color) {
|
|
70
|
-
var pre = dom.createElement('pre')
|
|
71
|
-
console.log(message)
|
|
72
|
-
pre.setAttribute('style', 'background-color: ' + color || '#eed' + ';')
|
|
73
|
-
div.appendChild(pre)
|
|
74
|
-
pre.appendChild(dom.createTextNode(message))
|
|
75
|
-
}
|
|
76
|
-
*/
|
|
77
|
-
var div = dom.createElement('div')
|
|
78
|
-
div.setAttribute('class', 'instancePane')
|
|
79
|
-
div.setAttribute(
|
|
80
|
-
'style',
|
|
81
|
-
' border-top: solid 1px #777; border-bottom: solid 1px #777; margin-top: 0.5em; margin-bottom: 0.5em '
|
|
82
|
-
)
|
|
83
|
-
|
|
84
|
-
// If this is an LDP container just list the directory
|
|
85
|
-
|
|
86
|
-
var noHiddenFiles = function (obj) {
|
|
87
|
-
// @@ This hiddenness should actually be server defined
|
|
88
|
-
var pathEnd = obj.uri.slice(obj.dir().uri.length)
|
|
89
|
-
return !(
|
|
90
|
-
pathEnd.startsWith('.') ||
|
|
91
|
-
pathEnd.endsWith('.acl') ||
|
|
92
|
-
pathEnd.endsWith('~')
|
|
93
|
-
)
|
|
94
|
-
}
|
|
95
|
-
const thisDir = subject.uri.endsWith('/') ? subject.uri : subject.uri + '/'
|
|
96
|
-
const indexThing = kb.sym(thisDir + 'index.ttl#this')
|
|
97
|
-
if (kb.holds(subject, ns.ldp('contains'), indexThing.doc())) {
|
|
98
|
-
console.log(
|
|
99
|
-
'View of folder will be view of indexThing. Loading ' + indexThing
|
|
100
|
-
)
|
|
101
|
-
const packageDiv = div.appendChild(dom.createElement('div'))
|
|
102
|
-
packageDiv.style.cssText = 'border-top: 0.2em solid #ccc;' // Separate folder views above from package views below
|
|
103
|
-
kb.fetcher.load(indexThing.doc()).then(function () {
|
|
104
|
-
mainTable = packageDiv.appendChild(dom.createElement('table'))
|
|
105
|
-
context
|
|
106
|
-
.getOutliner(dom)
|
|
107
|
-
.GotoSubject(indexThing, true, undefined, false, undefined, mainTable)
|
|
108
|
-
})
|
|
109
|
-
return div
|
|
110
|
-
} else {
|
|
111
|
-
// check folder text/turtle has been loaded
|
|
112
|
-
async function loadFolder () {
|
|
113
|
-
if (!kb.anyStatementMatching(subject, ns.rdf('type'), ns.ldp('Container'), subject.doc())) {
|
|
114
|
-
return kb.fetcher
|
|
115
|
-
.webOperation('GET', subject.uri, kb.fetcher.initFetchOptions(subject.uri, { headers: { accept: 'text/turtle' } }))
|
|
116
|
-
.then(response => {
|
|
117
|
-
$rdf.parse(response.responseText, kb, subject.uri, 'text/turtle')
|
|
118
|
-
})
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
mainTable = div.appendChild(dom.createElement('table'))
|
|
122
|
-
var refresh = async function () {
|
|
123
|
-
await loadFolder()
|
|
124
|
-
var objs = kb.each(subject, ns.ldp('contains')).filter(noHiddenFiles)
|
|
125
|
-
objs = objs.map(obj => [UI.utils.label(obj).toLowerCase(), obj])
|
|
126
|
-
objs.sort() // Sort by label case-insensitive
|
|
127
|
-
objs = objs.map(pair => pair[1])
|
|
128
|
-
UI.utils.syncTableToArray(mainTable, objs, function (obj) {
|
|
129
|
-
const st = kb.statementsMatching(subject, ns.ldp('contains'), obj)[0]
|
|
130
|
-
const defaultpropview = outliner.VIEWAS_boring_default
|
|
131
|
-
const tr = outliner.propertyTR(dom, st, false)
|
|
132
|
-
tr.firstChild.textContent = '' // Was initialized to 'Contains'
|
|
133
|
-
tr.firstChild.style.cssText += 'min-width: 3em;'
|
|
134
|
-
tr.appendChild(
|
|
135
|
-
outliner.outlineObjectTD(obj, defaultpropview, undefined, st)
|
|
136
|
-
)
|
|
137
|
-
// UI.widgets.makeDraggable(tr, obj)
|
|
138
|
-
return tr
|
|
139
|
-
})
|
|
140
|
-
}
|
|
141
|
-
mainTable.refresh = refresh
|
|
142
|
-
refresh()
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// Allow user to create new things within the folder
|
|
146
|
-
var creationDiv = div.appendChild(dom.createElement('div'))
|
|
147
|
-
var me = UI.authn.currentUser()
|
|
148
|
-
var creationContext = {
|
|
149
|
-
folder: subject,
|
|
150
|
-
div: creationDiv,
|
|
151
|
-
dom: dom,
|
|
152
|
-
statusArea: creationDiv,
|
|
153
|
-
me: me
|
|
154
|
-
}
|
|
155
|
-
creationContext.refreshTarget = mainTable
|
|
156
|
-
UI.authn
|
|
157
|
-
.filterAvailablePanes(context.session.paneRegistry.list)
|
|
158
|
-
.then(function (relevantPanes) {
|
|
159
|
-
UI.create.newThingUI(creationContext, context, relevantPanes) // Have to pass panes down newUI
|
|
160
|
-
|
|
161
|
-
UI.aclControl.preventBrowserDropEvents(dom)
|
|
162
|
-
|
|
163
|
-
const explictDropIcon = false
|
|
164
|
-
var target
|
|
165
|
-
if (explictDropIcon) {
|
|
166
|
-
const iconStyleFound = creationDiv.firstChild.style.cssText
|
|
167
|
-
target = creationDiv.insertBefore(
|
|
168
|
-
dom.createElement('img'),
|
|
169
|
-
creationDiv.firstChild
|
|
170
|
-
)
|
|
171
|
-
target.style.cssText = iconStyleFound
|
|
172
|
-
target.setAttribute('src', UI.icons.iconBase + 'noun_748003.svg')
|
|
173
|
-
target.setAttribute('style', 'width: 2em; height: 2em') // Safari says target.style is read-only
|
|
174
|
-
} else {
|
|
175
|
-
target = creationDiv.firstChild // Overload drop target semantics onto the plus sign
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// /////////// Allow new file to be Uploaded
|
|
179
|
-
UI.widgets.makeDropTarget(target, null, droppedFileHandler)
|
|
180
|
-
})
|
|
181
|
-
|
|
182
|
-
return div
|
|
183
|
-
|
|
184
|
-
function droppedFileHandler (files) {
|
|
185
|
-
UI.widgets.uploadFiles(
|
|
186
|
-
kb.fetcher,
|
|
187
|
-
files,
|
|
188
|
-
subject.uri,
|
|
189
|
-
subject.uri,
|
|
190
|
-
function (file, uri) {
|
|
191
|
-
// A file has been uploaded
|
|
192
|
-
const destination = kb.sym(uri)
|
|
193
|
-
console.log(' Upload: put OK: ' + destination)
|
|
194
|
-
kb.add(subject, ns.ldp('contains'), destination, subject.doc())
|
|
195
|
-
mainTable.refresh()
|
|
196
|
-
}
|
|
197
|
-
)
|
|
198
|
-
}
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
// ends
|