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

HUE-7968 [metastore] Disable the description HTML editor in the table browser

Johan Ahlen пре 7 година
родитељ
комит
d2a2539

+ 2 - 2
apps/metastore/src/metastore/templates/metastore.mako

@@ -155,7 +155,7 @@ ${ components.menubar(is_embeddable) }
               <!-- ko ifnot: table.isView() -->
               <div class="show-inactive-on-hover">
               <a class="inactive-action pointer toggle-editable" title="${ _('Edit the description') }"><i class="fa fa-pencil"></i></a>
-              <span data-bind="editable: comment, editableOptions: { escape: true, enabled: true, type: 'wysihtml5', toggle: 'manual', skipNewLines: true, toggleElement: '.toggle-editable', placement: 'left', placeholder: '${ _ko('Add a description...') }', emptytext: '${ _ko('Add a description...') }', inputclass: 'input-xlarge'}">
+              <span data-bind="editable: comment, editableOptions: { escape: true, enabled: true, type: 'textarea', toggle: 'manual', toggleElement: '.toggle-editable', placement: 'left', placeholder: '${ _ko('Add a description...') }', emptytext: '${ _ko('Add a description...') }', inputclass: 'input-xlarge'}">
                 ${ _('Add a description...') }</span>
               </div>
               <!-- /ko -->
@@ -895,7 +895,7 @@ ${ components.menubar(is_embeddable) }
   <div style="position: relative;" class="show-inactive-on-hover">
     <div style="position:absolute; left: 10px; top: 2px;"><a class="inactive-action pointer toggle-editable" title="${ _('Edit the description') }"><i class="fa fa-pencil vertical-align-top"></i></a></div>
     <div style="margin-left: 25px;" data-bind="toggleOverflow: { height: 24 }">
-      <div style="height: inherit" data-bind="editable: comment, editableOptions: { escape: true, enabled: true, type: 'wysihtml5', toggle: 'manual', toggleElement: '.toggle-editable', placement: 'bottom', forcePlacement: true, placeholder: '${ _ko('Add a description...') }', emptytext: '${ _ko('No description available') }', inputclass:'input-xlarge', rows: 10 }" class="inline-block">
+      <div style="height: inherit" data-bind="editable: comment, editableOptions: { escape: true, enabled: true, type: 'textarea', toggle: 'manual', toggleElement: '.toggle-editable', placement: 'bottom', forcePlacement: true, placeholder: '${ _ko('Add a description...') }', emptytext: '${ _ko('No description available') }', inputclass:'input-xlarge', rows: 10 }" class="inline-block">
         ${ _('Add a description...') }
       </div>
     </div>

+ 11 - 7
desktop/core/src/desktop/static/desktop/js/ko.editable.js

@@ -94,17 +94,21 @@
       //update observable on save
       if (ko.isObservable(value)) {
         $editable.on('save.ko', function (e, params) {
-          if (editableOptions.type && editableOptions.type == 'wysihtml5') {
+          var newValue = params.newValue || '';
+          if (editableOptions.type === 'wysihtml5') {
             if (editableOptions.skipNewLines) {
-              value(params.newValue.replace(/<br\s*[\/]?>/gi, ' ').replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ''));
+              newValue = newValue.replace(/<br\s*[\/]?>/gi, ' ').replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
+            } else {
+              newValue = newValue.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, '');
             }
-            else {
-              value(params.newValue.replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, ''));
+          } else {
+            newValue = newValue.replace(/<(?:.|\n)*?>/gm, '');
+
+            if (editableOptions.type !== 'textarea') {
+              newValue = newValue.replace(/\r?\n|\r/g, ' ');
             }
           }
-          else {
-            value(params.newValue.replace(/<(?:.|\n)*?>/gm, '').replace(/\r?\n|\r/g, ' '));
-          }
+          value(newValue);
         })
       }