Skip to content

Commit

Permalink
Disable Figure Scripts if selected objects not suitable
Browse files Browse the repository at this point in the history
  • Loading branch information
Will Moore committed Jan 15, 2013
1 parent 35aaf71 commit 92f3a07
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,29 @@ def getPlateId(self):
elif self.acquisition:
return self.acquisition._obj.plate.id.val


def listFigureScripts(self, objDict=None):
"""
This configures all the Figure Scripts, setting their enabled status given the
currently selected object (self.image etc) or batch objects (uses objDict).
"""
figureScripts = []
# id is used in url and is mapped to full script path by views.figure_script()
splitView = {'id': 'SplitView', 'name':'Split View Figure', 'enabled': False,
'tooltip': "Create a figure of images, splitting their channels into separate views"}
# Split View Figure is enabled if we have at least one image with SizeC > 1
if self.image:
splitView['enabled'] = (self.image.getSizeC() > 1)
elif objDict is not None:
if 'image' in objDict:
for i in objDict['image']:
if i.getSizeC() > 1:
splitView['enabled'] = True
break
figureScripts.append(splitView)
return figureScripts


def openAstexViewerCompatible(self):
"""
Is the image suitable to be viewed with the Volume viewer 'Open Astex Viewer' applet?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,13 @@ OME.initToolbarDropdowns = function() {

// For Figure scripts, we need a popup:
$("#figScriptList li a").click(function(event){
OME.openScriptWindow(event, 800, 600);
if (!$(this).parent().hasClass("disabled")) {
OME.openScriptWindow(event, 800, 600);
}
event.preventDefault();
return false;
});
}
};

jQuery.fn.tooltip_init = function() {
$(this).tooltip({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,13 @@
<span></span>
</button>
<ul id="figScriptList" class="dropdown">
<li>
<a href="{% url figure_script 'SplitView' %}">
Split View Figure
{% for script in figScripts %}
<li {% if not script.enabled %}class="disabled"{% endif %}
title="{{ script.tooltip }}">
<a href="{% url figure_script script.id %}">
{{ script.name }}
</a>
</li>
{% endfor %}
</ul>
</div>
8 changes: 6 additions & 2 deletions components/tools/OmeroWeb/omeroweb/webclient/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,14 +811,16 @@ def load_metadata_details(request, c_type, c_id, conn=None, share_id=None, **kwa
if share_id is None:
template = "webclient/annotations/metadata_general.html"
manager.annotationList()
figScripts = manager.listFigureScripts()
form_comment = CommentAnnotationForm(initial=initial)
else:
template = "webclient/annotations/annotations_share.html"

if c_type in ("tag"):
context = {'manager':manager}
else:
context = {'manager':manager, 'form_comment':form_comment, 'index':index, 'share_id':share_id}
context = {'manager':manager, 'form_comment':form_comment, 'index':index,
'share_id':share_id, 'figScripts':figScripts}
context['template'] = template
context['webclient_path'] = request.build_absolute_uri(reverse('webindex'))
return context
Expand Down Expand Up @@ -1083,6 +1085,7 @@ def batch_annotate(request, conn=None, **kwargs):

manager = BaseContainer(conn)
batchAnns = manager.loadBatchAnnotations(objs)
figScripts = manager.listFigureScripts(objs)

obj_ids = []
obj_labels = []
Expand All @@ -1094,7 +1097,8 @@ def batch_annotate(request, conn=None, **kwargs):
link_string = "|".join(obj_ids).replace("=", "-")

context = {'form_comment':form_comment, 'obj_string':obj_string, 'link_string': link_string,
'obj_labels': obj_labels, 'batchAnns': batchAnns, 'batch_ann':True, 'index': index}
'obj_labels': obj_labels, 'batchAnns': batchAnns, 'batch_ann':True, 'index': index,
'figScripts':figScripts}
context['template'] = "webclient/annotations/batch_annotate.html"
context['webclient_path'] = request.build_absolute_uri(reverse('webindex'))
return context
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@
float:none;
position:relative;
}

.dropdown li.disabled {
background: transparent;
}
.dropdown li.disabled a {
color: #999;
}

/* The menuItem class is added by js to items with children */
.dropdown > li > a.menuItem {
Expand All @@ -488,6 +495,12 @@
filter:progid:DXImageTransform.Microsoft.gradient( startColorstr='#6B8FB3', endColorstr='#5C7A99',GradientType=0 ); /* IE6-9 */
background:linear-gradient(top, hsl(210,50%,60%) 0%,hsl(210,50%,50%) 100%); /* W3C */

}

.dropdown li.disabled:hover {
background: transparent !important;
border-bottom: 1px solid transparent;
border-top: 1px solid transparent;
}

.dropdown a, #group_user_chooser li strong{
Expand All @@ -514,6 +527,10 @@
color:white ;
text-shadow:none !important;
}

.dropdown li.disabled:hover a {
color: #999;
}

.dropdown li ul li a{
color:#333 !important;
Expand Down

0 comments on commit 92f3a07

Please sign in to comment.