From a1dbaa3590eb52851972547dd63257cf669589bc Mon Sep 17 00:00:00 2001 From: rnlee0054 Date: Tue, 19 May 2015 11:20:38 -0700 Subject: [PATCH] Deck WIP, flashcard directive now has pull card from feed but doesn't check it's already pulled --- gjslint.conf | 2 +- scripts/FeedController.js | 10 +++--- scripts/FlashcardDirective.js | 12 +++++-- templates/deck.html | 76 +++++++++++++++++-------------------------- templates/flashcard.html | 2 +- 5 files changed, 45 insertions(+), 57 deletions(-) diff --git a/gjslint.conf b/gjslint.conf index b1a8d11..884230f 100644 --- a/gjslint.conf +++ b/gjslint.conf @@ -1 +1 @@ ---max_line_length=140 +--max_line_length=80 diff --git a/scripts/FeedController.js b/scripts/FeedController.js index e0e5a01..19fc1f6 100644 --- a/scripts/FeedController.js +++ b/scripts/FeedController.js @@ -19,15 +19,13 @@ angular.module('flashy.FeedController', ['ui.router']). console.log('go to deck'); }; + /* $scope.pullCard = function(card) { - /* - $http.post('/api/flashcards/' + card + '/pull', - {} - */ - var index = $scope.cards.indexOf(card); + $http.post('/api/flashcards/' + card.id + '/pull/', card); - console.log($scope.cards[index]); + console.log("Pulling card w/ id: " + card.id); }; + */ $scope.pushCard = function () { console.log('make! card content:' + $scope.text); diff --git a/scripts/FlashcardDirective.js b/scripts/FlashcardDirective.js index 7244e1f..b077b45 100644 --- a/scripts/FlashcardDirective.js +++ b/scripts/FlashcardDirective.js @@ -1,18 +1,24 @@ angular.module('flashy.FlashcardDirective', []). -directive('flashcard', function() { +directive('flashcard', ['$http', function($http) { return { templateUrl: '/app/templates/flashcard.html', restrict: 'E', scope: { flashcard: '=flashcardObj' // flashcard-obj in html }, - link: function(scope) { + link: function(scope, $scope) { console.log("HELLO FROM FLASHCARD DIRECTIVE"); console.log(scope.flashcard); + scope.pullCard = function(flashcard) { + $http.post('/api/flashcards/' + flashcard.id + '/pull/', flashcard); + console.log("pulled flashcard #" + flashcard.id); + } + + // Put flashcard-specific functions here. // This will probably include add/hide/modals/etc. } }; -}); +}]); diff --git a/templates/deck.html b/templates/deck.html index 70e7487..2770a0c 100644 --- a/templates/deck.html +++ b/templates/deck.html @@ -1,56 +1,40 @@ - - - - -
- -
-
-
-
-
-

{{card.content}}

-
- -
- - - - + +
+
+ + + -
- - diff --git a/templates/flashcard.html b/templates/flashcard.html index e7d2a45..997a6d5 100644 --- a/templates/flashcard.html +++ b/templates/flashcard.html @@ -4,7 +4,7 @@
-
+
-- 1.9.1