Skip to content
This repository was archived by the owner on Aug 21, 2018. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app/nation/app/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3485,6 +3485,36 @@ $(function() {
App.$el.children('.body').html(dashboard.el)
dashboard.render()
var communityNames = [];
/*$.ajax({
type: 'GET',
url: '/publicationdistribution/_all_docs?include_docs=true',
dataType: 'json',
success: function(response) {
for (var i = 0; i < response.rows.length; i++) {
if(response.rows[i].doc._id != "_design/bell"){
var communityName = response.rows[i].doc.communityName
var publication = new App.Models.Publication({
_id: response.rows[i].doc.publicationId
})
publication.fetch({
async: false
});
var updatePub = publication.attributes.communityNames
if (updatePub.indexOf(communityName) == -1)
updatePub.push(communityName)
publication.set('communityNames', updatePub);
publication.save(null, {
success:function(){
console.log("saved")
},
error: function() {
console.log("Not Saved")
}
});
}
}
}
});*/
$.ajax({
type: 'GET',
url: '/community/_design/bell/_view/getCommunityByCode?include_docs=true&limit=5',
Expand Down
24 changes: 23 additions & 1 deletion app/nation/app/views/PublicationRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,36 @@ $(function() {
},

vars: {},

template: _.template($("#template-PublicationRow").html()),

initialize: function(e) {
this.model.on('destroy', this.remove, this)
},

render: function() {
var that =this
var sentToList = [];
$.ajax({
type: 'GET',
url: '/publicationdistribution/_design/bell/_view/pubdistributionByPubId?_include_docs=true&key="' + this.model.attributes._id + '"',
dataType: 'json',
success: function(response) {
for (var i = 0; i < response.rows.length; i++){
sentToList.push(response.rows[i].value.communityName)
}
if(that.model.attributes.communityNames.length != sentToList.length){
that.model.set("communityNames", sentToList)
that.model.save(null, {
success:function(){
console.log("saved")
},
error: function() {
console.log("Not Saved")
}
});
}
}
});
var vars = this.model.toJSON()
vars.auto_publication = false
if(this.model.attributes.autoPublication != undefined)
Expand Down