瀏覽代碼

HUE-1246 [pig] Change name of default saved script

Popup is shown when you haven't changed the name from the default one
Enrico Berti 12 年之前
父節點
當前提交
1d5fc18
共有 2 個文件被更改,包括 34 次插入3 次删除
  1. 20 0
      apps/pig/src/pig/templates/app.mako
  2. 14 3
      apps/pig/static/js/pig.ko.js

+ 20 - 0
apps/pig/src/pig/templates/app.mako

@@ -456,6 +456,26 @@ ${ commonheader(None, "pig", user, "100px") | n,unicode }
   </div>
 </div>
 
+<div id="nameModal" class="modal hide fade">
+  <div class="modal-header">
+    <a href="#" class="close" data-dismiss="modal">&times;</a>
+    <h3>${_('Save script')}</h3>
+  </div>
+  <div class="modal-body">
+    <p>
+      ${_('Please give a meaningful name to this script.')}<br/><br/>
+      <label>
+        ${ _('Script name') } &nbsp;
+        <input type="text" class="input-xlarge" data-bind="value: currentScript().name" />
+      </label>
+    </p>
+  </div>
+  <div class="modal-footer">
+    <a class="btn" data-dismiss="modal">${_('Cancel')}</a>
+    <button class="btn btn-primary disable-feedback" data-bind="click: saveScript, enable: currentScript().name() != '' && currentScript().name() != $root.LABELS.NEW_SCRIPT_NAME">${_('Save')}</button>
+  </div>
+</div>
+
 
 <div class="bottomAlert alert"></div>
 

+ 14 - 3
apps/pig/static/js/pig.ko.js

@@ -243,8 +243,14 @@ var PigViewModel = function (props) {
   };
 
   self.saveScript = function () {
-    callSave(self.currentScript());
-    viewModel.isDirty(false);
+    if (self.LABELS.NEW_SCRIPT_NAME == self.currentScript().name()){
+      showNameModal();
+    }
+    else {
+      $("#nameModal").modal("hide");
+      callSave(self.currentScript());
+      viewModel.isDirty(false);
+    }
   };
 
   self.runScript = function () {
@@ -400,7 +406,12 @@ var PigViewModel = function (props) {
     });
   }
 
-
+  function showNameModal() {
+    $("#nameModal").modal({
+      keyboard: true,
+      show: true
+    });
+  }
 
   function callSave(script) {
     $(document).trigger("saving");