diff options
Diffstat (limited to 'bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html')
-rw-r--r-- | bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html b/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html new file mode 100644 index 0000000..821bbda --- /dev/null +++ b/bitbake/lib/toaster/toastergui/templates/layers_dep_modal.html @@ -0,0 +1,68 @@ +<!-- 'Layer dependencies modal' --> + <div id="dependencies_modal" class="modal hide fade" tabindex="-1" role="dialog" aria-hidden="true"> + <form id="dependencies_modal_form"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">x</button> + <h3><span class="layer-name"></span> dependencies</h3> + </div> + <div class="modal-body"> + <p><strong class="layer-name"></strong> depends on some layers that are not added to your project. Select the ones you want to add:</p> + <ul class="unstyled" id="dependencies_list"> + </ul> + </div> + <div class="modal-footer"> + <button class="btn btn-primary" type="submit">Add layers</button> + <button class="btn" type="reset" data-dismiss="modal">Cancel</button> + </div> + </form> + </div> + +<script> +function show_layer_deps_modal(projectId, layer, dependencies, successAdd) { + // update layer name + $('.layer-name').text(layer.name); + var deplistHtml = ""; + for (var i = 0; i < dependencies.length; i++) { + deplistHtml += "<li><label class=\"checkbox\"><input name=\"dependencies\" value=\""; + deplistHtml += dependencies[i].id; + deplistHtml +="\" type=\"checkbox\" checked=\"checked\"/>"; + deplistHtml += dependencies[i].name; + deplistHtml += "</label></li>"; + } + $('#dependencies_list').html(deplistHtml); + + var selected = [layer.id]; + var layer_link_list = "<a href='"+layer.url+"'>"+layer.name+"</a>"; + + $("#dependencies_modal_form").submit(function (e) { + e.preventDefault(); + $("input[name='dependencies']:checked").map(function () { selected.push(parseInt($(this).val()))}); + if (selected.length > 1) { + tooltipUpdateText = "" + selected.length + " layers added"; + } else { + tooltipUpdateText = "1 layer added"; + } + + for (var i = 0; i < selected.length; i++) { + for (var j = 0; j < dependencies.length; j++) { + if (dependencies[j].id == selected[i]) { + layer_link_list+= ", <a href='"+dependencies[j].layerdetailurl+"'>"+dependencies[j].name+"</a>" + break; + } + } + } + + $('#dependencies_modal').modal('hide'); + + var editProjectUrl = "{% url 'xhr_projectedit' project.id %}"; + libtoaster.editProject(editProjectUrl, projectId, { 'layerAdd': selected.join(",") }, function () { + if (successAdd) { + successAdd(selected); + } + }, function () { + console.log ("Adding layers to project failed"); + }); + }); + $('#dependencies_modal').modal('show'); +} +</script> |