1 function run_pipeline_button_state() {
2 var a = $('a.editable.required.editable-empty,input.form-control.required[value=""]');
3 if ((a.length > 0) || ($('.unreadable-inputs-present').length)) {
4 $(".run-pipeline-button").addClass("disabled");
7 $(".run-pipeline-button").removeClass("disabled");
11 $(document).on('editable:success', function(event, tag, response, newValue) {
13 if ($('.run-pipeline-button').length == 0)
15 if ($tag.hasClass("required")) {
16 if (newValue && newValue.trim() != "") {
17 $tag.removeClass("editable-empty");
18 $tag.parent().css("background-color", "");
19 $tag.parent().prev().css("background-color", "");
22 $tag.addClass("editable-empty");
23 $tag.parent().css("background-color", "#ffdddd");
24 $tag.parent().prev().css("background-color", "#ffdddd");
27 if ($tag.attr('data-name')) {
28 // Update other inputs representing the same piece of data
29 $('.editable[data-name="' + $tag.attr('data-name') + '"]').
30 editable('setValue', newValue);
32 run_pipeline_button_state();
35 $(document).on('ready ajax:complete', function() {
36 $('a.editable.required').each(function() {
38 if ($tag.hasClass("editable-empty")) {
39 $tag.parent().css("background-color", "#ffdddd");
40 $tag.parent().prev().css("background-color", "#ffdddd");
43 $tag.parent().css("background-color", "");
44 $tag.parent().prev().css("background-color", "");
47 $('input.required').each(function() {
49 if ($tag.hasClass("unreadable-input")) {
50 $tag.parent().parent().css("background-color", "#ffdddd");
51 $tag.parent().parent().prev().css("background-color", "#ffdddd");
54 $tag.parent().parent().css("background-color", "");
55 $tag.parent().parent().prev().css("background-color", "");
58 run_pipeline_button_state();
61 $(document).on('arv-log-event', '.arv-refresh-on-state-change', function(event, eventData) {
62 if (this != event.target) {
63 // Not interested in events sent to child nodes.
66 if (eventData.event_type == "update" &&
67 eventData.properties.old_attributes.state != eventData.properties.new_attributes.state)
69 $(event.target).trigger('arv:pane:reload');
73 $(document).on('arv-log-event', '.arv-log-event-subscribe-to-pipeline-job-uuids', function(event, eventData){
74 if (this != event.target) {
75 // Not interested in events sent to child nodes.
78 if (!((eventData.object_kind == 'arvados#pipelineInstance') &&
79 (eventData.event_type == "create" ||
80 eventData.event_type == "update") &&
81 eventData.properties &&
82 eventData.properties.new_attributes &&
83 eventData.properties.new_attributes.components)) {
87 var components = eventData.properties.new_attributes.components;
88 for (a in components) {
89 if (components[a].job && components[a].job.uuid) {
90 objs += " " + components[a].job.uuid;
93 $(event.target).attr("data-object-uuids", eventData.object_uuid + objs);
96 $(document).on('ready ajax:success', function() {
97 $('.arv-log-refresh-control').each(function() {
98 var uuids = $(this).attr('data-object-uuids');
99 var $pane = $(this).closest('[data-pane-content-url]');
100 $pane.attr('data-object-uuids', uuids);
104 // Set up all events for the pipeline instances compare button.
106 var compare_form = '#compare';
107 var compare_inputs = '#comparedInstances :checkbox[name="uuids[]"]';
108 var update_button = function(event) {
109 var $form = $(compare_form);
110 var $checked_inputs = $(compare_inputs).filter(':checked');
111 $(':submit', $form).prop('disabled', (($checked_inputs.length < 2) ||
112 ($checked_inputs.length > 3)));
113 $('input[name="uuids[]"]', $form).remove();
114 $form.append($checked_inputs.clone()
115 .removeAttr('id').attr('type', 'hidden'));
118 .on('ready ajax:success', compare_form, update_button)
119 .on('change', compare_inputs, update_button);