Jelajahi Sumber

HUE-7876 [presentation] Persist when the document is in Presentation mode

Romain Rigaux 7 tahun lalu
induk
melakukan
07cd46f142

+ 3 - 3
desktop/libs/notebook/src/notebook/static/notebook/js/notebook.ko.js

@@ -305,7 +305,7 @@ var EditorViewModel = (function() {
     self.ace = function (newVal) {
       if (newVal) {
         aceEditor = newVal;
-        if (!vm.isPresentationMode()) {
+        if (!notebook.isPresentationMode()) {
           aceEditor.focus();
         }
       }
@@ -1635,7 +1635,7 @@ var EditorViewModel = (function() {
         setTimeout(function () {
           self.fetchResultData(rows, false);
         }, 500);
-      } else if (! vm.editorMode() && ! vm.isPresentationMode() && notebook.snippets()[notebook.snippets().length - 1] == self) {
+      } else if (! vm.editorMode() && ! notebook.isPresentationMode() && notebook.snippets()[notebook.snippets().length - 1] == self) {
         notebook.newSnippet();
       }
     };
@@ -2069,6 +2069,7 @@ var EditorViewModel = (function() {
     self.canWrite = ko.observable(typeof notebook.can_write != "undefined" && notebook.can_write != null ? notebook.can_write : true);
     self.onSuccessUrl = ko.observable(typeof notebook.onSuccessUrl != "undefined" && notebook.onSuccessUrl != null ? notebook.onSuccessUrl : null);
     self.pubSubUrl = ko.observable(typeof notebook.pubSubUrl != "undefined" && notebook.pubSubUrl != null ? notebook.pubSubUrl : null);
+    self.isPresentationMode = ko.observable(typeof notebook.isPresentationMode != "undefined" && notebook.isPresentationMode != null ? notebook.isPresentationMode : false);
     self.presentationSnippets = ko.observable({});
 
     self.snippets = ko.observableArray();
@@ -2839,7 +2840,6 @@ var EditorViewModel = (function() {
     self.selectedNotebook = ko.observable();
 
     self.combinedContent = ko.observable();
-    self.isPresentationMode = ko.observable(false);
     self.isPresentationModeEnabled = ko.pureComputed(function () {
       return self.selectedNotebook() && self.selectedNotebook().snippets().length === 1 && self.selectedNotebook().snippets()[0].isSqlDialect()
     });

+ 17 - 15
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -249,14 +249,17 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
 <script type="text/html" id="notebook-menu-buttons-${ suffix }">
   <div class="pull-right margin-right-10">
   % if ENABLE_PRESENTATION.get():
-    <!-- ko if: $root.isPresentationModeEnabled -->
+    <div class="btn-group" data-bind="visible: $root.isPresentationMode()">
+      <a class="btn" title="${ _ko('Open document as presentation by default') }" data-bind="click: function() { $root.isPresentationMode(true); }">
+        <i class="fa" data-bind="css: {'fa-toggle-off': $root.isPresentationMode()}"></i>
+      </a>
+    </div>
     <div class="btn-group">
       <a class="btn" title="${ _ko('View as a presentation') }" data-bind="click: function() { $root.isPresentationMode(true); },
-        css: {'btn-inverse': $root.isPresentationMode(), 'btn': true}">
+        css: {'btn-inverse': $root.isPresentationMode()}">
         <i class="fa fa-line-chart"></i>
       </a>
     </div>
-    <!-- /ko -->
   % endif
 
     % if IS_EMBEDDED.get():
@@ -352,21 +355,21 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
 </a>
 <!-- /ko -->
 
-<div class="player-toolbar margin-top-10" data-bind="visible: $root.isPresentationMode() || $root.isResultFullScreenMode()" style="display: none;">
+<div class="player-toolbar margin-top-10" data-bind="visible: $root.isPresentationMode()" style="display: none">
   <!-- ko if: $root.isPresentationMode() -->
     <!-- ko if: $root.selectedNotebook() -->
       <!-- ko if: $root.selectedNotebook().name() || $root.selectedNotebook().description() -->
-      <h2 class="margin-left-30 margin-right-10 inline padding-left-5" data-bind="text: $root.selectedNotebook().name"></h2>
-      <h2 class="muted inline" data-bind="text: $root.selectedNotebook().description"></h2>
-      <div class="clearfix"></div>
-      <!-- ko template: { name: 'notebook-menu-buttons-${ suffix }' } --><!-- /ko -->
+        <h2 class="margin-left-30 margin-right-10 inline padding-left-5" data-bind="text: $root.selectedNotebook().name"></h2>
+        <h2 class="muted inline" data-bind="text: $root.selectedNotebook().description"></h2>
+        <div class="clearfix"></div>
+        <!-- ko template: { name: 'notebook-menu-buttons-${ suffix }' } --><!-- /ko -->
       <!-- /ko -->
 
       <div class="margin-left-30 margin-top-10 padding-left-5 margin-bottom-20">
-      <!-- ko template: { name: 'notebook-actions' }--><!-- /ko -->
-      <!-- ko if: $root.preEditorTogglingSnippet -->
-        <!-- ko template: { if: $root.isPresentationMode(), name: 'snippet-variables', data: $root.preEditorTogglingSnippet }--><!-- /ko -->
-      <!-- /ko -->
+        <!-- ko template: { name: 'notebook-actions' } --><!-- /ko -->
+        <!-- ko if: $root.preEditorTogglingSnippet -->
+          <!-- ko template: { if: $root.isPresentationMode(), name: 'snippet-variables', data: $root.preEditorTogglingSnippet }--><!-- /ko -->
+        <!-- /ko -->
       </div>
 
     <!-- /ko -->
@@ -3299,14 +3302,13 @@ ${ sqlSyntaxDropdown.sqlSyntaxDropdown() }
           wasLeftPanelVisible = viewModel.isLeftPanelVisible();
           console.log(viewModel.isPresentationMode());
           wasRightPanelVisible = viewModel.isRightPanelVisible();
-          
+
           if (wasResultFullScreenMode) {
             huePubSub.publish('side.panels.hide', true);
           } else {
             huePubSub.publish('side.panel.right.hide', true);
           }
-          
-          
+
           viewModel.assistWithoutStorage(true);
           viewModel.assistAvailable(false);
           viewModel.isLeftPanelVisible(true);