From d5848362a0daec4403733284a16a8915a97df085 Mon Sep 17 00:00:00 2001 From: Jerry Jalava Date: Wed, 30 Jan 2008 16:02:26 +0200 Subject: [PATCH] Fixed Empty trash -functionality. Added total trashed count to the list title --- js/views/system.js | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/js/views/system.js b/js/views/system.js index 7f7c4fc..70311c2 100644 --- a/js/views/system.js +++ b/js/views/system.js @@ -414,11 +414,15 @@ } }, - get_items: function(on_success) { + get_items: function(on_success, limit) { var trash_view = 'if (doc.value.metadata.deleted.val == true) {'; trash_view += 'map( doc.value.metadata.revised, {"_type": doc.value._type,'; trash_view += '"title": doc.value.title,'; + if (typeof limit == 'undefined') { + limit = true; + } + $.each($.ajatus.preferences.client.content_types, function(key,type){ if (type['title_item']) { $.each(type['title_item'], function(i,part){ @@ -446,10 +450,16 @@ return data; }; - $.jqCouch.connection('view', conn_on_success).temp($.ajatus.preferences.client.content_database, "$.ajatus.views.generate('"+trash_view+"')", { - count: $.ajatus.views.system.trash.options.group_item_count, - descending: true - }); + if (limit) { + $.jqCouch.connection('view', conn_on_success).temp($.ajatus.preferences.client.content_database, "$.ajatus.views.generate('"+trash_view+"')", { + count: $.ajatus.views.system.trash.options.group_item_count, + descending: true + }); + } else { + $.jqCouch.connection('view', conn_on_success).temp($.ajatus.preferences.client.content_database, "$.ajatus.views.generate('"+trash_view+"')", { + descending: true + }); + } }, render: function() @@ -474,6 +484,13 @@ return false; } + var trash_type_count_view = 'if (doc.value.metadata.deleted.val == true && doc.value._type == "'+type.name+'") {'; + trash_type_count_view += 'map( doc._id, {"_type": doc.value._type});}'; + + total_trashed_count = $.jqCouch.connection('view').temp($.ajatus.preferences.client.content_database, "$.ajatus.views.generate('"+trash_type_count_view+"')", { + count: 0 + }).total_rows; + result_count[type.name] = 0; $.each(rows, function(i,doc){ @@ -495,6 +512,7 @@ id: type.name + '_list_holder', append: true, title: type.title, + title_suffix: '('+total_trashed_count+')', headers: [ 'title', 'revised', 'by' ], @@ -548,7 +566,7 @@ empty: function() { var answer = confirm($.ajatus.i10n.get("Deleting all items in trash. Are you sure?")); if (answer) { - $.ajatus.views.system.trash.get_items($.ajatus.views.system.trash.execute_empty); + $.ajatus.views.system.trash.get_items($.ajatus.views.system.trash.execute_empty, false); } }, execute_empty: function(rows) { -- 2.11.4.GIT