Skip to content
This repository has been archived by the owner on Aug 21, 2018. It is now read-only.

Commit

Permalink
[#1044] Auto publication list on sent to
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupesh87 committed Oct 13, 2017
1 parent 2dd5a4c commit e4abc3d
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions app/MyApp/app/views/CommunityConfigurationsForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,7 @@ $(function() {
success: function (model, response) {
var docIds = [];
var id = that.model.get('id');
var community_name = $.trim($('#community-name').val())
docIds.push(id);
$.ajax({
headers: {
Expand Down Expand Up @@ -427,19 +428,52 @@ $(function() {
if(response.rows[i].doc._id != "_design/bell"){
if(response.rows[i].doc.autoPublication == true){
var publicationsId = response.rows[i].doc._id
var publicationsRev = response.rows[i].doc._rev
$.ajax({
type: 'GET',
url: '/configurations/_all_docs?include_docs=true',
dataType: 'json',
async: false,
success: function(response) {
var sendPub = new Array()
var communityName = response.rows[0].doc.name
sendPub.push({
communityUrl: response.rows[0].doc.sponsorUrl,
communityName: response.rows[0].doc.name,
publicationId: publicationsId,
Viewed: false
})
$.ajax({
type: 'GET',
url: 'http://' + nationUrl + '/publications/_design/bell/_view/allPublication?_include_docs=true&key="'+publicationsId+'"',
dataType: 'jsonp',
async: false,
success: function(response) {
var sendCommunityName = response.rows[0].value
if (sendCommunityName['communityNames'].indexOf(community_name) == -1) {
sendCommunityName.communityNames.push(community_name)
console.log(sendCommunityName)
console.log('http://niroj.np:oleoleole@' + nationUrl + '/publications/'+publicationsId+ '?rev=' + publicationsRev)
$.ajax({
url : 'http://niroj.np:oleoleole@' + nationUrl + '/publications/'+publicationsId,
data : sendCommunityName,
type : 'PUT',
dataType : "jsonp",
contentType : "application/json",
async: false,
success : function(resp) {
console.log(resp)
},
error: function(status) {
console.log(status)
}
});
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(App.languageDict.attributes.TryLater_Error)
}
})
$.couch.db("publicationdistribution").bulkSave({
"docs": sendPub
}, {
Expand Down

0 comments on commit e4abc3d

Please sign in to comment.