From 1167ab44a0a38136da297ccc26efd4ec3db08804 Mon Sep 17 00:00:00 2001
From: rnlee0054 <rnl002@ucsd.edu>
Date: Tue, 19 May 2015 10:22:32 -0700
Subject: [PATCH] Feed submit is good and flashcard directive is gooder

---
 scripts/FeedController.js     | 16 ++++++++--------
 scripts/FlashcardDirective.js |  5 ++---
 templates/feed.html           | 25 ++++++++++++-------------
 templates/flashcard.html      |  2 +-
 4 files changed, 23 insertions(+), 25 deletions(-)

diff --git a/scripts/FeedController.js b/scripts/FeedController.js
index 46ea84b..e0e5a01 100644
--- a/scripts/FeedController.js
+++ b/scripts/FeedController.js
@@ -7,9 +7,8 @@ angular.module('flashy.FeedController', ['ui.router']).
 
         $http.get('/api/sections/' + sectionId + '/feed/').
             success(function (data) {
-                for (var i = 0; i < data.length; i++) {
-                    $scope.cards.push({'title': data[i].title, 'content': data[i].text});
-                }
+                console.log(data);
+                $scope.cards = data;
             }).
             error(function (err) {
                 console.log('pulling feed failed');
@@ -22,29 +21,30 @@ angular.module('flashy.FeedController', ['ui.router']).
 
         $scope.pullCard = function(card) {
             /*
-            $http.post('/api/flashcards/pk/pull',
+            $http.post('/api/flashcards/' + card + '/pull',
                 {}
                 */
             var index = $scope.cards.indexOf(card);
 
             console.log($scope.cards[index]);
         };
-
+ 
         $scope.pushCard = function () {
             console.log('make! card content:' + $scope.text);
             var pushed = new Date(Date.now());
             console.log(pushed.toString());
             text = $scope.text;
             // attempt to make card :(
-            $http.post('/api/flashcards/', {
+            var myCard = {
                 'text': $scope.text,
                 'material_date': pushed,
                 'mask': '[]',
                 section: sectionId
-            }).
+            }
+            $http.post('/api/flashcards/', myCard).
                 success(function (data) {
                     console.log('pushed a card!');
-                    $scope.cards.push({content: text});
+                    $scope.cards.push(myCard);
                 }).
                 error(function (error) {
                     console.log('haha, n00b');
diff --git a/scripts/FlashcardDirective.js b/scripts/FlashcardDirective.js
index 8118a47..7244e1f 100644
--- a/scripts/FlashcardDirective.js
+++ b/scripts/FlashcardDirective.js
@@ -5,12 +5,11 @@ directive('flashcard', function() {
         templateUrl: '/app/templates/flashcard.html',
         restrict: 'E',
         scope: {
-            content: '=flashcardContent' //flashcard-content in outer scope
+            flashcard: '=flashcardObj' // flashcard-obj in html
         },
         link: function(scope) {
             console.log("HELLO FROM FLASHCARD DIRECTIVE");
-            console.log(scope.content);
-
+            console.log(scope.flashcard);
 
             // Put flashcard-specific functions here.
             // This will probably include add/hide/modals/etc.
diff --git a/templates/feed.html b/templates/feed.html
index 5ed4e9f..375775d 100644
--- a/templates/feed.html
+++ b/templates/feed.html
@@ -7,7 +7,7 @@
       <!--cards-->
       <div class="row">
         <div ng-repeat="card in cards">
-          <flashcard flashcard-content="card.content"/>
+          <flashcard flashcard-obj="card"/>
         </div>
       </div>
 
@@ -27,23 +27,22 @@
         </div>
       </div>
 
-      <div id="newCard" class="modal bottom-sheet">
-        <div class="modal-content">
-          <form>
+      <form>
+        <div id="newCard" class="modal bottom-sheet">
+          <div class="modal-content">
             <div class="row">
               <div class="input-field">
                 <i class="mdi-editor-mode-edit prefix"></i>
-                <textarea class="materialize-textarea" ng-model="text" type="text"></textarea>
+                <input class="materialize-textarea" ng-model="text" type="text"/>
                 <label id="newCardSign" for="newCard">New Flashcard</label>
               </div>
             </div>
-          </form>
+          </div>
+          <div class="modal-footer">
+            <button class="btn modal-close" type="submit" ng-click="pushCard()">Submit
+              <i class="mdi-content-send right"></i>
+            </button>
+          </div>
         </div>
-      <div class="modal-footer">
-          <button class="btn modal-close" type="submit" ng-click="pushCard()">Submit
-            <i class="mdi-content-send right"></i>
-          </button>
-        </div>
-      </div>
-     </div>
+      </form>
 </body>
diff --git a/templates/flashcard.html b/templates/flashcard.html
index 7ae237e..e7d2a45 100644
--- a/templates/flashcard.html
+++ b/templates/flashcard.html
@@ -1,6 +1,6 @@
     <div class="card flashy">
       <div class="card-content">
-        <p>{{content}}</p>
+        <p>{{flashcard.text}}</p>
       </div>
       <div class="card-overlay">
         <a href="#">
-- 
1.9.1