Switch to a new single-selected-context layout and system in the view repository screen. Now selecting tags or images changes the context
This commit is contained in:
parent
b584d74bf0
commit
7337adf498
4 changed files with 193 additions and 68 deletions
|
@ -40,6 +40,11 @@ function ImageHistoryTree(namespace, name, images, formatComment, formatTime) {
|
|||
*/
|
||||
this.currentImage_ = null;
|
||||
|
||||
/**
|
||||
* The currently highlighted node (if any).
|
||||
*/
|
||||
this.currentNode_ = null;
|
||||
|
||||
/**
|
||||
* Counter for creating unique IDs.
|
||||
*/
|
||||
|
@ -231,6 +236,23 @@ ImageHistoryTree.prototype.setImage = function(imageId) {
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Updates the highlighted path in the tree.
|
||||
*/
|
||||
ImageHistoryTree.prototype.setHighlightedPath_ = function(image) {
|
||||
if (this.currentNode_) {
|
||||
this.markPath_(this.currentNode_, false);
|
||||
}
|
||||
|
||||
var imageByDBID = this.imageByDBID_;
|
||||
var currentNode = imageByDBID[image.dbid];
|
||||
if (currentNode) {
|
||||
this.markPath_(currentNode, true);
|
||||
this.currentNode_ = currentNode;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Returns the ancestors of the given image.
|
||||
*/
|
||||
|
@ -468,26 +490,15 @@ ImageHistoryTree.prototype.setTag_ = function(tagName) {
|
|||
// Save the current tag.
|
||||
var previousTagName = this.currentTag_;
|
||||
this.currentTag_ = tagName;
|
||||
this.currentImage_ = null;
|
||||
|
||||
// Update the state of each existing node to no longer be highlighted.
|
||||
var previousImage = this.findImage_(function(image) {
|
||||
return image.tags.indexOf(previousTagName || '(no tag specified)') >= 0;
|
||||
});
|
||||
|
||||
if (previousImage) {
|
||||
var currentNode = imageByDBID[previousImage.dbid];
|
||||
this.markPath_(currentNode, false);
|
||||
}
|
||||
|
||||
// Find the new current image (if any).
|
||||
this.currentImage_ = this.findImage_(function(image) {
|
||||
// Update the path.
|
||||
var tagImage = this.findImage_(function(image) {
|
||||
return image.tags.indexOf(tagName || '(no tag specified)') >= 0;
|
||||
});
|
||||
|
||||
// Update the state of the new node path.
|
||||
if (this.currentImage_) {
|
||||
var currentNode = imageByDBID[this.currentImage_.dbid];
|
||||
this.markPath_(currentNode, true);
|
||||
if (tagImage) {
|
||||
this.setHighlightedPath_(tagImage);
|
||||
}
|
||||
|
||||
// Ensure that the children are in the correct order.
|
||||
|
@ -531,7 +542,9 @@ ImageHistoryTree.prototype.setImage_ = function(imageId) {
|
|||
return;
|
||||
}
|
||||
|
||||
this.setHighlightedPath_(newImage);
|
||||
this.currentImage_ = newImage;
|
||||
this.currentTag_ = null;
|
||||
this.update_(this.root_);
|
||||
};
|
||||
|
||||
|
|
Reference in a new issue