solid-ui 2.4.23 → 2.4.24
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/dist/main.js +2159 -5039
- package/dist/main.js.map +1 -1
- package/lib/acl/access-controller.js +4 -67
- package/lib/acl/access-controller.js.map +1 -1
- package/lib/acl/access-groups.js +59 -137
- package/lib/acl/access-groups.js.map +1 -1
- package/lib/acl/acl-control.js +14 -54
- package/lib/acl/acl-control.js.map +1 -1
- package/lib/acl/acl.js +32 -107
- package/lib/acl/acl.js.map +1 -1
- package/lib/acl/add-agent-buttons.js +0 -92
- package/lib/acl/add-agent-buttons.js.map +1 -1
- package/lib/acl/index.js +1 -3
- package/lib/acl/index.js.map +1 -1
- package/lib/acl/styles.js +1 -2
- package/lib/acl/styles.js.map +1 -1
- package/lib/chat/bookmarks.js +8 -80
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +109 -180
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +6 -91
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +33 -185
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +37 -150
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +23 -96
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +33 -91
- package/lib/chat/thread.js.map +1 -1
- package/lib/create/create.js +19 -51
- package/lib/create/create.js.map +1 -1
- package/lib/create/index.js +0 -2
- package/lib/create/index.js.map +1 -1
- package/lib/debug.js +0 -8
- package/lib/debug.js.map +1 -1
- package/lib/folders.js +4 -27
- package/lib/folders.js.map +1 -1
- package/lib/footer/index.js +2 -24
- package/lib/footer/index.js.map +1 -1
- package/lib/footer/styleMap.js.map +1 -1
- package/lib/header/empty-profile.js.map +1 -1
- package/lib/header/index.js +3 -72
- package/lib/header/index.js.map +1 -1
- package/lib/header/styleMap.js +4 -3
- package/lib/header/styleMap.js.map +1 -1
- package/lib/iconBase.js +3 -4
- package/lib/iconBase.js.map +1 -1
- package/lib/index.js +5 -46
- package/lib/index.js.map +1 -1
- package/lib/jss/index.js +3 -9
- package/lib/jss/index.js.map +1 -1
- package/lib/log.js +15 -51
- package/lib/log.js.map +1 -1
- package/lib/login/login.js +74 -303
- package/lib/login/login.js.map +1 -1
- package/lib/matrix/index.js +0 -2
- package/lib/matrix/index.js.map +1 -1
- package/lib/matrix/matrix.js +7 -55
- package/lib/matrix/matrix.js.map +1 -1
- package/lib/media/index.js +0 -2
- package/lib/media/index.js.map +1 -1
- package/lib/media/media-capture.js +13 -33
- package/lib/media/media-capture.js.map +1 -1
- package/lib/messageArea.js +23 -64
- package/lib/messageArea.js.map +1 -1
- package/lib/noun_Camera_1618446_000000.js.map +1 -1
- package/lib/ns.js +5 -7
- package/lib/ns.js.map +1 -1
- package/lib/pad.js +48 -234
- package/lib/pad.js.map +1 -1
- package/lib/participation.js +10 -65
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +21 -42
- package/lib/preferences.js.map +1 -1
- package/lib/signup/config-default.js +1 -8
- package/lib/signup/config-default.js.map +1 -1
- package/lib/signup/signup.js +6 -13
- package/lib/signup/signup.js.map +1 -1
- package/lib/stories/decorators.js +0 -2
- package/lib/stories/decorators.js.map +1 -1
- package/lib/style.js +8 -5
- package/lib/style.js.map +1 -1
- package/lib/style_multiSelect.js +1 -5
- package/lib/style_multiSelect.js.map +1 -1
- package/lib/table.js +309 -322
- package/lib/table.js.map +1 -1
- package/lib/tabs.js +20 -100
- package/lib/tabs.js.map +1 -1
- package/lib/utils/headerFooterHelpers.js +4 -52
- package/lib/utils/headerFooterHelpers.js.map +1 -1
- package/lib/utils/index.js +41 -135
- package/lib/utils/index.js.map +1 -1
- package/lib/utils/label.js +13 -34
- package/lib/utils/label.js.map +1 -1
- package/lib/versionInfo.js +4 -4
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/buttons/iconLinks.js +0 -8
- package/lib/widgets/buttons/iconLinks.js.map +1 -1
- package/lib/widgets/buttons.js +115 -291
- package/lib/widgets/buttons.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +12 -41
- package/lib/widgets/dragAndDrop.js.map +1 -1
- package/lib/widgets/error.js +3 -9
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteBar.js +8 -71
- package/lib/widgets/forms/autocomplete/autocompleteBar.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompleteField.js +13 -65
- package/lib/widgets/forms/autocomplete/autocompleteField.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +15 -107
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/autocomplete/language.js +6 -55
- package/lib/widgets/forms/autocomplete/language.js.map +1 -1
- package/lib/widgets/forms/autocomplete/publicData.js +12 -131
- package/lib/widgets/forms/autocomplete/publicData.js.map +1 -1
- package/lib/widgets/forms/basic.js +12 -55
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/comment.js +1 -15
- package/lib/widgets/forms/comment.js.map +1 -1
- package/lib/widgets/forms/fieldFunction.js +3 -16
- package/lib/widgets/forms/fieldFunction.js.map +1 -1
- package/lib/widgets/forms/fieldParams.js +0 -12
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms/formStyle.js +1 -14
- package/lib/widgets/forms/formStyle.js.map +1 -1
- package/lib/widgets/forms.js +70 -474
- package/lib/widgets/forms.js.map +1 -1
- package/lib/widgets/index.js +0 -21
- package/lib/widgets/index.js.map +1 -1
- package/lib/widgets/multiSelect.js +48 -171
- package/lib/widgets/multiSelect.js.map +1 -1
- package/lib/widgets/peoplePicker.js +20 -90
- package/lib/widgets/peoplePicker.js.map +1 -1
- package/lib/widgets/widgetHelpers.js +2 -9
- package/lib/widgets/widgetHelpers.js.map +1 -1
- package/package.json +28 -28
package/lib/widgets/buttons.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
@@ -45,37 +44,21 @@ exports.setName = setName;
|
|
|
45
44
|
exports.shortDate = shortDate;
|
|
46
45
|
exports.shortTime = shortTime;
|
|
47
46
|
exports.timestamp = timestamp;
|
|
48
|
-
|
|
49
47
|
var _rdflib = require("rdflib");
|
|
50
|
-
|
|
51
48
|
var _iconBase = require("../iconBase");
|
|
52
|
-
|
|
53
49
|
var ns = _interopRequireWildcard(require("../ns"));
|
|
54
|
-
|
|
55
50
|
var style = _interopRequireWildcard(require("../style"));
|
|
56
|
-
|
|
57
51
|
var debug = _interopRequireWildcard(require("../debug"));
|
|
58
|
-
|
|
59
52
|
var _log = require("../log");
|
|
60
|
-
|
|
61
53
|
var _jss = require("../jss");
|
|
62
|
-
|
|
63
54
|
var _dragAndDrop = require("./dragAndDrop");
|
|
64
|
-
|
|
65
55
|
var _solidLogic = require("solid-logic");
|
|
66
|
-
|
|
67
56
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
68
|
-
|
|
69
57
|
var _error = require("./error");
|
|
70
|
-
|
|
71
58
|
var _widgetHelpers = require("./widgetHelpers");
|
|
72
|
-
|
|
73
59
|
var _iconLinks = require("./buttons/iconLinks");
|
|
74
|
-
|
|
75
60
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
76
|
-
|
|
77
61
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
78
|
-
|
|
79
62
|
/* Buttons
|
|
80
63
|
*/
|
|
81
64
|
|
|
@@ -85,105 +68,90 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
|
85
68
|
*/
|
|
86
69
|
|
|
87
70
|
/* global alert */
|
|
71
|
+
|
|
88
72
|
var iconBase = _iconBase.icons.iconBase;
|
|
89
73
|
var cancelIconURI = iconBase + 'noun_1180156.svg'; // black X
|
|
90
|
-
|
|
91
74
|
var checkIconURI = iconBase + 'noun_1180158.svg'; // green checkmark; Continue
|
|
92
75
|
|
|
93
76
|
function getStatusArea(context) {
|
|
94
77
|
var box = context && context.statusArea || context && context.div || null;
|
|
95
78
|
if (box) return box;
|
|
96
79
|
var dom = context && context.dom;
|
|
97
|
-
|
|
98
80
|
if (!dom && typeof document !== 'undefined') {
|
|
99
81
|
dom = document;
|
|
100
82
|
}
|
|
101
|
-
|
|
102
83
|
if (dom) {
|
|
103
84
|
var body = dom.getElementsByTagName('body')[0];
|
|
104
85
|
box = dom.createElement('div');
|
|
105
86
|
body.insertBefore(box, body.firstElementChild);
|
|
106
|
-
|
|
107
87
|
if (context) {
|
|
108
88
|
context.statusArea = box;
|
|
109
89
|
}
|
|
110
|
-
|
|
111
90
|
return box;
|
|
112
91
|
}
|
|
113
|
-
|
|
114
92
|
return null;
|
|
115
93
|
}
|
|
94
|
+
|
|
116
95
|
/**
|
|
117
96
|
* Display an error message block
|
|
118
97
|
*/
|
|
119
|
-
|
|
120
|
-
|
|
121
98
|
function complain(context, err) {
|
|
122
99
|
if (!err) return; // only if error
|
|
123
|
-
|
|
124
100
|
var ele = getStatusArea(context);
|
|
125
101
|
debug.log('Complaint: ' + err);
|
|
126
102
|
if (ele) ele.appendChild((0, _error.errorMessageBlock)(context && context.dom || document, err));else alert(err);
|
|
127
103
|
}
|
|
104
|
+
|
|
128
105
|
/**
|
|
129
106
|
* Remove all the children of an HTML element
|
|
130
107
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
108
|
function clearElement(ele) {
|
|
134
109
|
while (ele.firstChild) {
|
|
135
110
|
ele.removeChild(ele.firstChild);
|
|
136
111
|
}
|
|
137
|
-
|
|
138
112
|
return ele;
|
|
139
113
|
}
|
|
114
|
+
|
|
140
115
|
/**
|
|
141
116
|
* To figure out the log URI from the full URI used to invoke the reasoner
|
|
142
117
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
118
|
function extractLogURI(fullURI) {
|
|
146
119
|
var logPos = fullURI.search(/logFile=/);
|
|
147
120
|
var rulPos = fullURI.search(/&rulesFile=/);
|
|
148
121
|
return fullURI.substring(logPos + 8, rulPos);
|
|
149
122
|
}
|
|
123
|
+
|
|
150
124
|
/**
|
|
151
125
|
* By default, converts e.g. '2020-02-19T19:35:28.557Z' to '19:35'
|
|
152
126
|
* if today is 19 Feb 2020, and to 'Feb 19' if not.
|
|
153
127
|
* @@@ TODO This needs to be changed to local time
|
|
154
128
|
* @param noTime Return a string like 'Feb 19' even if it's today.
|
|
155
129
|
*/
|
|
156
|
-
|
|
157
|
-
|
|
158
130
|
function shortDate(str, noTime) {
|
|
159
131
|
if (!str) return '???';
|
|
160
132
|
var month = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
161
|
-
|
|
162
133
|
try {
|
|
163
|
-
var nowZ = new Date().toISOString();
|
|
134
|
+
var nowZ = new Date().toISOString();
|
|
135
|
+
// var nowZ = $rdf.term(now).value
|
|
164
136
|
// var n = now.getTimezoneOffset() // Minutes
|
|
165
|
-
|
|
166
137
|
if (str.slice(0, 10) === nowZ.slice(0, 10) && !noTime) {
|
|
167
138
|
return str.slice(11, 16);
|
|
168
139
|
}
|
|
169
|
-
|
|
170
140
|
if (str.slice(0, 4) === nowZ.slice(0, 4)) {
|
|
171
141
|
return month[parseInt(str.slice(5, 7), 10) - 1] + ' ' + parseInt(str.slice(8, 10), 10);
|
|
172
142
|
}
|
|
173
|
-
|
|
174
143
|
return str.slice(0, 10);
|
|
175
144
|
} catch (e) {
|
|
176
145
|
return 'shortdate:' + e;
|
|
177
146
|
}
|
|
178
147
|
}
|
|
148
|
+
|
|
179
149
|
/**
|
|
180
150
|
* Format a date and time
|
|
181
151
|
* @param date for instance `new Date()`
|
|
182
152
|
* @param format for instance '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}'
|
|
183
153
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
184
154
|
*/
|
|
185
|
-
|
|
186
|
-
|
|
187
155
|
function formatDateTime(date, format) {
|
|
188
156
|
return format.split('{').map(function (s) {
|
|
189
157
|
var k = s.split('}')[0];
|
|
@@ -197,52 +165,47 @@ function formatDateTime(date, format) {
|
|
|
197
165
|
return s ? ('000' + (date['get' + k]() + (d[k] || 0))).slice(-(width[k] || 2)) + s.split('}')[1] : '';
|
|
198
166
|
}).join('');
|
|
199
167
|
}
|
|
168
|
+
|
|
200
169
|
/**
|
|
201
170
|
* Get a string representation of the current time
|
|
202
171
|
* @returns for instance '2000-01-15T23:14:23.002'
|
|
203
172
|
*/
|
|
204
|
-
|
|
205
|
-
|
|
206
173
|
function timestamp() {
|
|
207
174
|
return formatDateTime(new Date(), '{FullYear}-{Month}-{Date}T{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
208
175
|
}
|
|
176
|
+
|
|
209
177
|
/**
|
|
210
178
|
* Get a short string representation of the current time
|
|
211
179
|
* @returns for instance '23:14:23.002'
|
|
212
180
|
*/
|
|
213
|
-
|
|
214
|
-
|
|
215
181
|
function shortTime() {
|
|
216
182
|
return formatDateTime(new Date(), '{Hours}:{Minutes}:{Seconds}.{Milliseconds}');
|
|
217
|
-
}
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ///////////////////// Handy UX widgets
|
|
218
186
|
|
|
219
187
|
/**
|
|
220
188
|
* Sets the best name we have and looks up a better one
|
|
221
189
|
*/
|
|
222
|
-
|
|
223
|
-
|
|
224
190
|
function setName(element, x) {
|
|
225
191
|
var kb = _solidLogic.store;
|
|
226
|
-
|
|
227
192
|
var findName = function findName(x) {
|
|
228
193
|
var name = kb.any(x, ns.vcard('fn')) || kb.any(x, ns.foaf('name')) || kb.any(x, ns.vcard('organization-name'));
|
|
229
194
|
return name ? name.value : null;
|
|
230
195
|
};
|
|
231
|
-
|
|
232
196
|
var name = x.sameTerm(ns.foaf('Agent')) ? 'Everyone' : findName(x);
|
|
233
197
|
element.textContent = name || utils.label(x);
|
|
234
|
-
|
|
235
198
|
if (!name && x.uri) {
|
|
236
199
|
if (!kb.fetcher) {
|
|
237
200
|
throw new Error('kb has no fetcher');
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
|
|
201
|
+
}
|
|
202
|
+
// Note this is only a fetch, not a lookUP of all sameAs etc
|
|
241
203
|
kb.fetcher.nowOrWhenFetched(x.doc(), undefined, function (_ok) {
|
|
242
204
|
element.textContent = findName(x) || utils.label(x); // had: (ok ? '' : '? ') +
|
|
243
205
|
});
|
|
244
206
|
}
|
|
245
207
|
}
|
|
208
|
+
|
|
246
209
|
/**
|
|
247
210
|
* Set of suitable images
|
|
248
211
|
* See also [[findImage]]
|
|
@@ -260,16 +223,13 @@ function setName(element, x) {
|
|
|
260
223
|
* * ns.foaf('depiction')
|
|
261
224
|
|
|
262
225
|
*/
|
|
263
|
-
|
|
264
|
-
|
|
265
226
|
function imagesOf(x, kb) {
|
|
266
227
|
return kb.each(x, ns.sioc('avatar')).concat(kb.each(x, ns.foaf('img'))).concat(kb.each(x, ns.vcard('logo'))).concat(kb.each(x, ns.vcard('hasPhoto'))).concat(kb.each(x, ns.vcard('photo'))).concat(kb.each(x, ns.foaf('depiction')));
|
|
267
228
|
}
|
|
229
|
+
|
|
268
230
|
/**
|
|
269
231
|
* Best logo or avatar or photo etc to represent someone or some group etc
|
|
270
232
|
*/
|
|
271
|
-
|
|
272
|
-
|
|
273
233
|
var iconForClass = {
|
|
274
234
|
// Potentially extendable by other apps, panes, etc
|
|
275
235
|
// Relative URIs to the iconBase
|
|
@@ -302,19 +262,17 @@ var iconForClass = {
|
|
|
302
262
|
'wf:Open': 'noun_17020_sans-tick.svg',
|
|
303
263
|
'wf:Closed': 'noun_17020.svg'
|
|
304
264
|
};
|
|
265
|
+
|
|
305
266
|
/**
|
|
306
267
|
* Returns the origin of the URI of a NamedNode
|
|
307
268
|
*/
|
|
308
|
-
|
|
309
269
|
exports.iconForClass = iconForClass;
|
|
310
|
-
|
|
311
270
|
function tempSite(x) {
|
|
312
271
|
// use only while one in rdflib fails with origins 2019
|
|
313
272
|
var str = x.uri.split('#')[0];
|
|
314
273
|
var p = str.indexOf('//');
|
|
315
274
|
if (p < 0) throw new Error('This URI does not have a web site part (origin)');
|
|
316
275
|
var q = str.indexOf('/', p + 2);
|
|
317
|
-
|
|
318
276
|
if (q < 0) {
|
|
319
277
|
// no third slash?
|
|
320
278
|
return str.slice(0) + '/'; // Add slash to a bare origin
|
|
@@ -322,20 +280,19 @@ function tempSite(x) {
|
|
|
322
280
|
return str.slice(0, q + 1);
|
|
323
281
|
}
|
|
324
282
|
}
|
|
283
|
+
|
|
325
284
|
/**
|
|
326
285
|
* Find an image for this thing as a class
|
|
327
286
|
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
287
|
function findImageFromURI(x) {
|
|
331
|
-
var iconDir = iconBase;
|
|
288
|
+
var iconDir = iconBase;
|
|
332
289
|
|
|
290
|
+
// Special cases from URI scheme:
|
|
333
291
|
if (typeof x !== 'string' && x.uri) {
|
|
334
292
|
if (x.uri.split('/').length === 4 && !x.uri.split('/')[1] && !x.uri.split('/')[3]) {
|
|
335
293
|
return iconDir + 'noun_15177.svg'; // App -- this is an origin
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
|
|
294
|
+
}
|
|
295
|
+
// Non-HTTP URI types imply types
|
|
339
296
|
if (x.uri.startsWith('message:') || x.uri.startsWith('mid:')) {
|
|
340
297
|
// message: is apple bug-- should be mid:
|
|
341
298
|
return iconDir + 'noun_480183.svg'; // envelope noun_567486
|
|
@@ -343,9 +300,8 @@ function findImageFromURI(x) {
|
|
|
343
300
|
|
|
344
301
|
if (x.uri.startsWith('mailto:')) {
|
|
345
302
|
return iconDir + 'noun_567486.svg'; // mailbox - an email desitination
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
303
|
+
}
|
|
304
|
+
// For HTTP(s) documents, we could look at the MIME type if we know it.
|
|
349
305
|
if (x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
|
|
350
306
|
return tempSite(x) + 'favicon.ico'; // was x.site().uri + ...
|
|
351
307
|
// Todo: make the document icon a fallback for if the favicon does not exist
|
|
@@ -355,9 +311,9 @@ function findImageFromURI(x) {
|
|
|
355
311
|
|
|
356
312
|
return null;
|
|
357
313
|
}
|
|
358
|
-
|
|
359
314
|
return iconDir + 'noun_10636_grey.svg'; // Grey Circle - some thing
|
|
360
315
|
}
|
|
316
|
+
|
|
361
317
|
/**
|
|
362
318
|
* Find something we have as explicit image data for the thing
|
|
363
319
|
* See also [[imagesOf]]
|
|
@@ -375,12 +331,9 @@ function findImageFromURI(x) {
|
|
|
375
331
|
* * ns.vcard('photo')
|
|
376
332
|
* * ns.foaf('depiction')
|
|
377
333
|
*/
|
|
378
|
-
|
|
379
|
-
|
|
380
334
|
function findImage(thing) {
|
|
381
335
|
var kb = _solidLogic.store;
|
|
382
336
|
var iconDir = iconBase;
|
|
383
|
-
|
|
384
337
|
if (thing.sameTerm(ns.foaf('Agent')) || thing.sameTerm(ns.rdf('Resource'))) {
|
|
385
338
|
return iconDir + 'noun_98053.svg'; // Globe
|
|
386
339
|
}
|
|
@@ -388,44 +341,37 @@ function findImage(thing) {
|
|
|
388
341
|
var image = kb.any(thing, ns.sioc('avatar')) || kb.any(thing, ns.foaf('img')) || kb.any(thing, ns.vcard('logo')) || kb.any(thing, ns.vcard('hasPhoto')) || kb.any(thing, ns.vcard('photo')) || kb.any(thing, ns.foaf('depiction'));
|
|
389
342
|
return image ? image.uri : null;
|
|
390
343
|
}
|
|
344
|
+
|
|
391
345
|
/**
|
|
392
346
|
* Do the best you can with the data available
|
|
393
347
|
*
|
|
394
348
|
* @return {Boolean} Are we happy with this icon?
|
|
395
349
|
* Sets src AND STYLE of the image.
|
|
396
350
|
*/
|
|
397
|
-
|
|
398
|
-
|
|
399
351
|
function trySetImage(element, thing, iconForClassMap) {
|
|
400
352
|
var kb = _solidLogic.store;
|
|
401
353
|
var explitImage = findImage(thing);
|
|
402
|
-
|
|
403
354
|
if (explitImage) {
|
|
404
355
|
element.setAttribute('src', explitImage);
|
|
405
356
|
return true;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
|
|
357
|
+
}
|
|
358
|
+
// This is one of the classes we know about - the class itself?
|
|
409
359
|
var typeIcon = iconForClassMap[thing.uri];
|
|
410
|
-
|
|
411
360
|
if (typeIcon) {
|
|
412
361
|
element.setAttribute('src', typeIcon);
|
|
413
|
-
element.style = style.classIconStyle;
|
|
362
|
+
element.style = style.classIconStyle;
|
|
363
|
+
// element.style.border = '0.1em solid green;'
|
|
414
364
|
// element.style.backgroundColor = '#eeffee' // pale green
|
|
415
|
-
|
|
416
365
|
return true;
|
|
417
366
|
}
|
|
418
|
-
|
|
419
367
|
var schemeIcon = findImageFromURI(thing);
|
|
420
|
-
|
|
421
368
|
if (schemeIcon) {
|
|
422
369
|
element.setAttribute('src', schemeIcon);
|
|
423
370
|
return true; // happy with this -- don't look it up
|
|
424
|
-
}
|
|
425
|
-
|
|
371
|
+
}
|
|
426
372
|
|
|
373
|
+
// Do we have a generic icon for something in any class its in?
|
|
427
374
|
var types = kb.findTypeURIs(thing);
|
|
428
|
-
|
|
429
375
|
for (var typeURI in types) {
|
|
430
376
|
if (iconForClassMap[typeURI]) {
|
|
431
377
|
element.setAttribute('src', iconForClassMap[typeURI]);
|
|
@@ -434,83 +380,71 @@ function trySetImage(element, thing, iconForClassMap) {
|
|
|
434
380
|
}
|
|
435
381
|
|
|
436
382
|
element.setAttribute('src', iconBase + 'noun_10636_grey.svg'); // Grey Circle - some thing
|
|
437
|
-
|
|
438
383
|
return false; // we can do better
|
|
439
384
|
}
|
|
385
|
+
|
|
440
386
|
/**
|
|
441
387
|
* ToDo: Also add icons for *properties* like home, work, email, range, domain, comment,
|
|
442
388
|
*/
|
|
443
|
-
|
|
444
|
-
|
|
445
389
|
function setImage(element, thing) {
|
|
446
390
|
// 20191230a
|
|
447
391
|
var kb = _solidLogic.store;
|
|
448
392
|
var iconForClassMap = {};
|
|
449
|
-
|
|
450
393
|
for (var k in iconForClass) {
|
|
451
394
|
var pref = k.split(':')[0];
|
|
452
395
|
var id = k.split(':')[1];
|
|
453
396
|
var theClass = ns[pref](id);
|
|
454
397
|
iconForClassMap[theClass.uri] = _rdflib.uri.join(iconForClass[k], iconBase);
|
|
455
398
|
}
|
|
456
|
-
|
|
457
399
|
var happy = trySetImage(element, thing, iconForClassMap);
|
|
458
|
-
|
|
459
400
|
if (!happy && thing.uri) {
|
|
460
401
|
if (!kb.fetcher) {
|
|
461
402
|
throw new Error('kb has no fetcher');
|
|
462
403
|
}
|
|
463
|
-
|
|
464
404
|
kb.fetcher.nowOrWhenFetched(thing.doc(), undefined, function (ok) {
|
|
465
405
|
if (ok) {
|
|
466
406
|
trySetImage(element, thing, iconForClassMap);
|
|
467
407
|
}
|
|
468
408
|
});
|
|
469
409
|
}
|
|
470
|
-
}
|
|
471
|
-
// See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
|
|
472
|
-
|
|
410
|
+
}
|
|
473
411
|
|
|
412
|
+
// If a web page, then a favicon, with a fallback to ???
|
|
413
|
+
// See, e.g., http://stackoverflow.com/questions/980855/inputting-a-default-image
|
|
474
414
|
function faviconOrDefault(dom, x) {
|
|
475
415
|
var image = dom.createElement('img');
|
|
476
416
|
image.style = style.iconStyle;
|
|
477
|
-
|
|
478
417
|
var isOrigin = function isOrigin(x) {
|
|
479
418
|
if (!x.uri) return false;
|
|
480
419
|
var parts = x.uri.split('/');
|
|
481
420
|
return parts.length === 3 || parts.length === 4 && parts[3] === '';
|
|
482
421
|
};
|
|
483
|
-
|
|
484
422
|
image.setAttribute('src', iconBase + (isOrigin(x) ? 'noun_15177.svg' : 'noun_681601.svg') // App symbol vs document
|
|
485
423
|
);
|
|
486
424
|
|
|
487
425
|
if (x.uri && x.uri.startsWith('https:') && x.uri.indexOf('#') < 0) {
|
|
488
426
|
var res = dom.createElement('object'); // favico with a fallback of a default image if no favicon
|
|
489
|
-
|
|
490
427
|
res.setAttribute('data', tempSite(x) + 'favicon.ico');
|
|
491
428
|
res.setAttribute('type', 'image/x-icon');
|
|
492
429
|
res.appendChild(image); // fallback
|
|
493
|
-
|
|
494
430
|
return res;
|
|
495
431
|
} else {
|
|
496
432
|
setImage(image, x);
|
|
497
433
|
return image;
|
|
498
434
|
}
|
|
499
435
|
}
|
|
436
|
+
|
|
500
437
|
/* Two-option dialog pop-up
|
|
501
438
|
*/
|
|
502
439
|
|
|
503
|
-
|
|
504
440
|
function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction) {
|
|
505
441
|
function removePopup() {
|
|
506
442
|
refererenceElement.parentElement.removeChild(refererenceElement);
|
|
507
443
|
}
|
|
508
|
-
|
|
509
444
|
function removePopupAndDoDeletion() {
|
|
510
445
|
removePopup();
|
|
511
446
|
deleteFunction();
|
|
512
447
|
}
|
|
513
|
-
|
|
514
448
|
var popup = dom.createElement('div');
|
|
515
449
|
popup.style = style.confirmPopupStyle;
|
|
516
450
|
popup.style.position = 'absolute';
|
|
@@ -521,7 +455,6 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
521
455
|
var affirm = dom.createElement('div');
|
|
522
456
|
affirm.style.gridColumn = '1/2';
|
|
523
457
|
affirm.style.gridRow = '1'; // @@ sigh; TS. could pass number in fact
|
|
524
|
-
|
|
525
458
|
var cancel = dom.createElement('div');
|
|
526
459
|
cancel.style.gridColumn = '1/2';
|
|
527
460
|
cancel.style.gridRow = '2';
|
|
@@ -536,7 +469,6 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
536
469
|
cancelPrompt.textContent = 'Cancel'; // @@ I18n
|
|
537
470
|
|
|
538
471
|
var affirmIcon = button(dom, _iconBase.icons.iconBase + 'noun_925021.svg', 'Delete it'); // trashcan
|
|
539
|
-
|
|
540
472
|
popup.appendChild(affirmIcon);
|
|
541
473
|
affirmIcon.style.gridRow = '1';
|
|
542
474
|
affirmIcon.style.gridColumn = '1';
|
|
@@ -547,8 +479,9 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
547
479
|
sureButtonElt.textContent = prompt;
|
|
548
480
|
popup.appendChild(sureButtonElt);
|
|
549
481
|
affirmIcon.addEventListener('click', removePopupAndDoDeletion);
|
|
550
|
-
sureButtonElt.addEventListener('click', removePopupAndDoDeletion);
|
|
482
|
+
sureButtonElt.addEventListener('click', removePopupAndDoDeletion);
|
|
551
483
|
|
|
484
|
+
// xButton.addEventListener('click', removePopup)
|
|
552
485
|
cancelPrompt.addEventListener('click', removePopup);
|
|
553
486
|
return popup;
|
|
554
487
|
}
|
|
@@ -556,28 +489,22 @@ function renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunctio
|
|
|
556
489
|
* Delete button with a check you really mean it
|
|
557
490
|
* @@ Supress check if command key held down?
|
|
558
491
|
*/
|
|
559
|
-
|
|
560
|
-
|
|
561
492
|
function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
562
493
|
function createPopup() {
|
|
563
494
|
var refererenceElement = dom.createElement('div');
|
|
564
495
|
container.insertBefore(refererenceElement, deleteButton);
|
|
565
496
|
refererenceElement.style.position = 'relative'; // Needed as reference for popup
|
|
566
|
-
|
|
567
497
|
refererenceElement.appendChild(renderDeleteConfirmPopup(dom, refererenceElement, prompt, deleteFunction));
|
|
568
498
|
}
|
|
569
|
-
|
|
570
499
|
var minusIconURI = iconBase + 'noun_2188_red.svg'; // white minus in red #cc0000 circle
|
|
571
|
-
|
|
572
500
|
var deleteButton = dom.createElement('img');
|
|
573
501
|
deleteButton.setAttribute('src', minusIconURI);
|
|
574
502
|
deleteButton.setAttribute('style', style.smallButtonStyle); // @@tsc - would set deleteButton.style
|
|
575
|
-
|
|
576
503
|
deleteButton.style["float"] = 'right'; // Historically this has alwaus floated right
|
|
577
504
|
|
|
578
505
|
var prompt = 'Remove this ' + noun;
|
|
579
|
-
deleteButton.title = prompt;
|
|
580
|
-
|
|
506
|
+
deleteButton.title = prompt;
|
|
507
|
+
// @@ In an ideal world, make use of hover an accessibility option
|
|
581
508
|
deleteButton.classList.add('hoverControlHide');
|
|
582
509
|
deleteButton.addEventListener('click', createPopup);
|
|
583
510
|
container.classList.add('hoverControl');
|
|
@@ -585,23 +512,21 @@ function deleteButtonWithCheck(dom, container, noun, deleteFunction) {
|
|
|
585
512
|
deleteButton.setAttribute('data-testid', 'deleteButtonWithCheck');
|
|
586
513
|
return deleteButton; // or button div? caller may change size of image
|
|
587
514
|
}
|
|
515
|
+
|
|
588
516
|
/**
|
|
589
517
|
* Get the button style, based on options.
|
|
590
518
|
* See https://design.inrupt.com/atomic-core/?cat=Atoms#Buttons
|
|
591
519
|
*/
|
|
592
|
-
|
|
593
|
-
|
|
594
520
|
function getButtonStyle() {
|
|
595
521
|
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
596
522
|
// default to primary color
|
|
597
523
|
var color = options.buttonColor === 'Secondary' ? '#01c9ea' : '#7c4dff';
|
|
598
524
|
var backgroundColor = color;
|
|
599
525
|
var fontColor = '#ffffff';
|
|
600
|
-
var borderColor = color;
|
|
601
|
-
|
|
526
|
+
var borderColor = color;
|
|
527
|
+
// default to primary color
|
|
602
528
|
var hoverBackgroundColor = options.buttonColor === 'Secondary' ? '#37cde6' : '#9f7dff';
|
|
603
529
|
var hoverFontColor = fontColor;
|
|
604
|
-
|
|
605
530
|
if (options.needsBorder) {
|
|
606
531
|
backgroundColor = '#ffffff';
|
|
607
532
|
fontColor = color;
|
|
@@ -609,7 +534,6 @@ function getButtonStyle() {
|
|
|
609
534
|
hoverBackgroundColor = color;
|
|
610
535
|
hoverFontColor = backgroundColor;
|
|
611
536
|
}
|
|
612
|
-
|
|
613
537
|
return {
|
|
614
538
|
'background-color': "".concat(backgroundColor),
|
|
615
539
|
color: "".concat(fontColor),
|
|
@@ -630,6 +554,7 @@ function getButtonStyle() {
|
|
|
630
554
|
}
|
|
631
555
|
};
|
|
632
556
|
}
|
|
557
|
+
|
|
633
558
|
/* Make a button
|
|
634
559
|
*
|
|
635
560
|
* @param dom - the DOM document object
|
|
@@ -639,42 +564,35 @@ function getButtonStyle() {
|
|
|
639
564
|
*
|
|
640
565
|
* @returns <dDomElement> - the button
|
|
641
566
|
*/
|
|
642
|
-
|
|
643
|
-
|
|
644
567
|
function button(dom, iconURI, text, handler) {
|
|
645
568
|
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {
|
|
646
569
|
buttonColor: 'Primary',
|
|
647
570
|
needsBorder: false
|
|
648
571
|
};
|
|
649
572
|
var button = dom.createElement('button');
|
|
650
|
-
button.setAttribute('type', 'button');
|
|
651
|
-
|
|
573
|
+
button.setAttribute('type', 'button');
|
|
574
|
+
// button.innerHTML = text // later, user preferences may make text preferred for some
|
|
652
575
|
if (iconURI) {
|
|
653
576
|
var img = button.appendChild(dom.createElement('img'));
|
|
654
577
|
img.setAttribute('src', iconURI);
|
|
655
578
|
img.setAttribute('style', 'width: 2em; height: 2em;'); // trial and error. 2em disappears
|
|
656
|
-
|
|
657
579
|
img.title = text;
|
|
658
580
|
button.setAttribute('style', style.buttonStyle);
|
|
659
581
|
} else {
|
|
660
582
|
button.textContent = text.toLocaleUpperCase();
|
|
661
|
-
|
|
662
583
|
var _style = getButtonStyle(options);
|
|
663
|
-
|
|
664
584
|
var _getClasses = (0, _jss.getClasses)(dom.head, {
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
585
|
+
textButton: _style
|
|
586
|
+
}),
|
|
587
|
+
classes = _getClasses.classes;
|
|
669
588
|
button.classList.add(classes.textButton);
|
|
670
589
|
}
|
|
671
|
-
|
|
672
590
|
if (handler) {
|
|
673
591
|
button.addEventListener('click', handler, false);
|
|
674
592
|
}
|
|
675
|
-
|
|
676
593
|
return button;
|
|
677
594
|
}
|
|
595
|
+
|
|
678
596
|
/* Make a cancel button
|
|
679
597
|
*
|
|
680
598
|
* @param dom - the DOM document object
|
|
@@ -682,11 +600,8 @@ function button(dom, iconURI, text, handler) {
|
|
|
682
600
|
*
|
|
683
601
|
* @returns <dDomElement> - the button
|
|
684
602
|
*/
|
|
685
|
-
|
|
686
|
-
|
|
687
603
|
function cancelButton(dom, handler) {
|
|
688
604
|
var b = button(dom, cancelIconURI, 'Cancel', handler);
|
|
689
|
-
|
|
690
605
|
if (b.firstChild) {
|
|
691
606
|
// sigh for tsc
|
|
692
607
|
b.firstChild.style.opacity = '0.3'; // Black X is too harsh: current language is grey X
|
|
@@ -694,6 +609,7 @@ function cancelButton(dom, handler) {
|
|
|
694
609
|
|
|
695
610
|
return b;
|
|
696
611
|
}
|
|
612
|
+
|
|
697
613
|
/* Make a continue button
|
|
698
614
|
*
|
|
699
615
|
* @param dom - the DOM document object
|
|
@@ -701,47 +617,40 @@ function cancelButton(dom, handler) {
|
|
|
701
617
|
*
|
|
702
618
|
* @returns <dDomElement> - the button
|
|
703
619
|
*/
|
|
704
|
-
|
|
705
|
-
|
|
706
620
|
function continueButton(dom, handler) {
|
|
707
621
|
return button(dom, checkIconURI, 'Continue', handler);
|
|
708
622
|
}
|
|
623
|
+
|
|
709
624
|
/* Grab a name for a new thing
|
|
710
625
|
*
|
|
711
626
|
* Form to get the name of a new thing before we create it
|
|
712
627
|
* @params theClass Misspelt to avoid clashing with the JavaScript keyword
|
|
713
628
|
* @returns: a promise of (a name or null if cancelled)
|
|
714
629
|
*/
|
|
715
|
-
|
|
716
|
-
|
|
717
630
|
function askName(dom, kb, container, predicate, theClass, noun) {
|
|
718
631
|
// eslint-disable-next-line promise/param-names
|
|
719
632
|
return new Promise(function (resolve, _reject) {
|
|
720
633
|
var form = dom.createElement('div'); // form is broken as HTML behaviour can resurface on js error
|
|
721
634
|
// classLabel = utils.label(ns.vcard('Individual'))
|
|
722
|
-
|
|
723
635
|
predicate = predicate || ns.foaf('name'); // eg 'name' in user's language
|
|
724
|
-
|
|
725
636
|
noun = noun || (theClass ? utils.label(theClass) : ' '); // eg 'folder' in users's language
|
|
726
|
-
|
|
727
637
|
var prompt = noun + ' ' + utils.label(predicate) + ': ';
|
|
728
638
|
form.appendChild(dom.createElement('p')).textContent = prompt;
|
|
729
639
|
var namefield = dom.createElement('input');
|
|
730
640
|
namefield.setAttribute('type', 'text');
|
|
731
641
|
namefield.setAttribute('size', '100');
|
|
732
642
|
namefield.setAttribute('maxLength', '2048'); // No arbitrary limits
|
|
733
|
-
|
|
734
643
|
namefield.setAttribute('style', style.textInputStyle);
|
|
735
644
|
namefield.select(); // focus next user input
|
|
736
|
-
|
|
737
645
|
form.appendChild(namefield);
|
|
738
|
-
container.appendChild(form);
|
|
646
|
+
container.appendChild(form);
|
|
647
|
+
|
|
648
|
+
// namefield.focus()
|
|
739
649
|
|
|
740
650
|
function gotName() {
|
|
741
651
|
form.parentNode.removeChild(form);
|
|
742
652
|
resolve(namefield.value.trim());
|
|
743
653
|
}
|
|
744
|
-
|
|
745
654
|
namefield.addEventListener('keyup', function (e) {
|
|
746
655
|
if (e.keyCode === 13) {
|
|
747
656
|
gotName();
|
|
@@ -758,31 +667,28 @@ function askName(dom, kb, container, predicate, theClass, noun) {
|
|
|
758
667
|
namefield.focus();
|
|
759
668
|
}); // Promise
|
|
760
669
|
}
|
|
670
|
+
|
|
761
671
|
/**
|
|
762
672
|
* A TR to represent a draggable person, etc in a list
|
|
763
673
|
*
|
|
764
674
|
* pred is unused param at the moment
|
|
765
675
|
*/
|
|
766
|
-
|
|
767
|
-
|
|
768
676
|
var personTR = renderAsRow; // The legacy name is used in a lot of places
|
|
769
|
-
|
|
770
677
|
exports.personTR = personTR;
|
|
771
|
-
|
|
772
678
|
function renderAsRow(dom, pred, obj, options) {
|
|
773
679
|
var tr = dom.createElement('tr');
|
|
774
|
-
options = options || {};
|
|
775
|
-
|
|
680
|
+
options = options || {};
|
|
681
|
+
// tr.predObj = [pred.uri, obj.uri] moved to acl-control
|
|
776
682
|
var td1 = tr.appendChild(dom.createElement('td'));
|
|
777
683
|
var td2 = tr.appendChild(dom.createElement('td'));
|
|
778
|
-
var td3 = tr.appendChild(dom.createElement('td'));
|
|
684
|
+
var td3 = tr.appendChild(dom.createElement('td'));
|
|
779
685
|
|
|
686
|
+
// const image = td1.appendChild(dom.createElement('img'))
|
|
780
687
|
var image = options.image || faviconOrDefault(dom, obj);
|
|
781
688
|
td1.setAttribute('style', 'vertical-align: middle; width:2.5em; padding:0.5em; height: 2.5em;');
|
|
782
689
|
td2.setAttribute('style', 'vertical-align: middle; text-align:left;');
|
|
783
690
|
td3.setAttribute('style', 'vertical-align: middle; width:2em; padding:0.5em; height: 4em;');
|
|
784
691
|
td1.appendChild(image);
|
|
785
|
-
|
|
786
692
|
if (options.title) {
|
|
787
693
|
td2.textContent = options.title;
|
|
788
694
|
} else {
|
|
@@ -792,7 +698,6 @@ function renderAsRow(dom, pred, obj, options) {
|
|
|
792
698
|
if (options.deleteFunction) {
|
|
793
699
|
deleteButtonWithCheck(dom, td3, options.noun || 'one', options.deleteFunction);
|
|
794
700
|
}
|
|
795
|
-
|
|
796
701
|
if (obj.uri) {
|
|
797
702
|
// blank nodes need not apply
|
|
798
703
|
if (options.link !== false) {
|
|
@@ -800,30 +705,25 @@ function renderAsRow(dom, pred, obj, options) {
|
|
|
800
705
|
anchor.classList.add('HoverControlHide');
|
|
801
706
|
td3.appendChild(dom.createElement('br'));
|
|
802
707
|
}
|
|
803
|
-
|
|
804
708
|
if (options.draggable !== false) {
|
|
805
709
|
// default is on
|
|
806
710
|
image.setAttribute('draggable', 'false'); // Stop the image being dragged instead - just the TR
|
|
807
|
-
|
|
808
711
|
(0, _dragAndDrop.makeDraggable)(tr, obj);
|
|
809
712
|
}
|
|
810
713
|
}
|
|
811
|
-
|
|
812
714
|
;
|
|
813
715
|
tr.subject = obj;
|
|
814
716
|
return tr;
|
|
815
717
|
}
|
|
718
|
+
|
|
816
719
|
/* A helper function for renderAsDiv
|
|
817
720
|
* creates the NameDiv for the person
|
|
818
721
|
* Note: could not move it to the helper file because they call exported functions
|
|
819
722
|
* from buttons
|
|
820
723
|
* @internal exporting this only for unit tests
|
|
821
724
|
*/
|
|
822
|
-
|
|
823
|
-
|
|
824
725
|
function createNameDiv(dom, div, title, obj) {
|
|
825
726
|
var nameDiv = div.appendChild(dom.createElement('div'));
|
|
826
|
-
|
|
827
727
|
if (title) {
|
|
828
728
|
nameDiv.textContent = title;
|
|
829
729
|
} else {
|
|
@@ -836,22 +736,17 @@ function createNameDiv(dom, div, title, obj) {
|
|
|
836
736
|
* from buttons
|
|
837
737
|
* @internal exporting this only for unit tests
|
|
838
738
|
*/
|
|
839
|
-
|
|
840
|
-
|
|
841
739
|
function createLinkDiv(dom, div, obj, options) {
|
|
842
740
|
var linkDiv = div.appendChild(dom.createElement('div'));
|
|
843
741
|
linkDiv.setAttribute('style', style.linkDivStyle);
|
|
844
|
-
|
|
845
742
|
if (options.deleteFunction) {
|
|
846
743
|
deleteButtonWithCheck(dom, linkDiv, options.noun || 'one', options.deleteFunction);
|
|
847
744
|
}
|
|
848
|
-
|
|
849
745
|
if (obj.uri) {
|
|
850
746
|
// blank nodes need not apply
|
|
851
747
|
if (options.link !== false) {
|
|
852
748
|
(0, _iconLinks.createLinkForURI)(dom, linkDiv, obj);
|
|
853
749
|
}
|
|
854
|
-
|
|
855
750
|
(0, _dragAndDrop.makeDraggable)(div, obj);
|
|
856
751
|
}
|
|
857
752
|
}
|
|
@@ -859,8 +754,6 @@ function createLinkDiv(dom, div, obj, options) {
|
|
|
859
754
|
* A Div to represent a draggable person, etc in a list
|
|
860
755
|
* configurable to add an onClick listener
|
|
861
756
|
*/
|
|
862
|
-
|
|
863
|
-
|
|
864
757
|
function renderAsDiv(dom, obj, options) {
|
|
865
758
|
var div = dom.createElement('div');
|
|
866
759
|
div.setAttribute('style', style.renderAsDivStyle);
|
|
@@ -869,39 +762,35 @@ function renderAsDiv(dom, obj, options) {
|
|
|
869
762
|
(0, _widgetHelpers.createImageDiv)(dom, div, image);
|
|
870
763
|
createNameDiv(dom, div, options.title, obj);
|
|
871
764
|
createLinkDiv(dom, div, obj, options);
|
|
872
|
-
|
|
873
765
|
if (options.clickable && options.onClickFunction) {
|
|
874
766
|
(0, _widgetHelpers.addClickListenerToElement)(div, options.onClickFunction);
|
|
875
|
-
}
|
|
876
|
-
|
|
767
|
+
}
|
|
877
768
|
|
|
769
|
+
// to be compatible with the SolidOS table layout
|
|
878
770
|
if (options.wrapInATR) {
|
|
879
771
|
var tr = (0, _widgetHelpers.wrapDivInATR)(dom, div, obj);
|
|
880
772
|
return tr;
|
|
881
773
|
}
|
|
882
|
-
|
|
883
774
|
return div;
|
|
884
775
|
}
|
|
776
|
+
|
|
885
777
|
/**
|
|
886
778
|
* Refresh a DOM tree recursively
|
|
887
779
|
*/
|
|
888
|
-
|
|
889
|
-
|
|
890
780
|
function refreshTree(root) {
|
|
891
781
|
if (root.refresh) {
|
|
892
782
|
root.refresh();
|
|
893
783
|
return;
|
|
894
784
|
}
|
|
895
|
-
|
|
896
785
|
for (var i = 0; i < root.children.length; i++) {
|
|
897
786
|
refreshTree(root.children[i]);
|
|
898
787
|
}
|
|
899
788
|
}
|
|
789
|
+
|
|
900
790
|
/**
|
|
901
791
|
* Options argument for [[attachmentList]] function
|
|
902
792
|
*/
|
|
903
793
|
|
|
904
|
-
|
|
905
794
|
/**
|
|
906
795
|
* Component that displays a list of resources, for instance
|
|
907
796
|
* the attachments of a message, or the various documents related
|
|
@@ -910,13 +799,12 @@ function refreshTree(root) {
|
|
|
910
799
|
*/
|
|
911
800
|
function attachmentList(dom, subject, div) {
|
|
912
801
|
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
913
|
-
|
|
914
802
|
// options = options || {}
|
|
803
|
+
|
|
915
804
|
var deleteAttachment = function deleteAttachment(target) {
|
|
916
805
|
if (!kb.updater) {
|
|
917
806
|
throw new Error('kb has no updater');
|
|
918
807
|
}
|
|
919
|
-
|
|
920
808
|
kb.updater.update((0, _rdflib.st)(subject, predicate, target, doc), [], function (uri, ok, errorBody, _xhr) {
|
|
921
809
|
if (ok) {
|
|
922
810
|
refresh();
|
|
@@ -925,42 +813,33 @@ function attachmentList(dom, subject, div) {
|
|
|
925
813
|
}
|
|
926
814
|
});
|
|
927
815
|
};
|
|
928
|
-
|
|
929
816
|
function createNewRow(target) {
|
|
930
817
|
var theTarget = target;
|
|
931
818
|
var opt = {
|
|
932
819
|
noun: noun
|
|
933
820
|
};
|
|
934
|
-
|
|
935
821
|
if (modify) {
|
|
936
822
|
opt.deleteFunction = function () {
|
|
937
823
|
deleteAttachment(theTarget);
|
|
938
824
|
};
|
|
939
825
|
}
|
|
940
|
-
|
|
941
826
|
return personTR(dom, predicate, target, opt);
|
|
942
827
|
}
|
|
943
|
-
|
|
944
828
|
var refresh = function refresh() {
|
|
945
829
|
var things = kb.each(subject, predicate);
|
|
946
830
|
things.sort();
|
|
947
831
|
utils.syncTableToArray(attachmentTable, things, createNewRow);
|
|
948
832
|
};
|
|
949
|
-
|
|
950
833
|
function droppedURIHandler(uris) {
|
|
951
834
|
var ins = [];
|
|
952
835
|
uris.forEach(function (u) {
|
|
953
836
|
var target = (0, _rdflib.sym)(u); // Attachment needs text label to disinguish I think not icon.
|
|
954
|
-
|
|
955
837
|
debug.log('Dropped on attachemnt ' + u); // icon was: iconBase + 'noun_25830.svg'
|
|
956
|
-
|
|
957
838
|
ins.push((0, _rdflib.st)(subject, predicate, target, doc));
|
|
958
839
|
});
|
|
959
|
-
|
|
960
840
|
if (!kb.updater) {
|
|
961
841
|
throw new Error('kb has no updater');
|
|
962
842
|
}
|
|
963
|
-
|
|
964
843
|
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
965
844
|
if (ok) {
|
|
966
845
|
refresh();
|
|
@@ -969,19 +848,16 @@ function attachmentList(dom, subject, div) {
|
|
|
969
848
|
}
|
|
970
849
|
});
|
|
971
850
|
}
|
|
972
|
-
|
|
973
851
|
function droppedFileHandler(files) {
|
|
974
852
|
var _options$uploadFolder, _options$uploadFolder2;
|
|
975
|
-
|
|
976
853
|
(0, _dragAndDrop.uploadFiles)(kb.fetcher, files, (_options$uploadFolder = options.uploadFolder) === null || _options$uploadFolder === void 0 ? void 0 : _options$uploadFolder.uri, // Files
|
|
977
|
-
(_options$uploadFolder2 = options.uploadFolder) === null || _options$uploadFolder2 === void 0 ? void 0 : _options$uploadFolder2.uri,
|
|
854
|
+
(_options$uploadFolder2 = options.uploadFolder) === null || _options$uploadFolder2 === void 0 ? void 0 : _options$uploadFolder2.uri,
|
|
855
|
+
// Pictures
|
|
978
856
|
function (theFile, destURI) {
|
|
979
857
|
var ins = [(0, _rdflib.st)(subject, predicate, kb.sym(destURI), doc)];
|
|
980
|
-
|
|
981
858
|
if (!kb.updater) {
|
|
982
859
|
throw new Error('kb has no updater');
|
|
983
860
|
}
|
|
984
|
-
|
|
985
861
|
kb.updater.update([], ins, function (uri, ok, errorBody, _xhr) {
|
|
986
862
|
if (ok) {
|
|
987
863
|
refresh();
|
|
@@ -991,13 +867,11 @@ function attachmentList(dom, subject, div) {
|
|
|
991
867
|
});
|
|
992
868
|
});
|
|
993
869
|
}
|
|
994
|
-
|
|
995
870
|
var doc = options.doc || subject.doc();
|
|
996
871
|
if (options.modify === undefined) options.modify = true;
|
|
997
872
|
var modify = options.modify;
|
|
998
873
|
var promptIcon = options.promptIcon || iconBase + 'noun_748003.svg'; // target
|
|
999
874
|
// const promptIcon = options.promptIcon || (iconBase + 'noun_25830.svg') // paperclip
|
|
1000
|
-
|
|
1001
875
|
var predicate = options.predicate || ns.wf('attachment');
|
|
1002
876
|
var noun = options.noun || 'attachment';
|
|
1003
877
|
var kb = _solidLogic.store;
|
|
@@ -1009,30 +883,32 @@ function attachmentList(dom, subject, div) {
|
|
|
1009
883
|
var attachmentTable = attachmentRight.appendChild(dom.createElement('table'));
|
|
1010
884
|
attachmentTable.appendChild(dom.createElement('tr')) // attachmentTableTop
|
|
1011
885
|
;
|
|
886
|
+
|
|
1012
887
|
attachmentOuter.refresh = refresh; // Participate in downstream changes
|
|
1013
888
|
// ;(attachmentTable as any).refresh = refresh <- outer should be best?
|
|
1014
889
|
|
|
1015
890
|
refresh();
|
|
1016
|
-
|
|
1017
891
|
if (modify) {
|
|
1018
892
|
// const buttonStyle = 'width; 2em; height: 2em; margin: 0.5em; padding: 0.1em;'
|
|
1019
|
-
var paperclip = button(dom, promptIcon, 'Drop attachments here');
|
|
1020
|
-
|
|
893
|
+
var paperclip = button(dom, promptIcon, 'Drop attachments here');
|
|
894
|
+
// paperclip.style = buttonStyle // @@ needed? default has white background
|
|
1021
895
|
attachmentLeft.appendChild(paperclip);
|
|
1022
896
|
var fhandler = options.uploadFolder ? droppedFileHandler : null;
|
|
1023
897
|
(0, _dragAndDrop.makeDropTarget)(paperclip, droppedURIHandler, fhandler); // beware missing the wire of the paparclip!
|
|
1024
|
-
|
|
1025
898
|
(0, _dragAndDrop.makeDropTarget)(attachmentLeft, droppedURIHandler, fhandler); // just the outer won't do it
|
|
1026
899
|
|
|
1027
900
|
if (options.uploadFolder) {
|
|
1028
901
|
// Addd an explicit file upload button as well
|
|
1029
902
|
var buttonDiv = fileUploadButtonDiv(dom, droppedFileHandler);
|
|
1030
|
-
attachmentLeft.appendChild(buttonDiv);
|
|
903
|
+
attachmentLeft.appendChild(buttonDiv);
|
|
904
|
+
// buttonDiv.children[1].style = buttonStyle
|
|
1031
905
|
}
|
|
1032
906
|
}
|
|
1033
907
|
|
|
1034
908
|
return attachmentOuter;
|
|
1035
|
-
}
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
// /////////////////////////////////////////////////////////////////////////////
|
|
1036
912
|
|
|
1037
913
|
/**
|
|
1038
914
|
* Event Handler for links within solid apps.
|
|
@@ -1040,8 +916,6 @@ function attachmentList(dom, subject, div) {
|
|
|
1040
916
|
* Note that native links have constraints in Firefox, they
|
|
1041
917
|
* don't work with local files for instance (2011)
|
|
1042
918
|
*/
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
919
|
function openHrefInOutlineMode(e) {
|
|
1046
920
|
e.preventDefault();
|
|
1047
921
|
e.stopPropagation();
|
|
@@ -1049,7 +923,6 @@ function openHrefInOutlineMode(e) {
|
|
|
1049
923
|
var uri = target.getAttribute('href');
|
|
1050
924
|
if (!uri) return debug.log('openHrefInOutlineMode: No href found!\n');
|
|
1051
925
|
var dom = window.document;
|
|
1052
|
-
|
|
1053
926
|
if (dom.outlineManager) {
|
|
1054
927
|
// @@ TODO Remove the use of document as a global object
|
|
1055
928
|
// TODO fix dependency cycle to solid-panes by calling outlineManager
|
|
@@ -1061,24 +934,23 @@ function openHrefInOutlineMode(e) {
|
|
|
1061
934
|
window.panes.getOutliner().GotoSubject(_solidLogic.store.sym(uri), true, undefined, true, undefined);
|
|
1062
935
|
} else {
|
|
1063
936
|
debug.log('ERROR: Can\'t access outline manager in this config');
|
|
1064
|
-
}
|
|
1065
|
-
|
|
937
|
+
}
|
|
938
|
+
// dom.outlineManager.GotoSubject(store.sym(uri), true, undefined, true, undefined)
|
|
1066
939
|
}
|
|
940
|
+
|
|
1067
941
|
/**
|
|
1068
942
|
* Make a URI in the Tabulator.org annotation store out of the URI of the thing to be annotated.
|
|
1069
943
|
*
|
|
1070
944
|
* @@ Todo: make it a personal preference.
|
|
1071
945
|
*/
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
946
|
function defaultAnnotationStore(subject) {
|
|
1075
947
|
if (subject.uri === undefined) return undefined;
|
|
1076
948
|
var s = subject.uri;
|
|
1077
949
|
if (s.slice(0, 7) !== 'http://') return undefined;
|
|
1078
950
|
s = s.slice(7); // Remove
|
|
1079
|
-
|
|
1080
951
|
var hash = s.indexOf('#');
|
|
1081
|
-
if (hash >= 0) s = s.slice(0, hash);
|
|
952
|
+
if (hash >= 0) s = s.slice(0, hash);
|
|
953
|
+
// Strip trailing
|
|
1082
954
|
else {
|
|
1083
955
|
var slash = s.lastIndexOf('/');
|
|
1084
956
|
if (slash < 0) return undefined;
|
|
@@ -1086,31 +958,27 @@ function defaultAnnotationStore(subject) {
|
|
|
1086
958
|
}
|
|
1087
959
|
return _solidLogic.store.sym('http://tabulator.org/wiki/annnotation/' + s);
|
|
1088
960
|
}
|
|
961
|
+
|
|
1089
962
|
/**
|
|
1090
963
|
* Retrieve all RDF class URIs from solid-ui's RDF store
|
|
1091
964
|
* @returns an object `ret` such that `Object.keys(ret)` is
|
|
1092
965
|
* the list of all class URIs.
|
|
1093
966
|
*/
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
967
|
function allClassURIs() {
|
|
1097
968
|
var set = {};
|
|
1098
|
-
|
|
1099
969
|
_solidLogic.store.statementsMatching(undefined, ns.rdf('type'), undefined).forEach(function (st) {
|
|
1100
970
|
if (st.object.value) set[st.object.value] = true;
|
|
1101
971
|
});
|
|
1102
|
-
|
|
1103
972
|
_solidLogic.store.statementsMatching(undefined, ns.rdfs('subClassOf'), undefined).forEach(function (st) {
|
|
1104
973
|
if (st.object.value) set[st.object.value] = true;
|
|
1105
974
|
if (st.subject.value) set[st.subject.value] = true;
|
|
1106
975
|
});
|
|
1107
|
-
|
|
1108
976
|
_solidLogic.store.each(undefined, ns.rdf('type'), ns.rdfs('Class')).forEach(function (c) {
|
|
1109
977
|
if (c.value) set[c.value] = true;
|
|
1110
978
|
});
|
|
1111
|
-
|
|
1112
979
|
return set;
|
|
1113
980
|
}
|
|
981
|
+
|
|
1114
982
|
/**
|
|
1115
983
|
* Figuring which properties we know about
|
|
1116
984
|
*
|
|
@@ -1123,21 +991,18 @@ function allClassURIs() {
|
|
|
1123
991
|
* @param {Store} kb The quadstore to be searched.
|
|
1124
992
|
*/
|
|
1125
993
|
|
|
1126
|
-
|
|
1127
994
|
function propertyTriage(kb) {
|
|
1128
|
-
var possibleProperties = {};
|
|
995
|
+
var possibleProperties = {};
|
|
996
|
+
// if (possibleProperties === undefined) possibleProperties = {}
|
|
1129
997
|
// const kb = store
|
|
1130
|
-
|
|
1131
998
|
var dp = {};
|
|
1132
999
|
var op = {};
|
|
1133
1000
|
var no = 0;
|
|
1134
1001
|
var nd = 0;
|
|
1135
1002
|
var nu = 0;
|
|
1136
1003
|
var pi = kb.predicateIndex; // One entry for each pred
|
|
1137
|
-
|
|
1138
1004
|
for (var p in pi) {
|
|
1139
1005
|
var object = pi[p][0].object;
|
|
1140
|
-
|
|
1141
1006
|
if (object.termType === 'Literal') {
|
|
1142
1007
|
dp[p] = true;
|
|
1143
1008
|
nd++;
|
|
@@ -1146,25 +1011,21 @@ function propertyTriage(kb) {
|
|
|
1146
1011
|
no++;
|
|
1147
1012
|
}
|
|
1148
1013
|
} // If nothing discovered, then could be either:
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
1014
|
var ps = kb.each(undefined, ns.rdf('type'), ns.rdf('Property'));
|
|
1152
|
-
|
|
1153
1015
|
for (var i = 0; i < ps.length; i++) {
|
|
1154
1016
|
var _p = ps[i].toNT();
|
|
1155
|
-
|
|
1156
1017
|
if (!op[_p] && !dp[_p]) {
|
|
1157
1018
|
dp[_p] = true;
|
|
1158
1019
|
op[_p] = true;
|
|
1159
1020
|
nu++;
|
|
1160
1021
|
}
|
|
1161
1022
|
}
|
|
1162
|
-
|
|
1163
1023
|
possibleProperties.op = op;
|
|
1164
1024
|
possibleProperties.dp = dp;
|
|
1165
1025
|
(0, _log.info)("propertyTriage: ".concat(no, " non-lit, ").concat(nd, " literal. ").concat(nu, " unknown."));
|
|
1166
1026
|
return possibleProperties;
|
|
1167
1027
|
}
|
|
1028
|
+
|
|
1168
1029
|
/**
|
|
1169
1030
|
* General purpose widgets
|
|
1170
1031
|
*/
|
|
@@ -1172,8 +1033,6 @@ function propertyTriage(kb) {
|
|
|
1172
1033
|
/**
|
|
1173
1034
|
* A button for jumping
|
|
1174
1035
|
*/
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
1036
|
function linkButton(dom, object) {
|
|
1178
1037
|
var b = dom.createElement('button');
|
|
1179
1038
|
b.setAttribute('type', 'button');
|
|
@@ -1186,22 +1045,22 @@ function linkButton(dom, object) {
|
|
|
1186
1045
|
}, true);
|
|
1187
1046
|
return b;
|
|
1188
1047
|
}
|
|
1048
|
+
|
|
1189
1049
|
/**
|
|
1190
1050
|
* A button to remove some other element from the page
|
|
1191
1051
|
*/
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
1052
|
function removeButton(dom, element) {
|
|
1195
1053
|
var b = dom.createElement('button');
|
|
1196
1054
|
b.setAttribute('type', 'button');
|
|
1197
1055
|
b.textContent = '✕'; // MULTIPLICATION X
|
|
1198
|
-
|
|
1199
1056
|
b.addEventListener('click', function (_event) {
|
|
1200
1057
|
;
|
|
1201
1058
|
element.parentNode.removeChild(element);
|
|
1202
1059
|
}, true);
|
|
1203
1060
|
return b;
|
|
1204
|
-
}
|
|
1061
|
+
}
|
|
1062
|
+
|
|
1063
|
+
// Description text area
|
|
1205
1064
|
//
|
|
1206
1065
|
// Make a box to demand a description or display existing one
|
|
1207
1066
|
//
|
|
@@ -1211,12 +1070,13 @@ function removeButton(dom, element) {
|
|
|
1211
1070
|
// @param predicate - a term, the predicate of the statement(s) being edited
|
|
1212
1071
|
// @param store - The web document being edited
|
|
1213
1072
|
// @param callbackFunction - takes (boolean ok, string errorBody)
|
|
1073
|
+
|
|
1214
1074
|
// /////////////////////////////////////// Random I/O widgets /////////////
|
|
1075
|
+
|
|
1215
1076
|
// //// Column Header Buttons
|
|
1216
1077
|
//
|
|
1217
1078
|
// These are for selecting different modes, sources,styles, etc.
|
|
1218
1079
|
//
|
|
1219
|
-
|
|
1220
1080
|
/*
|
|
1221
1081
|
buttons.headerButtons = function (dom, kb, name, words) {
|
|
1222
1082
|
const box = dom.createElement('table')
|
|
@@ -1237,38 +1097,30 @@ buttons.headerButtons = function (dom, kb, name, words) {
|
|
|
1237
1097
|
//
|
|
1238
1098
|
// @param inverse means this is the object rather than the subject
|
|
1239
1099
|
//
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
1100
|
function selectorPanel(dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1243
1101
|
return selectorPanelRefresh(dom.createElement('div'), dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback);
|
|
1244
1102
|
}
|
|
1245
|
-
|
|
1246
1103
|
function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible, options, callbackFunction, linkCallback) {
|
|
1247
1104
|
var style0 = 'border: 0.1em solid #ddd; border-bottom: none; width: 95%; height: 2em; padding: 0.5em;';
|
|
1248
1105
|
var selected = null;
|
|
1249
1106
|
list.innerHTML = '';
|
|
1250
|
-
|
|
1251
1107
|
var refreshItem = function refreshItem(box, x) {
|
|
1252
1108
|
// Scope to hold item and x
|
|
1253
|
-
var item;
|
|
1254
|
-
|
|
1109
|
+
var item;
|
|
1110
|
+
// eslint-disable-next-line prefer-const
|
|
1255
1111
|
var image;
|
|
1256
|
-
|
|
1257
1112
|
var setStyle = function setStyle() {
|
|
1258
1113
|
var already = inverse ? kb.each(undefined, predicate, x) : kb.each(x, predicate);
|
|
1259
1114
|
iconDiv.setAttribute('class', already.length === 0 ? 'hideTillHover' : ''); // See tabbedtab.css
|
|
1260
|
-
|
|
1261
1115
|
image.setAttribute('src', options.connectIcon || iconBase + 'noun_25830.svg');
|
|
1262
1116
|
image.setAttribute('title', already.length ? already.length : 'attach');
|
|
1263
1117
|
};
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1118
|
+
var f = index.twoLine.widgetForClass(type);
|
|
1119
|
+
// eslint-disable-next-line prefer-const
|
|
1267
1120
|
item = f(dom, x);
|
|
1268
1121
|
item.setAttribute('style', style0);
|
|
1269
1122
|
var nav = dom.createElement('div');
|
|
1270
1123
|
nav.setAttribute('class', 'hideTillHover'); // See tabbedtab.css
|
|
1271
|
-
|
|
1272
1124
|
nav.setAttribute('style', 'float:right; width:10%');
|
|
1273
1125
|
var a = dom.createElement('a');
|
|
1274
1126
|
a.setAttribute('href', x.uri);
|
|
@@ -1291,7 +1143,6 @@ function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible,
|
|
|
1291
1143
|
item.setAttribute('style', style0 + 'background-color: #ccc; color:black;');
|
|
1292
1144
|
selected = item;
|
|
1293
1145
|
}
|
|
1294
|
-
|
|
1295
1146
|
callbackFunction(x, event, selected === item);
|
|
1296
1147
|
setStyle();
|
|
1297
1148
|
}, false);
|
|
@@ -1301,52 +1152,47 @@ function selectorPanelRefresh(list, dom, kb, type, predicate, inverse, possible,
|
|
|
1301
1152
|
box.appendChild(item);
|
|
1302
1153
|
return box;
|
|
1303
1154
|
};
|
|
1304
|
-
|
|
1305
1155
|
for (var i = 0; i < possible.length; i++) {
|
|
1306
1156
|
var box = dom.createElement('div');
|
|
1307
1157
|
list.appendChild(box);
|
|
1308
1158
|
refreshItem(box, possible[i]);
|
|
1309
1159
|
}
|
|
1310
|
-
|
|
1311
1160
|
return list;
|
|
1312
|
-
}
|
|
1161
|
+
}
|
|
1162
|
+
|
|
1163
|
+
// ###########################################################################
|
|
1313
1164
|
//
|
|
1314
1165
|
// Small compact views of things
|
|
1315
1166
|
//
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
var index = {}; // ///////////////////////////////////////////////////////////////////////////
|
|
1167
|
+
var index = {};
|
|
1168
|
+
// ///////////////////////////////////////////////////////////////////////////
|
|
1319
1169
|
// We need these for anything which is a subject of an attachment.
|
|
1320
1170
|
//
|
|
1321
1171
|
// These should be moved to type-dependeent UI code. Related panes maybe
|
|
1322
|
-
|
|
1323
1172
|
exports.index = index;
|
|
1324
|
-
|
|
1325
1173
|
function twoLineDefault(dom, x) {
|
|
1326
1174
|
// Default
|
|
1327
1175
|
var box = dom.createElement('div');
|
|
1328
1176
|
box.textContent = utils.label(x);
|
|
1329
1177
|
return box;
|
|
1330
1178
|
}
|
|
1179
|
+
|
|
1331
1180
|
/**
|
|
1332
1181
|
* Find a function that can create a widget for a given class
|
|
1333
1182
|
* @param c The RDF class for which we want a widget generator function
|
|
1334
1183
|
*/
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
1184
|
function twoLineWidgetForClass(c) {
|
|
1338
1185
|
var widget = index.twoLine[c.uri];
|
|
1339
1186
|
var kb = _solidLogic.store;
|
|
1340
1187
|
if (widget) return widget;
|
|
1341
1188
|
var sup = kb.findSuperClassesNT(c);
|
|
1342
|
-
|
|
1343
1189
|
for (var cl in sup) {
|
|
1344
1190
|
widget = index.twoLine[kb.fromNT(cl).uri];
|
|
1345
1191
|
if (widget) return widget;
|
|
1346
1192
|
}
|
|
1347
|
-
|
|
1348
1193
|
return index.twoLine[''];
|
|
1349
1194
|
}
|
|
1195
|
+
|
|
1350
1196
|
/**
|
|
1351
1197
|
* Display a transaction
|
|
1352
1198
|
* @param x Should have attributes through triples in store:
|
|
@@ -1354,27 +1200,22 @@ function twoLineWidgetForClass(c) {
|
|
|
1354
1200
|
* * ns.qu('date) -> a literal
|
|
1355
1201
|
* * ns.qu('amount') -> a literal
|
|
1356
1202
|
*/
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
1203
|
function twoLineTransaction(dom, x) {
|
|
1360
1204
|
var failed = '';
|
|
1361
|
-
|
|
1362
1205
|
var enc = function enc(p) {
|
|
1363
1206
|
var y = _solidLogic.store.any(x, ns.qu(p));
|
|
1364
|
-
|
|
1365
1207
|
if (!y) failed += '@@ No value for ' + p + '! ';
|
|
1366
1208
|
return y ? utils.escapeForXML(y.value) : '?'; // @@@@
|
|
1367
1209
|
};
|
|
1368
1210
|
|
|
1369
1211
|
var box = dom.createElement('table');
|
|
1370
1212
|
box.innerHTML = "\n <tr>\n <td colspan=\"2\"> ".concat(enc('payee'), "</td>\n < /tr>\n < tr >\n <td>").concat(enc('date').slice(0, 10), "</td>\n <td style = \"text-align: right;\">").concat(enc('amount'), "</td>\n </tr>");
|
|
1371
|
-
|
|
1372
1213
|
if (failed) {
|
|
1373
1214
|
box.innerHTML = "\n <tr>\n <td><a href=\"".concat(utils.escapeForXML(x.uri), "\">").concat(utils.escapeForXML(failed), "</a></td>\n </tr>");
|
|
1374
1215
|
}
|
|
1375
|
-
|
|
1376
1216
|
return box;
|
|
1377
1217
|
}
|
|
1218
|
+
|
|
1378
1219
|
/**
|
|
1379
1220
|
* Display a trip
|
|
1380
1221
|
* @param x Should have attributes through triples in store:
|
|
@@ -1382,76 +1223,64 @@ function twoLineTransaction(dom, x) {
|
|
|
1382
1223
|
* * ns.cal('dtstart') -> a literal
|
|
1383
1224
|
* * ns.cal('dtend') -> a literal
|
|
1384
1225
|
*/
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
1226
|
function twoLineTrip(dom, x) {
|
|
1388
1227
|
var enc = function enc(p) {
|
|
1389
1228
|
var y = _solidLogic.store.any(x, p);
|
|
1390
|
-
|
|
1391
1229
|
return y ? utils.escapeForXML(y.value) : '?';
|
|
1392
1230
|
};
|
|
1393
|
-
|
|
1394
1231
|
var box = dom.createElement('table');
|
|
1395
1232
|
box.innerHTML = "\n <tr>\n <td colspan=\"2\">".concat(enc(ns.dc('title')), "</td>\n </tr>\n <tr style=\"color: #777\">\n <td>").concat(enc(ns.cal('dtstart')), "</td>\n <td>").concat(enc(ns.cal('dtend')), "</td>\n </tr>");
|
|
1396
1233
|
return box;
|
|
1397
1234
|
}
|
|
1235
|
+
|
|
1398
1236
|
/**
|
|
1399
1237
|
* Stick a stylesheet link the document if not already there
|
|
1400
1238
|
*/
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
1239
|
function addStyleSheet(dom, href) {
|
|
1404
1240
|
var links = dom.querySelectorAll('link');
|
|
1405
|
-
|
|
1406
1241
|
for (var i = 0; i < links.length; i++) {
|
|
1407
1242
|
if ((links[i].getAttribute('rel') || '') === 'stylesheet' && (links[i].getAttribute('href') || '') === href) {
|
|
1408
1243
|
return;
|
|
1409
1244
|
}
|
|
1410
1245
|
}
|
|
1411
|
-
|
|
1412
1246
|
var link = dom.createElement('link');
|
|
1413
1247
|
link.setAttribute('rel', 'stylesheet');
|
|
1414
1248
|
link.setAttribute('type', 'text/css');
|
|
1415
1249
|
link.setAttribute('href', href);
|
|
1416
1250
|
dom.getElementsByTagName('head')[0].appendChild(link);
|
|
1417
|
-
}
|
|
1418
|
-
//
|
|
1419
|
-
|
|
1251
|
+
}
|
|
1420
1252
|
|
|
1253
|
+
// Figure (or guess) whether this is an image, etc
|
|
1254
|
+
//
|
|
1421
1255
|
function isAudio(file) {
|
|
1422
1256
|
return isImage(file, 'audio');
|
|
1423
1257
|
}
|
|
1424
|
-
|
|
1425
1258
|
function isVideo(file) {
|
|
1426
1259
|
return isImage(file, 'video');
|
|
1427
1260
|
}
|
|
1428
1261
|
/**
|
|
1429
1262
|
*
|
|
1430
1263
|
*/
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
1264
|
function isImage(file, kind) {
|
|
1434
1265
|
var dcCLasses = {
|
|
1435
1266
|
audio: 'http://purl.org/dc/dcmitype/Sound',
|
|
1436
1267
|
image: 'http://purl.org/dc/dcmitype/Image',
|
|
1437
1268
|
video: 'http://purl.org/dc/dcmitype/MovingImage'
|
|
1438
1269
|
};
|
|
1439
|
-
var what = kind || 'image';
|
|
1270
|
+
var what = kind || 'image';
|
|
1271
|
+
// See https://github.com/linkeddata/rdflib.js/blob/e367d5088c/src/formula.ts#L554
|
|
1440
1272
|
//
|
|
1441
|
-
|
|
1442
|
-
|
|
1273
|
+
var typeURIs = _solidLogic.store.findTypeURIs(file);
|
|
1274
|
+
// See https://github.com/linkeddata/rdflib.js/blob/d5000f/src/utils-js.js#L14
|
|
1443
1275
|
// e.g.'http://www.w3.org/ns/iana/media-types/audio'
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
1276
|
var prefix = _rdflib.Util.mediaTypeClass(what + '/*').uri.split('*')[0];
|
|
1447
|
-
|
|
1448
1277
|
for (var t in typeURIs) {
|
|
1449
1278
|
if (t.startsWith(prefix)) return true;
|
|
1450
1279
|
}
|
|
1451
|
-
|
|
1452
1280
|
if (dcCLasses[what] in typeURIs) return true;
|
|
1453
1281
|
return false;
|
|
1454
1282
|
}
|
|
1283
|
+
|
|
1455
1284
|
/**
|
|
1456
1285
|
* File upload button
|
|
1457
1286
|
* @param dom The DOM aka document
|
|
@@ -1460,8 +1289,6 @@ function isImage(file, kind) {
|
|
|
1460
1289
|
* The input is hidden, as it is uglky - the user clicks on the nice icons and fires the input.
|
|
1461
1290
|
*/
|
|
1462
1291
|
// See https://developer.mozilla.org/en-US/docs/Web/API/File/Using_files_from_web_applications
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
1292
|
function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
1466
1293
|
var div = dom.createElement('div');
|
|
1467
1294
|
var input = div.appendChild(dom.createElement('input'));
|
|
@@ -1469,7 +1296,6 @@ function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
|
1469
1296
|
input.setAttribute('multiple', 'true');
|
|
1470
1297
|
input.addEventListener('change', function (event) {
|
|
1471
1298
|
debug.log('File drop event: ', event);
|
|
1472
|
-
|
|
1473
1299
|
if (event.files) {
|
|
1474
1300
|
droppedFileHandler(event.files);
|
|
1475
1301
|
} else if (event.target && event.target.files) {
|
|
@@ -1483,10 +1309,8 @@ function fileUploadButtonDiv(dom, droppedFileHandler) {
|
|
|
1483
1309
|
input.click();
|
|
1484
1310
|
}));
|
|
1485
1311
|
(0, _dragAndDrop.makeDropTarget)(buttonElt, null, droppedFileHandler); // Can also just drop on button
|
|
1486
|
-
|
|
1487
1312
|
return div;
|
|
1488
1313
|
}
|
|
1489
|
-
|
|
1490
1314
|
exports.index = index = {
|
|
1491
1315
|
line: {// Approx 80em
|
|
1492
1316
|
},
|