From 1cf8f215b3543ce0f39ebd3321d58cfb518f1c1f Mon Sep 17 00:00:00 2001 From: Elliot Smith Date: Tue, 19 Apr 2016 17:28:46 +0100 Subject: bitbake: toaster: add modal to select custom image for editing Add functionality to the placeholder button on the build dashboard to open a modal dialog displaying editable custom images, in cases where multiple custom images were built by the build. Where there is only one editable custom image, go direct to its edit page. The images shown in the modal are custom recipes for the project which were built during the build shown in the dashboard. This also affects the new custom image dialog, as that also has to show custom image recipes as well as image recipes built during the build. Modify the API on the Build object to support both. Also modify and rename the queryset_to_list template filter so that it can deal with lists as well as querysets, as the new custom image modal has to show a list of image recipes which is an amalgam of two querysets. [YOCTO #9123] (Bitbake rev: 8c2aea3fa8e1071de60390e86e2536904fa9b7c0) Signed-off-by: Elliot Smith Signed-off-by: Michael Wood Signed-off-by: Richard Purdie --- .../toastergui/templates/basebuildpage.html | 62 ++++++++++++---------- 1 file changed, 35 insertions(+), 27 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/templates/basebuildpage.html') diff --git a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html index 4a8e2a7abd..0d8c8820da 100644 --- a/bitbake/lib/toaster/toastergui/templates/basebuildpage.html +++ b/bitbake/lib/toaster/toastergui/templates/basebuildpage.html @@ -1,7 +1,7 @@ {% extends "base.html" %} {% load projecttags %} {% load project_url_tag %} -{% load queryset_to_list_filter %} +{% load objects_to_dictionaries_filter %} {% load humanize %} {% block pagecontent %} @@ -81,33 +81,40 @@

-
  • - - - {% include 'editcustomimage_modal.html' %} - -
  • + // edit custom image which was built during this build + editCustomImageTrigger.click(function () { + // single editable custom image: redirect to the edit page + // for that image + if (editableCustomImageRecipes.length === 1) { + var url = '{% url "customrecipe" build.project.id custom_image_recipes.first.id %}'; + document.location.href = url; + } + // multiple editable custom images: show modal to select + // one of them for editing + else { + editCustomImageModal.modal('show'); + } + }); + }); + +

    + + {% endif %} + {% endwith %}
  • @@ -119,7 +126,7 @@ // imageRecipes includes both custom image recipes and built-in // image recipes, any of which can be used as the basis for a // new custom image - var imageRecipes = {{ build.get_image_recipes | queryset_to_list:"id,name" | json }}; + var imageRecipes = {{ build.get_image_recipes | objects_to_dictionaries:"id,name" | json }}; $(document).ready(function () { var newCustomImageModal = $('#new-custom-image-modal'); @@ -131,6 +138,7 @@ if (!imageRecipes.length) { return; } + newCustomImageModalSetRecipes(imageRecipes); newCustomImageModal.modal('show'); }); -- cgit v1.2.3-54-g00ecf