system links with spaces do not work
authorCornelius Weiß <c.weiss@metaways.de>
Wed, 21 Jun 2017 20:39:38 +0000 (22:39 +0200)
committerMichael Spahn <m.spahn@metaways.de>
Thu, 22 Jun 2017 11:52:39 +0000 (13:52 +0200)
Change-Id: I867ef271f106ebef7ffe55d853abff5111eea3cf
Reviewed-on: http://gerrit.tine20.com/customers/4924
Reviewed-by: Michael Spahn <m.spahn@metaways.de>
Tested-by: Michael Spahn <m.spahn@metaways.de>
tine20/Filemanager/js/Filemanager.js
tine20/Filemanager/js/Model.js
tine20/Filemanager/js/NodeGridPanel.js
tine20/Filemanager/js/NodeTreePanel.js
tine20/Filemanager/js/nodeActions.js
tine20/Tinebase/Tinebase.jsb2
tine20/Tinebase/css/Tinebase.css
tine20/Tinebase/js/ux/util/urlCoder.js [new file with mode: 0644]

index a32db04..4659e8f 100644 (file)
@@ -35,6 +35,8 @@ Tine.Filemanager.Application = Ext.extend(Tine.Tinebase.Application, {
     showNode: function(path) {
         this.getMainScreen().getCenterPanel().initialLoadAfterRender = false;
         Tine.Tinebase.MainScreenPanel.show(this);
+        // NOTE: decodeURIComponent can't cope with +
+        path = Ext.ux.util.urlCoder.decodeURIComponent(path);
 
         // if file, show directory file is in
         var dirPath = path;
index 9143565..582cada 100644 (file)
@@ -50,6 +50,15 @@ Tine.Filemanager.Model.Node = Tine.Tinebase.data.Record.create(Tine.Tinebase.Mod
         var _ = window.lodash;
 
         return _.indexOf(['/', Tine.Tinebase.container.getMyFileNodePath(), '/personal', '/shared'], this.get('path')) >= 0;
+    },
+
+    getSystemLink: function() {
+        var _ = window.lodash,
+            encodedPath = _.map(String(this.get('path')).replace(/(^\/|\/$)/, '').split('/'), Ext.ux.util.urlCoder.encodeURIComponent).join('/');
+
+        return [Tine.Tinebase.common.getUrl().replace(/\/$/, ''), '#/Filemanager/showNode', encodedPath].join('/');
+
+
     }
 });
 
index aaca82d..141cab5 100644 (file)
@@ -458,6 +458,7 @@ Tine.Filemanager.NodeGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
         this.action_download = Tine.Filemanager.nodeActionsMgr.get('download');
         this.action_moveRecord = Tine.Filemanager.nodeActionsMgr.get('move');
         this.action_publish = Tine.Filemanager.nodeActionsMgr.get('publish');
+        this.action_systemLink = Tine.Filemanager.nodeActionsMgr.get('systemLink');
 
         if (this.previewsEnabled) {
             this.action_preview = Tine.Filemanager.nodeActionsMgr.get('preview');
@@ -482,7 +483,7 @@ Tine.Filemanager.NodeGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
             }.createDelegate(this)
         });
 
-        var contextActions = [this.action_deleteRecord, 'rename', this.action_moveRecord, this.action_download, 'resume', 'pause', this.action_editFile, this.action_publish];
+        var contextActions = [this.action_deleteRecord, 'rename', this.action_moveRecord, this.action_download, 'resume', 'pause', this.action_editFile, this.action_publish, this.action_systemLink];
 
         if (this.previewsEnabled) {
             contextActions.push(this.action_preview);
@@ -498,7 +499,7 @@ Tine.Filemanager.NodeGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
 
         this.folderContextMenu = Tine.Filemanager.nodeContextMenu.getMenu({
             nodeName: Tine.Filemanager.Model.Node.getContainerName(),
-            actions: [this.action_deleteRecord, 'rename', this.action_moveRecord, this.action_editFile, this.action_publish],
+            actions: [this.action_deleteRecord, 'rename', this.action_moveRecord, this.action_editFile, this.action_publish, this.action_systemLink],
             scope: this,
             backend: 'Filemanager',
             backendModel: 'Node'
@@ -514,7 +515,8 @@ Tine.Filemanager.NodeGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
             this.action_download,
             this.action_deleteRecord,
             this.action_editFile,
-            this.action_publish
+            this.action_publish,
+            this.action_systemLink
         ];
 
         if (this.previewsEnabled) {
@@ -594,6 +596,11 @@ Tine.Filemanager.NodeGridPanel = Ext.extend(Tine.widgets.grid.GridPanel, {
                     scale: 'medium',
                     rowspan: 2,
                     iconAlign: 'top'
+                }),
+                Ext.apply(new Ext.Button(this.action_systemLink), {
+                    scale: 'medium',
+                    rowspan: 2,
+                    iconAlign: 'top'
                 })
             ];
 
index 3b1ca88..fbc21f6 100644 (file)
@@ -298,7 +298,7 @@ Tine.Filemanager.NodeTreePanel = Ext.extend(Tine.widgets.container.TreePanel, {
         this.ctxMenu = Tine.Filemanager.nodeContextMenu.getMenu({
             actionMgr: Tine.Filemanager.nodeActionsMgr,
             nodeName: this.recordClass.getContainerName(),
-            actions: ['reload', 'createFolder', 'delete', 'rename', 'move', 'edit', 'publish'],
+            actions: ['reload', 'createFolder', 'delete', 'rename', 'move', 'edit', 'publish', 'systemLink'],
             scope: this,
             backend: 'Filemanager',
             backendModel: 'Node'
index 65546c2..bc40890 100644 (file)
@@ -153,6 +153,37 @@ Tine.Filemanager.nodeActions.Rename = {
 };
 
 /**
+ * single file or directory node with editGrant
+ */
+Tine.Filemanager.nodeActions.SystemLink = {
+    app: 'Filemanager',
+    requiredGrant: 'readGrant',
+    allowMultiple: false,
+    text: 'System Link', // _('System Link')
+    iconCls: 'action_system_link',
+    disabled: true,
+    // actionType: 'edit',
+    scope: this,
+    handler: function () {
+        var _ = window.lodash,
+            app = this.initialConfig.app,
+            record = this.initialConfig.selections[0];
+
+        Ext.MessageBox.show({
+            title: i18n._('System Link'),
+            // minWidth:
+            maxWidth: screen.availWidth,
+            msg: '<b>' + i18n._('Use this link to share the entry with other system users') + ':</b><br>'
+                    + record.getSystemLink(),
+            buttons: Ext.MessageBox.OK,
+            // value: record.getSystemLink(),
+            // prompt: true,
+            icon: Ext.MessageBox.INFO
+        });
+    }
+};
+
+/**
  * one or multiple nodes, all need deleteGrant
  */
 Tine.Filemanager.nodeActions.Delete = {
index cfeea6c..e1db9a1 100644 (file)
           "path": "js/ux/util/"
         },
         {
+          "text": "urlCoder.js",
+          "path": "js/ux/util/"
+        },
+        {
           "text": "FieldLabeler.js",
           "path": "js/ux/"
         },
index 04f0886..f8fed64 100644 (file)
@@ -94,6 +94,16 @@ html, body {
 }
 
 
+.action_system_link {
+    background-image:url(../../images/oxygen/16x16/places/link.png) !important;
+}
+.x-btn-medium .action_system_link {
+    background-image:url(../../images/oxygen/22x22/places/link.png) !important;
+}
+.x-btn-large .action_system_link {
+    background-image:url(../../images/oxygen/32x32/places/link.png) !important;
+}
+
 .action_rename {
     background-image:url(../../images/oxygen/16x16/actions/document-properties.png) !important;
 }
diff --git a/tine20/Tinebase/js/ux/util/urlCoder.js b/tine20/Tinebase/js/ux/util/urlCoder.js
new file mode 100644 (file)
index 0000000..eda88a7
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Tine 2.0
+ *
+ * @license     http://www.gnu.org/licenses/agpl.html AGPL Version 3
+ * @author      Cornelius Weiss <c.weiss@metaways.de>
+ * @copyright   Copyright (c) 2017 Metaways Infosystems GmbH (http://www.metaways.de)
+ */
+Ext.ns('Ext.ux.util.urlCoder');
+
+/**
+ * native encodeURIComponent converts space into %20 -> convert to modern +
+ *
+ * @param string
+ * @returns {string}
+ */
+Ext.ux.util.urlCoder.encodeURIComponent = function(string) {
+    return encodeURIComponent(string).replace(/\%20/gm,"+");
+};
+
+/**
+ * native encodeURI converts space into %20 -> convert to modern +
+ *
+ * @param string
+ * @returns {string}
+ */
+Ext.ux.util.urlCoder.encodeURI = function(string) {
+    return encodeURI(string).replace(/\%20/gm,"+");
+};
+
+/**
+ * native decodeURIComponent converts can't cope with modern + for spaces
+ *
+ * @param string
+ * @returns {string}
+ */
+Ext.ux.util.urlCoder.decodeURIComponent = function(string) {
+    return decodeURIComponent((string+'').replace(/\+/gm,"%20"));
+};
+
+/**
+ * native decodeURI converts can't cope with modern + for spaces
+ *
+ * @param string
+ * @returns {string}
+ */
+Ext.ux.util.urlCoder.decodeURI = function(string) {
+    return decodeURI((string+'').replace(/\+/gm,"%20"));
+};
\ No newline at end of file