From 60663220e19ae25463ac7ed4363e856a3c4df8b2 Mon Sep 17 00:00:00 2001 From: Sergey Linnik Date: Wed, 1 Mar 2017 11:45:28 +0300 Subject: [PATCH] onlyofficeOpen as default action for Office Open XML formats https://github.com/ONLYOFFICE/onlyoffice-owncloud/issues/4 --- CHANGELOG.md | 2 +- js/main.js | 10 +++++++--- lib/appconfig.php | 8 ++++---- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d55425f..dd2f73aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,7 @@ ## owncloud-onlyoffice (1.0.1) - fix exception when versions app is disabled - adding protocol to document server url - +- onlyofficeOpen is default action ## owncloud-onlyoffice (1.0.0) - Initial release \ No newline at end of file diff --git a/js/main.js b/js/main.js index 14dcf2dd..a53ef164 100644 --- a/js/main.js +++ b/js/main.js @@ -80,8 +80,8 @@ } }; - OCA.Onlyoffice.FileClick = function (context, attr) { - var fileInfoModel = context.fileInfoModel; + OCA.Onlyoffice.FileClick = function (fileName, context, attr) { + var fileInfoModel = context.fileInfoModel || context.fileList.getModelForFile(fileName); var fileList = context.fileList; if (!attr.conv) { OCA.Onlyoffice.OpenEditor(fileInfoModel.id); @@ -140,9 +140,13 @@ return OC.imagePath(OCA.Onlyoffice.AppName, "btn-edit"); }, actionHandler: function (fileName, context) { - OCA.Onlyoffice.FileClick(context, attr); + OCA.Onlyoffice.FileClick(fileName, context, attr); } }); + + if (attr.def && !fileList.fileActions.getDefaultFileAction(attr.mime, "file", OC.PERMISSION_READ)) { + fileList.fileActions.setDefault(attr.mime, "onlyofficeOpen"); + } }); } ); diff --git a/lib/appconfig.php b/lib/appconfig.php index 8e640c5e..b97cfc9f 100644 --- a/lib/appconfig.php +++ b/lib/appconfig.php @@ -129,10 +129,10 @@ private function DropSKey() { * @var array */ public $formats = [ - "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "text", "edit" => true ], - "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "spreadsheet", "edit" => true ], - "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "presentation", "edit" => true ], - "ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "presentation", "edit" => true ], + "docx" => [ "mime" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document", "type" => "text", "edit" => true, "def" => true ], + "xlsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "type" => "spreadsheet", "edit" => true, "def" => true ], + "pptx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.presentation", "type" => "presentation", "edit" => true, "def" => true ], + "ppsx" => [ "mime" => "application/vnd.openxmlformats-officedocument.presentationml.slideshow", "type" => "presentation", "edit" => true, "def" => true ], "txt" => [ "mime" => "text/plain", "type" => "text", "edit" => true ], "csv" => [ "mime" => "text/csv", "type" => "spreadsheet"/*, "edit" => true*/ ], "odt" => [ "mime" => "application/vnd.oasis.opendocument.text", "type" => "text", "conv" => true ],