diff options
author | Sujith H <sujith.h@gmail.com> | 2016-05-10 00:01:48 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-05-11 11:32:58 +0100 |
commit | 9bdfed856b2e780cf40342bd22ac35fb28f1b2c4 (patch) | |
tree | edf0321735587f9ad3192a68fb9ff007733b71d9 /bitbake | |
parent | cc2f1368dc9615669765f2852eac0da383401d49 (diff) | |
download | poky-9bdfed856b2e780cf40342bd22ac35fb28f1b2c4.tar.gz |
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>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/libtoaster.js | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js index 43930a2c30..0d1486b831 100644 --- a/bitbake/lib/toaster/toastergui/static/js/libtoaster.js +++ b/bitbake/lib/toaster/toastergui/static/js/libtoaster.js | |||
@@ -374,6 +374,67 @@ var libtoaster = (function (){ | |||
374 | }); | 374 | }); |
375 | } | 375 | } |
376 | 376 | ||
377 | /* Validate project names. Use unique project names | ||
378 | |||
379 | All arguments accepted by this function are JQeury objects. | ||
380 | |||
381 | For example if the HTML element has "hint-error-project-name", then | ||
382 | it is passed to this function as $("#hint-error-project-name"). | ||
383 | |||
384 | Arg1 - projectName : This is a string object. In the HTML, project name will be entered here. | ||
385 | Arg2 - hintEerror : This is a jquery object which will accept span which throws error for | ||
386 | duplicate project | ||
387 | Arg3 - ctrlGrpValidateProjectName : This object holds the div with class "control-group" | ||
388 | Arg4 - enableOrDisableBtn : This object will help the API to enable or disable the form. | ||
389 | For example in the new project the create project button will be hidden if the | ||
390 | duplicate project exist. Similarly in the projecttopbar the save button will be | ||
391 | disabled if the project name already exist. | ||
392 | |||
393 | Return - This function doesn't return anything. It sets/unsets the behavior of the elements. | ||
394 | */ | ||
395 | |||
396 | function _makeProjectNameValidation(projectName, hintError, | ||
397 | ctrlGrpValidateProjectName, enableOrDisableBtn ) { | ||
398 | |||
399 | function checkProjectName(projectName){ | ||
400 | $.ajax({ | ||
401 | type: "GET", | ||
402 | url: libtoaster.ctx.projectsTypeAheadUrl, | ||
403 | data: { 'search' : projectName }, | ||
404 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
405 | success: function(data){ | ||
406 | if (data.results.length > 0 && | ||
407 | data.results[0].name === projectName) { | ||
408 | // This project name exists hence show the error and disable | ||
409 | // the save button | ||
410 | ctrlGrpValidateProjectName.addClass('control-group error'); | ||
411 | hintError.show(); | ||
412 | enableOrDisableBtn.attr('disabled', 'disabled'); | ||
413 | } else { | ||
414 | ctrlGrpValidateProjectName.removeClass('control-group error'); | ||
415 | hintError.hide(); | ||
416 | enableOrDisableBtn.removeAttr('disabled'); | ||
417 | } | ||
418 | }, | ||
419 | error: function (data) { | ||
420 | console.log(data); | ||
421 | }, | ||
422 | }); | ||
423 | } | ||
424 | |||
425 | /* The moment user types project name remove the error */ | ||
426 | projectName.on("input", function() { | ||
427 | var projectName = $(this).val(); | ||
428 | checkProjectName(projectName) | ||
429 | }); | ||
430 | |||
431 | /* Validate new project name */ | ||
432 | projectName.on("blur", function(){ | ||
433 | var projectName = $(this).val(); | ||
434 | checkProjectName(projectName) | ||
435 | }); | ||
436 | } | ||
437 | |||
377 | 438 | ||
378 | return { | 439 | return { |
379 | reload_params : reload_params, | 440 | reload_params : reload_params, |
@@ -390,6 +451,7 @@ var libtoaster = (function (){ | |||
390 | makeLayerAddRmAlertMsg : _makeLayerAddRmAlertMsg, | 451 | makeLayerAddRmAlertMsg : _makeLayerAddRmAlertMsg, |
391 | showChangeNotification : _showChangeNotification, | 452 | showChangeNotification : _showChangeNotification, |
392 | createCustomRecipe: _createCustomRecipe, | 453 | createCustomRecipe: _createCustomRecipe, |
454 | makeProjectNameValidation: _makeProjectNameValidation, | ||
393 | }; | 455 | }; |
394 | })(); | 456 | })(); |
395 | 457 | ||