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 --- .../toaster/toastergui/static/js/newcustomimage_modal.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js') diff --git a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js index 1ae0d34e90..cb9ed4da05 100644 --- a/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js +++ b/bitbake/lib/toaster/toastergui/static/js/newcustomimage_modal.js @@ -12,6 +12,7 @@ for the new custom image. This will manage the addition of radio buttons to select the base image (or remove the radio buttons, if there is only a single base image available). */ + function newCustomImageModalInit(){ var newCustomImgBtn = $("#create-new-custom-image-btn"); @@ -21,7 +22,8 @@ function newCustomImageModalInit(){ var nameInput = imgCustomModal.find('input'); var invalidNameMsg = "Image names cannot contain spaces or capital letters. The only allowed special character is dash (-)."; - var duplicateNameMsg = "An image with this name already exists. Image names must be unique."; + var duplicateNameMsg = "A recipe with this name already exists. Image names must be unique."; + var duplicateImageInProjectMsg = "An image with this name already exists in this project." var invalidBaseRecipeIdMsg = "Please select an image to customise."; // capture clicks on radio buttons inside the modal; when one is selected, @@ -51,9 +53,12 @@ function newCustomImageModalInit(){ if (ret.error === "invalid-name") { showNameError(invalidNameMsg); return; - } else if (ret.error === "already-exists") { + } else if (ret.error === "recipe-already-exists") { showNameError(duplicateNameMsg); return; + } else if (ret.error === "image-already-exists") { + showNameError(duplicateImageInProjectMsg); + return; } } else { imgCustomModal.modal('hide'); @@ -112,13 +117,13 @@ function newCustomImageModalSetRecipes(baseRecipes) { var imageSelector = $('#new-custom-image-modal [data-role="image-selector"]'); var imageSelectRadiosContainer = $('#new-custom-image-modal [data-role="image-selector-radios"]'); + // remove any existing radio buttons + labels + imageSelector.remove('[data-role="image-radio"]'); + if (baseRecipes.length === 1) { // hide the radio button container imageSelector.hide(); - // remove any radio buttons + labels - imageSelector.remove('[data-role="image-radio"]'); - // set the single recipe ID on the modal as it's the only one // we can build from imgCustomModal.data('recipe', baseRecipes[0].id); -- cgit v1.2.3-54-g00ecf