From d5dcd392f7144140667c9c4e2b5a812e70debe4f Mon Sep 17 00:00:00 2001 From: Tanshu Date: Thu, 30 May 2013 18:28:41 +0530 Subject: [PATCH] Error in message-detail.html partial Public and Closed checkboxes should now be working. Delete button in message-detail.html was accidentally left, removed. Removed cacheing from an-autocomplete. Message list now returns tags list also. --- brewman/brewman/static/offline.appcache | 2 +- brewman/brewman/static/partial/home.html | 47 ++++++++++++------- .../static/partial/message-detail.html | 8 +--- .../static/scripts/angular_directive.js | 36 ++++++-------- .../brewman/static/scripts/angular_service.js | 2 +- brewman/brewman/static/scripts/home.js | 3 +- brewman/brewman/views/messaging.py | 9 +++- 7 files changed, 57 insertions(+), 50 deletions(-) diff --git a/brewman/brewman/static/offline.appcache b/brewman/brewman/static/offline.appcache index 42341d27..6e069717 100644 --- a/brewman/brewman/static/offline.appcache +++ b/brewman/brewman/static/offline.appcache @@ -1,6 +1,6 @@ CACHE MANIFEST -# version 2013-05-29.1 +# version 2013-05-30.1 CACHE: /partial/404.html diff --git a/brewman/brewman/static/partial/home.html b/brewman/brewman/static/partial/home.html index 1feaf25b..32b7ba5b 100644 --- a/brewman/brewman/static/partial/home.html +++ b/brewman/brewman/static/partial/home.html @@ -1,21 +1,34 @@ Messages Add -
-
+
+
+ +
+
+ + + + +
+ - -
- - - - - - - - - +

{{item.Title}}

+ {{tag}} + + + + +
- -

{{item.Title}}

- {{tag}} -
diff --git a/brewman/brewman/static/partial/message-detail.html b/brewman/brewman/static/partial/message-detail.html index d7e917cd..2d6b1f21 100644 --- a/brewman/brewman/static/partial/message-detail.html +++ b/brewman/brewman/static/partial/message-detail.html @@ -25,10 +25,10 @@ ng-options="l.id as l.name for l in priorities">
@@ -59,9 +59,5 @@
-
diff --git a/brewman/brewman/static/scripts/angular_directive.js b/brewman/brewman/static/scripts/angular_directive.js index 9b012ec4..63a8c25f 100644 --- a/brewman/brewman/static/scripts/angular_directive.js +++ b/brewman/brewman/static/scripts/angular_directive.js @@ -5,32 +5,24 @@ overlord_directive.directive('ngAutocomplete', ['$q', '$parse', 'DeepLabel', fun return { restrict: 'A', link: function (scope, element, attrs, ngModel) { - var labelsCache = {}, - mappedCache = {}, + var mappedCache = {}, labels = [], mapped = {}, deepLabel = DeepLabel; element.typeahead({ source: function (query, process) { - if (query in labelsCache) { - labels = labelsCache[query]; - mapped = mappedCache[query]; - process(labels); - } else { - var Entity = angular.injector(['overlord.service']).get(attrs.resource); - Entity.autocomplete({term: query, count: 20}, function (result) { - labels = []; - mapped = {}; - $.each(result, function (i, item) { - var label = deepLabel(item, attrs.label); - mapped[label] = item - labels.push(label) - }) - labelsCache[query] = labels; - mappedCache[query] = mapped; - process(labels) - }); - } + var Entity = angular.injector(['overlord.service']).get(attrs.resource); + Entity.autocomplete({term: query, count: 20}, function (result) { + labels = []; + mapped = {}; + $.each(result, function (i, item) { + var label = deepLabel(item, attrs.label); + mapped[label] = item + labels.push(label) + }) + mappedCache[query] = mapped; + process(labels) + }); }, minLength: 1, items: 20, @@ -316,7 +308,7 @@ overlord_directive.directive('chosen', ['$parse', function ($parse) { element.chosen({ create_option: function (data) { - if (typeof createFunction !== 'undefined'){ + if (typeof createFunction !== 'undefined') { var fn = $parse(attrs['createFunction'] + '("' + data + '")'); scope.$apply(function () { fn(scope); diff --git a/brewman/brewman/static/scripts/angular_service.js b/brewman/brewman/static/scripts/angular_service.js index a69aa0ab..012e4294 100644 --- a/brewman/brewman/static/scripts/angular_service.js +++ b/brewman/brewman/static/scripts/angular_service.js @@ -157,7 +157,7 @@ overlord_service.factory('Account', ['$resource', function ($resource) { overlord_service.factory('Message', ['$resource', function ($resource) { return $resource('/api/Message/:id', {id:'@ThreadID'}, { - query:{method:'GET', params:{list:true}, isArray:true} + query:{method:'GET', params:{list:true}} }); }]); diff --git a/brewman/brewman/static/scripts/home.js b/brewman/brewman/static/scripts/home.js index 8866f6e6..ede236d6 100644 --- a/brewman/brewman/static/scripts/home.js +++ b/brewman/brewman/static/scripts/home.js @@ -1,7 +1,8 @@ 'use strict'; var HomeCtrl = ['$scope', '$location', 'messages', function ($scope, $location, messages) { - $scope.info = messages; + $scope.info = messages.Threads; + $scope.tags = messages.Tags $scope.openMessage = function (item) { $location.path('/Message/' + item.ThreadID); } diff --git a/brewman/brewman/views/messaging.py b/brewman/brewman/views/messaging.py index c987bdf9..58fc1229 100644 --- a/brewman/brewman/views/messaging.py +++ b/brewman/brewman/views/messaging.py @@ -94,19 +94,24 @@ def show_list(request): if authenticated_userid(request) is None: list = list.filter(Thread.public == True) list = list.order_by(Thread.priority).all() + tags = {} threads = [] for item in list: thread = {'ThreadID': item.id, 'Title': item.title, 'CreationDate': item.creation_date.strftime('%d-%b-%Y %H:%M'), 'User': item.user.name, 'Priority': item.priority, 'Public': item.public, 'Tags': [], 'Posts': []} - threads.append(thread) for tag in item.tags: thread['Tags'].append(tag.name) + if not tag.name in tags: + tags[tag.name] = 1 + else: + tags[tag.name] += 1 for post in item.posts: thread['Posts'].append({'PostID': post.id, 'Content': post.content, 'User': post.user.name, 'Date': post.date.strftime('%d-%b-%Y %H:%M'), 'CreationDate': post.creation_date.strftime('%d-%b-%Y %H:%M')}) - return threads + threads.append(thread) + return {'Tags': tags, 'Threads': threads} def thread_info(id):