Commit 6fd36f978c0cfd21cca17c1c5e10b758d343ac60

Authored by Andrew Buss
1 parent 742c7cd5f8

autocomplete is working

Showing 7 changed files with 62 additions and 55 deletions Side-by-side Diff

... ... @@ -4,7 +4,7 @@
4 4 <head>
5 5 <link type="text/css" rel="stylesheet" href="styles/materialize.min.css" media="screen,projection"/>
6 6 <!--<link rel="stylesheet" href="styles/bootstrap-3.3.4-dist/css/bootstrap.css"/>-->
7   - <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.8.3/angular-material.min.css">
  7 + <link rel="stylesheet" href="https://ajax.googleapis.com/ajax/libs/angular_material/0.9.0/angular-material.min.css">
8 8  
9 9 <link rel="stylesheet" href="flashy.css"/>
10 10 </head>
scripts/ClassAddController.js View file @ 6fd36f9
1 1 angular.module('flashy.ClassAddController', ['ui.router', 'angucomplete-alt', 'ngMaterial']).
2 2  
3   - controller('ClassAddController', ['$scope', '$state', '$http', function ($scope, $state, $http) {
  3 + controller('ClassAddController', ['$scope', '$state', '$http', function($scope, $state, $http) {
4 4  
5   - $scope.trySearch = function (searchText) {
  5 + $scope.trySearch = function(searchText) {
6 6 return $http.get('/api/sections/search/', {
7 7 params: {
8 8 q: searchText
9 9 }
10   - }).then(function (response) {
  10 + }).then(function(response) {
11 11 return response.data;
12   - })
  12 + });
13 13 };
14 14  
15   - $scope.searchText = "";
  15 + $scope.searchText = '';
16 16  
17 17 /*$scope.trySearch = function() {
18 18 $http.get('/api/sections/search', [$scope.searchText]).
scripts/DeckController.js View file @ 6fd36f9
1 1 var app = angular.module('flashy.DeckController', ['ui.router']);
2 2  
3 3 app.controller('DeckController', ['$scope', '$http', function($scope, $http) {
4   -
5 4  
6   -
  5 +
  6 +
7 7 $scope.cards = [];
8   -
9 8  
10 9  
11   - $scope.cards[0] = { "id": 1, "title": "title1", "content": "abc" };
12   - $scope.cards[1] = { "id": 2, "title": "title2", "content": "xyz" };
13   - $scope.cards[2] = { "id": 2, "title": "title3", "content": "qwe" };
14 10  
  11 + $scope.cards[0] = { 'id': 1, 'title': 'title1', 'content': 'abc' };
  12 + $scope.cards[1] = { 'id': 2, 'title': 'title2', 'content': 'xyz' };
  13 + $scope.cards[2] = { 'id': 2, 'title': 'title3', 'content': 'qwe' };
15 14  
16   - $scope.removeCard = function (item) {
17 15  
  16 + $scope.removeCard = function(item) {
18 17  
  18 +
19 19 var index = $scope.cards.indexOf(item);
20 20  
21   - $scope.cards.splice(index, 1);
  21 + $scope.cards.splice(index, 1);
22 22  
23   - alert("removed card");
24   - }
  23 + alert('removed card');
  24 + };
25 25  
26 26  
27 27 $http.get('/api/sections/{pk}/deck').
28   - success(function (data) {
  28 + success(function(data) {
29 29  
30 30  
31 31 for (var i = 0; i < data.length; i++) {
32   - cards.push({ "title": data[i].title, "content": data[i].content });
  32 + cards.push({ 'title': data[i].title, 'content': data[i].content });
33 33 }
34 34 }).
35   - error(function (data) {
  35 + error(function(data) {
36 36  
37   - console.log("no cards?!!");
  37 + console.log('no cards?!!');
38 38  
39 39 });
40   -
  40 +
41 41  
42 42  
43 43  
scripts/FeedController.js View file @ 6fd36f9
... ... @@ -20,20 +20,20 @@
20 20 console.log(pushed.toString());
21 21  
22 22 // attempt to make card :(
23   - $http.post('/api/flashcards/', {"text": $scope.text, "pushed": pushed, "mask": []}).
  23 + $http.post('/api/flashcards/', {'text': $scope.text, 'pushed': pushed, 'mask': []}).
24 24 success(function(data) {
25   - console.log("No way, really?");
  25 + console.log('No way, really?');
26 26 }).
27 27 error(function(error) {
28   - console.log("haha, n00b");
  28 + console.log('haha, n00b');
29 29 });
30 30  
31 31 $scope.create = false; // hide make flashcard
32   - $scope.text = "";
  32 + $scope.text = '';
33 33 };
34 34  
35   - $scope.flashcard = "hi i am a flashcard";
36   - $scope.text = "";
  35 + $scope.flashcard = 'hi i am a flashcard';
  36 + $scope.text = '';
37 37  
38 38 }]);
scripts/LoginController.js View file @ 6fd36f9
1 1 angular.module('flashy.LoginController', ['ui.router']).
2 2  
3 3 controller('LoginController', ['$scope', '$state', '$http', 'UserService',
4   - function ($scope, $state, $http, UserService) {
  4 + function($scope, $state, $http, UserService) {
5 5 'use strict';
6 6  
7 7 $scope.uniqueError = false;
8 8 $scope.loginError = false;
9   - $scope.login = function (email, password) {
  9 + $scope.login = function(email, password) {
10 10 $http.post('/api/login', JSON.stringify({
11 11 'email': email,
12 12 'password': password
13 13 })).
14   - success(function (data) {
  14 + success(function(data) {
15 15 UserService.getUserData();
16 16 $state.go('feed');
17 17 console.log(data);
18 18 }).
19   - error(function (data, status, header, config) {
  19 + error(function(data, status, header, config) {
20 20 if (data.detail) { // assume 'invalid email or pass'
21 21 $scope.loginError = true;
22 22 }
23 23 console.log(data);
24 24 });
25 25 };
26   - $scope.signUp = function (email, password) {
  26 + $scope.signUp = function(email, password) {
27 27 $http.post('/api/register', JSON.stringify({
28 28 'email': email,
29 29 'password': password
30 30 })).
31   - success(function (data) {
  31 + success(function(data) {
32 32 $state.go('feed');
33 33 console.log(data);
34 34 }).
35   - error(function (data, status, headers, config) {
  35 + error(function(data, status, headers, config) {
36 36 console.log(data.email);
37 37 if (data.email == 'This field is required.') {
38 38 $scope.invalid = true;
... ... @@ -46,7 +46,7 @@
46 46 });
47 47  
48 48 };
49   - $scope.triggerPasswordReset = function () {
  49 + $scope.triggerPasswordReset = function() {
50 50 $state.go('requestpasswordreset');
51 51 };
52 52 }
scripts/RootController.js View file @ 6fd36f9
1 1 angular.module('flashy.RootController', ['ui.router']).
2 2  
3   - controller('RootController', ['$scope', '$state', 'UserService', function ($scope, $state, UserService) {
  3 + controller('RootController', ['$scope', '$state', 'UserService', function($scope, $state, UserService) {
4 4 if (UserService.isLoggedIn()) $state.go('login');
5 5 else $state.go('addclass');
6 6 }]);
templates/addclass.html View file @ 6fd36f9
1   -<div layout="column">
2   - <div>
3   - <md-content layout-padding layout="column">
4   - <form>
5   - <md-autocomplete flex
6   - nd-no-cache="noCache"
7   - md-selected-item="selectedItem"
8   - md-search-text="searchText"
9   - md-items="item in trySearch(searchText)"
10   - md-item-text="item.short_name"
11   - md-floating-label="Search Classes">
12   - <md-item-template>
13   - <span md-highlight-text="searchText">{{item.long_name}}</span>
14   - </md-item-template>
15   - <md-not-found>
16   - No matching classes found.
17   - </md-not-found>
18   - </md-autocomplete>
  1 +<div>
  2 +
  3 + <div layout="column">
  4 + <md-content layout-padding="" layout="column" style="overflow:hidden">
  5 +
  6 + <form ng-submit="$event.preventDefault()">
  7 + <div layout="column">
  8 + <md-autocomplete flex=""
  9 + md-autofocus="true"
  10 + md-selected-item="selectedItem"
  11 + md-search-text="searchText"
  12 + md-items="item in trySearch(searchText)"
  13 + md-item-text="item.short_name"
  14 + >
  15 + <md-item-template>
  16 + <div layout="row">
  17 + <div>{{item.short_name}}: {{item.course_title}} ({{item.instructor}})</div>
  18 + <div style="margin-left:auto;text-align:right;padding-left:30px">{{item.lecture_times}}</div>
  19 + </div>
  20 + </md-item-template>
  21 + <md-not-found>
  22 + No classes match "{{searchText}}".
  23 + </md-not-found>
  24 + </md-autocomplete>
  25 + </div>
19 26 </form>
20 27 </md-content>
21 28 </div>