Diff
Modified: trunk/app/controllers/workflows_controller.rb (3165 => 3166)
--- trunk/app/controllers/workflows_controller.rb 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/app/controllers/workflows_controller.rb 2012-10-19 14:48:14 UTC (rev 3166)
@@ -550,24 +550,35 @@
# PUT /workflows/1;update_version
def update_version
+ original_title = @workflow.title
+
success = false
- if params[:version]
+ if params[:version] && params[:workflow]
- original_title = @workflow.title
- version = @workflow.find_version(params[:version])
- do_preview = !params[:workflow][:preview].blank? && params[:workflow][:preview].size > 0
+ version = @workflow.find_version(params[:version])
- attributes_to_update = {
- :title => params[:workflow][:title],
- :body => params[:workflow][:body],
- :last_edited_by => current_user.id
- }
+ attributes_to_update = { :last_edited_by => current_user.id }
- # only set the preview to update if one was provided
+ # only update title if the title isn't provided from the workflow processor
- attributes_to_update[:image] = params[:workflow][:preview] if do_preview
+ unless version.can_infer_title?
+ attributes_to_update[:title] = params[:workflow][:title] if params[:workflow][:title]
+ end
+ # only update description if the description isn't provided by the workflow processor
+
+ unless version.can_infer_description?
+ attributes_to_update[:body] = params[:workflow][:body] if params[:workflow][:body]
+ end
+
+ # only set the preview to update if one was provided and it can't be
+ # generated from the workflow processer
+
+ if !version.can_generate_preview_image? && !params[:workflow][:preview].blank? && params[:workflow][:preview].size > 0
+ attributes_to_update[:image] = params[:workflow][:preview]
+ end
+
success = version.update_attributes(attributes_to_update)
end
Modified: trunk/app/models/workflow.rb (3165 => 3166)
--- trunk/app/models/workflow.rb 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/app/models/workflow.rb 2012-10-19 14:48:14 UTC (rev 3166)
@@ -160,6 +160,30 @@
return proc_class.can_infer_metadata?
end
+ def can_infer_title?
+ if processor_class
+ processor_class.can_infer_title?
+ else
+ false
+ end
+ end
+
+ def can_infer_description?
+ if processor_class
+ processor_class.can_infer_description?
+ else
+ false
+ end
+ end
+
+ def can_generate_preview_image?
+ if processor_class
+ processor_class.can_generate_preview_image?
+ else
+ false
+ end
+ end
+
def type_display_name
content_type.title
end
Modified: trunk/app/models/workflow_version.rb (3165 => 3166)
--- trunk/app/models/workflow_version.rb 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/app/models/workflow_version.rb 2012-10-19 14:48:14 UTC (rev 3166)
@@ -33,7 +33,7 @@
def processor_class
if self.content_type
- @processor_class ||= WorkflowTypesHandler.processor_class_for_type_display_name(self.content_type.title)
+ @processor_class ||= WorkflowTypesHandler.processor_class_for_type_display_name(self.content_type.title)
end
end
@@ -42,5 +42,28 @@
@display_data_format = (klass.nil? ? self.file_ext : klass.display_data_format)
end
+ def can_infer_title?
+ if processor_class
+ processor_class.can_infer_title?
+ else
+ false
+ end
+ end
+
+ def can_infer_description?
+ if processor_class
+ processor_class.can_infer_description?
+ else
+ false
+ end
+ end
+
+ def can_generate_preview_image?
+ if processor_class
+ processor_class.can_generate_preview_image?
+ else
+ false
+ end
+ end
end
Modified: trunk/app/views/workflows/edit_version.rhtml (3165 => 3166)
--- trunk/app/views/workflows/edit_version.rhtml 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/app/views/workflows/edit_version.rhtml 2012-10-19 14:48:14 UTC (rev 3166)
@@ -1,5 +1,11 @@
<% t "Edit Version" -%>
+<% title_edit = address@hidden %>
+<% preview_edit = address@hidden %>
+<% description_edit = address@hidden %>
+
+<% can_edit_anything = title_edit || preview_edit || description_edit %>
+
<%= _javascript__include_tag "fckeditor/fckeditor.js" %>
<h1>
@@ -25,29 +31,50 @@
<!-- Title -->
<p>
<b>Title</b>
- <span class="required">*</span>
+ <% if title_edit %>
+ <span class="required">*</span>
+ <% end %>
</p>
- <%= text_field_tag 'workflow[title]', @viewing_version.title, :size => '60' %>
+
+ <% if title_edit %>
+ <%= text_field_tag 'workflow[title]', @viewing_version.title, :size => '60' %>
+ <% else %>
+ <p class="derived_annotation_notice">The title is derived from the workflow file. Please edit the workflow directly and upload a new version to change the title of this workflow.</p>
+ <% end %>
<br/>
<!-- Preview Image -->
<p><b>Preview Image</b></p>
- <input id="workflow_preview" name="workflow[preview]" size="50" type="file" />
- <p style="font-size: 77%; color: #666666; font-style: italic; padding-top: 0;">
- Leave this blank to keep the existing preview image
- </p>
+
+ <% if preview_edit %>
+ <input id="workflow_preview" name="workflow[preview]" size="50" type="file" />
+ <p style="font-size: 77%; color: #666666; font-style: italic; padding-top: 0;">
+ Leave this blank to keep the existing preview image
+ </p>
+ <% else %>
+ <p class="derived_annotation_notice">The preview image is derived from the workflow file. Please edit the workflow directly and upload a new version to change the appearance of this workflow.</p>
+ <% end %>
<br/>
<!-- Description -->
<p><b>Description</b></p>
- <%= fckeditor_textarea(:workflow, :body, :toolbarSet => 'Simple', :width => '500px', :height => '500px') %>
-
- <br />
+ <% if description_edit %>
+ <%= fckeditor_textarea(:workflow, :body, :toolbarSet => 'Simple', :width => '500px', :height => '500px') %>
+
+ <br />
+ <% else %>
+ <p class="derived_annotation_notice">The description is derived from the workflow file. Please edit the workflow directly and upload a new version to change the description of this workflow.</p>
+ <% end %>
+
<br />
- <center><%= submit_tag "Update", :disable_with => "Updating..." %></center>
+ <center>
+ <% if can_edit_anything %>
+ <%= submit_tag "Update", :disable_with => "Updating..." %>
+ <% end %>
+ </center>
</div>
</center>
Modified: trunk/lib/workflow_processors/interface.rb (3165 => 3166)
--- trunk/lib/workflow_processors/interface.rb 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/lib/workflow_processors/interface.rb 2012-10-19 14:48:14 UTC (rev 3166)
@@ -6,23 +6,23 @@
# Defines an interface that all workflow type processors need to adhere to.
module WorkflowProcessors
class Interface
-
+
# Begin Class Methods
-
- # These:
+
+ # These:
# - provide information about the Workflow Type supported by this processor,
# - provide information about the processor's capabilites, and
# - provide any general functionality.
-
+
# MUST be unique across all processors
def self.display_name
""
end
-
+
def self.display_data_format
""
end
-
+
def self.mime_type
"application/octet-stream"
end
@@ -36,27 +36,35 @@
def self.default_file_extension
nil
end
-
+
def self.can_determine_type_from_file?
false
end
-
+
def self.recognised?(file)
false
end
-
+
def self.can_infer_metadata?
false
end
-
+
+ def self.can_infer_title?
+ false
+ end
+
+ def self.can_infer_description?
+ false
+ end
+
def self.can_generate_preview_image?
false
end
-
+
def self.can_generate_preview_svg?
false
end
-
+
def self.show_download_section?
true
end
@@ -71,36 +79,36 @@
end
# End Object Initializer
-
-
+
+
# Begin Instance Methods
-
+
# These provide more specific functionality for a given workflow definition, such as parsing for metadata and image generation.
-
+
def get_title
nil
end
-
+
def get_description
nil
end
-
+
def get_preview_image
nil
end
-
+
def get_preview_svg
nil
end
-
+
def get_workflow_model_object
nil
end
-
+
def get_workflow_model_input_ports
-
+
end
-
+
def get_search_terms
""
end
@@ -113,6 +121,6 @@
end
# End Instance Methods
-
+
end
end
Modified: trunk/lib/workflow_processors/taverna2.rb (3165 => 3166)
--- trunk/lib/workflow_processors/taverna2.rb 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/lib/workflow_processors/taverna2.rb 2012-10-19 14:48:14 UTC (rev 3166)
@@ -64,6 +64,14 @@
def self.can_infer_metadata?
true
end
+
+ def self.can_infer_title?
+ true
+ end
+
+ def self.can_infer_description?
+ true
+ end
def self.can_generate_preview_image?
true
Modified: trunk/lib/workflow_processors/taverna_scufl.rb (3165 => 3166)
--- trunk/lib/workflow_processors/taverna_scufl.rb 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/lib/workflow_processors/taverna_scufl.rb 2012-10-19 14:48:14 UTC (rev 3166)
@@ -62,6 +62,14 @@
def self.can_infer_metadata?
true
end
+
+ def self.can_infer_title?
+ true
+ end
+
+ def self.can_infer_description?
+ true
+ end
def self.can_generate_preview_image?
true
Modified: trunk/public/stylesheets/styles.css (3165 => 3166)
--- trunk/public/stylesheets/styles.css 2012-10-19 09:45:57 UTC (rev 3165)
+++ trunk/public/stylesheets/styles.css 2012-10-19 14:48:14 UTC (rev 3166)
@@ -1521,6 +1521,7 @@
line-height: 1.4;
}
+.derived_annotation_notice,
.none_text {
font-style: italic;
color: #666666;