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

Commit

Permalink
[#995] Set autopublication button (#1002)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rupesh87 committed Aug 29, 2017
1 parent ffcdbe0 commit 791aa3c
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 13 deletions.
32 changes: 31 additions & 1 deletion app/nation/app/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -4251,6 +4251,25 @@ $(function() {
App.stopActivityIndicator()

},

AutoPublication: function(status,pubId) {
var publicationObject = new App.Models.Publication({
_id: pubId
})
publicationObject.fetch({
async: false
})
publicationObject.set("autoPublication",status);
publicationObject.save(null, {
success: function(model, response){
location.reload();
},
error: function() {
console.log("Not Saved")
}
});
},

PublicationDetails: function(publicationId) {

var publicationObject = new App.Models.Publication({
Expand All @@ -4265,7 +4284,12 @@ $(function() {
var lang = App.Router.getLanguage(loginOfMem);
App.languageDictValue=App.Router.loadLanguageDocs(lang);
App.$el.children('.body').html('<div id="parentDiv"></div>');
$('#parentDiv').append('<div style="margin-top:10px"><h6 style="float:left;">'+App.languageDictValue.get('IssueNumber')+ ' '+ publicationObject.get('IssueNo') + '</h6> <a class="btn btn-success" style="margin-left:20px" href="#courses/' + publicationId + '">'+App.languageDictValue.get('Add_Course')+'</a> <a class="btn btn-success" href = "../MyApp/index.html#search-bell/' + publicationId + '" style="float:left;margin-left:20px;margin-bottom:10px;">'+App.languageDictValue.get('Add_Resource')+'</a><button class="btn btn-info" style="float:left;margin-left:20px" onclick="SelectCommunity(\'' + publicationId + '\')">'+App.languageDictValue.get('Send_Publication')+'</button></div>')
$('#parentDiv').append('<div id="parentChildDiv" style="margin-top:10px"><h6 style="float:left;">'+App.languageDictValue.get('IssueNumber')+ ' '+ publicationObject.get('IssueNo') + '</h6> <a class="btn btn-success" style="margin-left:20px" href="#courses/' + publicationId + '">'+App.languageDictValue.get('Add_Course')+'</a> <a class="btn btn-success" href = "../MyApp/index.html#search-bell/' + publicationId + '" style="float:left;margin-left:20px;margin-bottom:10px;">'+App.languageDictValue.get('Add_Resource')+'</a><button class="btn btn-info" style="float:left;margin-left:20px" onclick="SelectCommunity(\'' + publicationId + '\')">'+App.languageDictValue.get('Send_Publication')+'</button></div>')
if( publicationObject.attributes.autoPublication == false){
$('#parentChildDiv').append(" <a role='button' id='auto_publication' style='margin-left: 15px;' class='btn btn-primary auto_publication'>"+App.languageDictValue.get('Enable_Auto_Sync')+"</a>");
}else{
$('#parentChildDiv').append(" <a role='button' style='margin-left: 15px;' id='resign_publication' class='btn btn-danger '>"+App.languageDictValue.get('Disable_Auto_Sync')+"</a>");
}
if(App.languageDictValue.get('directionOfLang').toLowerCase()==="right")
{
$('#parentDiv div').find('h6').css({"float":"right"});
Expand Down Expand Up @@ -4311,6 +4335,12 @@ $(function() {
publicationcourseTable.Id = publicationId
publicationcourseTable.render()
$('#parentDiv').append(publicationcourseTable.el)
$("#auto_publication").click(function(){
App.Router.AutoPublication(true,publicationId);
});
$("#resign_publication").click(function(){
App.Router.AutoPublication(false,publicationId);
});
App.Router.applyCorrectStylingSheet(App.languageDictValue.get('directionOfLang'));
},

Expand Down
1 change: 0 additions & 1 deletion app/nation/app/views/PublicationRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ $(function() {
"click #a": function (id) {
alert(id)
}

},

vars: {},
Expand Down
35 changes: 26 additions & 9 deletions app/nation/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1120,15 +1120,32 @@ <h5><%=languageDict.attributes.community_details%></h5>

</select>
</td>
<td>
<a href="#publicationdetail/<%= _id %>" class="btn btn-warning">
<%= languageDict.attributes.Details%>
</a>
</td>
<td>
<a class='btn btn-danger destroy'>
<%= languageDict.attributes.DeleteLabel%>
</a>
<td style="width:160px;">
<div>
<span>
<a href="#publicationdetail/<%= _id %>" class="btn btn-warning">
<%= languageDict.attributes.Details%>
</a>
</span>
<span style="margin-left:-1px;">
<a class='btn btn-danger destroy'>
<%= languageDict.attributes.DeleteLabel%>
</a>
</span>
</div>
<%if(autoPublication == false){%>
<div style="margin-top: 2px;">
<a role='button' onclick="App.Router.AutoPublication(true, '<%= _id %>' )" class="btn btn-primary auto_publication">
<%= languageDict.attributes.Enable_Auto_Sync%>
</a>
</div>
<%}else{%>
<div style="margin-top: 2px; ">
<a role='button' onclick="App.Router.AutoPublication(false, '<%= _id %>' )"class="btn btn-danger resign_publication">
<%= languageDict.attributes.Disable_Auto_Sync%>
</a>
</div>
<%}%>
</td>
</script>

Expand Down
4 changes: 3 additions & 1 deletion init_docs/Text.json
Original file line number Diff line number Diff line change
Expand Up @@ -939,5 +939,7 @@
"Course_Answers_Replicated":"Course Answers Replicated",
"Please_provide_atleast_one_correct_answer":"Please provide atleast one correct answer",
"You_choose_the_option_without_correct_answer":"You choose the option without correct answer",
"Auto_Publication":"Auto Publication"
"Auto_Publication":"Auto Publication",
"Enable_Auto_Sync":"Enable Auto Sync",
"Disable_Auto_Sync":"Disable Auto Sync"
}
2 changes: 1 addition & 1 deletion tests/pages/publication_po.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = {
addIssue: '//*[@href="#publication/add"]',
saveIssue: '//*[@name="save"]',
cancelIssue: '//*[@id="cancel"]',
deleteIssueBtns: '//*[@id="parentDiv"]/table/tbody/tr/td/*[@class="btn btn-danger destroy"]',
deleteIssueBtns: '//*[@id="parentDiv"]/table/tbody/tr/td/div/span/*[@class="btn btn-danger destroy"]',
editorName: '//*[@name="editorName"]',
editorEmail: '//*[@name="editorEmail"]',
editorPhone: '//*[@name="editorPhone"]',
Expand Down

0 comments on commit 791aa3c

Please sign in to comment.