Fixed tests
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
This commit is contained in:
parent
ae86845062
commit
bd1929a3b1
|
@ -239,7 +239,7 @@
|
||||||
var params;
|
var params;
|
||||||
if (e && e.itemId) {
|
if (e && e.itemId) {
|
||||||
params = {
|
params = {
|
||||||
view: e.view !== '' ? e.view : e.itemId,
|
view: typeof e.view === 'string' && e.view !== '' ? e.view : e.itemId,
|
||||||
dir: e.dir ? e.dir : '/'
|
dir: e.dir ? e.dir : '/'
|
||||||
};
|
};
|
||||||
this._changeUrl(params.view, params.dir);
|
this._changeUrl(params.view, params.dir);
|
||||||
|
|
|
@ -81,8 +81,6 @@
|
||||||
_setupEvents: function () {
|
_setupEvents: function () {
|
||||||
this.$el.on('click', 'li a', _.bind(this._onClickItem, this))
|
this.$el.on('click', 'li a', _.bind(this._onClickItem, this))
|
||||||
this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this));
|
this.$el.on('click', 'li button', _.bind(this._onClickMenuButton, this));
|
||||||
this._setOnDrag();
|
|
||||||
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -135,7 +133,7 @@
|
||||||
}
|
}
|
||||||
this._activeItem = itemId;
|
this._activeItem = itemId;
|
||||||
currentItem.children('a').addClass('active');
|
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');
|
this.$currentContent.removeClass('hidden');
|
||||||
if (!options || !options.silent) {
|
if (!options || !options.silent) {
|
||||||
this.$currentContent.trigger(jQuery.Event('show'));
|
this.$currentContent.trigger(jQuery.Event('show'));
|
||||||
|
@ -169,74 +167,6 @@
|
||||||
ev.preventDefault();
|
ev.preventDefault();
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
|
||||||
* 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
|
* Event handler for clicking a button
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -72,6 +72,9 @@
|
||||||
var quickAccessList = 'sublist-favorites';
|
var quickAccessList = 'sublist-favorites';
|
||||||
var collapsibleButtonId = 'button-collapse-favorites';
|
var collapsibleButtonId = 'button-collapse-favorites';
|
||||||
var listULElements = document.getElementById(quickAccessList);
|
var listULElements = document.getElementById(quickAccessList);
|
||||||
|
if (!listULElements) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var listLIElements = listULElements.getElementsByTagName('li');
|
var listLIElements = listULElements.getElementsByTagName('li');
|
||||||
|
|
||||||
var apppath=appfolder;
|
var apppath=appfolder;
|
||||||
|
@ -101,6 +104,9 @@
|
||||||
var quickAccessList = 'sublist-favorites';
|
var quickAccessList = 'sublist-favorites';
|
||||||
var collapsibleButtonId = 'button-collapse-favorites';
|
var collapsibleButtonId = 'button-collapse-favorites';
|
||||||
var listULElements = document.getElementById(quickAccessList);
|
var listULElements = document.getElementById(quickAccessList);
|
||||||
|
if (!listULElements) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
var listLIElements = listULElements.getElementsByTagName('li');
|
var listLIElements = listULElements.getElementsByTagName('li');
|
||||||
|
|
||||||
var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
|
var appName = appfolder.substring(appfolder.lastIndexOf("/") + 1, appfolder.length);
|
||||||
|
|
|
@ -206,10 +206,6 @@ class ViewController extends Controller {
|
||||||
// show_Quick_Access stored as string
|
// show_Quick_Access stored as string
|
||||||
$defaultExpandedState = $this->config->getUserValue($this->userSession->getUser()->getUID(), 'files', 'show_Quick_Access', '0') === '1';
|
$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(
|
\OCA\Files\App::getNavigationManager()->add(
|
||||||
[
|
[
|
||||||
'id' => 'favorites',
|
'id' => 'favorites',
|
||||||
|
@ -219,7 +215,6 @@ class ViewController extends Controller {
|
||||||
'order' => 5,
|
'order' => 5,
|
||||||
'name' => $this->l10n->t('Favorites'),
|
'name' => $this->l10n->t('Favorites'),
|
||||||
'sublist' => $favoritesSublistArray,
|
'sublist' => $favoritesSublistArray,
|
||||||
'draggableSublist' => $quickAccessDraggable,
|
|
||||||
'defaultExpandedState' => $defaultExpandedState,
|
'defaultExpandedState' => $defaultExpandedState,
|
||||||
'enableMenuButton' => 0,
|
'enableMenuButton' => 0,
|
||||||
]
|
]
|
||||||
|
|
|
@ -81,7 +81,7 @@ function NavigationListElements($item, $l, $pinned) {
|
||||||
?>
|
?>
|
||||||
<button id="button-collapse-<?php p($item['id']); ?>"
|
<button id="button-collapse-<?php p($item['id']); ?>"
|
||||||
class="collapse app-navigation-noclose" <?php if (sizeof($item['sublist']) == 0) { ?> style="display: none" <?php } ?>></button>
|
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
|
<?php
|
||||||
foreach ($item['sublist'] as $item) {
|
foreach ($item['sublist'] as $item) {
|
||||||
$pinned = NavigationListElements($item, $l, $pinned);
|
$pinned = NavigationListElements($item, $l, $pinned);
|
||||||
|
|
|
@ -239,31 +239,31 @@ describe('OCA.Files.App tests', function() {
|
||||||
expect(App.navigation.getActiveItem()).toEqual('other');
|
expect(App.navigation.getActiveItem()).toEqual('other');
|
||||||
expect($('#app-content-files').hasClass('hidden')).toEqual(true);
|
expect($('#app-content-files').hasClass('hidden')).toEqual(true);
|
||||||
expect($('#app-content-other').hasClass('hidden')).toEqual(false);
|
expect($('#app-content-other').hasClass('hidden')).toEqual(false);
|
||||||
expect($('li[data-id=files]').hasClass('active')).toEqual(false);
|
expect($('li[data-id=files] > a').hasClass('active')).toEqual(false);
|
||||||
expect($('li[data-id=other]').hasClass('active')).toEqual(true);
|
expect($('li[data-id=other] > a').hasClass('active')).toEqual(true);
|
||||||
|
|
||||||
App._onPopState({view: 'files', dir: '/somedir'});
|
App._onPopState({view: 'files', dir: '/somedir'});
|
||||||
|
|
||||||
expect(App.navigation.getActiveItem()).toEqual('files');
|
expect(App.navigation.getActiveItem()).toEqual('files');
|
||||||
expect($('#app-content-files').hasClass('hidden')).toEqual(false);
|
expect($('#app-content-files').hasClass('hidden')).toEqual(false);
|
||||||
expect($('#app-content-other').hasClass('hidden')).toEqual(true);
|
expect($('#app-content-other').hasClass('hidden')).toEqual(true);
|
||||||
expect($('li[data-id=files]').hasClass('active')).toEqual(true);
|
expect($('li[data-id=files] > a').hasClass('active')).toEqual(true);
|
||||||
expect($('li[data-id=other]').hasClass('active')).toEqual(false);
|
expect($('li[data-id=other] > a').hasClass('active')).toEqual(false);
|
||||||
});
|
});
|
||||||
it('clicking on navigation switches the panel visibility', function() {
|
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.navigation.getActiveItem()).toEqual('other');
|
||||||
expect($('#app-content-files').hasClass('hidden')).toEqual(true);
|
expect($('#app-content-files').hasClass('hidden')).toEqual(true);
|
||||||
expect($('#app-content-other').hasClass('hidden')).toEqual(false);
|
expect($('#app-content-other').hasClass('hidden')).toEqual(false);
|
||||||
expect($('li[data-id=files]').hasClass('active')).toEqual(false);
|
expect($('li[data-id=files] > a').hasClass('active')).toEqual(false);
|
||||||
expect($('li[data-id=other]').hasClass('active')).toEqual(true);
|
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.navigation.getActiveItem()).toEqual('files');
|
||||||
expect($('#app-content-files').hasClass('hidden')).toEqual(false);
|
expect($('#app-content-files').hasClass('hidden')).toEqual(false);
|
||||||
expect($('#app-content-other').hasClass('hidden')).toEqual(true);
|
expect($('#app-content-other').hasClass('hidden')).toEqual(true);
|
||||||
expect($('li[data-id=files]').hasClass('active')).toEqual(true);
|
expect($('li[data-id=files] > a').hasClass('active')).toEqual(true);
|
||||||
expect($('li[data-id=other]').hasClass('active')).toEqual(false);
|
expect($('li[data-id=other] > a').hasClass('active')).toEqual(false);
|
||||||
});
|
});
|
||||||
it('clicking on navigation sends "show" and "urlChanged" event', function() {
|
it('clicking on navigation sends "show" and "urlChanged" event', function() {
|
||||||
var handler = sinon.stub();
|
var handler = sinon.stub();
|
||||||
|
|
Loading…
Reference in New Issue