group snapshots by place

This commit is contained in:
Howard Stearns 2016-11-12 17:00:54 -08:00
parent 0876dbc809
commit fac5d1e12e
2 changed files with 25 additions and 4 deletions

View file

@ -114,6 +114,7 @@ Window {
timestamp: model.created_at; timestamp: model.created_at;
onlineUsers: model.online_users; onlineUsers: model.online_users;
storyId: model.metaverseId; storyId: model.metaverseId;
drillDownToPlace: model.drillDownToPlace;
hoverThunk: function () { ListView.view.currentIndex = index; } hoverThunk: function () { ListView.view.currentIndex = index; }
unhoverThunk: function () { ListView.view.currentIndex = -1; } unhoverThunk: function () { ListView.view.currentIndex = -1; }
} }
@ -362,6 +363,7 @@ Window {
tags: tags, tags: tags,
description: description, description: description,
online_users: data.details.concurrency || 0, online_users: data.details.concurrency || 0,
drillDownToPlace: false,
searchText: [name].concat(tags, description || []).join(' ').toUpperCase() searchText: [name].concat(tags, description || []).join(' ').toUpperCase()
} }
@ -373,6 +375,22 @@ Window {
return (place.place_name !== AddressManager.hostname); // Not our entry, but do show other entry points to current domain. return (place.place_name !== AddressManager.hostname); // Not our entry, but do show other entry points to current domain.
// could also require right protocolVersion // could also require right protocolVersion
} }
property var placeMap: ({});
function addToSuggestions(place) {
// This version always collapses. But, if we have a tabbed interface as in #9061, we might only collapse on all.
var collapse = place.action !== 'concurrency';
if (collapse) {
var existing = placeMap[place.place_name];
if (existing) {
existing.drillDownToPlace = true;
return;
}
}
suggestions.append(place);
if (collapse) {
placeMap[place.place_name] = suggestions.get(suggestions.count - 1);
}
}
function getUserStoryPage(pageNumber, cb) { // cb(error) after all pages of domain data have been added to model function getUserStoryPage(pageNumber, cb) { // cb(error) after all pages of domain data have been added to model
var options = [ var options = [
'include_actions=snapshot,concurrency', 'include_actions=snapshot,concurrency',
@ -391,7 +409,7 @@ Window {
if (!addressLine.text) { // Don't add if the user is already filtering if (!addressLine.text) { // Don't add if the user is already filtering
stories.forEach(function (story) { stories.forEach(function (story) {
if (suggestable(story)) { if (suggestable(story)) {
suggestions.append(story); addToSuggestions(story);
} }
}); });
} }
@ -403,6 +421,7 @@ Window {
} }
function filterChoicesByText() { function filterChoicesByText() {
suggestions.clear(); suggestions.clear();
placeMap = {};
var words = addressLine.text.toUpperCase().split(/\s+/).filter(identity), var words = addressLine.text.toUpperCase().split(/\s+/).filter(identity),
data = allStories; data = allStories;
function matches(place) { function matches(place) {
@ -415,7 +434,7 @@ Window {
} }
data.forEach(function (place) { data.forEach(function (place) {
if (matches(place)) { if (matches(place)) {
suggestions.append(place); addToSuggestions(place);
} }
}); });
} }
@ -423,6 +442,7 @@ Window {
function fillDestinations() { function fillDestinations() {
allStories = []; allStories = [];
suggestions.clear(); suggestions.clear();
placeMap = {};
getUserStoryPage(1, function (error) { getUserStoryPage(1, function (error) {
console.log('user stories query', error || 'ok', allStories.length); console.log('user stories query', error || 'ok', allStories.length);
}); });

View file

@ -27,6 +27,7 @@ Rectangle {
property var goFunction: null; property var goFunction: null;
property string storyId: ""; property string storyId: "";
property bool drillDownToPlace: false;
property string timePhrase: pastTime(timestamp); property string timePhrase: pastTime(timestamp);
property int onlineUsers: 0; property int onlineUsers: 0;
@ -113,7 +114,7 @@ Rectangle {
} }
FiraSansRegular { FiraSansRegular {
id: users; id: users;
text: (action === 'concurrency') ? onlineUsers : 'snapshot'; text: (action === 'concurrency') ? onlineUsers : ('snapshot' + (drillDownToPlace ? 's' : ''));
size: (action === 'concurrency') ? textSize : textSizeSmall; size: (action === 'concurrency') ? textSize : textSizeSmall;
color: hifi.colors.white; color: hifi.colors.white;
anchors { anchors {
@ -140,7 +141,7 @@ Rectangle {
id: usersImage; id: usersImage;
imageURL: "../../images/" + action + ".svg"; imageURL: "../../images/" + action + ".svg";
size: 32; size: 32;
onClicked: goFunction("/user_stories/" + storyId); onClicked: goFunction(drillDownToPlace ? ("/places/" + placeName) : ("/user_stories/" + storyId));
buttonState: 0; buttonState: 0;
defaultState: 0; defaultState: 0;
hoverState: 1; hoverState: 1;