Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Able to change states to archived and starred
- Loading branch information
Michael Hughes
authored and
Michael Hughes
committed
Mar 23, 2013
1 parent
c8737c9
commit 420bfe9
Showing
7 changed files
with
88 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
controller = exports ? this | ||
|
||
states = { | ||
NEW:"new" | ||
ARCHIVED:"archived" | ||
STARRED:"starred" | ||
} | ||
|
||
controller.EntryListCtrl = ($scope,$http)-> | ||
|
||
$scope.entries = [] | ||
if $http | ||
$http.get("/latest/json") | ||
.success (data,status)-> | ||
$scope.entries = data | ||
.error (data,status)-> | ||
|
||
ignoreOutput = (data,status)-> | ||
|
||
$scope.encode = (url)-> | ||
encodeURIComponent url | ||
|
||
$scope.plusMinus = (open)-> | ||
if open then "minus" else "plus" | ||
|
||
$scope.remove = (index)-> | ||
entry = $scope.entries[index] | ||
$scope.entries.splice index,1 | ||
if $http | ||
$http.get("/changeState?state=" + states.ARCHIVED + "&id=" + $scope.encode(entry.id)) | ||
.success(ignoreOutput) | ||
.error(ignoreOutput) | ||
|
||
$scope.star = (index)-> | ||
entry = $scope.entries[index] | ||
if entry.state==states.STARRED | ||
entry.state=states.NEW | ||
else | ||
entry.state=states.STARRED | ||
if $http | ||
$http.get("/changeState?state="+ entry.state + "&id=" + $scope.encode(entry.id)) | ||
.success(ignoreOutput) | ||
.error(ignoreOutput) | ||
|
||
$scope.status = (state)-> | ||
if state==states.STARRED then "" else "-empty" | ||
|
||
|
||
scope:$scope |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
controller = require '../../../src/client/EntryListController.coffee' | ||
expect = (require 'chai').expect | ||
|
||
describe 'A EntryListCtrl controller', -> | ||
it 'should be able to remove entries from a list', ()-> | ||
c = new controller.EntryListCtrl({}) | ||
c.scope.entries = [ | ||
{title:"a",id:"aa"}, | ||
{title:"b",id:"bb"}, | ||
{title:"c",id:"cc"} | ||
] | ||
c.scope.remove(1) | ||
expect(c.scope.entries).to.eql [ | ||
{title:"a",id:"aa"}, | ||
{title:"c",id:"cc"} | ||
] | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters