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.
This commit is contained in:
Tanshu 2013-05-30 18:28:41 +05:30
parent 86b5beaa0d
commit d5dcd392f7
7 changed files with 57 additions and 50 deletions

View File

@ -1,6 +1,6 @@
CACHE MANIFEST
# version 2013-05-29.1
# version 2013-05-30.1
CACHE:
/partial/404.html

View File

@ -1,21 +1,34 @@
<legend>Messages <a href="/Message" class="btn btn-success pull-right">Add <i class="icon-plus icon-white"></i></a>
</legend>
<div class="widget-box">
<div class="widget-title">
<div class="widget-box">
<div class="widget-title">
<ul class="nav nav-tabs">
<li><a href="#">Open</a></li>
<li><a href="#">Closed</a></li>
<li><a href="#">All</a></li>
<li class="dropdown pull-right">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Tags
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li ng-repeat="(name, count) in tags"><a href="#">{{name}} x {{count}}</a></li>
</ul>
</li>
</ul>
</div>
<div class="widget-content nopadding">
<table class="table table-bordered table-striped">
<tbody>
<tr ng-repeat="item in info">
<td><input type="checkbox" ng-model="item.selected"></td>
<td>
<span class="user-info">User: {{item.User}} at {{item.CreationDate | localTime}}</span>
</div>
<div class="widget-content nopadding">
<table class="table table-bordered table-striped">
<tbody>
<tr ng-repeat="item in info" >
<td><input type="checkbox" ng-model="item.selected"></td>
<td>
<span class="user-info">User: {{item.User}} at {{item.CreationDate | localTime}}</span>
<p><a ng-click="openMessage(item)">{{item.Title}}</a></p>
<a class="btn btn-mini" ng-repeat="tag in item.Tags"> {{tag}}</a>
</td>
</tr>
</tbody>
</div>
</div>
<p><a ng-click="openMessage(item)">{{item.Title}}</a></p>
<a class="btn btn-mini" ng-repeat="tag in item.Tags"> {{tag}}</a>
</td>
</tr>
</tbody>
</div>
</div>
</table>

View File

@ -25,10 +25,10 @@
ng-options="l.id as l.name for l in priorities"> </select>
<label class="checkbox inline">
<input type="checkbox" ng-model="account.Public"> Is Public
<input type="checkbox" ng-model="message.Public"> Is Public
</label>
<label class="checkbox inline">
<input type="checkbox" ng-model="account.Closed"> Is Closed
<input type="checkbox" ng-model="message.Closed"> Is Closed
</label>
</div>
</div>
@ -59,9 +59,5 @@
</ul>
<div class="form-actions">
<button class="btn btn-primary" ng-click="save()">Save</button>
<button class="btn btn-danger" ng-show="account.LedgerID" ng-confirm title="Delete Account"
action-text="Are you sure? This cannot be undone."
action-button-text="Delete" action-function="delete()"> Delete
</button>
</div>
</form>

View File

@ -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);

View File

@ -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}}
});
}]);

View File

@ -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);
}

View File

@ -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):