Explorar el Código

[spark] Saveas does not lose the design id

Romain Rigaux hace 11 años
padre
commit
dcee4fe77a

+ 4 - 0
apps/spark/src/spark/templates/editor.mako

@@ -500,6 +500,10 @@ ${ common.createContextModal() }
     $.jHueNotify.info("${_('Application saved successfully!')}")
   });
 
+  $(document).on('savedas.query', function() {
+    window.location.href = "${ url('spark:editor') }" + viewModel.query.id();
+  });
+
   var dataTable = null;
 
   function cleanResultsTable() {

+ 1 - 1
apps/spark/src/spark/urls.py

@@ -25,7 +25,7 @@ urlpatterns = patterns('spark.views',
   url(r'^editor/query/(?P<query_history_id>.+)$', 'editor', name='watch_query_history'), # For Beeswax
   url(r'^editor/(?P<design_id>.+)?$', 'editor', name='view_job'), # For browser
   url(r'^editor/(?P<design_id>.+)?$', 'editor', name='editor'),
-  url(r'^editor/(?P<design_id>.+)?$', 'editor', name='execute_query'), # For Beeswax  
+  url(r'^editor/(?P<design_id>.+)?$', 'editor', name='execute_query'), # For Beeswax
   url(r'^list_jobs', 'list_jobs', name='list_jobs'),
   url(r'^list_contexts', 'list_contexts', name='list_contexts'),
   url(r'^delete_contexts', 'delete_contexts', name='delete_contexts'),

+ 9 - 4
apps/spark/static/js/spark.vm.js

@@ -222,9 +222,14 @@ function sparkViewModel() {
         type: 'POST',
         success: function(data) {
           if (data.status == 0) {
-            $(document).trigger('saved.query', data);
+            if (self.query.id() == -1) {
+              self.query.id(data.design_id);
+              $(document).trigger('savedas.query', data);
+            } else {
+              $(document).trigger('saved.query', data);
+            }
           } else {
-        	self.query.errors.push(data.message);
+            self.query.errors.push(data.message);
           }
         },
         error: function() {
@@ -283,8 +288,8 @@ function sparkViewModel() {
             self.updateResults(data.results.result);
             self.resultsEmpty($.isEmptyObject(data.results.result));
           } else {
-        	self.query.errors.push(data.results.ERROR.message);
-          }          
+            self.query.errors.push(data.results.ERROR.message);
+          }
           $(document).trigger('executed.query', data);
         }
       },