mirror of
https://git.yoctoproject.org/poky
synced 2026-05-09 05:29:32 +00:00
bitbake: toaster: projectNameValidation API added
The projectNameValidation API would help users to validate if a project name exists or not. This API is added to libtoaster. [YOCTO #7005] (Bitbake rev: 3b1843553f23d78f1ddfec9f7865895ee42356a3) Signed-off-by: Sujith H <sujith.h@gmail.com> Signed-off-by: Michael Wood <michael.g.wood@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
@@ -374,6 +374,67 @@ var libtoaster = (function (){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Validate project names. Use unique project names
|
||||||
|
|
||||||
|
All arguments accepted by this function are JQeury objects.
|
||||||
|
|
||||||
|
For example if the HTML element has "hint-error-project-name", then
|
||||||
|
it is passed to this function as $("#hint-error-project-name").
|
||||||
|
|
||||||
|
Arg1 - projectName : This is a string object. In the HTML, project name will be entered here.
|
||||||
|
Arg2 - hintEerror : This is a jquery object which will accept span which throws error for
|
||||||
|
duplicate project
|
||||||
|
Arg3 - ctrlGrpValidateProjectName : This object holds the div with class "control-group"
|
||||||
|
Arg4 - enableOrDisableBtn : This object will help the API to enable or disable the form.
|
||||||
|
For example in the new project the create project button will be hidden if the
|
||||||
|
duplicate project exist. Similarly in the projecttopbar the save button will be
|
||||||
|
disabled if the project name already exist.
|
||||||
|
|
||||||
|
Return - This function doesn't return anything. It sets/unsets the behavior of the elements.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function _makeProjectNameValidation(projectName, hintError,
|
||||||
|
ctrlGrpValidateProjectName, enableOrDisableBtn ) {
|
||||||
|
|
||||||
|
function checkProjectName(projectName){
|
||||||
|
$.ajax({
|
||||||
|
type: "GET",
|
||||||
|
url: libtoaster.ctx.projectsTypeAheadUrl,
|
||||||
|
data: { 'search' : projectName },
|
||||||
|
headers: { 'X-CSRFToken' : $.cookie('csrftoken')},
|
||||||
|
success: function(data){
|
||||||
|
if (data.results.length > 0 &&
|
||||||
|
data.results[0].name === projectName) {
|
||||||
|
// This project name exists hence show the error and disable
|
||||||
|
// the save button
|
||||||
|
ctrlGrpValidateProjectName.addClass('control-group error');
|
||||||
|
hintError.show();
|
||||||
|
enableOrDisableBtn.attr('disabled', 'disabled');
|
||||||
|
} else {
|
||||||
|
ctrlGrpValidateProjectName.removeClass('control-group error');
|
||||||
|
hintError.hide();
|
||||||
|
enableOrDisableBtn.removeAttr('disabled');
|
||||||
|
}
|
||||||
|
},
|
||||||
|
error: function (data) {
|
||||||
|
console.log(data);
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/* The moment user types project name remove the error */
|
||||||
|
projectName.on("input", function() {
|
||||||
|
var projectName = $(this).val();
|
||||||
|
checkProjectName(projectName)
|
||||||
|
});
|
||||||
|
|
||||||
|
/* Validate new project name */
|
||||||
|
projectName.on("blur", function(){
|
||||||
|
var projectName = $(this).val();
|
||||||
|
checkProjectName(projectName)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
reload_params : reload_params,
|
reload_params : reload_params,
|
||||||
@@ -390,6 +451,7 @@ var libtoaster = (function (){
|
|||||||
makeLayerAddRmAlertMsg : _makeLayerAddRmAlertMsg,
|
makeLayerAddRmAlertMsg : _makeLayerAddRmAlertMsg,
|
||||||
showChangeNotification : _showChangeNotification,
|
showChangeNotification : _showChangeNotification,
|
||||||
createCustomRecipe: _createCustomRecipe,
|
createCustomRecipe: _createCustomRecipe,
|
||||||
|
makeProjectNameValidation: _makeProjectNameValidation,
|
||||||
};
|
};
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user