Commit 1b2fe2fdfe75316fa0c22611d4b0beeda78585c2

Authored by Andrew Buss
1 parent 06a2cb08d5

fixed view feed button on deck view

Showing 2 changed files with 52 additions and 55 deletions Side-by-side Diff

scripts/DeckController.js View file @ 1b2fe2f
1 1 var app = angular.module('flashy.DeckController', ['ui.router']);
2 2  
3 3 app.controller('DeckController', ['$scope', '$state', '$http', '$stateParams',
4   - function($scope, $state, $http, $stateParams) {
  4 + function ($scope, $state, $http, $stateParams) {
5 5 // cards array
6 6 sectionId = $stateParams.sectionId;
  7 + $scope.sectionId = sectionId;
7 8 $scope.cards = [];
8 9  
9   - // Populate our page with cards.
10   - $http.get('/api/sections/' + sectionId + '/deck/').
11   - success(function(data) {
12   - console.log(data);
13   - $scope.cards = data;
14   - }).
15   - error(function(err) {
16   - console.log('pulling feed failed');
17   - });
  10 + // Populate our page with cards.
  11 + $http.get('/api/sections/' + sectionId + '/deck/').
  12 + success(function (data) {
  13 + console.log(data);
  14 + $scope.cards = data;
  15 + }).
  16 + error(function (err) {
  17 + console.log('pulling feed failed');
  18 + });
18 19  
19   - /* Lets page refresh the cards shown on the page. */
20   - $scope.refreshCards = function() {
21   - var myDelay = 260; // ms
  20 + /* Lets page refresh the cards shown on the page. */
  21 + $scope.refreshCards = function () {
  22 + var myDelay = 260; // ms
22 23  
23   - setTimeout(function() {
24   - $http.get('/api/sections/' + sectionId + '/deck/').
25   - success(function(data) {
26   - console.log(data);
27   - $scope.cards = data;
28   - console.log('success in refresh cards...');
29   - }).
30   - error(function(err) {
31   - console.log('refresh fail');
32   - });
33   - }, myDelay);
34   - }
  24 + setTimeout(function () {
  25 + $http.get('/api/sections/' + sectionId + '/deck/').
  26 + success(function (data) {
  27 + console.log(data);
  28 + $scope.cards = data;
  29 + console.log('success in refresh cards...');
  30 + }).
  31 + error(function (err) {
  32 + console.log('refresh fail');
  33 + });
  34 + }, myDelay);
  35 + };
35 36  
36 37  
37   - /* all kmach's stuff below, do not touch */
38   - // reorganize cards in array based on time
39   - $scope.filter = function(card) {
  38 + /* all kmach's stuff below, do not touch */
  39 + // reorganize cards in array based on time
  40 + $scope.filter = function (card) {
40 41  
41 42 // get index of card
42 43 var index = $scope.cards.indexOf(card);
... ... @@ -47,7 +48,7 @@
47 48 };
48 49  
49 50 // remove card from deck
50   - $scope.removeCard = function(card) {
  51 + $scope.removeCard = function (card) {
51 52  
52 53 // get index of card
53 54 var index = $scope.cards.indexOf(card);
... ... @@ -58,7 +59,7 @@
58 59 };
59 60  
60 61  
61   - $scope.editCard = function(card) {
  62 + $scope.editCard = function (card) {
62 63  
63 64 var index = $scope.cards.indexOf(card);
64 65  
65 66  
... ... @@ -67,12 +68,12 @@
67 68 opacity: .5, // Opacity of modal background
68 69 in_duration: 300, // Transition in duration
69 70 out_duration: 200, // Transition out duration
70   - ready: function() {
  71 + ready: function () {
71 72  
72 73  
73 74 $scope.editableContent = $scope.cards[index].content;
74 75 }, // Callback for Modal open
75   - complete: function() {
  76 + complete: function () {
76 77  
77 78 $scope.cards[index].content = $scope.editableContent;
78 79  
templates/deck.html View file @ 1b2fe2f
1 1 <div class="row">
2   - <a class="btn" ng-click="viewFeed()" style="margin-top: 15px">View Feed</a>
  2 + <a class="btn" ui-sref="feed({sectionId:{{sectionId}}})" style="margin-top: 15px">View Feed</a>
3 3 </div>
4 4  
5 5 <!--<i class="small mdi-content-sort" ng-click="filter()">Filter</i>-->
6 6 <div class="row">
7 7 <div ng-repeat="card in cards">
8 8 <flashcard flashcard-obj="card" refresh="refreshCards()"/>
9   -
  9 +
10 10 <!--
11 11 <div class="col s6">
12 12 <div class="card">
13 13  
14 14  
15 15  
... ... @@ -18,28 +18,24 @@
18 18 <i class="small mdi-action-delete" ng-click="removeCard(card)"></i>
19 19 <a class="modal-trigger" href="#editModal"><i class="small mdi-editor-border-color modal-trigger" ng-click="editCard(card)"></i></a>
20 20 <!-- Modal Structure -->
21   - <div id="editModal" class="modal modal-fixed-footer">
22   - <div class="modal-content">
23   - <div class="row">
24   - <form class="col s12">
25   - <div class="row">
26   - <div class="input-field col s6">
27   - <i class="mdi-editor-mode-edit prefix"></i>
28   - <textarea id="icon_prefix2" class="materialize-textarea" ng-model="$parent.editableContent">{{card.content}}</textarea>
29   - <label for="icon_prefix2"></label>
30   - </div>
31   - </div>
32   - </form>
  21 + <div id="editModal" class="modal modal-fixed-footer">
  22 + <div class="modal-content">
  23 + <div class="row">
  24 + <form class="col s12">
  25 + <div class="row">
  26 + <div class="input-field col s6">
  27 + <i class="mdi-editor-mode-edit prefix"></i>
  28 + <textarea id="icon_prefix2" class="materialize-textarea" ng-model="$parent.editableContent">{{card.content}}</textarea>
  29 + <label for="icon_prefix2"></label>
33 30 </div>
34 31 </div>
35   - <div class="modal-footer">
36   - <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">Done</a>
37   - </div>
38   - </div>
  32 + </form>
39 33 </div>
40 34 </div>
  35 + <div class="modal-footer">
  36 + <a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat">Done</a>
  37 + </div>
41 38 </div>
42   - -->
43 39 </div>
44 40 </div>