From a30ddb7c3255b7f88430607ce70485144d53a75a Mon Sep 17 00:00:00 2001 From: rolux Date: Thu, 19 Apr 2012 08:50:41 +0000 Subject: [PATCH] when duplicating a list, copy its description (fixes #749) --- static/js/pandora/utils.js | 44 +++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 17 deletions(-) diff --git a/static/js/pandora/utils.js b/static/js/pandora/utils.js index 98e13d902..fea5e9b02 100644 --- a/static/js/pandora/utils.js +++ b/static/js/pandora/utils.js @@ -34,28 +34,38 @@ pandora.addList = function() { data.query = listData.query; } } - if (isDuplicate && listData.type == 'static') { - var query = { - conditions: [{key: 'list', value: list, operator: '=='}], - operator: '&' - }; - pandora.api.find({ - query: query + if (isDuplicate) { + pandora.api.findLists({ + query: {conditions: [{key: 'id', value: list, operator: '=='}]}, + keys: ['description'] }, function(result) { - if (result.data.items) { + data.description = result.data.items[0].description; + if (data.type == 'static') { + var query = { + conditions: [{key: 'list', value: list, operator: '=='}], + operator: '&' + }; pandora.api.find({ - query: query, - keys: ['id'], - sort: [{key: 'id', operator: ''}], - range: [0, result.data.items] + query: query }, function(result) { - var items = result.data.items.map(function(item) { - return item.id; - }); - addList(items); + if (result.data.items) { + pandora.api.find({ + query: query, + keys: ['id'], + sort: [{key: 'id', operator: ''}], + range: [0, result.data.items] + }, function(result) { + var items = result.data.items.map(function(item) { + return item.id; + }); + addList(items); + }); + } else { + addList(); + } }); } else { - addList(); + addList() } }); } else {