diff --git a/static/js/folders.js b/static/js/folders.js index c27cbe0..3b5411e 100644 --- a/static/js/folders.js +++ b/static/js/folders.js @@ -306,8 +306,9 @@ oml.ui.folders = function() { }); }; - that.updateUser = function(id, name) {s - // ... + that.updateUser = function(index) { + oml.$ui.folder[index].options({title: ui._users[index].name}) + return that; }; oml.bindEvent({ diff --git a/static/js/info.js b/static/js/info.js index 4eb10f9..60cf5c4 100644 --- a/static/js/info.js +++ b/static/js/info.js @@ -12,6 +12,9 @@ oml.ui.info = function() { overflowY: 'auto' }) .bindEvent({ + toggle: function(data) { + oml.UI.set({showInfo: !data.collapsed}); + }, oml_item: function() { that.updateElement(); }, diff --git a/static/js/infoView.js b/static/js/infoView.js index 9a035a4..5c832d2 100644 --- a/static/js/infoView.js +++ b/static/js/infoView.js @@ -282,7 +282,7 @@ oml.ui.infoView = function(identifyData) { click: function() { data.mediastate = 'unavailable'; that.updateElement(data, $data); - oml.api.cancelDownload({id: ui.item}, function() { + oml.api.cancelDownloads({ids: [ui.item]}, function() { that.updateElement(ui.item, $data); }); } diff --git a/static/js/listDialog.js b/static/js/listDialog.js index fa4b0bc..8898e1b 100644 --- a/static/js/listDialog.js +++ b/static/js/listDialog.js @@ -49,7 +49,7 @@ oml.ui.listDialog = function() { oml.api.getLists(function(result) { var lists = result.data.lists.filter(function(list) { - return list.user == oml.user.preferences.username; + return list.user == ''; }), listData = Ox.getObjectById(lists, list), listNames = lists.map(function(list) { diff --git a/static/js/usersDialog.js b/static/js/usersDialog.js index 8933f1c..7432b86 100644 --- a/static/js/usersDialog.js +++ b/static/js/usersDialog.js @@ -270,6 +270,7 @@ oml.ui.usersDialog = function() { nickname: data.value }, function(result) { Ox.print('EDIT USER', result.data, folder); + oml.renameUser(result.data) // FIXME: ugly Ox.forEach($lists, function($list) { var selected = $list.options('selected'); diff --git a/static/js/utils.js b/static/js/utils.js index e17bb5c..439af26 100644 --- a/static/js/utils.js +++ b/static/js/utils.js @@ -305,8 +305,7 @@ oml.enableDragAndDrop = function($list, canMove) { }), drag = {}, scrollInterval, - ui = oml.user.ui, - username = oml.user.preferences.username; + ui = oml.user.ui; $list.bindEvent({ draganddropstart: function(data) { @@ -326,8 +325,8 @@ oml.enableDragAndDrop = function($list, canMove) { drag.targets[id] = Ox.extend(data, { editable: data.editable || ( data.type == 'library' - && drag.source.user != username - && data.user == username + && drag.source.user != '' + && data.user == '' ), selected: data.id == ui._list }, data); @@ -467,14 +466,14 @@ oml.enableDragAndDrop = function($list, canMove) { function getTitle() { var image, text, actionText = drag.action == 'copy' ? ( - drag.source.user == username ? 'copy' : 'download' + drag.source.user == '' ? 'copy' : 'download' ) : 'move', itemText = Ox.isString(drag.item) ? '"' + Ox.encodeHTMLEntities(Ox.truncate(drag.item, 32)) + '"' : Ox._('{0} books', [drag.item]), targetText; if (drag.action == 'move') { - if (drag.source.user != username) { + if (drag.source.user != '') { text = Ox._('You can only remove books
from your own lists.'); } else if (drag.source.type == 'library') { text = Ox._('You cannot move books
out of your library.'); @@ -488,8 +487,8 @@ oml.enableDragAndDrop = function($list, canMove) { if ( ( drag.target.type == 'library' - && drag.source.user == username - && drag.target.user == username + && drag.source.user == '' + && drag.target.user == '' ) || drag.target.selected ) { @@ -497,7 +496,7 @@ oml.enableDragAndDrop = function($list, canMove) { Ox._(itemText[0] == '"' ? '' : 'These ') + itemText, targetText ]); - } else if (drag.target.user != username) { + } else if (drag.target.user != '') { text = Ox._( 'You can only {0} books
to your own {1}.', [actionText, drag.target.type == 'library' ? 'library' : 'lists'] @@ -510,7 +509,7 @@ oml.enableDragAndDrop = function($list, canMove) { image = 'symbolClose' } else { image = drag.action == 'copy' ? ( - drag.source.user == username ? 'symbolAdd' : 'symbolDownload' + drag.source.user == '' ? 'symbolAdd' : 'symbolDownload' ) : 'symbolRemove', text = Ox._(Ox.toTitleCase(actionText)) + ' ' + ( Ox.isString(drag.item) @@ -519,7 +518,7 @@ oml.enableDragAndDrop = function($list, canMove) { ) + '
' + ( drag.target && drag.target.editable && !drag.target.selected ? Ox._('to {0}.', [targetText]) - : drag.source.user == username + : drag.source.user == '' ? Ox._('to {0} list.', [ui._list == ':' ? 'a' : 'another']) : Ox._('to your library or to one of your lists.') ); @@ -799,7 +798,7 @@ oml.getLists = function(callback) { list.name = list.type == 'libraries' ? Ox._('Libraries') : list.type == 'library' ? Ox._('Library') : list.name; return Ox.extend(list, { - editable: list.user == username && list.type == 'static', + editable: list.user == '' && list.type == 'static', own: list.user == '', title: (list.user ? list.user + ': ' : '') + list.name }); @@ -890,6 +889,29 @@ oml.reloadList = function() { oml.$ui.list.updateElement(); }; +oml.renameUser = function(data) { + var ui = oml.user.ui, + index = Ox.getIndexById(ui._users, data.id), + name = ui._users[index].name, + set = {}; + ui._users[index].name = data.name; + ui._users[index].nickname = data.nickname; + oml.$ui.folders.updateUser(index); + set['showFolder.' + data.name] = ui.showFolder[name]; + set['showFolder.' + name] = null; + Ox.forEach(ui.lists, function(value, key) { + var split = key.split(':'), + username = split[0], + listname = split.slice(1).join(':'); + if (username == name) { + set['lists.' + data.name + ':' + listname] = value; + set['lists.' + key] = null; + } + }); + Ox.print('$$$ SET', set); + oml.UI.set(set, false); +}; + oml.resizeFilters = function() { // ... };