ソースを参照

[oozie] Support edit and non edit mode in Bundle editor

Romain Rigaux 10 年 前
コミット
858ae0e

+ 14 - 10
apps/oozie/src/oozie/templates/editor2/bundle_editor.mako

@@ -88,26 +88,31 @@ ${ commonheader(_("Bundle Editor"), "Oozie", user) | n,unicode }
         <h1 class="card-heading simple">${ _('Which schedules to bundle?') }</h1>
         <h1 class="card-heading simple">${ _('Which schedules to bundle?') }</h1>
 
 
         <div class="card-body">
         <div class="card-body">
-
-          <a class="pointer" data-bind="click: function() { showChooseCoordinator(); }">
+          <a class="pointer" data-bind="visible: ! isEditing(), click: function() { showChooseCoordinator(); }, visible: $root.isEditing">
             <i class="fa fa-plus"></i> ${ _('Add a coordinator') }
             <i class="fa fa-plus"></i> ${ _('Add a coordinator') }
           </a>
           </a>
         </div>
         </div>
       </div>
       </div>
-
           
           
       <div data-bind="foreach: bundle.coordinators">
       <div data-bind="foreach: bundle.coordinators">
         <div class="card card-home" style="margin-top: 20px; padding-bottom: 10px">
         <div class="card card-home" style="margin-top: 20px; padding-bottom: 10px">
           <h1 class="card-heading simple">
           <h1 class="card-heading simple">
-          <a class="pointer" data-bind="click: function() { showChooseCoordinator(this); }, text: $root.getCoordinatorById(coordinator()).name"></a>
-          <a data-bind="attr: { href: '${ url('oozie:edit_coordinator') }?coordinator=' + $root.getCoordinatorById(coordinator()).id() }" target="_blank" title="${ _('Open') }"><i class="fa fa-external-link-square"></i></a>
-          <a class="pointer pull-right" data-bind="click: function() { $root.bundle.coordinators.remove(this); }"><i class="fa fa-times"></i></a>
+            <a class="pointer" data-bind="click: function() { showChooseCoordinator(this); }, text: $root.getCoordinatorById(coordinator()).name"></a>
+            <a data-bind="attr: { href: '${ url('oozie:edit_coordinator') }?coordinator=' + $root.getCoordinatorById(coordinator()).id() }" target="_blank" title="${ _('Open') }">
+              <i class="fa fa-external-link-square"></i>
+            </a>
+            <a class="pointer pull-right" data-bind="click: function() { $root.bundle.coordinators.remove(this); }, visible: $root.isEditing">
+              <i class="fa fa-times"></i>
+            </a>
           </h1>
           </h1>
 
 
           <div class="card-body">
           <div class="card-body">
-
             <ul data-bind="foreach: properties" class="unstyled">
             <ul data-bind="foreach: properties" class="unstyled">
-              <li>
+              <li data-bind="visible: ! $root.isEditing()">
+                <span data-bind="text: name"></span>
+                <span data-bind="text: value"></span>
+              </li>
+              <li data-bind="visible: $root.isEditing">              
                 <input data-bind="value: name"/>
                 <input data-bind="value: name"/>
                 <input data-bind="value: value"/>
                 <input data-bind="value: value"/>
                 <a href="#" data-bind="click: function(){ $parent.properties.remove(this); }">
                 <a href="#" data-bind="click: function(){ $parent.properties.remove(this); }">
@@ -116,13 +121,12 @@ ${ commonheader(_("Bundle Editor"), "Oozie", user) | n,unicode }
               </li>
               </li>
             </ul>
             </ul>
 
 
-            <a class="pointer" data-bind="click: function(){ $data.properties.push({'name': '', 'value': ''}); }">
+            <a class="pointer" data-bind="click: function(){ $data.properties.push({'name': '', 'value': ''}); }, visible: $root.isEditing">
               <i class="fa fa-plus"></i> ${ _('Add a parameter') }
               <i class="fa fa-plus"></i> ${ _('Add a parameter') }
             </a>
             </a>
           </div>
           </div>
         </div>
         </div>
       </div>
       </div>
-   
 
 
     </div>
     </div>
   </div>
   </div>

+ 3 - 4
apps/oozie/src/oozie/templates/editor2/coordinator_editor.mako

@@ -271,7 +271,6 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
                   <span data-bind="visible: dataset_variable().length > 0">
                   <span data-bind="visible: dataset_variable().length > 0">
                     ${ _('Will convert to') }
                     ${ _('Will convert to') }
                     <a data-bind="text: convertVariables(dataset_variable()), attr: {'href': '/filebrowser/view' + convertVariables(dataset_variable())}"></a>
                     <a data-bind="text: convertVariables(dataset_variable()), attr: {'href': '/filebrowser/view' + convertVariables(dataset_variable())}"></a>
-                    ## use start_date as the date
                   </span>
                   </span>
                   </a>
                   </a>
                 </span>
                 </span>
@@ -281,7 +280,7 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
                     <div class="control-group">
                     <div class="control-group">
                       <label class="control-label">${ _('Done flag') }</label>
                       <label class="control-label">${ _('Done flag') }</label>
                       <div class="controls">
                       <div class="controls">
-                        <input type="checkbox" data-bind="checked: use_done_flag, style: {'margin-top': !use_done_flag()?'9px':'-1px'}" />
+                        <input type="checkbox" data-bind="checked: use_done_flag, style: {'margin-top': !use_done_flag() ? '9px' : '-1px'}" />
                         <input type="text" data-bind="value: done_flag, visible: use_done_flag"/>
                         <input type="text" data-bind="value: done_flag, visible: use_done_flag"/>
                       </div>
                       </div>
                     </div>
                     </div>
@@ -308,14 +307,14 @@ ${ commonheader(_("Coordinator Editor"), "Oozie", user) | n,unicode }
                     <div class="control-group">
                     <div class="control-group">
                       <label class="control-label">${ _('Same start') }</label>
                       <label class="control-label">${ _('Same start') }</label>
                       <div class="controls">
                       <div class="controls">
-                        <input type="checkbox" data-bind="checked: same_start, style: {'margin-top': same_start()?'9px':'-1px'}" />
+                        <input type="checkbox" data-bind="checked: same_start, style: {'margin-top': same_start() ? '9px' : '-1px'}" />
                         <input type="text" data-bind="value: start, visible: ! same_start()"/>
                         <input type="text" data-bind="value: start, visible: ! same_start()"/>
                       </div>
                       </div>
                     </div>                  
                     </div>                  
                     <div class="control-group">
                     <div class="control-group">
                       <label class="control-label">${ _('Same timezone') }</label>
                       <label class="control-label">${ _('Same timezone') }</label>
                       <div class="controls">
                       <div class="controls">
-                        <input type="checkbox" data-bind="checked: same_timezone, style: {'margin-top': same_timezone()?'5px':'0'}" />
+                        <input type="checkbox" data-bind="checked: same_timezone, style: {'margin-top': same_timezone() ? '5px' : '0'}" />
                         <select data-bind="options: $root.availableTimezones, select2: { placeholder: '${ _("Select a Timezone") }', update: timezone}, visible: ! same_timezone()" style="width: 180px"></select>
                         <select data-bind="options: $root.availableTimezones, select2: { placeholder: '${ _("Select a Timezone") }', update: timezone}, visible: ! same_timezone()" style="width: 180px"></select>
                       </div>
                       </div>
                     </div>
                     </div>

+ 1 - 1
apps/oozie/static/js/bundle-editor.ko.js

@@ -41,7 +41,7 @@ var BundleEditorViewModel = function (bundle_json, coordinators_json, can_edit_j
   var self = this;
   var self = this;
 
 
   self.canEdit = ko.mapping.fromJS(can_edit_json);
   self.canEdit = ko.mapping.fromJS(can_edit_json);
-  self.isEditing = ko.observable(true && self.canEdit());
+  self.isEditing = ko.observable(bundle_json.id == null);
   self.isEditing.subscribe(function(newVal){
   self.isEditing.subscribe(function(newVal){
     $(document).trigger("editingToggled");
     $(document).trigger("editingToggled");
   });
   });