Skip to content

Commit

Permalink
Merge pull request #3744 from PraneetMokkapati/master
Browse files Browse the repository at this point in the history
Disabled Tags and Slide Types for non editable cells
  • Loading branch information
blink1073 committed Aug 13, 2018
2 parents 34baae5 + b3457a0 commit 98085dc
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 13 deletions.
3 changes: 3 additions & 0 deletions notebook/static/notebook/js/celltoolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,9 @@ define([
var button_container = $(div);
var lbl = $("<label/>").append($('<span/>').text(label));
var select = $('<select/>');
if(!cell.is_editable()){
select.attr("disabled","disabled")
}
for(var i=0; i < list_list.length; i++){
var opt = $('<option/>')
.attr('value', list_list[i][1])
Expand Down
30 changes: 17 additions & 13 deletions notebook/static/notebook/js/celltoolbarpresets/tags.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ define([

if (changed) {
// Make tag UI
var tag = make_tag(name, on_remove);
var tag = make_tag(name, on_remove, cell.is_editable());
tag_container.append(tag);
var tag_map = jQuery.data(tag_container, "tag_map") || {};
tag_map[name] = tag;
Expand All @@ -84,7 +84,7 @@ define([
};
};

var init_tag_container = function(cell, tag_container, on_remove) {
var init_tag_container = function(cell, tag_container, on_remove) {
var tag_list = cell.metadata.tags || [];
if (!Array.isArray(tag_list)) {
// We cannot make tags UI for this cell!
Expand All @@ -99,27 +99,29 @@ define([
// Unexpected type, disable toolbar for safety
return false;
}
var tag = make_tag(tag_name, on_remove);
var tag = make_tag(tag_name, on_remove, cell.is_editable());
tag_container.append(tag);
tag_map[tag_name] = tag;
}
jQuery.data(tag_container, 'tag_map', tag_map);
return true;
};

var make_tag = function(name, on_remove) {
var make_tag = function(name, on_remove, is_editable) {
var tag_UI = $('<span/>')
.addClass('cell-tag')
.text(name);

var remove_button = $('<i/>')
.addClass('remove-tag-btn')
.addClass('fa fa-times')
.click(function () {
on_remove(name);
return false;
});
tag_UI.append(remove_button);
if(is_editable){
var remove_button = $('<i/>')
.addClass('remove-tag-btn')
.addClass('fa fa-times')
.click(function () {
on_remove(name);
return false;
});
tag_UI.append(remove_button);
}
return tag_UI;
};

Expand Down Expand Up @@ -234,7 +236,9 @@ define([
button_container.append(tag_container);

var on_add = add_tag(cell, tag_container, on_remove);
add_tag_edit(div, cell, on_add, on_remove);
if(cell.is_editable()){
add_tag_edit(div, cell, on_add, on_remove);
}
};

var register = function(notebook) {
Expand Down

0 comments on commit 98085dc

Please sign in to comment.