function basePageInit (ctx) {
var newBuildButton = $("#new-build-button");
- /* Hide the button if we're on the project,newproject or importlyaer page */
- if (ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
- newBuildButton.hide();
- return;
+ /* Hide the button if we're on the project,newproject or importlyaer page
+ * or if there are no projects yet defined
+ */
+ if (ctx.numProjects == 0 || ctx.currentUrl.search('newproject|project/\\d/$|importlayer/$') > 0){
+ newBuildButton.hide();
+ return;
}
function _checkProjectBuildable(){
+ if (ctx.projectId == undefined)
+ return;
+
libtoaster.getProjectInfo(ctx.projectInfoUrl, ctx.projectId,
function(data){
if (data.machine.name == undefined || data.layers.length == 0) {
ctx.projectBuildUrl = "{% url 'xhr_build' %}";
ctx.projectPageUrl = "{% url 'project' %}";
ctx.projectInfoUrl = "{% url 'xhr_projectinfo' %}";
+ ctx.numProjects = {{projects|length}};
{% if project %}
ctx.projectId = {{project.id}};
{% endif %}