Improved detection of paramater data type to choose the right editing control.
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", "");
- }
- }
- } );
-
-})();
--- /dev/null
+
+(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() {
+ 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", "");
+ }
+ }
+ run_pipeline_button_state();
+ } );
+
+})();
+++ /dev/null
-# 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/
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")
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
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
"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)
<%= 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">