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

Commit

Permalink
[#840]: CareerPath Updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Pr0chin committed Jul 4, 2017
1 parent dd50dd1 commit 9eaffa2
Show file tree
Hide file tree
Showing 7 changed files with 398 additions and 14 deletions.
66 changes: 63 additions & 3 deletions app/MyApp/app/Router.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ $(function() {
'members': 'Members',
'reports': 'Reports',
'trendreport': 'trendReport',
// added to new page 'reports/sync' : 'syncReports',
'reports/edit/:resportId': 'ReportForm',
'reports/add': 'ReportForm',
'mail': 'email',
Expand All @@ -82,7 +81,6 @@ $(function() {
'weeklyreports': 'WeeklyReports',
'removecache': 'UpdateManifest',
'logreports': 'LogQuery',
// Not required 'syncLog':'syncLogActivitiy',
'reportsActivity': 'LogActivity',
'setbit': 'setNeedOptimizedBit',
'CompileAppManifest': 'CompileAppManifest',
Expand All @@ -95,7 +93,8 @@ $(function() {
'checksum(/:nation/:url)': 'checkSum',
'listLearnersCredits/:cid': 'showLearnersListForCredits',
'passwordResetEmail': 'showPasswordResetEmail',
'password-reset': 'showPasswordReset'
'password-reset': 'showPasswordReset',
'courseCareerPath':'addCareerPath'
},
addOrUpdateWelcomeVideoDoc: function() {
// fetch existing welcome video doc if there is any
Expand Down Expand Up @@ -6935,6 +6934,67 @@ $(function() {
});
passwordResetView.render();
App.$el.children('.body').append(passwordResetView.el)
},

addCareerPath:function(){
var courses = new App.Collections.Courses()
courses.memberId = $.cookie('Member._id');
courses.fetch({
async:false
});
$.ajax({
url: '/coursecareerpath/_design/bell/_view/getCourseCareerByName',
type: 'GET',
dataType: "jsonp",
async: false,
success: function(json) {
console.log(json)
$(careerList).insertBefore('#searchText');
}
});
var addCourseCareer = new App.Views.AddCourseCareer({
collection:courses
});
addCourseCareer.render()
App.$el.children('.body').html('<div id="ManageCourseCareer"></div>');
$('#ManageCourseCareer').append('<a id="addCourseButton" class="btn btn-success" href="#course/add">'+App.languageDict.attributes.Add_Course+'</a>')
$('#ManageCourseCareer').append('<a id="requestCourseButton" class="btn btn-success" style="margin: 13px;margin-left: 9px;" onclick=showRequestForm("Course")>'+App.languageDict.attributes.Request_Course+'</a>')
if($.url().attr('fragment') == "courses") {
$('#ManageCourseCareer').append('<p id="labelOnResource" style="font-size:30px; margin-bottom: -23px;color:#808080"><a href="#courses"style="font-size:30px;text-decoration: underline;">'+languageDict.attributes.Courses+'</a>&nbsp&nbsp|&nbsp&nbsp<a href="#courseCareerPath" style="font-size:30px;text-decoration: underline;"checked data-toggle="toggle">'+languageDict.attributes.Career_Path+'</a></p>')
}else{
$('#ManageCourseCareer').append('<p id="labelOnResource" style="font-size:30px; margin-bottom: -23px;color:#808080"><a href="#courses"style="font-size:30px;">'+languageDict.attributes.Courses+'</a>&nbsp&nbsp|&nbsp&nbsp<a href="#courseCareerPath" style="font-size:30px;text-decoration: underline;"checked data-toggle="toggle">'+languageDict.attributes.Career_Path+'</a></p>')
}
$('#ManageCourseCareer').append(addCourseCareer.el);
$("#EditCareerPath").hide();
$('#LCourse').multiselect().multiselectfilter();
$('#LCourse').multiselect({
checkAllText: App.languageDict.attributes.checkAll,
uncheckAllText: App.languageDict.attributes.unCheckAll,
selectedText: '# '+App.languageDict.attributes.Selected
});
$('#LCourse').multiselect().multiselectfilter("widget")[0].children[0].firstChild.data=App.languageDict.attributes.Filter;
$('.ui-multiselect-filter').find('input').attr('placeholder',App.languageDict.attributes.KeyWord_s);
$('#LCourse').attr("multiple", true);
$('#LCourse').multiselect("uncheckAll");
///--CarrerList
var courseCareerPath = new App.Collections.CourseCareerPath()
courseCareerPath.fetch({
async:false
});
$('#LCareer').multiselect().multiselectfilter();
$('#LCareer').multiselect({
checkAllText: App.languageDict.attributes.checkAll,
uncheckAllText: App.languageDict.attributes.unCheckAll,
selectedText: '# '+App.languageDict.attributes.Selected
});
$('#LCareer').multiselect().multiselectfilter("widget")[0].children[0].firstChild.data=App.languageDict.attributes.Filter;
$('.ui-multiselect-filter').find('input').attr('placeholder',App.languageDict.attributes.KeyWord_s);
$('#LCareer').attr("multiple", true);
$('#LCareer').multiselect("uncheckAll");
///
var directionOfLang = App.languageDict.get('directionOfLang');
applyCorrectStylingSheet(directionOfLang)
}

}))
})
26 changes: 26 additions & 0 deletions app/MyApp/app/collections/CourseCareerPath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$(function() {

App.Collections.CourseCareerPath = Backbone.Collection.extend({
url: function() {
if (this.CoursePathName!= undefined && this.MemberID!= undefined ) {
return App.Server + '/coursecareerpath/_design/bell/_view/GetCourseCareerByLevelNameMemberIds?key=["' +this.CoursePathName + '","' +this.MemberID+ '"]&include_docs=true'
} else if (this.CoursePathName!= undefined ) {
return App.Server + '/coursecareerpath/_design/bell/_view/getCourseCareerByName?key=["' +this.CoursePathName + '"]&include_docs=true'
} else {
return App.Server + '/coursecareerpath/_all_docs?include_docs=true'
}
},

parse: function(response) {
var models = []
_.each(response.rows, function(row) {
models.push(row.doc)
});
return models
},
initialize: function() {
this.sort_key = 'CoursePathName';
}
})

})
26 changes: 26 additions & 0 deletions app/MyApp/app/models/CoursecareerPath.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
$(function() {

App.Models.CoursecareerPath = Backbone.Model.extend({

idAttribute: "_id",
url: function() {
if (_.has(this, 'id')) {
var url = (_.has(this.toJSON(), '_rev')) ? App.Server + '/coursecareerpath/' + this.id + '?rev=' + this.get('_rev') // For UPDATE and DELETE
: App.Server + '/coursecareerpath/' + this.id // For READ
} else {
var url = App.Server + '/coursecareerpath' // for CREATE
}
return url
},
defaults: {
kind: 'coursecareerpath',//Saves kind of document according to corresponding db's.Mostly used in couch db views.
},
schema: {
Level_Name: 'Text',
CareerPathName:'Text',
Courselist: 'Text',
CourseIds:[],//Array:Multiple Courses
MemberID:'Text'
},
})
})
179 changes: 179 additions & 0 deletions app/MyApp/app/views/AddCourseCareer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,179 @@
$(function() {

App.Views.AddCourseCareer = Backbone.View.extend({
template: $('#template-addCourseCareer').html(),
vars: {},
searchText: "",
events: {
"click .Search": function(e) {
this.renderTable($('#searchText').val().toLowerCase())
},
"click #buttonCareer": function(){
},
"click #AddCareerPath": function() {
var a1 = $("#careerPath").val()
if(a1 != "")
this.saveCareerPath();
},
"click #CancelCoursePath": function(e) {
},
"click #Delete": function(e) {
var a = $(e.target).attr('data-id')
var career = new App.Models.CoursecareerPath({
_id: a
})
career.fetch({
async: false
})
career.destroy()
alert(App.languageDict.attributes.Selected);
location.reload();
},
"click #careerEdit": function(e) {
var currentId = $(e.target).attr("data-id");
$('#AddCareerPath').hide();
var courseCareer = new App.Models.CoursecareerPath({
_id : currentId
})
courseCareer.fetch({
async: false
});
$('#careerPath').val(courseCareer.attributes.CoursePathName);
$('#UpdateCareerPath').css('display','');
$('#UpdateCareerPath').attr('data-id',currentId);
},
"click #UpdateCareerPath": function(e) {
this.saveCareerPath($('#UpdateCareerPath').attr('data-id'));
},
},

renderTable: function(searchText) {
App.startActivityIndicator()
var that = this
var career = new App.Collections.CourseCareerPath()
career.CoursePathName = searchText
career.fetch({
success: function(response){
var careerTable = new App.Views.AddCourseCareer({
collection: response
})
$(".btable").append("<tr><td>"+career.models[0].attributes.CoursePathName+"</td><td><ul><li>"+career.models[0].attributes.Courses+"</ul></li></td><td></td></tr>")
App.stopActivityIndicator()
},
error: function() {
App.stopActivityIndicator()
}
})
},

saveCareerPath: function(previousId){
var selectedCourseId = []
var selectedCourseName = []
var selectedCareerIds = []
if(previousId){
var courseCareer = new App.Models.CoursecareerPath({
_id : previousId
})
courseCareer.fetch({
async: false
});
$('#LCourse option:selected').each(function(){
if ($(this).length) {
selectedCourseId.push($(this).val());
selectedCourseName.push($(this).text());
}
});
$('#LCareer option:selected').each(function(){
if ($(this).length) {
selectedCareerIds.push($(this).val());
}
});
var courseCareerTitle = $('#careerPath').val()
courseCareer.set('CareerPathName',courseCareerTitle);
courseCareer.set('Courses',selectedCourseName);
courseCareer.set('CourseIds',selectedCourseId);
courseCareer.set('MemberID',$.cookie('Member._id'));
courseCareer.set('requiredCareerPathIds',selectedCareerIds);
courseCareer.save(null, {
success: function(response){
location.reload();
},
error: function() {
console.log("Not Saved")
}
})
location.reload();
} else {
$('#LCourse option:selected').each(function(){
if ($(this).length) {
selectedCourseId.push($(this).val());
selectedCourseName.push($(this).text());
}
});
$('#LCareer option:selected').each(function(){
if ($(this).length) {
selectedCareerIds.push($(this).val());
}
});
var courseCareerTitle = $('#careerPath').val()
var savecoursecareer = new App.Models.CoursecareerPath()
savecoursecareer.set('CoursePathName',courseCareerTitle);
savecoursecareer.set('Courses',selectedCourseName);
savecoursecareer.set('CourseIds',selectedCourseId);
savecoursecareer.set('MemberID',$.cookie('Member._id'));
savecoursecareer.set('requiredCareerPathIds',selectedCareerIds);
savecoursecareer.save(null, {
success: function(response){
location.reload();
},
error: function(status) {
console.log(status)
console.log("Not Saved")
}
})
}
},

render: function() {
var arrcourses = []
var arrCourseIds = []
for(var i = 0; i <this.collection.models.length; i++){
if(this.collection.models[i].id != '_design/bell'){
var courseslist = this.collection.models[i].attributes.CourseTitle
var courseId = this.collection.models[i].attributes._id
arrcourses.push(courseslist)
arrCourseIds.push(courseId)
}

}
var courseCareers = new App.Collections.CourseCareerPath()
courseCareers.memberId = $.cookie('Member._id');
courseCareers.fetch({
async:false
});

this.vars.careerList = [];
for(var i = 0; i < (courseCareers.length); i++) {
if(courseCareers.models[i].attributes._id !== "_design/bell"){
this.vars.careerList.push(courseCareers.models[i].attributes);
}
}
this.vars.Courselist = arrcourses
this.vars.Courseid = arrCourseIds
this.vars.Course_Length = this.collection.models.length-1
////PushRequired ID
this.vars.CareerList = [];
this.vars.careerListIds = [];
this.vars.careerlength = null;
for(var j = 0; j< courseCareers.length; j++){
if(courseCareers.models[j].attributes._id != '_design/bell'){
this.vars.CareerList.push(courseCareers.models[j].attributes.CoursePathName);
this.vars.careerListIds.push(courseCareers.models[j].attributes._id);
this.vars.careerlength = j + 1
}
}
this.$el.html(_.template(this.template,this.vars))
},
})

})
51 changes: 51 additions & 0 deletions app/MyApp/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1438,6 +1438,57 @@ <h4 style="width:25em;word-wrap:break-word;">
</tr>
</table>
</script>

<script type="text/template" id="template-addCourseCareer">
<input id="searchText" type="Text" placeholder="Course Career Name" style="margin-top: -137px; margin-left: 1056px; height: 28px; width: 170px;">
<button style="margin-top: -183px; margin-left: 1251px;" class="Search btn btn-info" id="SearchCoursePath" >Search</button>
<div class ="multipleCourse">
<form>
<label for="cpName"><b><%= languageDict.attributes.Career_Path_Name %></b></label>
<input type="text" id="careerPath" placeholder="Career Path Name" style="padding: 2px; margin-top: 8px;" required>
<label for="LCourse"><b><%= languageDict.attributes.List_of_Courses %></b></label>
<select id="LCourse">
<%for(var i =0; i<Course_Length;i++){%>
<option value='<%=Courseid[i]%>'><%=Courselist[i]%></option>
<%}%>
</select>
<label for="LCareer"><b><%= languageDict.attributes.Required_Course_Career_Path %></b></label>

<select id="LCareer">

<% for (var j =0; j<careerlength;j++){%>
<option value ='<%=CareerList[j]%>'><%=CareerList[j]%></option>
<%}%>
</select>
<button id="AddCareerPath" class="course btn btn-success" style="margin-top: -1px;"><%= languageDict.attributes.Create_Career_Path %></button>
<button id="UpdateCareerPath" class="course btn btn-success" style=" margin-top: -1px; display:none;"><%= languageDict.attributes.Update_Career_Path %></button>
</form>
</div>
<div>
<table class="btable btable-striped">
<tbody>
<tr>
<th><%=languageDict.attributes.Career_Path_Name%></th>
<th><%=languageDict.attributes.Courses_List%></th>
<th><%= languageDict.attributes.Career_List %></th>
<th><%= languageDict.attributes.Actions %></th>
</tr>
<%for (var i=0; i < careerList.length; i++) {%>
<tr>
<td><%= careerList[i].CoursePathName %></td>
<td><ul><li><%= careerList[i].Courses %></li></ul></td>
<td><ul><li><%= careerList[i].requiredCareerPathIds%></li></ul></td>
<td>
<a role="button" id="careerEdit" data-id = <%= careerList[i]._id %> class='course btn btn-success'><%=languageDict.attributes.EditLabel%></a>
<a role="button" data-id="<%= careerList[i]['_id'] %>" class='destroy btn btn-danger' id='Delete'><%=languageDict.attributes.DeleteLabel%></a>
</td>
</tr>
<% } %>
</tbody>
</table>
</div>
</script>

<script type="text/html" id="template-courseLevelsTable">
<h3 class="bigheader">
<div style="width:95%"><%= languageDict.attributes.Step%>-<%= step%>: <b>&nbsp;&nbsp; <%=title%></b>
Expand Down
Loading

0 comments on commit 9eaffa2

Please sign in to comment.