Skip to content

Commit 811c804

Browse files
author
Erik Loyer
committed
Visualization and lens tweaks
1 parent 43ba2a3 commit 811c804

File tree

2 files changed

+89
-52
lines changed

2 files changed

+89
-52
lines changed

system/application/views/melons/cantaloupe/js/scalarlenses.jquery.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -593,6 +593,9 @@
593593
case 'media':
594594
buttonText = 'All ' + scalarapi.model.scalarTypes[contentType].plural;
595595
break;
596+
case 'reply':
597+
buttonText = 'All ' + scalarapi.model.relationTypes['comment'].bodyPlural;
598+
break;
596599
default:
597600
buttonText = 'All ' + scalarapi.model.relationTypes[contentType].bodyPlural;
598601
break;
@@ -1082,13 +1085,14 @@
10821085
});
10831086

10841087
element.find('.done').on('click', function(evt){
1085-
console.log(me.validateItemsByType())
10861088
if(me.validateItemsByType()){
1087-
10881089
let contentSelector = {
10891090
"type": "items-by-type",
10901091
"content-type": $('#byType').text().split(/[_\s]/).join("-").toLowerCase()
10911092
}
1093+
if (contentSelector['content-type'] == 'comment') {
1094+
contentSelector['content-type'] = 'reply';
1095+
}
10921096
let contentSelections = me.scalarLensObject.components[me.editedComponentIndex]["content-selector"]
10931097
delete contentSelections.quantity;
10941098
delete contentSelections.units;
@@ -1716,7 +1720,7 @@
17161720
{label: "paths", value: "path"},
17171721
{label: "tags", value: "tag"},
17181722
{label: "annotations", value: "annotation"},
1719-
{label: "comments", value: "comment"}
1723+
{label: "comments", value: "reply"}
17201724
]);
17211725

17221726
let contentList = $('#content-type-list li');

system/application/views/melons/cantaloupe/js/scalarvisualizations.jquery.js

Lines changed: 82 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,11 @@ window.scalarvis = { instanceCount: -1 };
5151
base.VisualizationTypes = {
5252
'force-directed': 'Force-directed',
5353
'grid': 'Grid',
54-
/*'list': 'List',*/
55-
'map': 'Map',
54+
/*'list': 'List',
55+
'map': 'Map',*/
5656
'radial': 'Radial',
5757
'tree': 'Tree',
58-
'word-cloud': 'Word cloud'
58+
/*'word-cloud': 'Word cloud'*/
5959
}
6060
base.VisualizationContent = {
6161
"all-content": "All content",
@@ -65,7 +65,7 @@ window.scalarvis = { instanceCount: -1 };
6565
"tag": "All tags",
6666
"annotation": "All annotations",
6767
"media": "All media",
68-
"comment": "All comments",
68+
"reply": "All comments",
6969
"current": "Current page"
7070
}
7171
base.VisualizationFilters = {
@@ -171,23 +171,6 @@ window.scalarvis = { instanceCount: -1 };
171171

172172
base.controls = $('<div class="vis-controls form-inline form-group-sm"></div>').appendTo(base.visElement);
173173

174-
/*var controls_html = '<select class="vis-content-control form-control">';
175-
for (var prop in base.VisualizationContent) {
176-
controls_html += '<option value="' + prop + '">' + base.VisualizationContent[prop] + '</option>';
177-
}
178-
controls_html += '</select> ' +
179-
'<select class="vis-relations-control form-control">' +
180-
'<option value="all">All relationships</option>' +
181-
'<option value="parents-children">Parents and children</option>' +
182-
'<option value="none">No relationships</option>' +
183-
'</select> ' +
184-
'<select class="vis-format-control form-control">' +
185-
'<option value="grid">Grid format</option>' +
186-
'<option value="tree">Tree format</option>' +
187-
'<option value="radial">Radial format</option>' +
188-
'<option value="force-directed">Force-directed format</option>' +
189-
'</select>';*/
190-
191174
var controls_html = '<div class="vis-control-header"><b>Type</b></br><select class="vis-type-control form-control">';
192175
for (var prop in base.VisualizationTypes) {
193176
controls_html += '<option value="' + prop + '">' + base.VisualizationTypes[prop] + '</option>';
@@ -327,8 +310,9 @@ window.scalarvis = { instanceCount: -1 };
327310
base.options.lens.components[0]['content-selector']['items'] = [base.currentNode.slug];
328311
} else {
329312
base.options.lens.components[0]['content-selector']['content-type'] = $(this).val();
330-
base.options.lens.components[0]['content-selector']['items'] = [];
313+
delete base.options.lens.components[0]['content-selector'].items;
331314
}
315+
base.updateLensModifiers();
332316
base.getLensResults();
333317
}
334318

@@ -356,7 +340,25 @@ window.scalarvis = { instanceCount: -1 };
356340
"subtype": "relationship",
357341
"relationship": base.visElement.find(".vis-filter-control").val()
358342
};
359-
filter["content-types"] = ["all-types"];
343+
let contentControlVal = base.visElement.find(".vis-content-control").val();
344+
switch (contentControlVal) {
345+
346+
case 'all-content':
347+
case 'table-of-contents':
348+
case 'current':
349+
case 'page':
350+
filter["content-types"] = ["all-types"];
351+
break;
352+
353+
case 'media':
354+
filter["content-types"] = ["reference"];
355+
break;
356+
357+
default:
358+
filter["content-types"] = [contentControlVal];
359+
break;
360+
361+
}
360362
base.options.lens.components[0].modifiers.push(filter);
361363
}
362364
if (base.visElement.find(".vis-sort-control").val() != 'none') {
@@ -1453,7 +1455,9 @@ window.scalarvis = { instanceCount: -1 };
14531455
})
14541456
let hasSingleType;
14551457
if (base.options.lens.components.length === 1 && base.options.lens.components[0]['content-selector'].type === 'items-by-type') {
1456-
hasSingleType = base.options.lens.components[0]['content-selector']['content-type'];
1458+
if (base.options.lens.components[0]['content-selector']['content-type'] != 'all-content') {
1459+
hasSingleType = base.options.lens.components[0]['content-selector']['content-type'];
1460+
}
14571461
}
14581462
base.updateTypeHierarchy(false, true, hasSingleType, hasToc);
14591463
break;
@@ -1576,7 +1580,18 @@ window.scalarvis = { instanceCount: -1 };
15761580
}
15771581
}
15781582

1583+
let isCurrentContent = false;
15791584
if (base.options.content == "current") {
1585+
isCurrentContent = true;
1586+
} else if (base.options.lens) {
1587+
if (base.options.lens.components[0]['content-selector'].items) {
1588+
if (base.options.lens.components[0]['content-selector'].type == 'items-by-type' && base.options.lens.components[0]['content-selector'].items.length == 1 && base.options.lens.components[0]['content-selector'].items[0] == base.currentNode.slug) {
1589+
isCurrentContent = true;
1590+
}
1591+
}
1592+
}
1593+
1594+
if (isCurrentContent) {
15801595

15811596
// replace the root node with the current node if showing types
15821597
// is not a priority
@@ -1612,6 +1627,18 @@ window.scalarvis = { instanceCount: -1 };
16121627
}
16131628
break;
16141629

1630+
case "lens":
1631+
if (topLevelType) {
1632+
if (isCurrentContent) {
1633+
typeList = [];
1634+
} else {
1635+
typeList = [topLevelType];
1636+
}
1637+
} else {
1638+
typeList = base.canonicalTypeOrder;
1639+
}
1640+
break;
1641+
16151642
default:
16161643
if (topLevelType) {
16171644
typeList = [topLevelType];
@@ -1817,23 +1844,35 @@ window.scalarvis = { instanceCount: -1 };
18171844
sourceData.children = [];
18181845
}
18191846
o = nodes.length;
1847+
let okToProcess;
18201848
for (j = 0; j < o; j++) {
18211849
destNode = nodes[j];
1822-
base.processNode(destNode);
1823-
destData = {
1824-
title: destNode.title,
1825-
shortTitle: destNode.shortTitle,
1826-
node: destNode,
1827-
type: destNode.type.id,
1828-
showsTitle: true,
1829-
parent: sourceData,
1830-
children: null,
1831-
localIndex: sourceData.children.length
1832-
};
1833-
sourceData.children.push(destData);
1834-
if (base.processedNodesForHierarchy.indexOf(destNode) == -1) {
1835-
base.processedNodesForHierarchy.push(destNode);
1836-
base.addRelationsForHierarchyNode(destData);
1850+
okToProcess = true;
1851+
// if this is a lens, don't include items not returned by the lens
1852+
if (base.options.content == 'lens') {
1853+
if (base.options.lens.items) {
1854+
if (!base.options.lens.items[destNode.url]) {
1855+
okToProcess = false;
1856+
}
1857+
}
1858+
}
1859+
if (okToProcess) {
1860+
base.processNode(destNode);
1861+
destData = {
1862+
title: destNode.title,
1863+
shortTitle: destNode.shortTitle,
1864+
node: destNode,
1865+
type: destNode.type.id,
1866+
showsTitle: true,
1867+
parent: sourceData,
1868+
children: null,
1869+
localIndex: sourceData.children.length
1870+
};
1871+
sourceData.children.push(destData);
1872+
if (base.processedNodesForHierarchy.indexOf(destNode) == -1) {
1873+
base.processedNodesForHierarchy.push(destNode);
1874+
base.addRelationsForHierarchyNode(destData);
1875+
}
18371876
}
18381877
}
18391878
}
@@ -1991,16 +2030,10 @@ window.scalarvis = { instanceCount: -1 };
19912030
base.visualization.empty();
19922031
}
19932032

1994-
switch (base.getFormat()) {
1995-
1996-
case "force-directed":
1997-
if (base.force != null) {
1998-
base.force.on("tick", null);
1999-
}
2000-
base.force = null;
2001-
base.links = [];
2002-
break;
2003-
2033+
if (base.getFormat() != 'force-directed' && base.force != null) {
2034+
base.force.on("tick", null);
2035+
base.force = null;
2036+
base.links = [];
20042037
}
20052038
}
20062039

0 commit comments

Comments
 (0)