From 78a65f0215eb8d5dde17a42216124b8755018650 Mon Sep 17 00:00:00 2001 From: Thomas Citharel Date: Tue, 27 Sep 2016 16:07:30 +0200 Subject: [PATCH] Move register script to utility (it was in public/ previously and was gitignored) --- appinfo/app.php | 2 +- js/utility/registerUtility.js | 41 +++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 js/utility/registerUtility.js diff --git a/appinfo/app.php b/appinfo/app.php index f1be16a44d..ddeea5205d 100644 --- a/appinfo/app.php +++ b/appinfo/app.php @@ -31,6 +31,6 @@ if (User::isLoggedIn()) { $eventDispatcher = $app->getContainer()->getServer()->getEventDispatcher(); $eventDispatcher->addListener('OCA\Files::loadAdditionalScripts', function() { - Util::addScript('calendar', 'public/registerUtility'); + Util::addScript('calendar', 'utility/registerUtility'); }); } diff --git a/js/utility/registerUtility.js b/js/utility/registerUtility.js new file mode 100644 index 0000000000..e86a5963c1 --- /dev/null +++ b/js/utility/registerUtility.js @@ -0,0 +1,41 @@ +/** + * Calendar App + * + * @author Thomas Citharel + * @copyright 2016 Thomas Citharel + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE + * License as published by the Free Software Foundation; either + * version 3 of the License, or any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU AFFERO GENERAL PUBLIC LICENSE for more details. + * + * You should have received a copy of the GNU Affero General Public + * License along with this library. If not, see . + * + */ + +'use strict'; + +let register = (function () { + + OCA.Files.fileActions.registerAction({ + name: 'View', + mime: 'text/calendar', + displayName: t('calendar', 'Calendar'), + actionHandler: function(filename, context) { + let path = $('#fileList').find('[data-file="'+filename+'"]').data('path'); + path = path.substring(1); + window.location = OC.generateUrl('apps/calendar/#/import/{filename}', {filename: encodeURI(path + '/' + filename)}); + }, + permissions: OC.PERMISSION_READ, + icon: function () { + return OC.imagePath('core', 'actions/view'); + } + }); + OCA.Files.fileActions.setDefault('text/calendar', 'View'); +})();