Skip to content

Commit

Permalink
Always select an allowed default marking in model wizards. Closes #311.
Browse files Browse the repository at this point in the history
  • Loading branch information
tshead2 committed Jan 21, 2015
1 parent 702e7a4 commit be53e70
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 8 deletions.
19 changes: 14 additions & 5 deletions web-server/js/slycat-markings.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,26 @@ DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government retains certain
rights in this software.
*/

define("slycat-markings", ["slycat-web-client", "knockout-mapping"], function(client, mapping)
define("slycat-markings", ["slycat-web-client", "knockout", "knockout-mapping"], function(client, ko, mapping)
{
var markings = mapping.fromJS([]);
var module = {};

module.allowed = mapping.fromJS([]);
module.preselected = ko.observable(null);

client.get_configuration_markings(
{
success: function(results)
success: function(markings)
{
mapping.fromJS(results, markings);
markings.sort(function(left, right)
{
return left.type == right.type ? 0 : left.type < right.type ? -1 : 1;
});
mapping.fromJS(markings, module.allowed);
if(markings.length)
module.preselected(markings[0].type)
},
});

return markings;
return module;
});
12 changes: 11 additions & 1 deletion web-server/js/slycat-model-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@ define("slycat-model-controls", ["slycat-server-root", "slycat-web-client", "sly
component.name = params.name;
component.description = params.description;
component.marking = params.marking;
component.markings = markings;
component.markings = markings.allowed;

// This is a tad awkward, but a default marking may-or-may-not be available yet.
if(component.marking() === null)
{
component.marking(markings.preselected());
markings.preselected.subscribe(function()
{
component.marking(markings.preselected());
});
}
},
template: { require: "text!" + server_root + "templates/slycat-model-controls.html" }
});
Expand Down
2 changes: 1 addition & 1 deletion web-server/js/slycat-navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ define("slycat-navbar", ["slycat-server-root", "slycat-web-client", "slycat-mark
component.version = mapping.fromJS({version:"unknown", commit:"unknown"});

// Get available server markings.
component.markings = markings;
component.markings = markings.allowed;

// Watch running models
component.models = models_feed.watch();
Expand Down
2 changes: 1 addition & 1 deletion web-server/js/slycat-project-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ define("slycat-project-main", ["slycat-server-root", "slycat-web-client", "slyca
{
return model.project() == page.project._id();
});
page.markings = markings;
page.markings = markings.allowed;
page.badge = function(marking)
{
for(var i = 0; i != page.markings().length; ++i)
Expand Down

0 comments on commit be53e70

Please sign in to comment.