]> _ Git - fluidbook-toolbox.git/commitdiff
wip #5639 @3
authorVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Dec 2022 18:14:28 +0000 (19:14 +0100)
committerVincent Vanwaelscappel <vincent@cubedesigners.com>
Mon, 12 Dec 2022 18:14:28 +0000 (19:14 +0100)
.docker/docker-compose.yml
app/Console/Commands/WorkshopMigration.php
app/Models/FluidbookDocument.php
app/Models/FluidbookPublication.php
resources/linkeditor/js/linkeditor.js
resources/linkeditor/js/linkeditor.resize.js
resources/linkeditor/js/linkeditor.utils.js
resources/linkeditor/js/linkeditor.zoom.js
resources/views/fluidbook_publication/link_editor.blade.php

index 8df95b10084f688987a1ed2d405f069917b152ed..bb03e38cf91886d0ece2001943bd11fe1cce7c03 100644 (file)
@@ -13,6 +13,7 @@ services:
       - '/home/toolbox/www:/application'
       - '/home/toolbox/www/storage/app/public/:/application/public/storage/'
       - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/'
+      - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/fluidbook/docs/'
       - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/'
       - '/home/extranet:/home/extranet'
       - '/data/extranet:/data/extranet'
@@ -72,6 +73,7 @@ services:
       - '/home/toolbox/www:/application'
       - '/home/toolbox/www/storage/app/public/:/application/public/storage/'
       - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/protected/fluidbookpublication/docs/'
+      - '/mnt/sshfs/godzilla/data/fluidbook/docs/:/application/fluidbook/docs/'
       - '/data/extranet/www/fluidbook/books/working/:/application/protected/fluidbookpublication/working/'
       - '/home/extranet:/home/extranet'
       - '/data/extranet:/data/extranet'
index 7da8eef26444cfe25f0749460d1f703a0593f947..369f7187003ddddde75a51d2f43107890e9f9c4b 100644 (file)
@@ -20,7 +20,7 @@ use Illuminate\Support\Facades\DB;
 
 class WorkshopMigration extends CubistCommand
 {
-    protected $signature = 'ws:migrate {--publications=v2} {--documents=v2}';
+    protected $signature = 'ws:migrate {--publications=v2} {--documents=missing}';
     protected $description = 'Migrate data from Workshop V2';
     protected $_wsRanks = [];
     protected $_oldDB = 'extranet_clean';
@@ -74,7 +74,7 @@ class WorkshopMigration extends CubistCommand
 
     protected function importDocuments()
     {
-        if($this->option('documents')==='none'){
+        if ($this->option('documents') === 'none') {
             return;
         }
 
@@ -84,7 +84,11 @@ class WorkshopMigration extends CubistCommand
 
         $q = DB::table($this->_oldDB . '.documents')->orderBy('document_id', 'desc');
 
-        if ($this->option('documents') === 'v2') {
+        if ($this->option('documents') === 'missing') {
+            $maxID = FluidbookDocument::where('id', '<', $ws3step)->orderBy('id', 'DESC')->first()->id;
+            $q = DB::table($this->_oldDB . '.documents')->where('document_id', '>', $maxID)->orderBy('document_id', 'desc');
+
+        } else if ($this->option('documents') === 'v2') {
             DB::update('DELETE FROM fluidbook_document WHERE id<' . $ws3step);
         } else if ($this->option('documents') === 'all') {
             FluidbookDocument::truncate();
@@ -145,7 +149,7 @@ class WorkshopMigration extends CubistCommand
 
     protected function importPublications($reset = false)
     {
-        if($this->option('publications')==='none'){
+        if ($this->option('publications') === 'none') {
             return;
         }
 
index ded006f17778629005d5b91c115bf0205f5702b0..3ae4385688d3a3142f9a20811f19f185a4a0e9de 100644 (file)
@@ -17,7 +17,7 @@ use Illuminate\Support\Facades\Cache;
 
 class FluidbookDocument extends ToolboxModel
 {
-    public const WS_DOCS = '/application/protected/fluidbookpublication/docs/';
+    public const WS_DOCS = '/application/fluidbook/docs/';
     protected $table = 'fluidbook_document';
     protected $_options = ['name' => 'fluidbook-document',
         'singular' => 'document',
@@ -57,6 +57,11 @@ class FluidbookDocument extends ToolboxModel
         return sqrt($a4surface / $docSurface);
     }
 
+    public function getPageSize($page)
+    {
+        return $this->pdf_data['page'][$page]['size'];
+    }
+
     public function processUpload($uploadID, $sync = false)
     {
         $this->processSync = $sync;
@@ -324,7 +329,7 @@ class FluidbookDocument extends ToolboxModel
     public function _getFile($page, $format = 'jpg', $resolution = 150, $withText = true, $withGraphics = true, $version = 'html')
     {
         if (!$this->hasFile($page, $format, $resolution, $withText, $withGraphics, $version)) {
-            return FluidbookFarm::getFile($page, $format, $resolution, $withText, $withGraphics, $version, $this->getResolutionRatio(), $this->getMobileFirstRatio(), $this->path() . '/');
+            return FluidbookFarm::getFile($page, $format, $resolution, $withText, $withGraphics, $version, $this->getResolutionRatio(), $this->getMobileFirstRatio(), $this->path());
         }
 
         $path = $this->_getPath($page, $format, $resolution, $withText, $withGraphics, $version);
index 26f777d14514ba5157b388fc2b49eec2eab49603..05bf5431db79e3fb4320650931a63dba880c89b0 100644 (file)
@@ -153,6 +153,11 @@ class FluidbookPublication extends ToolboxSettingsModel
     {
         /** @var \App\Models\User $owner */
         $owner = \App\Models\User::find($this->owner);
+        if (null === $owner) {
+            $this->owner = 1;
+            $this->saveQuietly();
+            $owner = \App\Models\User::find(1);
+        }
         /** @var Company $company */
         $company = Company::find($owner->company);
 
@@ -295,8 +300,8 @@ class FluidbookPublication extends ToolboxSettingsModel
 
     public function getDocumentSize($page = 1)
     {
-        $sizes = $this->getDocumentSizes();
-        return $sizes[$this->composition[$page][0]];
+        $document=$this->getDocument($page);
+        return $document->getPageSize($this->composition[$page][1]);
     }
 
     public function getPageWidth($page = 1)
index 7e1e3b13a8034c43f04e1272a77517484c7da6e1..9d729d24d6b96dbd2c673e67d642aeb46b448705 100644 (file)
@@ -332,6 +332,9 @@ LinkEditor.prototype = {
             this.loader.loadPage(this.currentPage + 1, 'right');
         }
         $("#linkeditor-page-field input").val(this.currentPage);
+        if (this.mobileFirst) {
+            this.zoom.reset();
+        }
         this.resize.resize();
         this.loader.preloadPages();
     },
index 2c651444305565a73b3ac344589b41f1c62ea698..516a9cde585089494154e217a0662b6f5d007c7a 100644 (file)
@@ -22,11 +22,11 @@ LinkeditorResize.prototype = {
         this.updateWindowDimensions();
         this.resizeMain();
         this.resizeCanvas();
-        if(this.linkeditor.panels) {
+        if (this.linkeditor.panels) {
             this.linkeditor.panels.resize(this.ww);
         }
         this.linkeditor.rulers.updateRulers();
-        if(this.linkeditor.popup){
+        if (this.linkeditor.popup) {
             this.linkeditor.popup.resize();
         }
     },
@@ -41,8 +41,16 @@ LinkeditorResize.prototype = {
         var aw = this.linkeditor.canvasRect.width - 30;
         var ah = this.linkeditor.canvasRect.height - 30;
         this.linkeditor.fs = Math.min(aw / this.linkeditor.fw, ah / this.linkeditor.fh);
-        var left = ((this.linkeditor.canvasRect.width * 2) - this.linkeditor.fw * this.linkeditor.fs) / 2;
-        var top = ((this.linkeditor.canvasRect.height * 2) - this.linkeditor.fh * this.linkeditor.fs) / 2;
+
+        let left, top;
+
+        if (!this.linkeditor.mobileFirst) {
+            left = ((this.linkeditor.canvasRect.width * 2) - this.linkeditor.fw * this.linkeditor.fs) / 2;
+            top = ((this.linkeditor.canvasRect.height * 2) - this.linkeditor.fh * this.linkeditor.fs) / 2;
+        } else {
+            left = (this.linkeditor.canvasRect.width - this.linkeditor.fw * this.linkeditor.fs) / 2;
+            top = 100;
+        }
         $("#linkeditor-fluidbook").css({left: left, top: top, transform: 'scale(' + this.linkeditor.fs + ')'});
     },
 };
index 25454c37198c45d5e673603edea26baf0e48f6ec..24fcc311e8898b6414d432680e4cbfcc5e134a3c 100644 (file)
@@ -8,6 +8,10 @@ LinkeditorUtils.prototype = {
 
     },
 
+    maxPageHeight: function () {
+
+    },
+
     normalizePage: function (page) {
         page = parseInt(page);
         if (page % 2 === 1 && !this.linkeditor.single) {
index d08f1bfd444bd41774b016d8620cea05b0d5cbc8..1322740b72ba6585de95b18b255b3d2de6bc900f 100644 (file)
@@ -10,25 +10,27 @@ LinkeditorZoom.prototype = {
         this.zoom = 1;
         this.zoomdragging = false;
 
-        $("#linkeditor-main").on('wheel', function (e) {
-            var step = $this.zoom >= 1 ? 0.25 : 0.1;
-            $this.linkeditor.setMouseCoordinates(e);
-            let delta = e.originalEvent.deltaY;
-            if (delta === 0) {
-                return true;
-            }
-            e.stopPropagation();
-            e.stopImmediatePropagation();
-            e.preventDefault();
-            if (delta < 0) {
-                if ($this.setZoom($this.zoom + step)) {
-                    $this.moveZoom(e);
+        if (!this.linkeditor.mobileFirst) {
+            $("#linkeditor-main").on('wheel', function (e) {
+                var step = $this.zoom >= 1 ? 0.25 : 0.1;
+                $this.linkeditor.setMouseCoordinates(e);
+                let delta = e.originalEvent.deltaY;
+                if (delta === 0) {
+                    return true;
                 }
-            } else {
-                $this.setZoom($this.zoom - step);
-            }
-            return false;
-        });
+                e.stopPropagation();
+                e.stopImmediatePropagation();
+                e.preventDefault();
+                if (delta < 0) {
+                    if ($this.setZoom($this.zoom + step)) {
+                        $this.moveZoom(e);
+                    }
+                } else {
+                    $this.setZoom($this.zoom - step);
+                }
+                return false;
+            });
+        }
     },
 
     mouseUp: function () {
@@ -76,18 +78,27 @@ LinkeditorZoom.prototype = {
     },
 
     setZoom: function (z, force) {
+        if (!this.linkeditor.mobileFirst) {
+            z = 1;
+        }
         let $this = this;
         z = this.normalizeZoom(z);
-        if (force !== true && z === this.zoom) {
-            return false;
-        }
+
         this.zoom = z;
-        let cw2 = this.linkeditor.canvasRect.width * 2;
-        let ch2 = this.linkeditor.canvasRect.height * 2;
-        let zh = ch2;
-        if (this.zoom < 1) {
-            zh *= this.zoom;
+
+        let cw2, ch2, zh;
+        if (this.linkeditor.mobileFirst) {
+            cw2 = this.linkeditor.canvasRect.width;
+            zh = parseFloat(FLUIDBOOK_DATA.pages_max_height) + 200;
+        } else {
+            cw2 = this.linkeditor.canvasRect.width * 2;
+            ch2 = this.linkeditor.canvasRect.height * 2;
+            zh = ch2;
+            if (this.zoom < 1) {
+                zh *= this.zoom;
+            }
         }
+
         $("#linkeditor-canvas").attr('data-z', this.zoom);
         $("#linkeditor-zoom").css({
             transform: 'scale(' + this.zoom + ')', overflow: 'visible',
@@ -112,7 +123,8 @@ LinkeditorZoom.prototype = {
 
     reset: function () {
         this.setZoom(1);
-        $("#linkeditor-canvas").scrollTo({top: '50%', left: '50%'});
+        var top = this.linkeditor.mobileFirst ? 0 : '50%';
+        $("#linkeditor-canvas").scrollTo({top: top, left: '50%'});
         this.resetZoomDrag();
     },
 };
index f79a9c1c158f7cab7159ad4b6893d1e60768ae14..d389f72c743c10e02f31cee4dde4d4b1195c74c9 100644 (file)
@@ -6,6 +6,12 @@
     $fbdata['settings']['width']=$fbdata['width']=$fluidbook->getPageWidth();
     $fbdata['settings']['height']=$fbdata['height']=$fluidbook->getPageHeight();
     $fbdata['settings']['pages']=$fbdata['pages']=$fluidbook->getPagesNumber();
+    $mh = 0;
+    for($i=1;$i<=$fbdata['pages'];$i++){
+        $mh = max($mh, $fluidbook->getPageHeight($i));
+    }
+    $fbdata['pages_max_height']=$mh;
+
     $translations=[
         'success_save'=>__('Liens sauvegardés'),
         'error_save'=>__('Une erreur s\'est produite lors de la sauvegarde des liens'),
@@ -48,7 +54,9 @@
         <div class="popup" data-popup="moveLinks" style="max-width: 300px">
             <h2>{{__('Déplacer les liens')}}</h2>
             <a nohref="" class="close" data-icon="close"></a>
-            <form action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/move" data-save-before-submit="{{__("Sauvegarde avant le déplacement de liens")}}" class="reloadAfterSuccess" method="post">
+            <form action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/move"
+                  data-save-before-submit="{{__("Sauvegarde avant le déplacement de liens")}}"
+                  class="reloadAfterSuccess" method="post">
                 @csrf
                 <p>{!! __('Déplacer les liens de :nb pages :br à partir de la page :page',
                     ['br'=>'</p><p>','nb'=>'<input type="number" name="number">','page'=>'<input type="text" name="start">'])!!}</p>
                     <div class="separator"></div>
                     <div data-icon="import-links"
                          data-tooltip="{{__('Importer les liens (Remplacer)')}}">
-                        <form class="importExcel" data-save-before-submit="{{__("Sauvegarde avant l'import d'un fichier excel")}}"
+                        <form class="importExcel"
+                              data-save-before-submit="{{__("Sauvegarde avant l'import d'un fichier excel")}}"
                               action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/import/replace" method="post"
                               enctype="multipart/form-data">
                             <input type="file"
                     </div>
                     <div data-icon="merge-links"
                          data-tooltip="{{__('Importer les liens (Ajouter)')}}">
-                        <form class="importExcel" data-save-before-submit="{{__("Sauvegarde avant l'import d'un fichier excel")}}"
+                        <form class="importExcel"
+                              data-save-before-submit="{{__("Sauvegarde avant l'import d'un fichier excel")}}"
                               action="/fluidbook-publication/{{$fbdata['id']}}/edit/links/import/merge" method="post"
                               enctype="multipart/form-data">
                             <input type="file"