Skip to content

Commit

Permalink
[Admin] News and newsgroup tracking #648
Browse files Browse the repository at this point in the history
- Added show / hide / remove buttons
- Hidden news has a "(Hidden)" on search page
- News sorted by date (Descending order)
  • Loading branch information
amngupta committed Oct 24, 2016
1 parent d804438 commit e6cc6af
Show file tree
Hide file tree
Showing 6 changed files with 72 additions and 11 deletions.
7 changes: 6 additions & 1 deletion app/packages/admin/client/templates/news/list/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ NewsIndex = new EasySearch.Index({
collection: Smartix.Messages.Collection,
fields: ['data.title'],
engine: new EasySearch.Minimongo({
sort: function()
{
return { 'createdAt': -1 };
},
selector: function (searchObject, options, aggregation) {

// selector contains the default mongo selector that Easy Search would use
Expand All @@ -12,5 +16,6 @@ NewsIndex = new EasySearch.Index({

return selector;
}
})
}),

});
10 changes: 7 additions & 3 deletions app/packages/admin/client/templates/news/list/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ <h1>{{_ "Admin.ListNews" }}</h1>
<thead>
<tr>
<th>{{_ "Admin.Title"}}</th>
<th>{{_ "Admin.Content"}}</th>

<th>{{_ "Admin.Content"}}</th>
</tr>
</thead>
<tbody>
{{#EasySearch.Each index=NewsIndex }}
<tr>
<!--<td><a href="{{pathFor route='admin.newsgroups.view' data=routeData}}"> {{name}} {{url}} {{_id}}</a></td>-->
<td><a href="{{pathFor route='admin.news.view' data=routeData}}"> {{data.title}} </a></td>
<td>
<a href="{{pathFor route='admin.news.view' data=routeData}}"> {{data.title}} </a>
{{#if hidden}}
&nbsp; ({{_ "Hidden"}})
{{/if}}
</td>
<td>{{{data.content}}}</td>
</tr>
{{/EasySearch.Each}}
Expand Down
31 changes: 26 additions & 5 deletions app/packages/admin/client/templates/news/view/view.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,34 @@
<div class="panel panel-flat">
{{#if Template.subscriptionsReady}}
{{#with newsData}}
<div class="panel-heading">
<div class="panel-heading">
<div class="panel-title">
<h1>{{_ "Admin.Title"}}: {{data.title}}</h1>
<small class="display-block">
{{{data.content}}}
</small>
<h5 class="display-block">
{{data.content}}
{{#if addons}}
<hr />
<span>{{_ "Contents"}}:</span>
<ul>
{{#each addons}}
<li style="text-transform:capitalize">{{ this.type}}</li>
{{/each}}
</ul>
{{/if}}
</h5>
</div>
<div class="item item-divider">News sent to newsgroup</div>
<div class="heading-elements">
<label class="checkbox-inline checkbox-switchery checkbox-right switchery-xs">
{{#if hidden}}
<button class='show-news-btn' data-msg-id="{{_id}}" type="button">{{_ "Admin.Show" }}</button>
{{else}}
<button class='hide-news-btn' data-msg-id="{{_id}}" type="button">{{_ "Admin.Hide" }}</button>
{{/if}}
<button class='remove-news-btn' data-msg-id="{{_id}}" type="button">{{_ "Admin.Remove" }}</button>
</label>
</div>
</div>
<div class="item item-divider">Newsgroups sent to newsgroup</div>
<div class="list">
{{#each groups}}
{{#with groupInfo this}}
Expand Down
27 changes: 26 additions & 1 deletion app/packages/admin/client/templates/news/view/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,29 @@ Template.AdminNewsView.helpers({
code: this.url
}
}
});
});


Template.AdminNewsView.events({
'click .show-news-btn':function(event,template){
var msgId = Router.current().params.msgcode;
Meteor.call('smartix:news/showMessage',msgId,function(){
toastr.info(TAPi18n.__("Admin.NewsShownAgain"));
});
},

'click .hide-news-btn':function(event,template){
var msgId = Router.current().params.msgcode;
Meteor.call('smartix:news/hideMessage',msgId,function(){
toastr.info(TAPi18n.__("Admin.NewsHiddenFromUser"));
});
},

'click .remove-news-btn':function(event,template){
var msgId = Router.current().params.msgcode;
Meteor.call('smartix:news/deleteMessage',msgId,function(){
toastr.info(TAPi18n.__("Admin.NewsRemoved"));
Router.go('admin.news.search', {school: UI._globalHelpers['getCurrentSchoolName']()})
});
}
})
6 changes: 5 additions & 1 deletion app/packages/news/server/publications.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,9 @@ Meteor.publish('allSchoolNews', function(schoolId) {
return Smartix.Messages.Collection.find({
groups: {$in: newsgroupIds},
type: 'article'
});
}, {
sort: {
"createdAt": -1
}
});
});
2 changes: 2 additions & 0 deletions app/packages/smartix-lib/i18n/en/en.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@
"Congratulations": "Congratulations !",
"Contact": "Contact",
"Contacts": "Contacts",
"Contents": "Contents",
"Copy": "Copy",
"Country": "My country",
"CreateAClass": "Create a class",
Expand Down Expand Up @@ -442,6 +443,7 @@
"HelpReply": "You can choose how you want people to reply. Do you allow comments or votes or both?",
"Hi": "Hi",
"Hide": "Hide",
"Hidden": "Hidden",
"Home": "Home",
"HowDidYouFind": "How did you find us?",
"HowSmartixExpect": "How do you expect Smartix to solve them?",
Expand Down

0 comments on commit e6cc6af

Please sign in to comment.