浏览代码

HUE-5057 [metadata] Add read-only option to the Navigator tag editor

Johan Ahlen 9 年之前
父节点
当前提交
4d5b4a4de1

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

@@ -91,13 +91,15 @@
 
       var $readOnlyContainer = $('<div>').hide().addClass('selectize-control selectize-read-only multi').attr('style', $element.attr('style')).insertAfter($(element));
 
-      $readOnlyContainer.on('mouseover', function () {
-        $readOnlyContainer.find('.selectize-actions').addClass('selectize-actions-visible');
-      });
+      if (!options.readOnly) {
+        $readOnlyContainer.on('mouseover', function () {
+          $readOnlyContainer.find('.selectize-actions').addClass('selectize-actions-visible');
+        });
 
-      $readOnlyContainer.on('mouseout', function () {
-        $readOnlyContainer.find('.selectize-actions').removeClass('selectize-actions-visible');
-      });
+        $readOnlyContainer.on('mouseout', function () {
+          $readOnlyContainer.find('.selectize-actions').removeClass('selectize-actions-visible');
+        });
+      }
 
       $element.hide();
 
@@ -134,11 +136,13 @@
           $('<span>').addClass('selectize-no-tags').text(options.placeholder).appendTo($readOnlyInner);
         }
 
-        $('<i>').addClass('fa fa-edit selectize-edit').appendTo($readOnlyInner);
 
-        $readOnlyInner.click(function () {
-          showEdit();
-        });
+        if (! options.readOnly) {
+          $('<i>').addClass('fa fa-edit selectize-edit pointer').appendTo($readOnlyInner);
+          $readOnlyInner.click(function () {
+            showEdit();
+          });
+        }
 
         $readOnlyContainer.show();
       };

+ 2 - 1
desktop/core/src/desktop/templates/nav_components.mako

@@ -19,7 +19,7 @@ from desktop.views import _ko
 from django.utils.translation import ugettext as _
 %>
 
-<%def name="nav_tags()">
+<%def name="nav_tags(readOnly=False)">
   <link href="${ static('desktop/ext/css/selectize.css') }" rel="stylesheet">
 
   <script type="text/html" id="nav-tags-template">
@@ -29,6 +29,7 @@ from django.utils.translation import ugettext as _
      <div style="width: 100%" data-bind="ifnot: loading">
        <textarea style="width: 100%" data-bind="tagEditor: {
           placeholder: '${_ko('No tags.')}',
+          readOnly: '${ readOnly }' === 'True',
           setTags: currentTags,
           onSave: onSave,
           load: loadTags