refs #2871
[arvados.git] / apps / workbench / app / assets / javascripts / pipeline_instances.js
1 function run_pipeline_button_state() {
2     var a = $('a.editable.required.editable-empty');
3     if (a.length > 0) {
4         $(".run-pipeline-button").addClass("disabled");
5     }
6     else {
7         $(".run-pipeline-button").removeClass("disabled");
8     }
9 }
10
11 $(document).on('editable:success', function(event, tag, response, newValue) {
12     var $tag = $(tag);
13     if ($('.run-pipeline-button').length == 0)
14         return;
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", "");
20         }
21         else {
22             $tag.addClass("editable-empty");
23             $tag.parent().css("background-color", "#ffdddd");
24             $tag.parent().prev().css("background-color", "#ffdddd");
25         }
26     }
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);
31     }
32     run_pipeline_button_state();
33 });
34
35 $(document).on('ready ajax:complete', function() {
36     $('a.editable.required').each(function() {
37         var $tag = $(this);
38         if ($tag.hasClass("editable-empty")) {
39             $tag.parent().css("background-color", "#ffdddd");
40             $tag.parent().prev().css("background-color", "#ffdddd");
41         }
42         else {
43             $tag.parent().css("background-color", "");
44             $tag.parent().prev().css("background-color", "");
45         }
46     });
47     run_pipeline_button_state();
48 });
49
50 $(document).on('arv-log-event', '.arv-log-event-handler-append-logs', function(event, eventData){
51   var parsedData = JSON.parse(eventData);
52
53   var propertyText = undefined
54
55   var properties = parsedData.properties;
56     if (properties !== null) {
57       propertyText = properties.text;
58     }
59
60     if (propertyText !== undefined) {
61       $(this).append(propertyText + "<br/>");
62     } else {
63       $(this).append(parsedData.summary + "<br/>");
64     }
65 });