move public list to the top

This commit is contained in:
j 2019-01-19 18:39:34 +05:30
parent 61fff0a8d7
commit 9c393cdd56
4 changed files with 42 additions and 10 deletions

View file

@ -349,7 +349,7 @@ def sortLists(data):
''' '''
n = 0 n = 0
logger.debug('sortLists %s', data) logger.debug('sortLists %s', data)
lists = [] lists = ['Public']
for id in data['ids']: for id in data['ids']:
l = models.List.get(id) l = models.List.get(id)
l.index_ = n l.index_ = n

View file

@ -7,12 +7,13 @@ oml.ui.folderList = function(options) {
that = Ox.TableList({ that = Ox.TableList({
columns: [ columns: [
{ {
format: function(value) { format: function(value, data) {
return $('<img>') return $('<img>')
.attr({ .attr({
src: Ox.UI.getImageURL( src: Ox.UI.getImageURL(
value == 'libraries' ? 'symbolData' value == 'libraries' ? 'symbolData'
: value == 'library' ? 'symbolUser' : value == 'library' ? 'symbolUser'
: data.name == 'Public' ? 'symbolPublish'
: value == 'static' ? 'symbolClick' : value == 'static' ? 'symbolClick'
: 'symbolFind' : 'symbolFind'
) )

View file

@ -42,6 +42,7 @@ oml.ui.folders = function() {
}).indexOf(list.user) : null; }).indexOf(list.user) : null;
return list.id == '' ? oml.$ui.librariesList return list.id == '' ? oml.$ui.librariesList
: Ox.endsWith(list.id, ':') ? oml.$ui.libraryList[index] : Ox.endsWith(list.id, ':') ? oml.$ui.libraryList[index]
: Ox.endsWith(list.id, ':Public') ? oml.$ui.publicList[index]
: oml.$ui.folderList[index]; : oml.$ui.folderList[index];
} }
@ -61,7 +62,11 @@ oml.ui.folders = function() {
index = userIndex[split[0]], index = userIndex[split[0]],
list = split[1], list = split[1],
$selectedList = !ui._list ? oml.$ui.librariesList $selectedList = !ui._list ? oml.$ui.librariesList
: !list ? oml.$ui[!list ? 'libraryList' : 'folderList'][index] : !list ? oml.$ui[
!list ? 'libraryList'
: 'folderList'
][index]
: list == 'Public' ? oml.$ui.publicList[index]
: oml.$ui.folderList[index]; : oml.$ui.folderList[index];
$lists.forEach(function($list) { $lists.forEach(function($list) {
if ($list == $selectedList) { if ($list == $selectedList) {
@ -82,6 +87,7 @@ oml.ui.folders = function() {
oml.$ui.folder = []; oml.$ui.folder = [];
oml.$ui.libraryList = []; oml.$ui.libraryList = [];
oml.$ui.folderList = []; oml.$ui.folderList = [];
oml.$ui.publicList = [];
getUsersAndLists(function(users, lists) { getUsersAndLists(function(users, lists) {
@ -114,9 +120,10 @@ oml.ui.folders = function() {
var $content, var $content,
items = lists.filter(function(list) { items = lists.filter(function(list) {
return list.user === user.name return list.user === user.name
&& list.type != 'library'; && list.type != 'library' && list.name != 'Public';
}), }),
libraryId = user.name + ':'; libraryId = user.name + ':',
publicId = user.name + ':Public';
userIndex[user.name] = index; userIndex[user.name] = index;
@ -168,7 +175,7 @@ oml.ui.folders = function() {
$content = oml.$ui.folder[index].$content $content = oml.$ui.folder[index].$content
.css({ .css({
height: (1 + items.length) * 16 + 'px' height: (2 + items.length) * 16 + 'px'
}); });
$lists.push( $lists.push(
@ -186,7 +193,7 @@ oml.ui.folders = function() {
oml.UI.set({find: getFind(data.ids[0])}); oml.UI.set({find: getFind(data.ids[0])});
}, },
selectnext: function() { selectnext: function() {
oml.UI.set({find: getFind(items[0].id)}); oml.UI.set({find: getFind(publicId)});
}, },
selectprevious: function() { selectprevious: function() {
// FIXME: ugly // FIXME: ugly
@ -210,6 +217,27 @@ oml.ui.folders = function() {
.appendTo($content) .appendTo($content)
); );
$lists.push(
oml.$ui.publicList[index] = oml.ui.folderList({
items: lists.filter(function(list) {
return list.user == user.name && list.name == 'Public';
})
})
.bindEvent({
select: function(data) {
oml.UI.set({find: getFind(data.ids[0])});
},
selectnext: function() {
oml.UI.set({find: getFind(items[0].id)});
},
selectprevious: function() {
oml.UI.set({find: getFind(libraryId)});
}
})
.appendTo($content)
);
oml.$ui.publicList[index].$body.css({top: '16px'});
$lists.push( $lists.push(
oml.$ui.folderList[index] = oml.ui.folderList({ oml.$ui.folderList[index] = oml.ui.folderList({
draggable: !!index, draggable: !!index,
@ -262,14 +290,14 @@ oml.ui.folders = function() {
} }
}, },
selectprevious: function() { selectprevious: function() {
oml.UI.set({find: getFind(libraryId)}); oml.UI.set({find: getFind(publicId)});
} }
}) })
.css({height: items.length * 16 + 'px'}) .css({height: items.length * 16 + 'px'})
.appendTo($content) .appendTo($content)
); );
oml.$ui.folderList[index].$body.css({top: '16px'}); oml.$ui.folderList[index].$body.css({top: '32px'});
}); });

View file

@ -316,7 +316,7 @@ oml.enableDragAndDrop = function($list, canMove) {
$list.bindEvent({ $list.bindEvent({
draganddropstart: function(data) { draganddropstart: function(data) {
var $lists = oml.$ui.libraryList.concat(oml.$ui.folderList); var $lists = oml.$ui.libraryList.concat(oml.$ui.publicList).concat(oml.$ui.folderList);
drag.action = 'copy'; drag.action = 'copy';
drag.ids = $list.options('selected'); drag.ids = $list.options('selected');
drag.item = drag.ids.length == 1 drag.item = drag.ids.length == 1
@ -992,6 +992,9 @@ oml.resizeListFolders = function() {
oml.$ui.libraryList[index] oml.$ui.libraryList[index]
.css({width: width + 'px'}) .css({width: width + 'px'})
.resizeColumn('name', columnWidth); .resizeColumn('name', columnWidth);
oml.$ui.publicList[index]
.css({width: width + 'px'})
.resizeColumn('name', columnWidth);
oml.$ui.folderList[index] oml.$ui.folderList[index]
.css({width: width + 'px'}) .css({width: width + 'px'})
.resizeColumn('name', columnWidth); .resizeColumn('name', columnWidth);