-
Notifications
You must be signed in to change notification settings - Fork 183
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Weekend challenge #148
base: master
Are you sure you want to change the base?
Weekend challenge #148
Changes from all commits
13e90b0
22b32ab
1532895
481048b
8009c0c
d921069
24f7305
cb93597
89b9bea
a8992c1
ff7c484
377671b
263cd43
ecddbce
c4efe3b
11400ae
d52a461
06ae51e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
node_modules | ||
bower_components | ||
npm-debug.log |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
var express = require('express'); | ||
var logger = require('morgan'); | ||
var app = express(); | ||
|
||
app.set('port', (process.env.PORT || 8080)); | ||
|
||
app.use(logger('dev')); | ||
app.use(express.static(__dirname)); | ||
|
||
app.get("/", function(req, res) { | ||
res.sendFile('index.html'); | ||
}); | ||
|
||
app.listen(app.get('port'), function() { | ||
console.log('Node app is running on port', app.get('port')); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "todo_list", | ||
"authors": [ | ||
"Sara Tateno" | ||
], | ||
"description": "", | ||
"main": "", | ||
"moduleType": [], | ||
"license": "MIT", | ||
"homepage": "", | ||
"ignore": [ | ||
"**/.*", | ||
"node_modules", | ||
"bower_components", | ||
"test", | ||
"tests" | ||
], | ||
"dependencies": { | ||
"jquery": "~2.2.0", | ||
"angular": "~1.4.9", | ||
"angular-resource": "~1.4.9", | ||
"bootstrap": "^3.3.6" | ||
}, | ||
"devDependencies": { | ||
"angular-mocks": "~1.4.9", | ||
"angular-route": "~1.4.9" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
.list-group .glyphicon-unchecked { | ||
font-size: 22px; | ||
} | ||
|
||
.list-group .glyphicon-check { | ||
font-size: 22px; | ||
} | ||
|
||
.description { | ||
max-width: | ||
} | ||
|
||
#page-title { | ||
padding: 0.2em; | ||
} | ||
|
||
#enter-todos { | ||
padding: 0.2em; | ||
margin-bottom: 3em; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
<!DOCTYPE html> | ||
<html lang="en" ng-app="TodoList"> | ||
<head> | ||
<meta charset="utf-8" name="viewport" content="width=device-width, initial-scale=1"> | ||
<title>To Do List</title> | ||
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"> | ||
<link rel='stylesheet' href='css/main.css'> | ||
<script src="bower_components/jquery/dist/jquery.js"></script> | ||
<script src="bower_components/angular/angular.js"></script> | ||
<script src="bower_components/angular-resource/angular-resource.js"></script> | ||
<script src="js/app.js"></script> | ||
<script src="js/todoListController.js"></script> | ||
</head> | ||
|
||
<body ng-controller="TodoListController as todoCtrl"> | ||
<div class="container"> | ||
|
||
<div class="col-md-12 text-center"> | ||
<div> | ||
<h2 id="page-title">My To Do List</h2> | ||
</div> | ||
|
||
<div class="count lead" ng-hide="todoCtrl.nothingToDo()"> | ||
You have completed {{ todoCtrl.countComplete() }}/{{ todoCtrl.count() }} things on your to do list | ||
</div> | ||
|
||
<div class="count lead text-muted" ng-show="todoCtrl.nothingToDo()"> | ||
Relax. You have nothing left to do. | ||
</div> | ||
</div> | ||
|
||
<div class="col-md-6 col-md-offset-3" id="todo-area"> | ||
<div id="enter-todos"> | ||
<form class="form-horizontal" name="newTodoForm"> | ||
<div> | ||
<div class="input-group"> | ||
<input class="form-control" type="text" ng-model="todoCtrl.newItem" > | ||
<span class="input-group-btn"> | ||
<button class="btn add btn-success" ng-click="todoCtrl.addItem()"><i class="glyphicon glyphicon-plus"></i></button> | ||
</span> | ||
</div> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<div class="text-left" id="todo-items"> | ||
<ul class="list-group"> | ||
<li class="list-group-item" ng-repeat="item in todoCtrl.items track by $index"> | ||
<div class="todo-item" ng-hide="item.editMode"> | ||
<div class="col-md-1" id="todo-status"> | ||
<i class="glyphicon glyphicon-check" ng-click="todoCtrl.markIncomplete(item)" ng-show="item.complete"></i> | ||
<i class="glyphicon glyphicon-unchecked" ng-click="todoCtrl.markComplete(item)" ng-hide="item.complete"></i> | ||
</div> | ||
<strong class="description"> {{ item.description }}</strong> | ||
<button class="btn edit pull-right" ng-click="todoCtrl.edit(item)"><i class="glyphicon glyphicon-pencil"></i></button> | ||
</div> | ||
|
||
<form class="form-horizontal" name="editForm" ng-show="item.editMode"> | ||
<div class="input-group"> | ||
<input class="form-control" type="text" ng-model="todoCtrl.newDescription" > | ||
<span class="input-group-btn"> | ||
<button class="btn submit-edit" ng-click="todoCtrl.submitEdit()">OK</button> | ||
</span> | ||
</div> | ||
</form> | ||
|
||
|
||
</li> | ||
</ul> | ||
</div> | ||
</div> | ||
|
||
</div> | ||
</body> | ||
</html> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
var todoList = angular.module('TodoList', ['ngResource']); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
todoList.controller("TodoListController", [function(){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function has too many statements. (12) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function has too many statements. (12) |
||
var self = this; | ||
var activeItemIndex = 0; | ||
self.items = []; | ||
|
||
self.addItem = function() { | ||
var item = { description: self.newItem }; | ||
self.items.push(item); | ||
self.newItem = ''; | ||
}; | ||
|
||
self.edit = function(item) { | ||
activeItemIndex = _position(item); | ||
self.items[activeItemIndex].editMode = true; | ||
self.newDescription = item.description; | ||
}; | ||
|
||
self.submitEdit = function(){ | ||
self.items[activeItemIndex].description = self.newDescription; | ||
self.items[activeItemIndex].editMode = false; | ||
}; | ||
|
||
self.markComplete = function(item) { | ||
self.items[_position(item)].complete = true; | ||
}; | ||
|
||
self.markIncomplete = function(item) { | ||
self.items[_position(item)].complete = false; | ||
}; | ||
|
||
self.countComplete = function(){ | ||
var count = 0; | ||
for (i = 0; i < self.items.length; i++) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'i' is not defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'i' is not defined. |
||
if(self.items[i].complete === true){ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'i' is not defined. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 'i' is not defined. |
||
count += 1; | ||
} | ||
} | ||
return count; | ||
}; | ||
|
||
self.count = function() { | ||
return self.items.length; | ||
}; | ||
|
||
self.nothingToDo = function() { | ||
return (self.count() - self.countComplete()) === 0; | ||
}; | ||
|
||
function _position(item) { | ||
return self.items.indexOf(item); | ||
} | ||
}]); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
{ | ||
"name": "todo_list", | ||
"version": "1.0.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"start": "node app.js", | ||
"test": "karma start test/karma.conf.js --browsers PhantomJS --single-run", | ||
"e2e": "protractor test/e2e/conf.js", | ||
"webdriver": "webdriver-manager start" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/saratateno/todo_list.git" | ||
}, | ||
"author": "", | ||
"license": "ISC", | ||
"bugs": { | ||
"url": "https://github.com/saratateno/todo_list/issues" | ||
}, | ||
"homepage": "https://github.com/saratateno/todo_list#readme", | ||
"devDependencies": { | ||
"jasmine-core": "^2.4.1", | ||
"jasmine-reporters": "^2.1.1", | ||
"karma": "^0.13.19", | ||
"karma-chrome-launcher": "^0.2.2", | ||
"karma-jasmine": "^0.3.6", | ||
"karma-phantomjs-launcher": "^0.2.3", | ||
"karma-spec-reporter": "0.0.23", | ||
"nodemon": "^1.8.1", | ||
"phantomjs-prebuilt": "^2.1.2", | ||
"protractor": "^3.0.0", | ||
"protractor-http-mock": "^0.2.1" | ||
}, | ||
"dependencies": { | ||
"bower": "^1.7.7", | ||
"express": "^4.13.4", | ||
"morgan": "^1.6.1" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
exports.config = { | ||
seleniumAddress: "http://localhost:4444/wd/hub", | ||
specs: ['todoListFeature.js'], | ||
capabilities: { | ||
browserName: 'chrome' | ||
}, | ||
|
||
onPrepare: function() { | ||
var jasmineReporters = require('jasmine-reporters'); | ||
jasmine.getEnv().addReporter(new jasmineReporters.TerminalReporter({ | ||
verbosity: 3, | ||
color: true, | ||
showStack: true | ||
})); | ||
|
||
require('protractor-http-mock').config = { | ||
rootDirectory: __dirname, | ||
protractorConfig: 'conf.js' | ||
}; | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
describe('todo List feature', function() { | ||
var newItemBox = element(by.model('todoCtrl.newItem')); | ||
var addItemButton = element(by.className('add')); | ||
var editButton = element(by.className('edit')); | ||
var editBox = element(by.model('todoCtrl.newDescription')); | ||
var submitEdit = element(by.className('submit-edit')); | ||
var completeCheck = element(by.className('glyphicon-unchecked')); | ||
var isCompleteIcon = element(by.className('glyphicon-check')); | ||
var counter = element(by.binding('todoCtrl.count()')); | ||
var items = element.all(by.repeater('')); | ||
var submitItem = function() { | ||
newItemBox.sendKeys('Buy some milk'); | ||
addItemButton.click(); | ||
}; | ||
|
||
beforeEach(function(){ | ||
browser.get('http://localhost:8080'); | ||
submitItem(); | ||
}); | ||
|
||
it('has a title', function() { | ||
expect(browser.getTitle()).toEqual('To Do List'); | ||
}); | ||
|
||
it('adds an item to the list', function() { | ||
expect(items.get(0).getText()).toEqual('Buy some milk'); | ||
}); | ||
|
||
|
||
it('clears the previous item after it has been added', function() { | ||
expect(element(by.model('todoCtrl.newItem')).getAttribute('value')).toEqual(""); | ||
}); | ||
|
||
|
||
it('allows the same item to be added more than once', function() { | ||
submitItem(); | ||
expect(items.get(1).getText()).toEqual('Buy some milk'); | ||
}); | ||
|
||
it('allows an item to be edited', function() { | ||
editButton.click(); | ||
editBox.sendKeys("y bars"); | ||
submitEdit.click(); | ||
expect(items.get(0).getText()).toEqual('Buy some milky bars'); | ||
}); | ||
|
||
it('marks items as complete', function(){ | ||
completeCheck.click(); | ||
expect(isCompleteIcon.isDisplayed()).toBe(true); | ||
}); | ||
|
||
it('unmarks items as complete', function(){ | ||
completeCheck.click(); | ||
isCompleteIcon.click(); | ||
expect(completeCheck.isDisplayed()).toBe(true); | ||
}); | ||
|
||
it('tracks the number of things to do', function() { | ||
expect(counter.getText()).toEqual("You have completed 0/1 things on your to do list"); | ||
}); | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'angular' is not defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
'angular' is not defined.