Commit 1167ab44a0a38136da297ccc26efd4ec3db08804

Authored by Rachel Lee
1 parent 89514560e7

Feed submit is good and flashcard directive is gooder

Showing 4 changed files with 23 additions and 25 deletions Side-by-side Diff

scripts/FeedController.js View file @ 1167ab4
... ... @@ -7,9 +7,8 @@
7 7  
8 8 $http.get('/api/sections/' + sectionId + '/feed/').
9 9 success(function (data) {
10   - for (var i = 0; i < data.length; i++) {
11   - $scope.cards.push({'title': data[i].title, 'content': data[i].text});
12   - }
  10 + console.log(data);
  11 + $scope.cards = data;
13 12 }).
14 13 error(function (err) {
15 14 console.log('pulling feed failed');
16 15  
17 16  
18 17  
19 18  
... ... @@ -22,29 +21,30 @@
22 21  
23 22 $scope.pullCard = function(card) {
24 23 /*
25   - $http.post('/api/flashcards/pk/pull',
  24 + $http.post('/api/flashcards/' + card + '/pull',
26 25 {}
27 26 */
28 27 var index = $scope.cards.indexOf(card);
29 28  
30 29 console.log($scope.cards[index]);
31 30 };
32   -
  31 +
33 32 $scope.pushCard = function () {
34 33 console.log('make! card content:' + $scope.text);
35 34 var pushed = new Date(Date.now());
36 35 console.log(pushed.toString());
37 36 text = $scope.text;
38 37 // attempt to make card :(
39   - $http.post('/api/flashcards/', {
  38 + var myCard = {
40 39 'text': $scope.text,
41 40 'material_date': pushed,
42 41 'mask': '[]',
43 42 section: sectionId
44   - }).
  43 + }
  44 + $http.post('/api/flashcards/', myCard).
45 45 success(function (data) {
46 46 console.log('pushed a card!');
47   - $scope.cards.push({content: text});
  47 + $scope.cards.push(myCard);
48 48 }).
49 49 error(function (error) {
50 50 console.log('haha, n00b');
scripts/FlashcardDirective.js View file @ 1167ab4
... ... @@ -5,12 +5,11 @@
5 5 templateUrl: '/app/templates/flashcard.html',
6 6 restrict: 'E',
7 7 scope: {
8   - content: '=flashcardContent' //flashcard-content in outer scope
  8 + flashcard: '=flashcardObj' // flashcard-obj in html
9 9 },
10 10 link: function(scope) {
11 11 console.log("HELLO FROM FLASHCARD DIRECTIVE");
12   - console.log(scope.content);
13   -
  12 + console.log(scope.flashcard);
14 13  
15 14 // Put flashcard-specific functions here.
16 15 // This will probably include add/hide/modals/etc.
templates/feed.html View file @ 1167ab4
... ... @@ -7,7 +7,7 @@
7 7 <!--cards-->
8 8 <div class="row">
9 9 <div ng-repeat="card in cards">
10   - <flashcard flashcard-content="card.content"/>
  10 + <flashcard flashcard-obj="card"/>
11 11 </div>
12 12 </div>
13 13  
14 14  
15 15  
16 16  
... ... @@ -27,24 +27,23 @@
27 27 </div>
28 28 </div>
29 29  
30   - <div id="newCard" class="modal bottom-sheet">
31   - <div class="modal-content">
32   - <form>
  30 + <form>
  31 + <div id="newCard" class="modal bottom-sheet">
  32 + <div class="modal-content">
33 33 <div class="row">
34 34 <div class="input-field">
35 35 <i class="mdi-editor-mode-edit prefix"></i>
36   - <textarea class="materialize-textarea" ng-model="text" type="text"></textarea>
  36 + <input class="materialize-textarea" ng-model="text" type="text"/>
37 37 <label id="newCardSign" for="newCard">New Flashcard</label>
38 38 </div>
39 39 </div>
40   - </form>
  40 + </div>
  41 + <div class="modal-footer">
  42 + <button class="btn modal-close" type="submit" ng-click="pushCard()">Submit
  43 + <i class="mdi-content-send right"></i>
  44 + </button>
  45 + </div>
41 46 </div>
42   - <div class="modal-footer">
43   - <button class="btn modal-close" type="submit" ng-click="pushCard()">Submit
44   - <i class="mdi-content-send right"></i>
45   - </button>
46   - </div>
47   - </div>
48   - </div>
  47 + </form>
49 48 </body>
templates/flashcard.html View file @ 1167ab4
1 1 <div class="card flashy">
2 2 <div class="card-content">
3   - <p>{{content}}</p>
  3 + <p>{{flashcard.text}}</p>
4 4 </div>
5 5 <div class="card-overlay">
6 6 <a href="#">