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

Commit

Permalink
[#952] CourseMem Filter by community added
Browse files Browse the repository at this point in the history
  • Loading branch information
razu9861 committed Oct 5, 2017
1 parent f6112c6 commit 0012ae0
Show file tree
Hide file tree
Showing 6 changed files with 153 additions and 17 deletions.
6 changes: 3 additions & 3 deletions app/MyApp/app/Home-Urdu.css
Original file line number Diff line number Diff line change
Expand Up @@ -1252,8 +1252,8 @@ form > fieldset > ul > li.bbf-field.field-selectLanguage {
#addIndividualResource{
width:110px;
}
#CommunitySelect{
.DropDownOptn{
float: left;
margin-top: -45px;
margin-right: 15px;
margin-left: 20px;
position: relative;
}
6 changes: 3 additions & 3 deletions app/MyApp/app/Home.css
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,8 @@ form > fieldset > ul > li.bbf-field.field-selectLanguage {
width:97%;
margin-left:20px;
}
#CommunitySelect{
.DropDownOptn{
float: right;
margin-top: -45px;
margin-right: 15px;
margin-right: 20px;
position: relative;
}
27 changes: 25 additions & 2 deletions app/MyApp/app/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -3055,10 +3055,33 @@ $(function() {
CourseMembers: function(cId) {
var courseMembers = new App.Views.CourseMembers()
courseMembers.courseId = cId;
App.$el.children('.body').empty();
App.$el.children('.body').html('<div class="DropDownOptn"></div>')
App.$el.children('.body').append('<div class="courseEditStep"></div>');
courseMembers.render();
$('.courseEditStep').append(courseMembers.el);
var CoursecommunityList = "";
if(App.configuration.get('type') == 'nation'){
$.ajax({
url: '/community/_design/bell/_view/getCommunityByCode',
type: 'GET',
dataType: "jsonp",
async: false,
success: function(json){
CoursecommunityList = '<option value="">'+App.languageDict.attributes.All+'</option>';
CoursecommunityList += '<option value="'+App.configuration.get('code')+'">'+App.configuration.get('name')+'</option>';
$.each(json.rows, function(rec, index) {
CoursecommunityList += '<option value="'+this.value.Code+'">'+this.value.Name+'</option>';
})
CoursecommunityList = '<select id="CommunitySelect">'+CoursecommunityList+'</select>';
$('.DropDownOptn').append(CoursecommunityList);
}
});
}
$('#CommunitySelect').change(function(){
var selectedvalue = $('#CommunitySelect').val();
var courseMembers = new App.Views.CourseMembers()
courseMembers.courseId = cId;
courseMembers.randerTable(selectedvalue);
});
var directionOfLang = App.languageDict.get('directionOfLang');
if(directionOfLang.toLowerCase()==="right") {
$('.courseEditStep').find('h3').css('margin-right','5%');
Expand Down
98 changes: 91 additions & 7 deletions app/MyApp/app/views/CourseMembers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ $(function () {

App.Views.CourseMembers = Backbone.View.extend({
vars: {},

initialize: function () {},

removeMember:function(e){
Expand All @@ -12,7 +11,7 @@ $(function () {
_id: this.courseId
})
courseModel.fetch({
success:function(result){
success:function(result){
var members = result.get('members')
members.splice(members.indexOf(memberId),1)
result.set('members',members)
Expand All @@ -24,11 +23,11 @@ $(function () {
async:false
})
while (model = memberCoursePro.first()) {
model.destroy();
}
model.destroy();
}
that.render()
alert(App.languageDict.attributes.Member_Removed_From_Course)
}
}
})
},

Expand All @@ -47,12 +46,13 @@ $(function () {
config.fetch({
async: false
})

var currentConfig = config.first().toJSON()
var code = currentConfig.rows[0].doc.code
var na = currentConfig.rows[0].doc.nationName.substring(3,5);
$('.courseEditStep').empty();
$('.courseEditStep').append('<h3>'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '</h3>')
var viewtext = '<table class="btable btable-striped"><th>'+App.languageDict.attributes.Photo+'</th><th>'+App.languageDict.attributes.Name+'</th><th>'+App.languageDict.attributes.Roles+'</th><th colspan=2>'+App.languageDict.attributes.Actions+'</th>'
var viewtext = '<table id = "Table1" class="btable btable-striped"><th>'+App.languageDict.attributes.Photo+'</th><th>'+App.languageDict.attributes.Name+'</th><th>'+App.languageDict.attributes.Roles+'</th><th colspan=2>'+App.languageDict.attributes.Actions+'</th>'
for (var i = 0; i < memberList.length; i++) {
var mem = new App.Models.Member({
_id: memberList[i]
Expand Down Expand Up @@ -94,9 +94,93 @@ $(function () {
'onclick=showComposePopupMultiple("' + mail + '") id="sendMailButton">'
+App.languageDict.attributes.Send_Email+'</button>' +
'<button class="btn" id="retrunBack" onclick=retrunBack()>'
+App.languageDict.attributes.Back+'</button></td></tr>';
+App.languageDict.attributes.Back+'</button></td><td></td><td></td></tr>';
viewtext += '</table>';
$('.courseEditStep').append(viewtext)
},
randerTable: function(selectedvalue){
$('#Table1').remove()
var courseModel = new App.Models.Course({
_id: this.courseId
})
courseModel.fetch({
async: false
})
var memberList = courseModel.get('members')
var configurations = Backbone.Collection.extend({
url: App.Server + '/configurations/_all_docs?include_docs=true'
})
var config = new configurations()
config.fetch({
async: false
})
var currentConfig = config.first().toJSON()
var code = currentConfig.rows[0].doc.code
var na = currentConfig.rows[0].doc.nationName.substring(3,5);
$('.courseEditStep').empty();
$('.courseEditStep').append('<h3>'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '</h3>')
var viewtext = '<table id = "Table1" class="btable btable-striped"><th>'+App.languageDict.attributes.Photo+'</th><th>'+App.languageDict.attributes.Name+'</th><th>'+App.languageDict.attributes.Roles+'</th><th colspan=2>'+App.languageDict.attributes.Actions+'</th>'
var newMemberList = [];
for (var i = 0; i < memberList.length; i++) {
var mem = new App.Models.Member({
_id: memberList[i]
})
mem.fetch({
async: false
})
if(mem.attributes.community == selectedvalue){
newMemberList.push(memberList[i]);
}
}
if(newMemberList.length > 0){
for (var i = 0; i < newMemberList.length; i++) {
var mem = new App.Models.Member({
_id: newMemberList[i]
})
mem.fetch({
async: false
})
var roleOfMem;
if(courseModel.get('courseLeader').indexOf(mem.get('_id')) > -1) {
roleOfMem=App.languageDict.attributes.Leader
} else {
roleOfMem=App.languageDict.attributes.Learner
}
var mail = mem.get('login') + '.' + code +na+ '@olebell.org'
var src = "img/default.jpg"
var attchmentURL = '/members/' + mem.id + '/'
if (typeof mem.get('_attachments') !== 'undefined') {
attchmentURL = attchmentURL + _.keys(mem.get('_attachments'))[0]
src = attchmentURL
}
viewtext += '<tr><td><img width="45px" height="45px" src="' + src + '"/></td><td>' + mem.get('firstName') + ' ' + mem.get('lastName') + '</td><td>'+roleOfMem+'</td><td><input type="checkbox" name="courseMember" value="' + mail + '">'+App.languageDict.attributes.Send_Email+'</td>'
var loggedIn = new App.Models.Member({
"_id": $.cookie('Member._id')
})
loggedIn.fetch({
async: false
})
var roles = loggedIn.get("roles")
if( courseModel.get('courseLeader') && courseModel.get('courseLeader').indexOf($.cookie('Member._id'))>-1 || roles.indexOf('Manager')>-1) {
var memId=mem.get('_id')+','+this.courseId;
viewtext+='<td><button class="btn btn-danger removeMember" value="' + mem.get('_id') + '" onclick=removeMemberFromCourse(\"' + memId + '")>'+App.languageDict.attributes.Remove+'</button></td>'
}
viewtext+='</tr>'
}
viewtext += '<tr><td></td><td></td><td>' +
'<button class="btn" id="selectAllMembersOnMembers" onclick=selectAllMembers()>' +
App.languageDict.attributes.Select_All+'</button>' +
'<button style="" class="btn" ' +
'onclick=showComposePopupMultiple("' + mail + '") id="sendMailButton">'
+App.languageDict.attributes.Send_Email+'</button>' +
'<button class="btn" id="retrunBack" onclick=retrunBack()>'
+App.languageDict.attributes.Back+'</button></td><td></td><td></td></tr>';
viewtext += '</table>';
$('.courseEditStep').append(viewtext)
} else {
viewtext += '<tr><td></td><td></td><td></td><td></td></tr>';
$('.courseEditStep').append(viewtext)
}
}
})
})
30 changes: 29 additions & 1 deletion app/MyApp/app/views/listSyncDbView.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $(function() {
}, 1000);
},
render: function() {
var $button = $('<h6>' + App.languageDict.get('Config_Sync_With_Nation_Head') + '</h6><br><br><input type="checkbox" value="ActivityReports" name="syncData">' + App.languageDict.get('Log_Activity_Reports') + '<br><input type="checkbox" value="Reports" name="syncData">' + App.languageDict.get('Reports') + '<br><input type="checkbox" value="ResourcesFeedbacks" name="syncData">' + App.languageDict.get('Resources_Feedbacks') + '<br><input type="checkbox" value="ApplicationFeedbacks" name="syncData">' + App.languageDict.get('Application_Feedbacks') + '<br><input type="checkbox" value="MembersDb" name="syncData">' + App.languageDict.get('Members_Database') + '<br><input type="checkbox" value="Surveys" name="syncData">' + App.languageDict.get('Surveys') + '<br><input type="checkbox" value="CourseProgress" name="syncData">' + App.languageDict.get('Course_Member_Progress')+'<br><input type="checkbox" value="CourseAnswers" name="syncData">' + App.languageDict.get('Course_Answers')+ '<br>');
var $button = $('<h6>' + App.languageDict.get('Config_Sync_With_Nation_Head') + '</h6><br><br><input type="checkbox" value="ActivityReports" name="syncData">' + App.languageDict.get('Log_Activity_Reports') + '<br><input type="checkbox" value="Reports" name="syncData">' + App.languageDict.get('Reports') + '<br><input type="checkbox" value="ResourcesFeedbacks" name="syncData">' + App.languageDict.get('Resources_Feedbacks') + '<br><input type="checkbox" value="ApplicationFeedbacks" name="syncData">' + App.languageDict.get('Application_Feedbacks') + '<br><input type="checkbox" value="MembersDb" name="syncData">' + App.languageDict.get('Members_Database') + '<br><input type="checkbox" value="Surveys" name="syncData">' + App.languageDict.get('Surveys') + '<br><input type="checkbox" value="CourseProgress" name="syncData">' + App.languageDict.get('Course_Member_Progress')+'<br><input type="checkbox" value="CourseAnswers" name="syncData">' + App.languageDict.get('Course_Answers')+ '<br><input type="checkbox" value="Courses" name="syncData">' + App.languageDict.get('Courses') + '<br>');
this.$el.append($button);
this.$el.append('<button class="btn btn-info" id="selectAll" style="width:110px">' + App.languageDict.get('Select_All') + '</button><button style="margin-left:10px; width:110px" class="btn btn-success" id="formButton" style="width:110px">' + App.languageDict.get('Send') + '</button>');
this.$el.append('<button class="btn btn-warning" id="cancelButton" style="width:110px;margin-left:10px">' + App.languageDict.get('Cancel') + '</button>');
Expand Down Expand Up @@ -70,6 +70,8 @@ $(function() {
context.syncCourseProgress();
} else if ($(this).val() == 'CourseAnswers') {
context.syncCourseAnswers();
} else if ($(this).val() == 'Courses') {
context.syncCourses();
}
if ($(this).val() == 'Application') {
context.checkAvailableUpdates()
Expand Down Expand Up @@ -155,6 +157,32 @@ $(function() {
async: false
})
},

syncCourses: function() {
$.ajax({
headers: {
'Accept': 'application/json',
'Content-Type': 'application/json; charset=utf-8'
},
type: 'POST',
url: '/_replicate',
dataType: 'json',
data: JSON.stringify({
"source": "courses",
"target": 'http://' + App.configuration.get('nationUrl') + '/courses',
}),
success: function(response) {
alert(App.languageDict.attributes.Courses_Replicated)
if (isActivityLogChecked == false) {
App.stopActivityIndicator();
}
},
error: function(XMLHttpRequest, textStatus, errorThrown) {
alert(App.languageDict.attributes.TryLater_Error)
}
})
},

syncReports: function() {

$.ajax({
Expand Down
3 changes: 2 additions & 1 deletion init_docs/Text.json
Original file line number Diff line number Diff line change
Expand Up @@ -941,5 +941,6 @@
"You_choose_the_option_without_correct_answer":"You choose the option without correct answer",
"Auto_Publication":"Auto Publication",
"Enable_Auto_Sync":"Enable Auto Sync",
"Disable_Auto_Sync":"Disable Auto Sync"
"Disable_Auto_Sync":"Disable Auto Sync",
"Courses_Replicated": "Courses Replicated"
}

0 comments on commit 0012ae0

Please sign in to comment.