diff options
author | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-07-12 16:49:25 +0200 |
---|---|---|
committer | John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com> | 2018-07-12 16:49:39 +0200 |
commit | bd1929a3b18ea97bb07fbf400b2f4c3670fa44a5 (patch) | |
tree | ad5e18d14def8a47311ed8de575aa81f724e36d4 /apps/files | |
parent | ae86845062e6bf303799c8ff52fd997db6cd22ab (diff) | |
download | nextcloud-server-bd1929a3b18ea97bb07fbf400b2f4c3670fa44a5.tar.gz nextcloud-server-bd1929a3b18ea97bb07fbf400b2f4c3670fa44a5.zip |
Fixed tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/js/app.js | 2 | ||||
-rw-r--r-- | apps/files/js/navigation.js | 72 | ||||
-rw-r--r-- | apps/files/js/tagsplugin.js | 6 | ||||
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 5 | ||||
-rw-r--r-- | apps/files/templates/appnavigation.php | 2 | ||||
-rw-r--r-- | apps/files/tests/js/appSpec.js | 24 |
6 files changed, 21 insertions, 90 deletions
diff --git a/apps/files/js/app.js b/apps/files/js/app.js index d407c49ea51..52c92645b2d 100644 --- a/apps/files/js/app.js +++ b/apps/files/js/app.js @@ -239,7 +239,7 @@ var params; if (e && e.itemId) { params = { - view: e.view !== '' ? e.view : e.itemId, + view: typeof e.view === 'string' && e.view !== '' ? e.view : e.itemId, dir: e.dir ? e.dir : '/' }; this._changeUrl(params.view, params.dir); diff --git a/apps/files/js/navigation.js b/apps/files/js/navigation.js index d783fcc2156..d4fa06cb45e 100644 --- a/apps/files/js/navigation.js +++ b/apps/files/js/navigation.js @@ -81,8 +81,6 @@ _setupEvents: function () { this.$el.on('click', 'li a', _.bind(this._onClickItem, this)) this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this)); - this._setOnDrag(); - }, /** @@ -135,7 +133,7 @@ } this._activeItem = itemId; currentItem.children('a').addClass('active'); - this.$currentContent = $('#app-content-' + (itemView !== '' ? itemView : itemId)); + this.$currentContent = $('#app-content-' + (typeof itemView === 'string' && itemView !== '' ? itemView : itemId)); this.$currentContent.removeClass('hidden'); if (!options || !options.silent) { this.$currentContent.trigger(jQuery.Event('show')); @@ -170,74 +168,6 @@ }, /** - * Event handler for when dragging an item - */ - _setOnDrag: function () { - var scope = this; - var element = $("#sublist-favorites"); - $(function () { - if (document.getElementById(scope.$quickAccessListKey.toString()).hasAttribute("draggable")) { - element.sortable({ - axis: "y", - containment: "parent", - scroll: false, - zIndex: 0, - opacity: 0.5, - tolerance: "pointer", - //revert: 0.05, - //delay: 150, - start: function (event, ui) { - //Fix for offset - ui.helper[0].style.left = '0px'; - - //Change Icon while dragging - var list = document.getElementById(scope.$quickAccessListKey).getElementsByTagName('li'); - for (var j = 0; j < list.length; j++) { - if (!(typeof list[j].getElementsByTagName('a')[0] === 'undefined')) { - list[j].getElementsByTagName('a')[0].classList.remove("nav-icon-files"); - list[j].getElementsByTagName('a')[0].classList.add('icon-menu'); - } - } - }, - stop: function (event, ui) { - //Clean up offset - ui.item.removeAttr("style"); - - //Change Icon back after dragging - var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); - for (var j = 0; j < list.length; j++) { - if (!(typeof list[j].getElementsByTagName('a')[0] === 'undefined')) { - list[j].getElementsByTagName('a')[0].classList.add("nav-icon-files"); - list[j].getElementsByTagName('a')[0].classList.remove('icon-menu'); - } - } - }, - update: function (event, ui) { - var list = document.getElementById(scope.$quickAccessListKey.toString()).getElementsByTagName('li'); - var string = []; - for (var j = 0; j < list.length; j++) { - var Object = { - id: j, - name: scope.getCompareValue(list, j, 'alphabet') - }; - string.push(Object); - } - var resultorder = JSON.stringify(string); - $.get(OC.generateUrl("/apps/files/api/v1/quickaccess/set/CustomSortingOrder"), { - order: resultorder - }, function (data, status) { - }); - } - }); - } else { - if (scope.$sortingStrategy === 'customorder') { - scope.$sortingStrategy = 'datemodified'; - } - } - }); - }, - - /** * Event handler for clicking a button */ _onClickMenuButton: function (ev) { diff --git a/apps/files/js/tagsplugin.js b/apps/files/js/tagsplugin.js index 3a1378cc9ad..bc1396b5104 100644 --- a/apps/files/js/tagsplugin.js +++ b/apps/files/js/tagsplugin.js @@ -72,6 +72,9 @@ var quickAccessList = 'sublist-favorites'; var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); + if (!listULElements) { + return; + } var listLIElements = listULElements.getElementsByTagName('li'); var apppath=appfolder; @@ -101,6 +104,9 @@ var quickAccessList = 'sublist-favorites'; var collapsibleButtonId = 'button-collapse-favorites'; var listULElements = document.getElementById(quickAccessList); + if (!listULElements) { + return; + } var listLIElements = listULElements.getElementsByTagName('li'); var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length); diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 2e91c83ee83..ba90e6e1fa2 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -206,10 +206,6 @@ class ViewController extends Controller { // show_Quick_Access stored as string $defaultExpandedState = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', '0') === '1'; - // see Javascript navigation.js for possible sorting strategies - $quickAccessDraggable = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'quickaccess_sorting_strategy', 'alphabet') === 'customorder'; - - \OCA\Files\App::getNavigationManager()->add( [ 'id' => 'favorites', @@ -219,7 +215,6 @@ class ViewController extends Controller { 'order' => 5, 'name' => $this->l10n->t('Favorites'), 'sublist' => $favoritesSublistArray, - 'draggableSublist' => $quickAccessDraggable, 'defaultExpandedState' => $defaultExpandedState, 'enableMenuButton' => 0, ] diff --git a/apps/files/templates/appnavigation.php b/apps/files/templates/appnavigation.php index 176af0d4c25..0b9ac665901 100644 --- a/apps/files/templates/appnavigation.php +++ b/apps/files/templates/appnavigation.php @@ -81,7 +81,7 @@ function NavigationListElements($item, $l, $pinned) { ?> <button id="button-collapse-<?php p($item['id']); ?>" class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button> - <ul id="sublist-<?php p($item['id']); ?>" <?php if ($item['draggableSublist'] === 'true') { ?> draggable="true" style="resize: none;"<?php } ?>> + <ul id="sublist-<?php p($item['id']); ?>"> <?php foreach ($item['sublist'] as $item) { $pinned = NavigationListElements($item, $l, $pinned); diff --git a/apps/files/tests/js/appSpec.js b/apps/files/tests/js/appSpec.js index 5728991e197..15297a029d4 100644 --- a/apps/files/tests/js/appSpec.js +++ b/apps/files/tests/js/appSpec.js @@ -239,38 +239,38 @@ describe('OCA.Files.App tests', function() { expect(App.navigation.getActiveItem()).toEqual('other'); expect($('#app-content-files').hasClass('hidden')).toEqual(true); expect($('#app-content-other').hasClass('hidden')).toEqual(false); - expect($('li[data-id=files]').hasClass('active')).toEqual(false); - expect($('li[data-id=other]').hasClass('active')).toEqual(true); + expect($('li[data-id=files] > a').hasClass('active')).toEqual(false); + expect($('li[data-id=other] > a').hasClass('active')).toEqual(true); App._onPopState({view: 'files', dir: '/somedir'}); expect(App.navigation.getActiveItem()).toEqual('files'); expect($('#app-content-files').hasClass('hidden')).toEqual(false); expect($('#app-content-other').hasClass('hidden')).toEqual(true); - expect($('li[data-id=files]').hasClass('active')).toEqual(true); - expect($('li[data-id=other]').hasClass('active')).toEqual(false); + expect($('li[data-id=files] > a').hasClass('active')).toEqual(true); + expect($('li[data-id=other] > a').hasClass('active')).toEqual(false); }); it('clicking on navigation switches the panel visibility', function() { - $('li[data-id=other]>a').click(); + $('li[data-id=other] > a').click(); expect(App.navigation.getActiveItem()).toEqual('other'); expect($('#app-content-files').hasClass('hidden')).toEqual(true); expect($('#app-content-other').hasClass('hidden')).toEqual(false); - expect($('li[data-id=files]').hasClass('active')).toEqual(false); - expect($('li[data-id=other]').hasClass('active')).toEqual(true); + expect($('li[data-id=files] > a').hasClass('active')).toEqual(false); + expect($('li[data-id=other] > a').hasClass('active')).toEqual(true); - $('li[data-id=files]>a').click(); + $('li[data-id=files] > a').click(); expect(App.navigation.getActiveItem()).toEqual('files'); expect($('#app-content-files').hasClass('hidden')).toEqual(false); expect($('#app-content-other').hasClass('hidden')).toEqual(true); - expect($('li[data-id=files]').hasClass('active')).toEqual(true); - expect($('li[data-id=other]').hasClass('active')).toEqual(false); + expect($('li[data-id=files] > a').hasClass('active')).toEqual(true); + expect($('li[data-id=other] > a').hasClass('active')).toEqual(false); }); it('clicking on navigation sends "show" and "urlChanged" event', function() { var handler = sinon.stub(); var showHandler = sinon.stub(); $('#app-content-other').on('urlChanged', handler); $('#app-content-other').on('show', showHandler); - $('li[data-id=other]>a').click(); + $('li[data-id=other] > a').click(); expect(handler.calledOnce).toEqual(true); expect(handler.getCall(0).args[0].view).toEqual('other'); expect(handler.getCall(0).args[0].dir).toEqual('/'); @@ -281,7 +281,7 @@ describe('OCA.Files.App tests', function() { var showHandler = sinon.stub(); $('#app-content-files').on('urlChanged', handler); $('#app-content-files').on('show', showHandler); - $('li[data-id=files]>a').click(); + $('li[data-id=files] > a').click(); expect(handler.calledOnce).toEqual(true); expect(handler.getCall(0).args[0].view).toEqual('files'); expect(handler.getCall(0).args[0].dir).toEqual('/'); |