From 15a256954e68bb8f98b28436019228b6dfee5227 Mon Sep 17 00:00:00 2001 From: Martin Chovanec Date: Thu, 4 May 2017 02:09:45 +0200 Subject: [PATCH] Set experiment config to be expandable (prototype) --- .../static/scripts/runs/dictionaryBrowser.html | 3 ++- .../static/scripts/runs/dictionaryBrowser.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/sacredboard/static/scripts/runs/dictionaryBrowser.html b/sacredboard/static/scripts/runs/dictionaryBrowser.html index ecf68f1..797c3d4 100644 --- a/sacredboard/static/scripts/runs/dictionaryBrowser.html +++ b/sacredboard/static/scripts/runs/dictionaryBrowser.html @@ -1,3 +1,4 @@ - + +
\ No newline at end of file diff --git a/sacredboard/static/scripts/runs/dictionaryBrowser.js b/sacredboard/static/scripts/runs/dictionaryBrowser.js index dcd6c0a..417610a 100644 --- a/sacredboard/static/scripts/runs/dictionaryBrowser.js +++ b/sacredboard/static/scripts/runs/dictionaryBrowser.js @@ -3,11 +3,18 @@ define(["knockout", "jquery", "escapeHtml", "text!runs/dictionaryBrowser.html"], function (ko, $, escapeHtml, htmlTemplate) { ko.components.register("dictionary-browser", { viewModel: function (params) { - this.dict = new DictEntry("", params.value); this.escape = escapeHtml; + this.dict = new DictEntry("", params.value); function DictEntry(name, value) { var self = this; + this.value = value; + this.contentCollapsed = ko.observable(true); + this.toggleCollapse = function () { + if (self.hasChildren()) { + self.contentCollapsed(!self.contentCollapsed()); + } + }; this.hasChildren = function () { return typeof value == "object"; }; @@ -27,12 +34,15 @@ define(["knockout", "jquery", "escapeHtml", "text!runs/dictionaryBrowser.html"], }; this.getDisplayValue = function () { if (value instanceof Array) { - return value.join(", "); + return "[" + value.join(", ") + "]"; } else { return value.toString(); } }; + + this.content = value; } + DictEntry.prototype.EMPTY = ""; }, template: htmlTemplate });