Forráskód Böngészése

HUE-5048 [frontend] Remove RequireJS from the editor

Johan Ahlen 9 éve
szülő
commit
f63e55d62d
21 módosított fájl, 607 hozzáadás és 744 törlés
  1. 5 13
      desktop/core/src/desktop/static/desktop/js/aceSqlWorker.js
  2. 2 8
      desktop/core/src/desktop/static/desktop/js/apiHelper.js
  3. 2 9
      desktop/core/src/desktop/static/desktop/js/assist/assistDbEntry.js
  4. 2 9
      desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js
  5. 2 8
      desktop/core/src/desktop/static/desktop/js/assist/assistHdfsEntry.js
  6. 73 2
      desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js
  7. 6 7
      desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js
  8. 2 12
      desktop/core/src/desktop/static/desktop/js/autocompleter.js
  9. 2 10
      desktop/core/src/desktop/static/desktop/js/fileBrowser/hueDocument.js
  10. 2 8
      desktop/core/src/desktop/static/desktop/js/hdfsAutocompleter.js
  11. 2 10
      desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js
  12. 2 8
      desktop/core/src/desktop/static/desktop/js/sqlAutocompleter.js
  13. 14 23
      desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js
  14. 2 8
      desktop/core/src/desktop/static/desktop/js/sqlFunctions.js
  15. 2 15
      desktop/core/src/desktop/templates/assist.mako
  16. 373 438
      desktop/core/src/desktop/templates/config_ko_components.mako
  17. 5 23
      desktop/core/src/desktop/templates/sql_context_popover.mako
  18. 2 14
      desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js
  19. 29 20
      desktop/libs/notebook/src/notebook/templates/editor_components.mako
  20. 77 98
      desktop/libs/notebook/src/notebook/templates/notebook_ko_components.mako
  21. 1 1
      tools/jison/hue-jison.sh

+ 5 - 13
desktop/core/src/desktop/static/desktop/js/aceSqlWorker.js

@@ -14,18 +14,10 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-importScripts('/static/desktop/ext/js/require.js');
+importScripts('/static/desktop/js/autocomplete/sql.js?version=3');
+importScripts('/static/desktop/js/sqlFunctions.js?version=3');
 
-// TODO: Figure out how to deal with this nicely, param needs to be updated for any changes
-// to sql.js and sqlFunctions.js to prevent caching issues.
-require.config({
-  urlArgs: "version=2"
-});
-
-require([
-  'autocomplete/sql',
-  'sqlFunctions'
-], function (sqlParser, sqlFunctions) {
+(function () {
 
   this.throttle = -1;
 
@@ -41,7 +33,7 @@ require([
         var locations = [];
         var lineCount = 0;
         msg.data.text.split(';').forEach(function (statement) {
-          var parseResult = sqlParser.parseSql(statement + ' ', '', msg.data.type, sqlFunctions, false);
+          var parseResult = sql.parseSql(statement + ' ', '', msg.data.type, false);
           if (parseResult.errors) {
             parseResult.errors.forEach(function (error) {
               if (error.token.indexOf('CURSOR') === -1) {
@@ -64,4 +56,4 @@ require([
       }
     }, 400);
   }
-});
+})();

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/apiHelper.js

@@ -14,13 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define(['knockout'], factory);
-  } else {
-    root.ApiHelper = factory(ko);
-  }
-}(this, function (ko) {
+var ApiHelper = (function () {
 
   var TIME_TO_LIVE_IN_MILLIS = $.totalStorage('hue.cacheable.ttl.override') || $.totalStorage('hue.cacheable.ttl'); // 1 day by default, configurable with desktop.custom.cacheable_ttl in the .ini or $.totalStorage('hue.cacheable.ttl.override', 1234567890)
 
@@ -1290,4 +1284,4 @@
       return instance;
     }
   };
-}));
+})();

+ 2 - 9
desktop/core/src/desktop/static/desktop/js/assist/assistDbEntry.js

@@ -14,14 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define(['knockout'], factory);
-  } else {
-    root.AssistDbEntry = factory(ko);
-  }
-}(this, function (ko) {
-
+var AssistDbEntry = (function () {
   /**
    * @param {Object} definition
    * @param {string} definition.type
@@ -403,4 +396,4 @@
   };
 
   return AssistDbEntry;
-}));
+})();

+ 2 - 9
desktop/core/src/desktop/static/desktop/js/assist/assistDbSource.js

@@ -14,14 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define(['knockout', 'desktop/js/assist/assistDbEntry'], factory);
-  } else {
-    root.AssistDbSource = factory(ko, AssistDbEntry);
-  }
-}(this, function (ko, AssistDbEntry) {
-
+var AssistDbSource = (function () {
   /**
    * @param {Object} options
    * @param {Object} options.i18n
@@ -269,4 +262,4 @@
   };
 
   return AssistDbSource;
-}));
+})();

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/assist/assistHdfsEntry.js

@@ -14,13 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define(['knockout'], factory);
-  } else {
-    root.AssistHdfsEntry = factory(ko);
-  }
-}(this, function (ko) {
+var AssistHdfsEntry = (function () {
 
   var PAGE_SIZE = 50;
 
@@ -205,4 +199,4 @@
   };
 
   return AssistHdfsEntry;
-}));
+})();

A különbségek nem kerülnek megjelenítésre, a fájl túl nagy
+ 73 - 2
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js


+ 6 - 7
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -145,13 +145,13 @@ var getValueExpressionKeywords = function (valueExpression, extras) {
       }
     }
   }
-  if (parser.yy.sqlFunctions.matchesType(parser.yy.activeDialect, ['BOOLEAN'], types)) {
+  if (SqlFunctions.matchesType(parser.yy.activeDialect, ['BOOLEAN'], types)) {
     keywords = keywords.concat(['AND', 'OR']);
   }
-  if (parser.yy.sqlFunctions.matchesType(parser.yy.activeDialect, ['NUMBER'], types)) {
+  if (SqlFunctions.matchesType(parser.yy.activeDialect, ['NUMBER'], types)) {
     keywords = keywords.concat(['+', '-', '*', '/', '%']);
   }
-  if (parser.yy.sqlFunctions.matchesType(parser.yy.activeDialect, ['STRING'], types)) {
+  if (SqlFunctions.matchesType(parser.yy.activeDialect, ['STRING'], types)) {
     keywords = keywords.concat(['LIKE', 'NOT LIKE', 'REGEX', 'RLIKE']);
   }
   return {suggestKeywords: keywords};
@@ -252,11 +252,11 @@ var findCaseType = function (whenThenList) {
 };
 
 findReturnTypes = function (functionName) {
-  return parser.yy.sqlFunctions.getReturnTypes(parser.yy.activeDialect, functionName.toLowerCase());
+  return SqlFunctions.getReturnTypes(parser.yy.activeDialect, functionName.toLowerCase());
 };
 
 var applyArgumentTypesToSuggestions = function (functionName, position) {
-  var foundArguments = parser.yy.sqlFunctions.getArgumentTypes(parser.yy.activeDialect, functionName.toLowerCase(), position);
+  var foundArguments = SqlFunctions.getArgumentTypes(parser.yy.activeDialect, functionName.toLowerCase(), position);
   if (foundArguments.length == 0 && parser.yy.result.suggestColumns) {
     delete parser.yy.result.suggestColumns;
     delete parser.yy.result.suggestKeyValues;
@@ -1105,8 +1105,7 @@ var lexerModified = false;
 /**
  * Main parser function
  */
-parser.parseSql = function (beforeCursor, afterCursor, dialect, sqlFunctions, debug) {
-  parser.yy.sqlFunctions = sqlFunctions;
+parser.parseSql = function (beforeCursor, afterCursor, dialect, debug) {
   parser.yy.result = {locations: []};
   parser.yy.lowerCase = false;
   parser.yy.locations = [];

+ 2 - 12
desktop/core/src/desktop/static/desktop/js/autocompleter.js

@@ -14,17 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define([
-      'desktop/js/sqlAutocompleter',
-      'desktop/js/sqlAutocompleter2',
-      'desktop/js/hdfsAutocompleter'
-    ], factory);
-  } else {
-    root.Autocompleter = factory(SqlAutocompleter, SqlAutocompleter2, HdfsAutocompleter);
-  }
-}(this, function (SqlAutocompleter, SqlAutocompleter2, HdfsAutocompleter) {
+var Autocompleter = (function () {
 
   /**
    * @param {Object} options {object}
@@ -112,4 +102,4 @@
   };
 
   return Autocompleter;
-}));
+})();

+ 2 - 10
desktop/core/src/desktop/static/desktop/js/fileBrowser/hueDocument.js

@@ -14,15 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define([
-      'knockout'
-    ], factory);
-  } else {
-    root.HueDocument = factory(ko);
-  }
-}(this, function (ko) {
+var HueDocument = (function() {
 
   /**
    *
@@ -236,4 +228,4 @@
   };
 
   return HueDocument;
-}));
+})();

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/hdfsAutocompleter.js

@@ -14,13 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define([], factory);
-  } else {
-    root.HdfsAutocompleter = factory();
-  }
-}(this, function () {
+var HdfsAutocompleter = (function () {
 
   var TIME_TO_LIVE_IN_MILLIS = 60000; // 1 minute
   var BASE_PATH = "/filebrowser/view=";
@@ -114,4 +108,4 @@
   };
 
   return HdfsAutocompleter;
-}));
+})();

+ 2 - 10
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -14,14 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (factory) {
-  if(typeof define === "function") {
-    define("ko.hue-bindings", ["knockout"], factory);
-  } else {
-    factory(ko);
-  }
-}(function (ko) {
-
+(function () {
   ko.bindingHandlers.autocomplete = {
     init: function (element, valueAccessor) {
       var options = valueAccessor();
@@ -4430,5 +4423,4 @@
       $(el).data('__ko_vm', viewModel);
     }
   }
-
-}));
+})();

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter.js

@@ -14,13 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define([], factory);
-  } else {
-    root.SqlAutocompleter = factory();
-  }
-}(this, function () {
+var SqlAutocompleter = (function () {
 
   var SQL_TERMS = /\b(FROM|TABLE|STATS|REFRESH|METADATA|DESCRIBE|ORDER BY|JOIN|ON|WHERE|SELECT|LIMIT|GROUP BY|SORT|USE|LOCATION|INPATH)\b/g;
 
@@ -910,4 +904,4 @@
   };
 
   return SqlAutocompleter;
-}));
+})();

+ 14 - 23
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

@@ -14,16 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if (typeof define === "function" && define.amd) {
-    define([
-      'desktop/js/autocomplete/sql',
-      'desktop/js/sqlFunctions'
-    ], factory);
-  } else {
-    root.SqlAutocompleter2 = factory(sql, sqlFunctions);
-  }
-}(this, function (sqlParser, sqlFunctions) {
+var SqlAutocompleter2 = (function () {
 
   var IDENTIFIER_REGEX = /[a-zA-Z_0-9\$\u00A2-\uFFFF]/;
 
@@ -54,7 +45,7 @@
 
   SqlAutocompleter2.prototype.autocomplete = function (beforeCursor, afterCursor, callback, editor) {
     var self = this;
-    var parseResult = sqlParser.parseSql(beforeCursor, afterCursor, self.snippet.type(), sqlFunctions, false);
+    var parseResult = sql.parseSql(beforeCursor, afterCursor, self.snippet.type(), false);
 
     if (typeof hueDebug !== 'undefined' && hueDebug.showParseResult) {
       console.log(parseResult);
@@ -127,14 +118,14 @@
       if (parseResult.suggestFunctions.types && parseResult.suggestFunctions.types[0] === 'COLREF') {
         colRefDeferral.done(function () {
           if (colRef !== null && colRef.type) {
-            sqlFunctions.suggestFunctions(self.snippet.type(), [colRef.type.toUpperCase()], parseResult.suggestAggregateFunctions || false, parseResult.suggestAnalyticFunctions || false, completions);
+            SqlFunctions.suggestFunctions(self.snippet.type(), [colRef.type.toUpperCase()], parseResult.suggestAggregateFunctions || false, parseResult.suggestAnalyticFunctions || false, completions);
           } else {
-            sqlFunctions.suggestFunctions(self.snippet.type(), ['T'], parseResult.suggestAggregateFunctions || false, parseResult.suggestAnalyticFunctions || false, completions);
+            SqlFunctions.suggestFunctions(self.snippet.type(), ['T'], parseResult.suggestAggregateFunctions || false, parseResult.suggestAnalyticFunctions || false, completions);
           }
           suggestFunctionsDeferral.resolve();
         });
       } else {
-        sqlFunctions.suggestFunctions(self.snippet.type(), parseResult.suggestFunctions.types || ['T'], parseResult.suggestAggregateFunctions || false, parseResult.suggestAnalyticFunctions || false, completions);
+        SqlFunctions.suggestFunctions(self.snippet.type(), parseResult.suggestFunctions.types || ['T'], parseResult.suggestAggregateFunctions || false, parseResult.suggestAnalyticFunctions || false, completions);
         suggestFunctionsDeferral.resolve();
       }
       deferrals.push(suggestFunctionsDeferral);
@@ -297,7 +288,7 @@
   SqlAutocompleter2.prototype.addColRefKeywords = function (parseResult, type, completions) {
     var self = this;
     Object.keys(parseResult.suggestColRefKeywords).forEach(function (typeForKeywords) {
-      if (sqlFunctions.matchesType(self.snippet.type(), [typeForKeywords], [type.toUpperCase()])) {
+      if (SqlFunctions.matchesType(self.snippet.type(), [typeForKeywords], [type.toUpperCase()])) {
         parseResult.suggestColRefKeywords[typeForKeywords].forEach(function (keyword) {
           completions.push({
             value: parseResult.lowerCase ? keyword.toLowerCase() : keyword,
@@ -491,8 +482,8 @@
               columnSuggestions.push({value: self.backTickIfNeeded(column.name) + '[]', meta: 'array', weight: DEFAULT_WEIGHTS.COLUMN, table: table })
             } else if (column.type.indexOf('array') === 0) {
               columnSuggestions.push({value: self.backTickIfNeeded(column.name), meta: 'array', weight: DEFAULT_WEIGHTS.COLUMN, table: table })
-            } else if (sqlFunctions.matchesType(self.snippet.type(), types, [column.type.toUpperCase()]) ||
-                sqlFunctions.matchesType(self.snippet.type(), [column.type.toUpperCase()], types)) {
+            } else if (SqlFunctions.matchesType(self.snippet.type(), types, [column.type.toUpperCase()]) ||
+                SqlFunctions.matchesType(self.snippet.type(), [column.type.toUpperCase()], types)) {
               columnSuggestions.push({value: self.backTickIfNeeded(column.name), meta: column.type, weight: DEFAULT_WEIGHTS.COLUMN, table: table })
             }
           });
@@ -511,8 +502,8 @@
           });
         } else if (data.type === 'map' && (data.value && data.value.fields)) {
           data.value.fields.forEach(function (field) {
-            if (sqlFunctions.matchesType(self.snippet.type(), types, [field.type.toUpperCase()]) ||
-                sqlFunctions.matchesType(self.snippet.type(), [field.type.toUpperCase()], types)) {
+            if (SqlFunctions.matchesType(self.snippet.type(), types, [field.type.toUpperCase()]) ||
+                SqlFunctions.matchesType(self.snippet.type(), [field.type.toUpperCase()], types)) {
               columnSuggestions.push({value: self.backTickIfNeeded(field.name), meta: field.type, weight: DEFAULT_WEIGHTS.COLUMN, table: table });
             }
           });
@@ -525,13 +516,13 @@
                 } else {
                   columnSuggestions.push({value: self.backTickIfNeeded(field.name), meta: field.type, weight: DEFAULT_WEIGHTS.COLUMN, table: table });
                 }
-              } else if (sqlFunctions.matchesType(self.snippet.type(), types, [field.type.toUpperCase()]) ||
-                  sqlFunctions.matchesType(self.snippet.type(), [field.type.toUpperCase()], types)) {
+              } else if (SqlFunctions.matchesType(self.snippet.type(), types, [field.type.toUpperCase()]) ||
+                  SqlFunctions.matchesType(self.snippet.type(), [field.type.toUpperCase()], types)) {
                 columnSuggestions.push({value: self.backTickIfNeeded(field.name), meta: field.type, weight: DEFAULT_WEIGHTS.COLUMN, table: table });
               }
             });
           } else if (typeof data.item.type !== 'undefined') {
-            if (sqlFunctions.matchesType(self.snippet.type(), types, [data.item.type.toUpperCase()])) {
+            if (SqlFunctions.matchesType(self.snippet.type(), types, [data.item.type.toUpperCase()])) {
               columnSuggestions.push({value: 'item', meta: data.item.type, weight: DEFAULT_WEIGHTS.COLUMN, table: table });
             }
           }
@@ -683,4 +674,4 @@
   };
 
   return SqlAutocompleter2;
-}));
+})();

+ 2 - 8
desktop/core/src/desktop/static/desktop/js/sqlFunctions.js

@@ -14,13 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if (typeof define === "function" && define.amd) {
-    define([], factory);
-  } else {
-    root.SqlFunctions = factory();
-  }
-}(this, function () {
+var SqlFunctions = (function () {
 
   var MATHEMATICAL_FUNCTIONS = {
     hive: {
@@ -2436,4 +2430,4 @@
     matchesType: matchesType,
     findFunction: findFunction
   };
-}));
+})();

+ 2 - 15
desktop/core/src/desktop/templates/assist.mako

@@ -979,20 +979,7 @@ from metadata.conf import has_navigator
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        define('assistPanel', [
-          'knockout',
-          'desktop/js/assist/assistDbSource',
-          'desktop/js/assist/assistHdfsEntry',
-          'desktop/js/apiHelper',
-          'desktop/js/fileBrowser/hueFileEntry'
-        ], factory);
-      } else {
-        factory(ko, AssistDbSource, AssistHdfsEntry, ApiHelper, HueFileEntry);
-      }
-    }(function (ko, AssistDbSource, AssistHdfsEntry, ApiHelper, HueFileEntry) {
-
+    (function () {
       ko.bindingHandlers.assistFileDroppable = {
         init: function(element, valueAccessor, allBindings, boundEntry) {
           var dragData;
@@ -1499,6 +1486,6 @@ from metadata.conf import has_navigator
         viewModel: AssistPanel,
         template: { element: 'assist-panel-template' }
       });
-    }));
+    })();
   </script>
 </%def>

+ 373 - 438
desktop/core/src/desktop/templates/config_ko_components.mako

@@ -134,193 +134,176 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
+    (function () {
+      function MultiGroupAlternative(alt, params, initiallyChecked) {
+        var self = this;
+        self.altChecked = ko.observable(initiallyChecked || false);
+        self.label = params.optionsText ? alt[params.optionsText] : alt;
+        var value = params.optionsValue ? alt[params.optionsValue] : alt;
+        self.altChecked.subscribe(function (newValue) {
+          if (newValue) {
+            params.selectedOptions.push(value);
+          } else {
+            params.selectedOptions.remove(value);
+          }
+        });
       }
-    }(function (ko) {
-      (function () {
-
-        function MultiGroupAlternative(alt, params, initiallyChecked) {
-          var self = this;
-          self.altChecked = ko.observable(initiallyChecked || false);
-          self.label = params.optionsText ? alt[params.optionsText] : alt;
-          var value = params.optionsValue ? alt[params.optionsValue] : alt;
-          self.altChecked.subscribe(function (newValue) {
-            if (newValue) {
-              params.selectedOptions.push(value);
-            } else {
-              params.selectedOptions.remove(value);
-            }
-          });
-        }
-
-        function MultiGroupSelectorViewModel(params) {
-          var self = this;
-          self.width = params.width || 600;
-          self.height = params.height || 300;
 
-          var textAccessor = function (alt) {
-            if (params.optionsText) {
-              return alt[params.optionsText];
-            }
-            return alt;
-          };
+      function MultiGroupSelectorViewModel(params) {
+        var self = this;
+        self.width = params.width || 600;
+        self.height = params.height || 300;
 
-          self.searchQuery = ko.observable();
+        var textAccessor = function (alt) {
+          if (params.optionsText) {
+            return alt[params.optionsText];
+          }
+          return alt;
+        };
 
-          var addToIndexedLists = function (index, key, value) {
-            if (! index[key]) {
-              index[key] = [];
-            }
-            index[key].push(value);
-          };
-
-          self.searchResult = ko.pureComputed(function () {
-            if (self.searchQuery()) {
-              var lowerQuery = self.searchQuery().toLowerCase();
-              var result = {};
-              Object.keys(self.addressBook()).forEach(function (key) {
-                self.addressBook()[key].forEach(function (alt) {
-                  if (alt.label.toLowerCase().indexOf(lowerQuery) !== -1) {
-                    addToIndexedLists(result, key, alt);
-                  }
-                });
-              });
-              return result;
-            }
-            return self.addressBook();
-          });
+        self.searchQuery = ko.observable();
 
-          var initiallyCheckedIndex = {};
-          params.selectedOptions().forEach(function (alt) {
-            initiallyCheckedIndex[alt] = true;
-          });
+        var addToIndexedLists = function (index, key, value) {
+          if (! index[key]) {
+            index[key] = [];
+          }
+          index[key].push(value);
+        };
 
-          self.addressBook = ko.pureComputed(function () {
+        self.searchResult = ko.pureComputed(function () {
+          if (self.searchQuery()) {
+            var lowerQuery = self.searchQuery().toLowerCase();
             var result = {};
-            ko.unwrap(params.options).forEach(function (alt) {
-              addToIndexedLists(result, textAccessor(alt).charAt(0).toUpperCase(), new MultiGroupAlternative(alt, params, initiallyCheckedIndex[params.optionsValue ? alt[params.optionsValue] : alt]));
-            });
-            Object.keys(result).forEach(function (key) {
-              result[key].sort();
+            Object.keys(self.addressBook()).forEach(function (key) {
+              self.addressBook()[key].forEach(function (alt) {
+                if (alt.label.toLowerCase().indexOf(lowerQuery) !== -1) {
+                  addToIndexedLists(result, key, alt);
+                }
+              });
             });
             return result;
-          });
+          }
+          return self.addressBook();
+        });
 
-          self.searchResultKeys = ko.pureComputed(function () {
-            return Object.keys(self.searchResult()).sort();
+        var initiallyCheckedIndex = {};
+        params.selectedOptions().forEach(function (alt) {
+          initiallyCheckedIndex[alt] = true;
+        });
+
+        self.addressBook = ko.pureComputed(function () {
+          var result = {};
+          ko.unwrap(params.options).forEach(function (alt) {
+            addToIndexedLists(result, textAccessor(alt).charAt(0).toUpperCase(), new MultiGroupAlternative(alt, params, initiallyCheckedIndex[params.optionsValue ? alt[params.optionsValue] : alt]));
+          });
+          Object.keys(result).forEach(function (key) {
+            result[key].sort();
           });
+          return result;
+        });
 
-          self.allSelected = ko.observable(false);
+        self.searchResultKeys = ko.pureComputed(function () {
+          return Object.keys(self.searchResult()).sort();
+        });
 
-          self.allSelected.subscribe(function (newValue) {
-            self.searchResultKeys().forEach(function (key) {
-              self.searchResult()[key].forEach(function (alt) {
-                alt.altChecked(newValue);
-              })
+        self.allSelected = ko.observable(false);
+
+        self.allSelected.subscribe(function (newValue) {
+          self.searchResultKeys().forEach(function (key) {
+            self.searchResult()[key].forEach(function (alt) {
+              alt.altChecked(newValue);
             })
           })
-        }
+        })
+      }
 
-        ko.components.register('multi-group-selector', {
-          viewModel: MultiGroupSelectorViewModel,
-          template: {element: 'multi-group-selector-template'}
-        });
-      }());
-    }));
+      ko.components.register('multi-group-selector', {
+        viewModel: MultiGroupSelectorViewModel,
+        template: {element: 'multi-group-selector-template'}
+      });
+    })();
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout', 'ko.selectize'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-      (function () {
-
-        function PropertySelectorViewModel(params) {
-          var self = this;
-          var allProperties = params.properties;
-
-          self.selectedProperties = ko.observableArray();
-          self.availableProperties = ko.observableArray();
-          self.propertyToAdd = ko.observable(null);
-
-          var setInitialProperties = function () {
-            self.selectedProperties([]);
-            self.availableProperties([]);
-            allProperties().forEach(function (property) {
-              if (property.defaultValue && ko.mapping.toJSON(property.value) !== ko.mapping.toJSON(property.defaultValue)) {
-                self.selectedProperties.push(property);
-              } else {
-                self.availableProperties.push(property);
-              }
-            });
-            self.sort();
-          };
-
-          setInitialProperties();
-          self.visibleObservable = params.visibleObservable || ko.observable();
-
-          self.visibleObservable.subscribe(function (newValue) {
-            if (!newValue) {
-              setInitialProperties();
+    (function () {
+
+      function PropertySelectorViewModel(params) {
+        var self = this;
+        var allProperties = params.properties;
+
+        self.selectedProperties = ko.observableArray();
+        self.availableProperties = ko.observableArray();
+        self.propertyToAdd = ko.observable(null);
+
+        var setInitialProperties = function () {
+          self.selectedProperties([]);
+          self.availableProperties([]);
+          allProperties().forEach(function (property) {
+            if (property.defaultValue && ko.mapping.toJSON(property.value) !== ko.mapping.toJSON(property.defaultValue)) {
+              self.selectedProperties.push(property);
+            } else {
+              self.availableProperties.push(property);
             }
           });
-        }
-
-        var niceNameSort = function (a, b) {
-          return a.nice_name().localeCompare(b.nice_name());
-        }
+          self.sort();
+        };
 
-        PropertySelectorViewModel.prototype.sort = function () {
-          var self = this;
-          self.availableProperties.sort(niceNameSort);
-          self.selectedProperties.sort(niceNameSort);
-        }
+        setInitialProperties();
+        self.visibleObservable = params.visibleObservable || ko.observable();
 
-        PropertySelectorViewModel.prototype.addProperty = function () {
-          var self = this;
-          if (self.propertyToAdd()) {
-            switch (self.propertyToAdd().type()) {
-              case 'csv-hdfs-files':
-                self.propertyToAdd().value('');
-                break;
-              case 'hdfs-files':
-                self.propertyToAdd().value([{ path: ko.observable(''), type: ko.observable('') }]);
-                break;
-              case 'functions':
-                self.propertyToAdd().value([{ name: ko.observable(''), class_name: ko.observable('') }]);
-                break;
-              case 'settings':
-                self.propertyToAdd().value([{ key: ko.observable(''), value: ko.observable('') }]);
-            }
-            self.selectedProperties.push(self.propertyToAdd());
-            self.availableProperties.remove(self.propertyToAdd());
-            self.propertyToAdd(null);
-            self.sort();
+        self.visibleObservable.subscribe(function (newValue) {
+          if (!newValue) {
+            setInitialProperties();
           }
-        };
+        });
+      }
 
-        PropertySelectorViewModel.prototype.removeProperty = function (property) {
-          var self = this;
-          property.value(property.defaultValue());
-          self.selectedProperties.remove(property);
-          self.availableProperties.push(property);
+      var niceNameSort = function (a, b) {
+        return a.nice_name().localeCompare(b.nice_name());
+      }
+
+      PropertySelectorViewModel.prototype.sort = function () {
+        var self = this;
+        self.availableProperties.sort(niceNameSort);
+        self.selectedProperties.sort(niceNameSort);
+      }
+
+      PropertySelectorViewModel.prototype.addProperty = function () {
+        var self = this;
+        if (self.propertyToAdd()) {
+          switch (self.propertyToAdd().type()) {
+            case 'csv-hdfs-files':
+              self.propertyToAdd().value('');
+              break;
+            case 'hdfs-files':
+              self.propertyToAdd().value([{ path: ko.observable(''), type: ko.observable('') }]);
+              break;
+            case 'functions':
+              self.propertyToAdd().value([{ name: ko.observable(''), class_name: ko.observable('') }]);
+              break;
+            case 'settings':
+              self.propertyToAdd().value([{ key: ko.observable(''), value: ko.observable('') }]);
+          }
+          self.selectedProperties.push(self.propertyToAdd());
+          self.availableProperties.remove(self.propertyToAdd());
+          self.propertyToAdd(null);
           self.sort();
         }
+      };
+
+      PropertySelectorViewModel.prototype.removeProperty = function (property) {
+        var self = this;
+        property.value(property.defaultValue());
+        self.selectedProperties.remove(property);
+        self.availableProperties.push(property);
+        self.sort();
+      }
 
-        ko.components.register('property-selector', {
-          viewModel: PropertySelectorViewModel,
-          template: {element: 'property-selector-template'}
-        });
-      }());
-    }));
+      ko.components.register('property-selector', {
+        viewModel: PropertySelectorViewModel,
+        template: {element: 'property-selector-template'}
+      });
+    })();
   </script>
 
   <script type="text/html" id="property">
@@ -405,47 +388,39 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
+    (function () {
+      var JVM_MEM_PATTERN = /([0-9]+)([MG])$/;
+      var UNITS = {'MB': 'M', 'GB': 'G'};
+
+      function JvmMemoryInputViewModel(params) {
+        this.valueObservable = params.value;
+        this.units = Object.keys(UNITS);
+        this.selectedUnit = ko.observable();
+        this.value = ko.observable('');
+
+        var match = JVM_MEM_PATTERN.exec(this.valueObservable());
+        if (match && match.length === 3) {
+          this.value(match[1]);
+          this.selectedUnit(match[2] === 'M' ? 'MB' : 'GB');
+        }
+
+        this.value.subscribe(this.updateValueObservable, this);
+        this.selectedUnit.subscribe(this.updateValueObservable, this);
       }
-    }(function (ko) {
-      (function () {
-        var JVM_MEM_PATTERN = /([0-9]+)([MG])$/;
-        var UNITS = {'MB': 'M', 'GB': 'G'};
-
-        function JvmMemoryInputViewModel(params) {
-          this.valueObservable = params.value;
-          this.units = Object.keys(UNITS);
-          this.selectedUnit = ko.observable();
-          this.value = ko.observable('');
-
-          var match = JVM_MEM_PATTERN.exec(this.valueObservable());
-          if (match && match.length === 3) {
-            this.value(match[1]);
-            this.selectedUnit(match[2] === 'M' ? 'MB' : 'GB');
-          }
 
-          this.value.subscribe(this.updateValueObservable, this);
-          this.selectedUnit.subscribe(this.updateValueObservable, this);
+      JvmMemoryInputViewModel.prototype.updateValueObservable = function () {
+        if (isNaN(this.value()) || this.value() === '') {
+          this.valueObservable(undefined);
+        } else {
+          this.valueObservable(this.value() + UNITS[this.selectedUnit()]);
         }
+      };
 
-        JvmMemoryInputViewModel.prototype.updateValueObservable = function () {
-          if (isNaN(this.value()) || this.value() === '') {
-            this.valueObservable(undefined);
-          } else {
-            this.valueObservable(this.value() + UNITS[this.selectedUnit()]);
-          }
-        };
-
-        ko.components.register('jvm-memory-input', {
-          viewModel: JvmMemoryInputViewModel,
-          template: { element: 'jvm-memory-input-template' }
-        });
-      }());
-    }));
+      ko.components.register('jvm-memory-input', {
+        viewModel: JvmMemoryInputViewModel,
+        template: { element: 'jvm-memory-input-template' }
+      });
+    })();
   </script>
 
   <script type="text/html" id="key-value-list-input-template">
@@ -474,58 +449,50 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-      (function () {
-
-        function KeyValueListInputViewModel(params) {
-          var self = this;
-          self.values = params.values;
-          self.options = typeof params.property.options !== 'undefined' ? $.map(params.property.options(), function (option) {
-            return { value: option }
-          }) : [];
-
-          if (self.options.length > 0) {
-            self.values().forEach(function (value) {
-              if (self.options.indexOf(value.key()) === -1) {
-                self.options.push({ value: value.key() });
-              }
-            })
-          }
-          params.visibleObservable.subscribe(function (newValue) {
-            if (!newValue) {
-              self.values($.grep(self.values(), function (value) {
-                return value.key() && value.value();
-              }))
+    (function () {
+
+      function KeyValueListInputViewModel(params) {
+        var self = this;
+        self.values = params.values;
+        self.options = typeof params.property.options !== 'undefined' ? $.map(params.property.options(), function (option) {
+          return { value: option }
+        }) : [];
+
+        if (self.options.length > 0) {
+          self.values().forEach(function (value) {
+            if (self.options.indexOf(value.key()) === -1) {
+              self.options.push({ value: value.key() });
             }
-          });
+          })
         }
+        params.visibleObservable.subscribe(function (newValue) {
+          if (!newValue) {
+            self.values($.grep(self.values(), function (value) {
+              return value.key() && value.value();
+            }))
+          }
+        });
+      }
 
-        KeyValueListInputViewModel.prototype.addValue = function () {
-          var self = this;
-          var newValue = {
-            key: ko.observable(''),
-            value: ko.observable('')
-          };
-          self.values.push(newValue);
-        };
-
-        KeyValueListInputViewModel.prototype.removeValue = function (valueToRemove) {
-          var self = this;
-          self.values.remove(valueToRemove);
+      KeyValueListInputViewModel.prototype.addValue = function () {
+        var self = this;
+        var newValue = {
+          key: ko.observable(''),
+          value: ko.observable('')
         };
-
-        ko.components.register('key-value-list-input', {
-          viewModel: KeyValueListInputViewModel,
-          template: { element: 'key-value-list-input-template' }
-        });
-      }());
-    }));
+        self.values.push(newValue);
+      };
+
+      KeyValueListInputViewModel.prototype.removeValue = function (valueToRemove) {
+        var self = this;
+        self.values.remove(valueToRemove);
+      };
+
+      ko.components.register('key-value-list-input', {
+        viewModel: KeyValueListInputViewModel,
+        template: { element: 'key-value-list-input-template' }
+      });
+    })();
   </script>
 
   <script type="text/html" id="name-value-list-input-template">
@@ -554,58 +521,50 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-      (function () {
-
-        function NameValueListInputViewModel(params) {
-          var self = this;
-          self.values = params.values;
-          self.options = typeof params.property.options !== 'undefined' ? $.map(params.property.options(), function (option) {
-            return { value: option }
-          }) : [];
-
-          if (self.options.length > 0) {
-            self.values().forEach(function (value) {
-              if (self.options.indexOf(value.name()) === -1) {
-                self.options.push({ value: value.name() });
-              }
-            })
-          }
-          params.visibleObservable.subscribe(function (newValue) {
-            if (!newValue) {
-              self.values($.grep(self.values(), function (value) {
-                return value.name() && value.value();
-              }))
+    (function () {
+
+      function NameValueListInputViewModel(params) {
+        var self = this;
+        self.values = params.values;
+        self.options = typeof params.property.options !== 'undefined' ? $.map(params.property.options(), function (option) {
+          return { value: option }
+        }) : [];
+
+        if (self.options.length > 0) {
+          self.values().forEach(function (value) {
+            if (self.options.indexOf(value.name()) === -1) {
+              self.options.push({ value: value.name() });
             }
-          });
+          })
         }
+        params.visibleObservable.subscribe(function (newValue) {
+          if (!newValue) {
+            self.values($.grep(self.values(), function (value) {
+              return value.name() && value.value();
+            }))
+          }
+        });
+      }
 
-        NameValueListInputViewModel.prototype.addValue = function () {
-          var self = this;
-          var newValue = {
-            name: ko.observable(''),
-            value: ko.observable('')
-          };
-          self.values.push(newValue);
-        };
-
-        NameValueListInputViewModel.prototype.removeValue = function (valueToRemove) {
-          var self = this;
-          self.values.remove(valueToRemove);
+      NameValueListInputViewModel.prototype.addValue = function () {
+        var self = this;
+        var newValue = {
+          name: ko.observable(''),
+          value: ko.observable('')
         };
-
-        ko.components.register('name-value-list-input', {
-          viewModel: NameValueListInputViewModel,
-          template: { element: 'name-value-list-input-template' }
-        });
-      }());
-    }));
+        self.values.push(newValue);
+      };
+
+      NameValueListInputViewModel.prototype.removeValue = function (valueToRemove) {
+        var self = this;
+        self.values.remove(valueToRemove);
+      };
+
+      ko.components.register('name-value-list-input', {
+        viewModel: NameValueListInputViewModel,
+        template: { element: 'name-value-list-input-template' }
+      });
+    })();
   </script>
 
   <script type="text/html" id="function-list-input-template">
@@ -627,47 +586,39 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
+    (function () {
+
+      function FunctionListInputViewModel(params) {
+        var self = this;
+        self.values = params.values;
+        params.visibleObservable.subscribe(function (newValue) {
+          if (!newValue) {
+            self.values($.grep(self.values(), function (value) {
+              return value.name() && value.class_name();
+            }))
+          }
+        });
       }
-    }(function (ko) {
-      (function () {
-
-        function FunctionListInputViewModel(params) {
-          var self = this;
-          self.values = params.values;
-          params.visibleObservable.subscribe(function (newValue) {
-            if (!newValue) {
-              self.values($.grep(self.values(), function (value) {
-                return value.name() && value.class_name();
-              }))
-            }
-          });
-        }
-
-        FunctionListInputViewModel.prototype.addValue = function () {
-          var self = this;
-          var newValue = {
-            name: ko.observable(''),
-            class_name: ko.observable('')
-          };
-          self.values.push(newValue);
-        };
 
-        FunctionListInputViewModel.prototype.removeValue = function (valueToRemove) {
-          var self = this;
-          self.values.remove(valueToRemove);
+      FunctionListInputViewModel.prototype.addValue = function () {
+        var self = this;
+        var newValue = {
+          name: ko.observable(''),
+          class_name: ko.observable('')
         };
-
-        ko.components.register('function-list-input', {
-          viewModel: FunctionListInputViewModel,
-          template: { element: 'function-list-input-template' }
-        });
-      }());
-    }));
+        self.values.push(newValue);
+      };
+
+      FunctionListInputViewModel.prototype.removeValue = function (valueToRemove) {
+        var self = this;
+        self.values.remove(valueToRemove);
+      };
+
+      ko.components.register('function-list-input', {
+        viewModel: FunctionListInputViewModel,
+        template: { element: 'function-list-input-template' }
+      });
+    })();
   </script>
 
   <script type="text/html" id="hdfs-file-list-input-template">
@@ -688,70 +639,62 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-      (function () {
-
-        var identifyType = function (path) {
-          switch (path.substr(path.lastIndexOf('.') + 1).toLowerCase()) {
-            case 'jar':
-              return 'jar';
-            case 'zip':
-            case 'tar':
-            case 'rar':
-            case 'bz2':
-            case 'gz':
-            case 'tgz':
-              return 'archive';
-          }
-          return 'file';
-        };
-
-        function HdfsFileListInputViewModel(params) {
-          var self = this;
-          self.values = params.values;
-          $.each(self.values(), function (idx, value) {
-            value.path.subscribe(function (newPath) {
-              value.type(identifyType(newPath));
-            });
-          });
-          params.visibleObservable.subscribe(function (newValue) {
-            if (!newValue) {
-              self.values($.grep(self.values(), function (value) {
-                return value.path();
-              }))
-            }
-          });
+    (function () {
+
+      var identifyType = function (path) {
+        switch (path.substr(path.lastIndexOf('.') + 1).toLowerCase()) {
+          case 'jar':
+            return 'jar';
+          case 'zip':
+          case 'tar':
+          case 'rar':
+          case 'bz2':
+          case 'gz':
+          case 'tgz':
+            return 'archive';
         }
-
-        HdfsFileListInputViewModel.prototype.addValue = function () {
-          var self = this;
-          var newValue = {
-            path: ko.observable(''),
-            type: ko.observable('')
-          };
-          newValue.path.subscribe(function (newPath) {
-            newValue.type(identifyType(newPath));
+        return 'file';
+      };
+
+      function HdfsFileListInputViewModel(params) {
+        var self = this;
+        self.values = params.values;
+        $.each(self.values(), function (idx, value) {
+          value.path.subscribe(function (newPath) {
+            value.type(identifyType(newPath));
           });
-          self.values.push(newValue);
-        };
+        });
+        params.visibleObservable.subscribe(function (newValue) {
+          if (!newValue) {
+            self.values($.grep(self.values(), function (value) {
+              return value.path();
+            }))
+          }
+        });
+      }
 
-        HdfsFileListInputViewModel.prototype.removeValue = function (valueToRemove) {
-          var self = this;
-          self.values.remove(valueToRemove);
+      HdfsFileListInputViewModel.prototype.addValue = function () {
+        var self = this;
+        var newValue = {
+          path: ko.observable(''),
+          type: ko.observable('')
         };
-
-        ko.components.register('hdfs-file-list-input', {
-          viewModel: HdfsFileListInputViewModel,
-          template: { element: 'hdfs-file-list-input-template' }
+        newValue.path.subscribe(function (newPath) {
+          newValue.type(identifyType(newPath));
         });
-      }());
-    }));
+        self.values.push(newValue);
+      };
+
+      HdfsFileListInputViewModel.prototype.removeValue = function (valueToRemove) {
+        var self = this;
+        self.values.remove(valueToRemove);
+      };
+
+      ko.components.register('hdfs-file-list-input', {
+        viewModel: HdfsFileListInputViewModel,
+        template: { element: 'hdfs-file-list-input-template' }
+      });
+    })();
   </script>
 
   <script type="text/html" id="csv-list-input-template">
@@ -775,59 +718,51 @@ from desktop.views import _ko
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if (typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-      (function () {
-        function CsvListInputViewModel(params) {
-          this.valueObservable = params.value;
-          this.isArray = $.isArray(this.valueObservable());
-          this.placeholder = params.placeholder || '';
-          this.inputTemplate = params.inputTemplate || null;
-
-          var initialValues;
-          if (this.isArray) {
-            initialValues = ko.mapping.toJS(this.valueObservable());
-          } else {
-            initialValues = this.valueObservable() != null ? this.valueObservable().split(",") : [];
-          }
-          for (var i = 0; i < initialValues.length; i++) {
-            initialValues[i] = {value: ko.observable(initialValues[i].trim())};
-            initialValues[i].value.subscribe(this.updateValueObservable, this);
-          }
-          this.values = ko.observableArray(initialValues);
-          this.values.subscribe(this.updateValueObservable, this);
+    (function () {
+      function CsvListInputViewModel(params) {
+        this.valueObservable = params.value;
+        this.isArray = $.isArray(this.valueObservable());
+        this.placeholder = params.placeholder || '';
+        this.inputTemplate = params.inputTemplate || null;
+
+        var initialValues;
+        if (this.isArray) {
+          initialValues = ko.mapping.toJS(this.valueObservable());
+        } else {
+          initialValues = this.valueObservable() != null ? this.valueObservable().split(",") : [];
         }
+        for (var i = 0; i < initialValues.length; i++) {
+          initialValues[i] = {value: ko.observable(initialValues[i].trim())};
+          initialValues[i].value.subscribe(this.updateValueObservable, this);
+        }
+        this.values = ko.observableArray(initialValues);
+        this.values.subscribe(this.updateValueObservable, this);
+      }
 
-        CsvListInputViewModel.prototype.addValue = function () {
-          var newValue = {value: ko.observable('')};
-          newValue.value.subscribe(this.updateValueObservable, this);
-          this.values.push(newValue);
-        };
-
-        CsvListInputViewModel.prototype.removeValue = function (valueToRemove) {
-          this.values.remove(valueToRemove);
-        };
+      CsvListInputViewModel.prototype.addValue = function () {
+        var newValue = {value: ko.observable('')};
+        newValue.value.subscribe(this.updateValueObservable, this);
+        this.values.push(newValue);
+      };
 
-        CsvListInputViewModel.prototype.updateValueObservable = function () {
-          var cleanValues = $.map(this.values(), function (item) {
-            return item.value();
-          });
-          cleanValues = $.grep(cleanValues, function (value) {
-            return value;
-          });
-          this.valueObservable(this.isArray ? cleanValues : cleanValues.join(','));
-        };
+      CsvListInputViewModel.prototype.removeValue = function (valueToRemove) {
+        this.values.remove(valueToRemove);
+      };
 
-        ko.components.register('csv-list-input', {
-          viewModel: CsvListInputViewModel,
-          template: { element: 'csv-list-input-template' }
+      CsvListInputViewModel.prototype.updateValueObservable = function () {
+        var cleanValues = $.map(this.values(), function (item) {
+          return item.value();
+        });
+        cleanValues = $.grep(cleanValues, function (value) {
+          return value;
         });
-      }());
-    }));
+        this.valueObservable(this.isArray ? cleanValues : cleanValues.join(','));
+      };
+
+      ko.components.register('csv-list-input', {
+        viewModel: CsvListInputViewModel,
+        template: { element: 'csv-list-input-template' }
+      });
+    })();
   </script>
 </%def>

+ 5 - 23
desktop/core/src/desktop/templates/sql_context_popover.mako

@@ -481,17 +481,7 @@ from metadata.conf import has_navigator
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        require([
-          'knockout',
-          'desktop/js/apiHelper',
-          'desktop/js/sqlFunctions'
-        ], factory);
-      } else {
-        factory(ko, ApiHelper, SqlFunctions);
-      }
-    }(function (ko, ApiHelper, sqlFunctions) {
+    (function () {
 
       var HALF_SIZE_LIMIT_X = 130;
       var HALF_SIZE_LIMIT_Y = 100;
@@ -824,7 +814,7 @@ from metadata.conf import has_navigator
       function FunctionContextTabs(data, sourceType) {
         var self = this;
         self.func = ko.observable({
-          details: sqlFunctions.findFunction(sourceType, data.function),
+          details: SqlFunctions.findFunction(sourceType, data.function),
           loading: ko.observable(false),
           hasErrors: ko.observable(false)
         });
@@ -1124,7 +1114,7 @@ from metadata.conf import has_navigator
           $(document).on('click', hideOnClickOutside);
         }, 0);
       });
-    }));
+    })();
   </script>
 
   <script type="text/html" id="sql-columns-table-template">
@@ -1163,15 +1153,7 @@ from metadata.conf import has_navigator
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        require([
-          'knockout'
-        ], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
+    (function () {
 
       function SqlColumnsTable(params) {
         var self = this;
@@ -1204,6 +1186,6 @@ from metadata.conf import has_navigator
         viewModel: SqlColumnsTable,
         template: { element: 'sql-columns-table-template' }
       });
-    }));
+    })();
   </script>
 </%def>

+ 2 - 14
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -14,19 +14,7 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-(function (root, factory) {
-  if(typeof define === "function" && define.amd) {
-    define([
-      'knockout',
-      'desktop/js/apiHelper',
-      'desktop/js/autocompleter',
-      'knockout-mapping',
-      'ko.charts'
-    ], factory);
-  } else {
-    root.EditorViewModel = factory(ko, ApiHelper, Autocompleter);
-  }
-}(this, function (ko, ApiHelper, Autocompleter) {
+var EditorViewModel = (function() {
 
   var NOTEBOOK_MAPPING = {
     ignore: [
@@ -2244,4 +2232,4 @@
   }
 
   return EditorViewModel;
-}));
+})();

+ 29 - 20
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -24,7 +24,6 @@ from desktop.views import _ko
 from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_BATCH_EXECUTE
 %>
 
-<%namespace name="require" file="/require.mako" />
 <%namespace name="hueIcons" file="/hue_icons.mako" />
 
 <%def name="includes()">
@@ -42,12 +41,39 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <link rel="stylesheet" href="${ static('desktop/css/bootstrap-medium-editor.css') }">
 <link rel="stylesheet" href="${ static('desktop/ext/css/jquery.mCustomScrollbar.min.css') }">
 
+
+<script src="${ static('desktop/ext/js/jquery/plugins/jquery-ui-1.10.4.custom.min.js') }"></script>
+<script src="${ static('desktop/ext/js/knockout.min.js') }"></script>
+<script src="${ static('desktop/ext/js/selectize.min.js') }"></script>
+<script src="${ static('desktop/js/apiHelper.js') }"></script>
+<script src="${ static('desktop/js/ko.charts.js') }"></script>
+<script src="${ static('notebook/js/notebook.ko.js') }"></script>
+% if ENABLE_QUERY_SCHEDULING.get():
+<script src="${ static('oozie/js/coordinator-editor.ko.js') }"></script>
+<script src="${ static('oozie/js/list-oozie-coordinator.ko.js') }"></script>
+% endif
+<script src="${ static('desktop/ext/js/knockout-mapping.min.js') }"></script>
+<script src="${ static('desktop/ext/js/knockout-sortable.min.js') }"></script>
+<script src="${ static('desktop/js/ko.editable.js') }"></script>
+<script src="${ static('desktop/js/ko.hue-bindings.js') }"></script>
+<script src="${ static('desktop/js/ko.switch-case.js') }"></script>
+<script src="${ static('desktop/js/sqlFunctions.js') }"></script>
+<script src="${ static('desktop/js/autocomplete/sql.js') }"></script>
+<script src="${ static('desktop/js/sqlAutocompleter.js') }"></script>
+<script src="${ static('desktop/js/sqlAutocompleter2.js') }"></script>
+<script src="${ static('desktop/js/hdfsAutocompleter.js') }"></script>
+<script src="${ static('desktop/js/autocompleter.js') }"></script>
 <script src="${ static('desktop/js/hue.json.js') }"></script>
 <script src="${ static('desktop/js/jquery.huedatatable.js') }"></script>
 <script src="${ static('desktop/ext/js/markdown.min.js') }"></script>
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery.hotkeys.js') }"></script>
 <script src="${ static('desktop/ext/js/jquery/plugins/jquery.mousewheel.min.js') }"></script>
 <script src="${ static('desktop/ext/js/jquery.mCustomScrollbar.concat.min.js') }"></script>
+<script src="${ static('desktop/js/assist/assistDbEntry.js') }"></script>
+<script src="${ static('desktop/js/assist/assistDbSource.js') }"></script>
+<script src="${ static('desktop/js/assist/assistHdfsEntry.js') }"></script>
+<script src="${ static('desktop/js/fileBrowser/hueDocument.js') }"></script>
+<script src="${ static('desktop/js/fileBrowser/hueFileEntry.js') }"></script>
 
 % if ENABLE_QUERY_SCHEDULING.get():
 <script src="${ static('oozie/js/dashboard-utils.js') }" type="text/javascript" charset="utf-8"></script>
@@ -169,8 +195,6 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script src="${ static('oozie/js/editor2-utils.js') }" type="text/javascript" charset="utf-8"></script>
 % endif
 
-${ require.config() }
-
 </%def>
 
 <%def name="topBar()">
@@ -2848,22 +2872,7 @@ ${ hueIcons.symbols() }
     }
   }
 
-  require([
-    "knockout",
-    "ko.charts",
-    "notebook/js/notebook.ko",
-    % if ENABLE_QUERY_SCHEDULING.get():
-    "oozie/js/coordinator-editor.ko",
-    "oozie/js/list-oozie-coordinator.ko",
-    % endif
-    "assistPanel",
-    "knockout-mapping",
-    "knockout-sortable",
-    "ko.editable",
-    "ko.hue-bindings",
-    "ko.switch-case"
-  ], function (ko, charts, EditorViewModel, CoordinatorEditorViewModel, RunningCoordinatorModel) {
-
+  (function () {
     ko.options.deferUpdates = true;
 
     var VIEW_MODEL_OPTIONS = $.extend(${ options_json | n,unicode }, {
@@ -3747,7 +3756,7 @@ ${ hueIcons.symbols() }
         }, 200);
       });
     });
-  });
+  })();
 
   var mathjax = document.createElement("script");
   mathjax.src = "//cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML";

+ 77 - 98
desktop/libs/notebook/src/notebook/templates/notebook_ko_components.mako

@@ -68,14 +68,7 @@ except ImportError, e:
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-
+    (function () {
       var SnippetDbSelection = function (params, element) {
         var self = this;
         self.dbSelectionVisible = ko.observable(false);
@@ -178,7 +171,7 @@ except ImportError, e:
         },
         template: { element: 'snippet-db-selection-template' }
       });
-    }));
+    })();
   </script>
 </%def>
 
@@ -225,94 +218,86 @@ except ImportError, e:
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
-      (function () {
-        var WHEEL_RADIUS = 75;
-        var PLUS_ICON_RADIUS = 27.859; // FA-5X
-
-        var calculatePositions = function (alternativeCount) {
-          var radius = WHEEL_RADIUS;
-          var radIncrements = 2 * Math.PI / alternativeCount;
-          var currentRad = -0.5 * Math.PI;
-
-          var result = [];
-
-          for (var i = 0; i < alternativeCount; i++) {
-            result.push({
-              left: radius * Math.cos(currentRad) + PLUS_ICON_RADIUS + 'px',
-              top: radius * Math.sin(currentRad) + PLUS_ICON_RADIUS + 'px'
-            });
-            currentRad += radIncrements;
+    (function () {
+      var WHEEL_RADIUS = 75;
+      var PLUS_ICON_RADIUS = 27.859; // FA-5X
+
+      var calculatePositions = function (alternativeCount) {
+        var radius = WHEEL_RADIUS;
+        var radIncrements = 2 * Math.PI / alternativeCount;
+        var currentRad = -0.5 * Math.PI;
+
+        var result = [];
+
+        for (var i = 0; i < alternativeCount; i++) {
+          result.push({
+            left: radius * Math.cos(currentRad) + PLUS_ICON_RADIUS + 'px',
+            top: radius * Math.sin(currentRad) + PLUS_ICON_RADIUS + 'px'
+          });
+          currentRad += radIncrements;
+        }
+
+        return result;
+      };
+
+      function AddSnippetMenuViewModel(params) {
+        var self = this;
+        self.notebook = params.notebook;
+        self.availableSnippets = params.availableSnippets;
+        self.snippetHistory = ko.observableArray([].concat(self.availableSnippets.slice(0, 5)));
+        self.lastUsedSnippet = self.snippetHistory()[0];
+        self.roundCount = 0;
+        self.positions = calculatePositions(self.snippetHistory().length);
+        self.showingHistory = ko.observable(false);
+        self.hasAdditionalSnippets = params.availableSnippets().length > 5;
+        self.showingSelectSnippet = ko.observable(false);
+
+        self.addLastUsedSnippet = function () {
+          self.addNewSnippet(self.lastUsedSnippet);
+        };
+
+        self.showSnippetModal = function () {
+          $("#addSnippetModal").modal('show');
+        };
+
+        self.addNewSnippet = function (alternative) {
+          clearTimeout(hideTimeout);
+          self.showingHistory(false);
+          self.showingSelectSnippet(false);
+          $("#addSnippetModal").modal('hide');
+
+          // When fewer than 5 it's always in history
+          if (self.snippetHistory().indexOf(alternative) == -1) {
+            self.snippetHistory.splice(4 - self.roundCount, 1, alternative);
+            self.roundCount = (self.roundCount + 1) % 5;
           }
 
-          return result;
+          self.lastUsedSnippet = alternative;
+          self.notebook.newSnippet(alternative.type())
         };
 
-        function AddSnippetMenuViewModel(params) {
-          var self = this;
-          self.notebook = params.notebook;
-          self.availableSnippets = params.availableSnippets;
-          self.snippetHistory = ko.observableArray([].concat(self.availableSnippets.slice(0, 5)));
-          self.lastUsedSnippet = self.snippetHistory()[0];
-          self.roundCount = 0;
-          self.positions = calculatePositions(self.snippetHistory().length);
-          self.showingHistory = ko.observable(false);
-          self.hasAdditionalSnippets = params.availableSnippets().length > 5;
-          self.showingSelectSnippet = ko.observable(false);
-
-          self.addLastUsedSnippet = function () {
-            self.addNewSnippet(self.lastUsedSnippet);
-          };
-
-          self.showSnippetModal = function () {
-            $("#addSnippetModal").modal('show');
-          };
-
-          self.addNewSnippet = function (alternative) {
-            clearTimeout(hideTimeout);
-            self.showingHistory(false);
-            self.showingSelectSnippet(false);
-            $("#addSnippetModal").modal('hide');
+        var hideTimeout = -1;
 
-            // When fewer than 5 it's always in history
-            if (self.snippetHistory().indexOf(alternative) == -1) {
-              self.snippetHistory.splice(4 - self.roundCount, 1, alternative);
-              self.roundCount = (self.roundCount + 1) % 5;
-            }
+        self.showHistory = function () {
+          clearTimeout(hideTimeout);
+          self.showingHistory(true);
+          self.showingSelectSnippet(true);
+        };
 
-            self.lastUsedSnippet = alternative;
-            self.notebook.newSnippet(alternative.type())
-          };
-
-          var hideTimeout = -1;
-
-          self.showHistory = function () {
-            clearTimeout(hideTimeout);
-            self.showingHistory(true);
-            self.showingSelectSnippet(true);
-          };
-
-          self.hideHistory = function () {
-            clearTimeout(hideTimeout);
-            hideTimeout = window.setTimeout(function () {
-              self.showingHistory(false);
-              self.showingSelectSnippet(false);
-            }, 500);
-          };
-        }
+        self.hideHistory = function () {
+          clearTimeout(hideTimeout);
+          hideTimeout = window.setTimeout(function () {
+            self.showingHistory(false);
+            self.showingSelectSnippet(false);
+          }, 500);
+        };
+      }
 
-        ko.components.register('add-snippet-menu', {
-          viewModel: AddSnippetMenuViewModel,
-          template: { element: 'add-snippet-menu-template' }
-        });
-      }());
-    }));
+      ko.components.register('add-snippet-menu', {
+        viewModel: AddSnippetMenuViewModel,
+        template: { element: 'add-snippet-menu-template' }
+      });
+    })();
   </script>
 </%def>
 
@@ -462,13 +447,7 @@ except ImportError, e:
   </script>
 
   <script type="text/javascript" charset="utf-8">
-    (function (factory) {
-      if(typeof require === "function") {
-        require(['knockout'], factory);
-      } else {
-        factory(ko);
-      }
-    }(function (ko) {
+    (function () {
       function DownloadResultsViewModel (params, element) {
         var self = this;
         self.$downloadForm = $(element).find(".download-form");
@@ -593,6 +572,6 @@ except ImportError, e:
         }},
         template: { element: 'download-results-template' }
       });
-    }));
+    })();
   </script>
 </%def>

+ 1 - 1
tools/jison/hue-jison.sh

@@ -33,7 +33,7 @@ echo "%%" > sql_end.jison
 
 cat sql_main.jison sql_valueExpression.jison sql_error.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison sql_end.jison ../sql_support.js > sql.jison
 
-jison sql.jison sql.jisonlex -m amd
+jison sql.jison sql.jisonlex
 cat license.txt sql.js > ../sql.js
 rm sql.jison
 rm sql.js

Nem az összes módosított fájl került megjelenítésre, mert túl sok fájl változott