This repository has been archived by the owner on Nov 4, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic Lesson saving + Lesson Model treatment
- We can select a course, an attendee, a teacher, a room and press "Save" to get it pushed to Parse - LessonFactory get the defineProperty Model treatment with getters and setters - createLesson.html: on a <select> element, ng-model creates an entire new scope so we need to pass it the $parent reference to catch it in the createLessonCtrl. see angular-ui/ui-select#18
- Loading branch information
Showing
3 changed files
with
77 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,47 @@ | ||
angular.module('studionic.controllers') | ||
|
||
.controller('CreateLessonCtrl', ['$scope','$stateParams','CourseFactory','RoleFactory','RoomFactory', function($scope, $stateParams, CourseFactory, RoleFactory, RoomFactory){ | ||
.controller('CreateLessonCtrl', ['$scope','$stateParams','CourseFactory','RoleFactory','RoomFactory','LessonFactory', function($scope, $stateParams, CourseFactory, RoleFactory, RoomFactory, LessonFactory){ | ||
|
||
$scope.selectedCourse; | ||
$scope.selectedAttendee; | ||
$scope.selectedTeacher; | ||
$scope.selectedRoom; | ||
|
||
CourseFactory.getAll().then(function(courses){ | ||
$scope.courses = courses; | ||
console.log(courses); | ||
}); | ||
RoleFactory.getAll().then(function(groups){ | ||
$scope.attendees = groups; | ||
console.log(groups); | ||
}); | ||
RoleFactory.getTeachers().then(function(teachers){ | ||
$scope.teachers = teachers; | ||
console.log(teachers); | ||
}); | ||
RoomFactory.getAll().then(function(rooms){ | ||
$scope.rooms = rooms; | ||
console.log(rooms); | ||
}); | ||
|
||
$scope.saveLesson = function(){ | ||
var lesson = new LessonFactory; | ||
|
||
try{ | ||
if(!this.selectedCourse) | ||
throw "Please select a Course"; | ||
if(!this.selectedAttendee) | ||
throw "Please select an Attendee"; | ||
if(!this.selectedTeacher) | ||
throw "Please select a Teacher"; | ||
if(!this.selectedRoom) | ||
throw "Please select a Room"; | ||
|
||
|
||
lesson.relation("course").add(this.selectedCourse); | ||
lesson.relation("attendees").add(this.selectedAttendee); | ||
lesson.relation("speakers").add(this.selectedTeacher); | ||
lesson.relation("room").add(this.selectedRoom); | ||
lesson.save().then(function(lessonAgain){ | ||
$scope.createLessonModal.hide(); | ||
}); | ||
}catch(error){alert(error);} | ||
}; | ||
|
||
}]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters