diff --git a/app/MyApp/app/collections/CourseCareerPath b/app/MyApp/app/collections/CourseCareerPath new file mode 100644 index 000000000..23ddf3394 --- /dev/null +++ b/app/MyApp/app/collections/CourseCareerPath @@ -0,0 +1,29 @@ +$(function() { + + App.Collections.CourseCareerPath = Backbone.Collection.extend({ + + url: function() { + if (this.CoursePathName != "" && this.MemberID != "") { + return App.Server + '/coursecareerpath/_design/bell/_view/GetCourseCareerByLevelNameMemberIds/?key=["' +this.CoursePathName + '","' +this.MemberID+ '"]&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 + }, + + comparator: function(model) { + var type = model.get('Type') + if (type) return type.toLowerCase() + }, + + model: App.Models.CourseacreerPath + }) + +}) diff --git a/app/MyApp/app/models/CoursecareerPath.js b/app/MyApp/app/models/CoursecareerPath.js index 3d529abc5..f5c0dfebe 100644 --- a/app/MyApp/app/models/CoursecareerPath.js +++ b/app/MyApp/app/models/CoursecareerPath.js @@ -17,9 +17,10 @@ $(function() { }, schema: { Level_Name: 'Text', - Course_Title: 'Text', + CoursePathName:'Text', + Courselist: 'Text', CourseIds:[],//Array:Multiple Courses - CourseCareer: []//Array:Arranging the Courses + MemberID:'Text' }, }) }) \ No newline at end of file diff --git a/app/MyApp/app/views/AddCourseCareer.js b/app/MyApp/app/views/AddCourseCareer.js index 1cc4d9d94..f8a35b508 100644 --- a/app/MyApp/app/views/AddCourseCareer.js +++ b/app/MyApp/app/views/AddCourseCareer.js @@ -5,7 +5,7 @@ $(function() { vars: {}, events: { "click #AddCareerPath": function() { - this.saveCareerPath(); + this.saveCareerPath(); }, "click #CancelCOursePath": function(e) { this.saveCareerPath(); @@ -17,18 +17,30 @@ $(function() { }, saveCareerPath: function(){ - var levelname = $('#level').val() + var levelname = $('#levelSelect').val() + var coursecareerpath = $('#careerPath').val() + var res = $('input:checked[name="multiselect_LCourse"]').val() + /* if ($("input[name = 'LCourse[]']").val() != undefined) { + var res = []; + $("input[name = 'LCourse[]']:checked").each(function(index) { + if($(this).is(':checked')==true){ + res.push(decodeURI($(this).val())); + } + }); + } + console.log(res)*/ var coursetitle = $('#LCourse').val() var arrcourseId = [] - for(var i = 0; i '+App.languageDict.attributes.Finish+'  '); this.vars.Courselist = arrcourses - this.vars.Course_Length = this.collection.models.length + this.vars.Course_Length = this.collection.models.length-1 this.$el.html(_.template(this.template,this.vars)) }, - - }) }) diff --git a/app/MyApp/index.html b/app/MyApp/index.html index f44158684..981f940fc 100644 --- a/app/MyApp/index.html +++ b/app/MyApp/index.html @@ -185,6 +185,7 @@ + diff --git a/databases/coursecareerpath.js b/databases/coursecareerpath.js index b82515352..5cdfdb154 100644 --- a/databases/coursecareerpath.js +++ b/databases/coursecareerpath.js @@ -13,10 +13,10 @@ ddoc.views = { } } }, - GetCourseCareerByMember: { + GetCourseCareerByLevelNameMemberIds: { map: function(doc) { - if (this.MemberID != "") { - emit([doc.MemberID], doc); + if (this.CoursePathName!= "" && this.MemberID != "" ) { + emit([doc.CoursePathName,doc.MemberID], doc); } } },