diff options
author | Michael Wood <michael.g.wood@intel.com> | 2016-09-26 13:59:31 +0300 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-09-30 16:52:22 +0100 |
commit | 0d70606022cad010f586ec29b558ee902be765ef (patch) | |
tree | dfcfb5b5ca63c6c1047807fd64ec482d73a2b1a5 /bitbake/lib/toaster/toastergui/static | |
parent | 7ca44f53bccf48d289c5f53c00ca7026aacef6dd (diff) | |
download | poky-0d70606022cad010f586ec29b558ee902be765ef.tar.gz |
bitbake: toaster: project page Implement front end feature to delete project
Add confirm modal and api calls to delete a project from the project
dashboard.
[YOCTO #6238]
(Bitbake rev: e1cca28826dfa66d905dd4daf9964564c355207e)
Signed-off-by: Michael Wood <michael.g.wood@intel.com>
Signed-off-by: Ed Bartosh <ed.bartosh@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/toastergui/static')
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/projectpage.js | 30 | ||||
-rw-r--r-- | bitbake/lib/toaster/toastergui/static/js/projecttopbar.js | 6 |
2 files changed, 32 insertions, 4 deletions
diff --git a/bitbake/lib/toaster/toastergui/static/js/projectpage.js b/bitbake/lib/toaster/toastergui/static/js/projectpage.js index 3bf3cbaf2b..7f19c0d7aa 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projectpage.js +++ b/bitbake/lib/toaster/toastergui/static/js/projectpage.js | |||
@@ -45,6 +45,9 @@ function projectPageInit(ctx) { | |||
45 | 45 | ||
46 | /* Now we're really ready show the page */ | 46 | /* Now we're really ready show the page */ |
47 | $("#project-page").show(); | 47 | $("#project-page").show(); |
48 | |||
49 | /* Set the project name in the delete modal */ | ||
50 | $("#delete-project-modal .project-name").text(prjInfo.name); | ||
48 | }); | 51 | }); |
49 | 52 | ||
50 | (function notificationRequest(){ | 53 | (function notificationRequest(){ |
@@ -328,7 +331,32 @@ function projectPageInit(ctx) { | |||
328 | 331 | ||
329 | $("#delete-project-confirmed").click(function(e){ | 332 | $("#delete-project-confirmed").click(function(e){ |
330 | e.preventDefault(); | 333 | e.preventDefault(); |
331 | 334 | libtoaster.disableAjaxLoadingTimer(); | |
335 | $(this).find('[data-role="submit-state"]').hide(); | ||
336 | $(this).find('[data-role="loading-state"]').show(); | ||
337 | $(this).attr("disabled", "disabled"); | ||
338 | $('#delete-project-modal [data-dismiss="modal"]').hide(); | ||
339 | |||
340 | $.ajax({ | ||
341 | type: 'DELETE', | ||
342 | url: libtoaster.ctx.xhrProjectUrl, | ||
343 | headers: { 'X-CSRFToken' : $.cookie('csrftoken')}, | ||
344 | success: function (data) { | ||
345 | if (data.error !== "ok") { | ||
346 | console.warn(data.error); | ||
347 | } else { | ||
348 | var msg = $('<span>You have deleted <strong>1</strong> project: <strong id="project-deleted"></strong></span>'); | ||
349 | |||
350 | msg.find("#project-deleted").text(libtoaster.ctx.projectName); | ||
351 | libtoaster.setNotification("project-deleted", msg.html()); | ||
352 | |||
353 | window.location.replace(data.gotoUrl); | ||
354 | } | ||
355 | }, | ||
356 | error: function (data) { | ||
357 | console.warn(data); | ||
358 | } | ||
359 | }); | ||
332 | }); | 360 | }); |
333 | 361 | ||
334 | } | 362 | } |
diff --git a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js index f0cd18bf48..92ab2d67fd 100644 --- a/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js +++ b/bitbake/lib/toaster/toastergui/static/js/projecttopbar.js | |||
@@ -4,7 +4,7 @@ function projectTopBarInit(ctx) { | |||
4 | 4 | ||
5 | var projectNameForm = $("#project-name-change-form"); | 5 | var projectNameForm = $("#project-name-change-form"); |
6 | var projectNameContainer = $("#project-name-container"); | 6 | var projectNameContainer = $("#project-name-container"); |
7 | var projectName = $("#project-name"); | 7 | var projectName = $(".project-name"); |
8 | var projectNameFormToggle = $("#project-change-form-toggle"); | 8 | var projectNameFormToggle = $("#project-change-form-toggle"); |
9 | var projectNameChangeCancel = $("#project-name-change-cancel"); | 9 | var projectNameChangeCancel = $("#project-name-change-cancel"); |
10 | 10 | ||
@@ -25,14 +25,14 @@ function projectTopBarInit(ctx) { | |||
25 | e.preventDefault(); | 25 | e.preventDefault(); |
26 | projectNameForm.hide(); | 26 | projectNameForm.hide(); |
27 | projectNameContainer.fadeIn(); | 27 | projectNameContainer.fadeIn(); |
28 | $("#project-name-change-input").val(projectName.text()); | 28 | $("#project-name-change-input").val(projectName.first().text()); |
29 | }); | 29 | }); |
30 | 30 | ||
31 | $("#project-name-change-btn").click(function(){ | 31 | $("#project-name-change-btn").click(function(){ |
32 | var newProjectName = $("#project-name-change-input").val(); | 32 | var newProjectName = $("#project-name-change-input").val(); |
33 | 33 | ||
34 | libtoaster.editCurrentProject({ projectName: newProjectName }, function (){ | 34 | libtoaster.editCurrentProject({ projectName: newProjectName }, function (){ |
35 | projectName.html(newProjectName); | 35 | projectName.text(newProjectName); |
36 | libtoaster.ctx.projectName = newProjectName; | 36 | libtoaster.ctx.projectName = newProjectName; |
37 | projectNameChangeCancel.click(); | 37 | projectNameChangeCancel.click(); |
38 | }); | 38 | }); |