Преглед изворни кода

HUE-6049 [importer] Renders deeply nested selects on fields in IE11

Enrico Berti пре 8 година
родитељ
комит
5bf0015

+ 9 - 0
desktop/core/src/desktop/static/desktop/js/ko.selectize.js

@@ -32,6 +32,15 @@ var inject_binding = function (allBindings, key, value) {
   };
 }
 
+ko.bindingHandlers.browserAwareSelectize = {
+  init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
+    (window.isIE11 ? ko.bindingHandlers.options : ko.bindingHandlers.selectize).init.apply(null, arguments);
+  },
+  update: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
+    (window.isIE11 ? ko.bindingHandlers.options : ko.bindingHandlers.selectize).update.apply(null, arguments);
+  }
+}
+
 ko.bindingHandlers.selectize = {
   init: function (element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
     if (typeof allBindingsAccessor.get('optionsCaption') == 'undefined')

+ 3 - 0
desktop/core/src/desktop/templates/common_header_footer_components.mako

@@ -158,6 +158,9 @@ from metadata.conf import has_optimizer, OPTIMIZER
     if (document.documentMode && document.documentMode < 9){
       location.href = "${ url('desktop.views.unsupported') }";
     }
+
+    // sets a global variable to see if it's IE11 or not
+    var isIE11 = !!window.MSInputMethodContext && !!document.documentMode;
   </script>
 </%def>
 

+ 5 - 5
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -792,11 +792,11 @@ ${ assist.assistPanel() }
 
     <label class="margin-left-5">${ _('Type') }&nbsp;
     <!-- ko if: ! (level() > 0 && $parent.type() == 'map') -->
-      <select class="input-small" data-bind="selectize: $root.createWizard.hiveFieldTypes, value: type"></select>
+      <select class="input-small" data-bind="browserAwareSelectize: $root.createWizard.hiveFieldTypes, value: type"></select>
     <!-- /ko -->
     <!-- ko if: level() > 0 && $parent.type() == 'map' -->
-      <select class="input-small" data-bind="selectize: $root.createWizard.hivePrimitiveFieldTypes, value: keyType"></select>
-      <select class="input-small" data-bind="selectize: $root.createWizard.hiveFieldTypes, value: type"></select>
+      <select class="input-small" data-bind="browserAwareSelectize: $root.createWizard.hivePrimitiveFieldTypes, value: keyType"></select>
+      <select class="input-small" data-bind="browserAwareSelectize: $root.createWizard.hiveFieldTypes, value: type"></select>
     <!-- /ko -->
 
       <input type="number" class="input-small" placeholder="${ _('Length') }" data-bind="value: length, visible: type() == 'varchar' || type() == 'char'">
@@ -838,7 +838,7 @@ ${ assist.assistPanel() }
     <input type="text" class="input-large" placeholder="${ _('Field name') }" data-bind="value: name">
   </label>
   <label class="margin-left-5">${ _('Type') }&nbsp;
-    <select class="input-small" data-bind="selectize: $root.createWizard.fieldTypes, value: type"></select>
+    <select class="input-small" data-bind="browserAwareSelectize: $root.createWizard.fieldTypes, value: type"></select>
   </label>
   <a href="javascript:void(0)" title="${ _('Show field properties') }" data-bind="css: {'inactive-action': !showProperties()}, click: function() {showProperties(!showProperties()) }"><i class="fa fa-sliders"></i></a>
   <span data-bind="visible: showProperties" class="field-properties">
@@ -869,7 +869,7 @@ ${ assist.assistPanel() }
 
 <script type="text/html" id="operation-template">
   <div class="operation">
-    <select data-bind="selectize: $root.createWizard.operationTypes.map(function(o){return o.name}), value: operation.type"></select>
+    <select data-bind="browserAwareSelectize: $root.createWizard.operationTypes.map(function(o){return o.name}), value: operation.type"></select>
     <!-- ko template: "args-template" --><!-- /ko -->
     <!-- ko if: operation.settings().outputType() == "custom_fields" -->
       <label class="margin-left-5">${ _('Number of expected fields') }