diff --git a/app/MyApp/app/Home-Urdu.css b/app/MyApp/app/Home-Urdu.css index 8b38e8d0f..8597c893e 100644 --- a/app/MyApp/app/Home-Urdu.css +++ b/app/MyApp/app/Home-Urdu.css @@ -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; } diff --git a/app/MyApp/app/Home.css b/app/MyApp/app/Home.css index b85164774..7b942a955 100644 --- a/app/MyApp/app/Home.css +++ b/app/MyApp/app/Home.css @@ -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; } diff --git a/app/MyApp/app/Router.js b/app/MyApp/app/Router.js index b39383b84..ff0d12e5b 100644 --- a/app/MyApp/app/Router.js +++ b/app/MyApp/app/Router.js @@ -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('') App.$el.children('.body').append('
'); 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 = ''; + CoursecommunityList += ''; + $.each(json.rows, function(rec, index) { + CoursecommunityList += ''; + }) + CoursecommunityList = ''; + $('.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%'); diff --git a/app/MyApp/app/views/CourseMembers.js b/app/MyApp/app/views/CourseMembers.js index eab70e1e5..1ee0f7e2c 100644 --- a/app/MyApp/app/views/CourseMembers.js +++ b/app/MyApp/app/views/CourseMembers.js @@ -2,7 +2,6 @@ $(function () { App.Views.CourseMembers = Backbone.View.extend({ vars: {}, - initialize: function () {}, removeMember:function(e){ @@ -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) @@ -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) - } + } }) }, @@ -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('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') - var viewtext = '' + var viewtext = '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' for (var i = 0; i < memberList.length; i++) { var mem = new App.Models.Member({ _id: memberList[i] @@ -94,9 +94,93 @@ $(function () { 'onclick=showComposePopupMultiple("' + mail + '") id="sendMailButton">' +App.languageDict.attributes.Send_Email+'' + ''; + +App.languageDict.attributes.Back+''; viewtext += '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
'; $('.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('

'+App.languageDict.attributes.Course_Members+ ' | ' + courseModel.get('name') + '

') + var viewtext = '' + 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 += '' + 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+='' + } + viewtext+='' + } + viewtext += ''; + viewtext += '
'+App.languageDict.attributes.Photo+''+App.languageDict.attributes.Name+''+App.languageDict.attributes.Roles+''+App.languageDict.attributes.Actions+'
' + mem.get('firstName') + ' ' + mem.get('lastName') + ''+roleOfMem+''+App.languageDict.attributes.Send_Email+'
' + + '' + + '' + + '
'; + $('.courseEditStep').append(viewtext) + } else { + viewtext += ''; + $('.courseEditStep').append(viewtext) + } } }) }) \ No newline at end of file diff --git a/app/MyApp/app/views/listSyncDbView.js b/app/MyApp/app/views/listSyncDbView.js index d5918a9c3..ecf649c30 100644 --- a/app/MyApp/app/views/listSyncDbView.js +++ b/app/MyApp/app/views/listSyncDbView.js @@ -17,7 +17,7 @@ $(function() { }, 1000); }, render: function() { - var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+ '
'); + var $button = $('
' + App.languageDict.get('Config_Sync_With_Nation_Head') + '


' + App.languageDict.get('Log_Activity_Reports') + '
' + App.languageDict.get('Reports') + '
' + App.languageDict.get('Resources_Feedbacks') + '
' + App.languageDict.get('Application_Feedbacks') + '
' + App.languageDict.get('Members_Database') + '
' + App.languageDict.get('Surveys') + '
' + App.languageDict.get('Course_Member_Progress')+'
' + App.languageDict.get('Course_Answers')+ '
' + App.languageDict.get('Courses') + '
'); this.$el.append($button); this.$el.append(''); this.$el.append(''); @@ -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() @@ -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({ diff --git a/init_docs/Text.json b/init_docs/Text.json index d27700cef..489e06a5c 100644 --- a/init_docs/Text.json +++ b/init_docs/Text.json @@ -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" }