[ARVADOS] updated: 9e778a62184d4604f62e6c30fec8d1be1781de4b
git at public.curoverse.com
git at public.curoverse.com
Thu Feb 27 16:14:54 EST 2014
Summary of changes:
apps/workbench/app/assets/javascripts/editable.js | 2 +-
.../app/assets/javascripts/pipeline_instances.js | 46 ++++++++++
.../javascripts/pipeline_instances.js.coffee | 3 -
apps/workbench/app/assets/javascripts/selection.js | 3 +-
.../controllers/pipeline_instances_controller.rb | 2 +
apps/workbench/app/helpers/application_helper.rb | 88 +++++++++++++-------
.../pipeline_instances/_show_components.html.erb | 38 +++++----
7 files changed, 129 insertions(+), 53 deletions(-)
create mode 100644 apps/workbench/app/assets/javascripts/pipeline_instances.js
delete mode 100644 apps/workbench/app/assets/javascripts/pipeline_instances.js.coffee
via 9e778a62184d4604f62e6c30fec8d1be1781de4b (commit)
via da5ff6947c567dfb391af544473475c029a78ece (commit)
from cf1e0b3f31b643899b556c3c7ae59630a0ec7495 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit 9e778a62184d4604f62e6c30fec8d1be1781de4b
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Feb 27 16:16:08 2014 -0500
Moved code specific to editing pipelines from editable.js to pipeline_instance.js.
Improved detection of paramater data type to choose the right editing control.
diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/editable.js
index 9418fb2..a743586 100644
--- a/apps/workbench/app/assets/javascripts/editable.js
+++ b/apps/workbench/app/assets/javascripts/editable.js
@@ -9,35 +9,3 @@ $.fn.editable.defaults.params = function (params) {
a[key][params.name] = params.value;
return a;
};
-
-(function() {
- $.fn.editable.defaults.success = function (response, newValue) {
- var tag = $(this);
- if (tag.hasClass("required")) {
- if (newValue && newValue.trim() != "") {
- tag.parent().css("background-color", "");
- tag.parent().prev().css("background-color", "");
- }
- else {
- tag.parent().css("background-color", "#ffdddd");
- tag.parent().prev().css("background-color", "#ffdddd");
- }
- }
- }
-
- $(window).on('load', function() {
- var a = $('a.editable.required');
- for (var i = 0; i < a.length; i++) {
- var tag = $(a[i]);
- if (tag.hasClass("editable-empty")) {
- tag.parent().css("background-color", "#ffdddd");
- tag.parent().prev().css("background-color", "#ffdddd");
- }
- else {
- tag.parent().css("background-color", "");
- tag.parent().prev().css("background-color", "");
- }
- }
- } );
-
-})();
diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/pipeline_instances.js
similarity index 69%
copy from apps/workbench/app/assets/javascripts/editable.js
copy to apps/workbench/app/assets/javascripts/pipeline_instances.js
index 9418fb2..ee14e3b 100644
--- a/apps/workbench/app/assets/javascripts/editable.js
+++ b/apps/workbench/app/assets/javascripts/pipeline_instances.js
@@ -1,28 +1,30 @@
-$.fn.editable.defaults.ajaxOptions = {type: 'put', dataType: 'json'};
-$.fn.editable.defaults.send = 'always';
-//$.fn.editable.defaults.mode = 'inline';
-$.fn.editable.defaults.params = function (params) {
- var a = {};
- var key = params.pk.key;
- a.id = params.pk.id;
- a[key] = {};
- a[key][params.name] = params.value;
- return a;
-};
(function() {
+ var run_pipeline_button_state = function() {
+ var a = $('a.editable.required.editable-empty');
+ if (a.length > 0) {
+ $("#run-pipeline-button").addClass("disabled");
+ }
+ else {
+ $("#run-pipeline-button").removeClass("disabled");
+ }
+ }
+
$.fn.editable.defaults.success = function (response, newValue) {
var tag = $(this);
if (tag.hasClass("required")) {
if (newValue && newValue.trim() != "") {
+ tag.removeClass("editable-empty");
tag.parent().css("background-color", "");
tag.parent().prev().css("background-color", "");
}
else {
+ tag.addClass("editable-empty");
tag.parent().css("background-color", "#ffdddd");
tag.parent().prev().css("background-color", "#ffdddd");
}
}
+ run_pipeline_button_state();
}
$(window).on('load', function() {
@@ -38,6 +40,7 @@ $.fn.editable.defaults.params = function (params) {
tag.parent().prev().css("background-color", "");
}
}
+ run_pipeline_button_state();
} );
})();
diff --git a/apps/workbench/app/assets/javascripts/pipeline_instances.js.coffee b/apps/workbench/app/assets/javascripts/pipeline_instances.js.coffee
deleted file mode 100644
index 7615679..0000000
--- a/apps/workbench/app/assets/javascripts/pipeline_instances.js.coffee
+++ /dev/null
@@ -1,3 +0,0 @@
-# Place all the behaviors and hooks related to the matching controller here.
-# All this logic will automatically be available in application.js.
-# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 2c2316b..6de96e8 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -118,13 +118,13 @@ module ApplicationHelper
datatype = nil
required = true
if template
- puts "Template is #{template.class} #{template.is_a? Hash} #{template}"
+ #puts "Template is #{template.class} #{template.is_a? Hash} #{template}"
if template.is_a? Hash
if template[:output_of]
return raw("<span class='label label-default'>#{template[:output_of]}</span>")
end
- if template[:datatype]
- datatype = template[:datatype]
+ if template[:dataclass]
+ dataclass = template[:dataclass]
end
if template[:optional] != nil
required = (template[:optional] != "true")
@@ -137,19 +137,31 @@ module ApplicationHelper
return attrvalue if !object.attribute_editable? attr
- if not datatype
- dataclass = ArvadosBase.resource_class_for_uuid(template)
- if dataclass
- datatype = 'select'
- else
- if template.is_a? Array
- # ?!?
- elsif template.is_a? String
- if /^\d+$/.match(template)
- datatype = 'number'
- else
- datatype = 'text'
- end
+ if not dataclass
+ rsc = template
+ if template.is_a? Hash
+ if template[:value]
+ rsc = template[:value]
+ elsif template[:default]
+ rsc = template[:default]
+ end
+ end
+
+ dataclass = ArvadosBase.resource_class_for_uuid(rsc)
+ end
+
+ if dataclass && dataclass.is_a?(Class)
+ datatype = 'select'
+ elsif dataclass == 'number'
+ datatype = 'number'
+ else
+ if template.is_a? Array
+ # ?!?
+ elsif template.is_a? String
+ if /^\d+$/.match(template)
+ datatype = 'number'
+ else
+ datatype = 'text'
end
end
end
@@ -164,12 +176,13 @@ module ApplicationHelper
attrvalue = attrvalue.strip
end
- if dataclass
+ if dataclass and dataclass.is_a? Class
items = []
- dataclass.where(uuid: attrvalue).each do |item|
- items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
- end
- dataclass.limit(19).each do |item|
+ items.append({name: attrvalue, uuid: attrvalue, type: dataclass.to_s})
+ #dataclass.where(uuid: attrvalue).each do |item|
+ # items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
+ #end
+ dataclass.limit(10).each do |item|
items.append({name: item.uuid, uuid: item.uuid, type: dataclass.to_s})
end
end
@@ -183,6 +196,7 @@ module ApplicationHelper
"data-name" => dn,
"data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
"data-showbuttons" => "false",
+ "data-value" => attrvalue,
:class => "editable #{'required' if required}",
:id => id
}.merge(htmloptions)
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
index 1148bff..af6da56 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -104,7 +104,7 @@ setInterval(function(){$('a.refresh').click()}, 30000);
<%= form_tag @object, :method => :put do |f| %>
<%= hidden_field @object.class.to_s.underscore.singularize.to_sym, :active, :value => true %>
- <%= button_tag "Run pipeline", {class: 'btn btn-primary pull-right'} %>
+ <%= button_tag "Run pipeline", {class: 'btn btn-primary pull-right', id: "run-pipeline-button"} %>
<% end %>
<table class="table pipeline-components-table" style="margin-top: -.1em">
commit da5ff6947c567dfb391af544473475c029a78ece
Author: Peter Amstutz <peter.amstutz at curoverse.com>
Date: Thu Feb 27 15:38:00 2014 -0500
UI for editing component parameters now correctly highlights the background of required parameters that are not set, and removes the highlight when the parameter is set.
diff --git a/apps/workbench/app/assets/javascripts/editable.js b/apps/workbench/app/assets/javascripts/editable.js
index 29cf2b8..9418fb2 100644
--- a/apps/workbench/app/assets/javascripts/editable.js
+++ b/apps/workbench/app/assets/javascripts/editable.js
@@ -8,4 +8,36 @@ $.fn.editable.defaults.params = function (params) {
a[key] = {};
a[key][params.name] = params.value;
return a;
-};
\ No newline at end of file
+};
+
+(function() {
+ $.fn.editable.defaults.success = function (response, newValue) {
+ var tag = $(this);
+ if (tag.hasClass("required")) {
+ if (newValue && newValue.trim() != "") {
+ tag.parent().css("background-color", "");
+ tag.parent().prev().css("background-color", "");
+ }
+ else {
+ tag.parent().css("background-color", "#ffdddd");
+ tag.parent().prev().css("background-color", "#ffdddd");
+ }
+ }
+ }
+
+ $(window).on('load', function() {
+ var a = $('a.editable.required');
+ for (var i = 0; i < a.length; i++) {
+ var tag = $(a[i]);
+ if (tag.hasClass("editable-empty")) {
+ tag.parent().css("background-color", "#ffdddd");
+ tag.parent().prev().css("background-color", "#ffdddd");
+ }
+ else {
+ tag.parent().css("background-color", "");
+ tag.parent().prev().css("background-color", "");
+ }
+ }
+ } );
+
+})();
diff --git a/apps/workbench/app/assets/javascripts/selection.js b/apps/workbench/app/assets/javascripts/selection.js
index d4af321..c8ec810 100644
--- a/apps/workbench/app/assets/javascripts/selection.js
+++ b/apps/workbench/app/assets/javascripts/selection.js
@@ -156,4 +156,5 @@ select_form_sources = null;
}
return ret;
};
-})();
\ No newline at end of file
+})();
+
diff --git a/apps/workbench/app/controllers/pipeline_instances_controller.rb b/apps/workbench/app/controllers/pipeline_instances_controller.rb
index 0922017..12db3c3 100644
--- a/apps/workbench/app/controllers/pipeline_instances_controller.rb
+++ b/apps/workbench/app/controllers/pipeline_instances_controller.rb
@@ -57,6 +57,8 @@ class PipelineInstancesController < ApplicationController
if param_value.is_a? Hash
if param_value[:value]
pipeline[component_name][:script_parameters][param_name] = param_value[:value]
+ elsif param_value[:default]
+ pipeline[component_name][:script_parameters][param_name] = param_value[:default]
elsif param_value[:optional] and param_value.length == 1
pipeline[component_name][:script_parameters][param_name] = ""
else
diff --git a/apps/workbench/app/helpers/application_helper.rb b/apps/workbench/app/helpers/application_helper.rb
index 921122f..2c2316b 100644
--- a/apps/workbench/app/helpers/application_helper.rb
+++ b/apps/workbench/app/helpers/application_helper.rb
@@ -116,14 +116,22 @@ module ApplicationHelper
end
datatype = nil
+ required = true
if template
puts "Template is #{template.class} #{template.is_a? Hash} #{template}"
if template.is_a? Hash
if template[:output_of]
return raw("<span class='label label-default'>#{template[:output_of]}</span>")
- elsif template[:datatype]
+ end
+ if template[:datatype]
datatype = template[:datatype]
end
+ if template[:optional] != nil
+ required = (template[:optional] != "true")
+ end
+ if template[:required] != nil
+ required = template[:required]
+ end
end
end
@@ -152,6 +160,10 @@ module ApplicationHelper
dn += "[#{a}]"
end
+ if attrvalue.is_a? String
+ attrvalue = attrvalue.strip
+ end
+
if dataclass
items = []
dataclass.where(uuid: attrvalue).each do |item|
@@ -169,20 +181,22 @@ module ApplicationHelper
"data-url" => url_for(action: "update", id: object.uuid, controller: object.class.to_s.pluralize.underscore),
"data-title" => "Update #{subattr[-1].to_s.titleize}",
"data-name" => dn,
- "data-value" => attrvalue,
"data-pk" => "{id: \"#{object.uuid}\", key: \"#{object.class.to_s.underscore}\"}",
- :class => "editable",
+ "data-showbuttons" => "false",
+ :class => "editable #{'required' if required}",
:id => id
}.merge(htmloptions)
- lt += raw(<<EOF
+ lt += raw('<script>')
+
+ if items and items.length > 0
+ lt += raw("add_form_selection_sources(#{items.to_json});\n")
+ end
+
+ lt += raw("$('##{id}').editable({source: function() { return select_form_sources('#{dataclass}'); } });\n")
+
+ lt += raw("</script>")
-<script>
- add_form_selection_sources(#{items.to_json});
- $('##{id}').editable({source: function() { return select_form_sources('#{dataclass}'); } });
-</script>
-EOF
-)
lt
end
end
diff --git a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
index 4a39c19..1148bff 100644
--- a/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
+++ b/apps/workbench/app/views/pipeline_instances/_show_components.html.erb
@@ -21,6 +21,10 @@ table.pipeline-components-table td {
text-overflow: ellipsis;
}
+td.required {
+ background: #ffdddd;
+}
+
<% end %>
<% if @object.active != nil %>
@@ -120,39 +124,37 @@ setInterval(function(){$('a.refresh').click()}, 30000);
</th><th>
parameter
</th><th>
- input
+ value
</th>
</tr>
</thead>
<tbody>
<% template = PipelineTemplate.find(@object.pipeline_template_uuid) %>
- <% template.components.each do |k, v| %>
-
- <% sp = v[:script_parameters].collect do |x, y| [x, y] end %>
+ <% template.components.each do |k, template_value| %>
<tr>
<td><span class="label label-default"><%= k %></span></td>
- <td><%= v[:script] %></td>
+ <td><%= render_editable_subattribute @object, :components, [k, :script], template_value[:script] %></td>
- <td>script_version</td>
+ <td>script version</td>
<td>
- <%= render_editable_subattribute @object, :components, [k, :script_version], v[:script_version] %>
+ <%= render_editable_subattribute @object, :components, [k, :script_version], template_value[:script_version] %>
</td>
</tr>
- <% if sp.length > 0 %>
- <tr>
- <td style="border-top: none"></td>
- <td style="border-top: none"></td>
-
- <% sp.each do |p| %>
- <td><%= p[0] %></td>
- <td><%= render_editable_subattribute @object, :components, [k, :script_parameters, p[0].to_sym], p[1] %></td>
+ <% if template_value[:script_parameters].length > 0 %>
+ <% template_value[:script_parameters].each do |p, tv| %>
+ <tr>
+ <td style="border-top: none"></td>
+ <td style="border-top: none"></td>
+
+ <td class="property-edit-row"><%= p %></td>
+ <td class="property-edit-row"><%= render_editable_subattribute @object, :components, [k, :script_parameters, p.to_sym], tv %></td>
<% end %>
- </tr>
- <% end %>
+ </tr>
+ <% end %>
<% end %>
</tbody>
</table>
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list