");
-
- layerRevisionCtrl.addClass("error");
-
- invalidLayerRevision.html("A layer "+layerData.name+" already exists with this revision. You can import "+layerData.name+" with a different revision");
- invalidLayerRevision.show();
- break;
-
- case 'hint-layer-exists-with-different-url':
- title.text("This layer already exists");
- body.html("A layer "+layerData.name+" already exists with a different Git repository URL:
");
- duplicatedLayerName.html("A layer "+layerData.name+" already exists with a different Git repository URL. To import this layer give it a different name.");
- duplicatedLayerName.show();
- layerNameCtrl.addClass("error");
- break;
-
- case 'hint-layer-exists':
- title.text("This layer already exists");
- body.html("A layer "+layerData.name+" already exists. You can:");
- optionsList.append("
Import the layer under a different name
");
- break;
- default:
- title.text("Error")
- body.text(data.error);
- }
- }
-
- function enable_import_btn (enabled) {
+ function enable_import_btn(enabled) {
var importAndAddHint = $("#import-and-add-hint");
if (enabled) {
@@ -244,6 +191,38 @@ function importLayerPageInit (ctx) {
enable_import_btn(true);
}
+ function layerExistsError(layer){
+ var dupLayerInfo = $("#duplicate-layer-info");
+ dupLayerInfo.find(".dup-layer-name").text(layer.name);
+ dupLayerInfo.find(".dup-layer-link").attr("href", layer.layerdetailurl);
+ dupLayerInfo.find("#dup-layer-vcs-url").text(layer.giturl);
+ dupLayerInfo.find("#dup-layer-revision").text(layer.revision);
+
+ $(".fields-apart-from-layer-name").fadeOut(function(){
+
+ dupLayerInfo.fadeIn();
+ });
+ }
+
+ layerNameInput.on('blur', function() {
+ if (!$(this).val()){
+ return;
+ }
+ var name = $(this).val();
+
+ /* Check if the layer name exists */
+ $.getJSON(ctx.xhrDataTypeaheadUrl, { type : "layers", project_id: ctx.projectId, include_added: "true" , value: name }, function(layer) {
+ if (layer.list.length > 0) {
+ for (var i in layer.list){
+ if (layer.list[i].name == name) {
+ console.log(layer.list[i])
+ layerExistsError(layer.list[i]);
+ }
+ }
+ }
+ });
+ });
+
vcsURLInput.on('input', function() {
check_form();
});
@@ -260,6 +239,13 @@ function importLayerPageInit (ctx) {
return;
}
+ if ($("#duplicate-layer-info").css("display") != "None"){
+ $("#duplicate-layer-info").fadeOut(function(){
+ $(".fields-apart-from-layer-name").show();
+ });
+
+ }
+
/* Don't remove the error class if we're displaying the error for another
* reason.
*/
diff --git a/bitbake/lib/toaster/toastergui/templates/importlayer.html b/bitbake/lib/toaster/toastergui/templates/importlayer.html
index 6b2111a1f4..5ef8a5786c 100644
--- a/bitbake/lib/toaster/toastergui/templates/importlayer.html
+++ b/bitbake/lib/toaster/toastergui/templates/importlayer.html
@@ -51,26 +51,51 @@
-
+
A valid layer name can only include letters, numbers and dashes
+
+
+
A layer called already exists
+
Layer names must be unqiue. Please use a different layer name.