##// END OF EJS Templates
Merge pull request #8000 from mathieu1/dashboard-nb-rename-dialog...
Min RK -
r20776:318462d4 merge
parent child Browse files
Show More
@@ -440,8 +440,8 define([
440 });
440 });
441 this.selected = selected;
441 this.selected = selected;
442
442
443 // Rename is only visible when one item is selected.
443 // Rename is only visible when one item is selected, and it is not a running notebook
444 if (selected.length==1) {
444 if (selected.length==1 && !has_running_notebook) {
445 $('.rename-button').css('display', 'inline-block');
445 $('.rename-button').css('display', 'inline-block');
446 } else {
446 } else {
447 $('.rename-button').css('display', 'none');
447 $('.rename-button').css('display', 'none');
@@ -588,29 +588,31 define([
588 if (this.selected.length != 1) return;
588 if (this.selected.length != 1) return;
589
589
590 var that = this;
590 var that = this;
591 var path = this.selected[0].path;
591 var item_path = this.selected[0].path;
592 var item_name = this.selected[0].name;
593 var item_type = this.selected[0].type;
592 var input = $('<input/>').attr('type','text').attr('size','25').addClass('form-control')
594 var input = $('<input/>').attr('type','text').attr('size','25').addClass('form-control')
593 .val(path);
595 .val(item_name);
594 var dialog_body = $('<div/>').append(
596 var dialog_body = $('<div/>').append(
595 $("<p/>").addClass("rename-message")
597 $("<p/>").addClass("rename-message")
596 .text('Enter a new directory name:')
598 .text('Enter a new '+ item_type + ' name:')
597 ).append(
599 ).append(
598 $("<br/>")
600 $("<br/>")
599 ).append(input);
601 ).append(input);
600 var d = dialog.modal({
602 var d = dialog.modal({
601 title : "Rename directory",
603 title : "Rename "+ item_type,
602 body : dialog_body,
604 body : dialog_body,
603 buttons : {
605 buttons : {
604 OK : {
606 OK : {
605 class: "btn-primary",
607 class: "btn-primary",
606 click: function() {
608 click: function() {
607 that.contents.rename(path, input.val()).then(function() {
609 that.contents.rename(item_path, utils.url_path_join(that.notebook_path, input.val())).then(function() {
608 that.load_list();
610 that.load_list();
609 }).catch(function(e) {
611 }).catch(function(e) {
610 dialog.modal({
612 dialog.modal({
611 title: "Rename Failed",
613 title: "Rename Failed",
612 body: $('<div/>')
614 body: $('<div/>')
613 .text("An error occurred while renaming \"" + path + "\" to \"" + input.val() + "\".")
615 .text("An error occurred while renaming \"" + item_name + "\" to \"" + input.val() + "\".")
614 .append($('<div/>')
616 .append($('<div/>')
615 .addClass('alert alert-danger')
617 .addClass('alert alert-danger')
616 .text(e.message || e)),
618 .text(e.message || e)),
General Comments 0
You need to be logged in to leave comments. Login now