Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disabled Tags and Slide Types for non editable cells #3744

Merged
merged 2 commits into from
Aug 13, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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