-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
h_dung
committed
Jul 7, 2014
1 parent
5417d61
commit 27f09b6
Showing
21 changed files
with
177 additions
and
32 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 |
---|---|---|
|
@@ -47,4 +47,5 @@ group :test do | |
gem 'capybara' | ||
gem 'rspec-rails' | ||
gem 'poltergeist' | ||
gem 'database_cleaner' | ||
end |
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 |
---|---|---|
@@ -1,22 +1,36 @@ | ||
|
||
var sampleApp = angular.module('sampleApp', ['ngRoute']); | ||
|
||
sampleApp.config(['$routeProvider', | ||
function($routeProvider){ | ||
$routeProvider. | ||
when('/AddNewOrder', { | ||
templateUrl: '/assets/add_order.html', | ||
controller: 'AddOrderController' | ||
}).when('/ShowOrders', { | ||
templateUrl: '/assets/show_orders.html', | ||
controller: 'ShowOrdersController' | ||
}).otherwise({ | ||
redirectTo: '/AddNewOrder' | ||
}); | ||
}]); | ||
sampleApp.controller('AddOrderController', function($scope){ | ||
$scope.message = 'This is Add new order screen'; | ||
var model = { | ||
user: "Adam", | ||
}; | ||
var sampleApp = angular.module('sampleApp', []); | ||
sampleApp.run(function ($http) { | ||
$http.get("items").success(function (data) { | ||
model.items = data; | ||
}); | ||
}); | ||
sampleApp.controller('ShowOrdersController', function($scope){ | ||
$scope.message = 'This is Show Orders screen'; | ||
sampleApp.filter("checkedItems", function () { | ||
return function (items, showComplete) { | ||
var resultArr = []; | ||
angular.forEach(items, function (item) { | ||
if (item.done == false || showComplete == true) { | ||
resultArr.push(item); | ||
} | ||
}); | ||
return resultArr; | ||
} | ||
}); | ||
sampleApp.controller("ToDoCtrl", function ($scope) { | ||
$scope.todo = model; | ||
$scope.incompleteCount = function () { | ||
var count = 0; | ||
angular.forEach($scope.todo.items, function (item) { | ||
if (!item.done) { count++ } | ||
}); | ||
return count; | ||
} | ||
$scope.warningLevel = function () { | ||
return $scope.incompleteCount() < 3 ? "label-success" : "label-warning"; | ||
} | ||
$scope.addNewItem = function (actionText) { | ||
$scope.todo.items.push({ action: actionText, done: false }); | ||
} | ||
}); |
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,3 @@ | ||
# Place all the behaviors and hooks related to the matching controller here. | ||
# All this logic will automatically be available in application.js. | ||
# You can use CoffeeScript in this file: http://coffeescript.org/ |
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,3 @@ | ||
// Place all the styles related to the Items controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
2 changes: 1 addition & 1 deletion
2
app/assets/templates/add_order.html → app/assets/templates/orders/add_order.html
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 |
---|---|---|
@@ -1,3 +1,3 @@ | ||
<h2>Add New Order</h2> | ||
|
||
{{ message }} | ||
{{ message }} |
File renamed without changes.
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,6 @@ | ||
class ItemsController < ApplicationController | ||
def index | ||
@items = Item.all | ||
render json: @items | ||
end | ||
end |
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,2 @@ | ||
module ItemsHelper | ||
end |
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,2 @@ | ||
class Item < ActiveRecord::Base | ||
end |
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 |
---|---|---|
@@ -1,13 +1,37 @@ | ||
<div class="container"> | ||
<div class="row"> | ||
<div class="col-md-3"> | ||
<ul class="nav"> | ||
<li><a href="#AddNewOrder"> Add New Order </a></li> | ||
<li><a href="#ShowOrders"> Show Orders </a></li> | ||
</ul> | ||
</div> | ||
<div class="col-md-9"> | ||
<div ng-view></div> | ||
</div> | ||
<div class="container"> | ||
<div ng-controller='ToDoCtrl'> | ||
<div class="page-header"> | ||
<h1> | ||
{{todo.user}}'s To Do List | ||
<span class="label label-default" ng-class="warningLevel()" ng-hide="incompleteCount() == 0"> | ||
{{incompleteCount()}} | ||
</span> | ||
</h1> | ||
</div> | ||
<div class="panel"> | ||
<div class="input-group"> | ||
<input class="form-control" ng-model="actionText" /> | ||
<span class="input-group-btn"> | ||
<button class="btn btn-default" ng-click="addNewItem(actionText)">Add</button> | ||
</span> | ||
</div> | ||
<table class="table table-striped"> | ||
<thead> | ||
<tr> | ||
<th>Description</th> | ||
<th>Done</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr ng-repeat="item in todo.items | checkedItems:showComplete | orderBy:'action'"> | ||
<td>{{item.action}}</td> | ||
<td><input type="checkbox" ng-model="item.done" /></td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
<div class="checkbox-inline"> | ||
<label><input type="checkbox" ng_model="showComplete"> Show Complete</label> | ||
</div> | ||
</div> | ||
</div> | ||
</div> |
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,2 @@ | ||
<h1>Items#index</h1> | ||
<p>Find me in app/views/items/index.html.erb</p> |
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,10 @@ | ||
class CreateItems < ActiveRecord::Migration | ||
def change | ||
create_table :items do |t| | ||
t.string :action | ||
t.boolean :done | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
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,23 @@ | ||
# encoding: UTF-8 | ||
# This file is auto-generated from the current state of the database. Instead | ||
# of editing this file, please use the migrations feature of Active Record to | ||
# incrementally modify your database, and then regenerate this schema definition. | ||
# | ||
# Note that this schema.rb definition is the authoritative source for your | ||
# database schema. If you need to create the application database on another | ||
# system, you should be using db:schema:load, not running all the migrations | ||
# from scratch. The latter is a flawed and unsustainable approach (the more migrations | ||
# you'll amass, the slower it'll run and the greater likelihood for issues). | ||
# | ||
# It's strongly recommended that you check this file into your version control system. | ||
|
||
ActiveRecord::Schema.define(version: 20140707042945) do | ||
|
||
create_table "items", force: true do |t| | ||
t.string "action" | ||
t.boolean "done" | ||
t.datetime "created_at" | ||
t.datetime "updated_at" | ||
end | ||
|
||
end |
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,9 @@ | ||
require 'test_helper' | ||
|
||
class ItemsControllerTest < ActionController::TestCase | ||
test "should get index" do | ||
get :index | ||
assert_response :success | ||
end | ||
|
||
end |
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,9 @@ | ||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html | ||
|
||
one: | ||
action: MyString | ||
done: false | ||
|
||
two: | ||
action: MyString | ||
done: false |
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,4 @@ | ||
require 'test_helper' | ||
|
||
class ItemsHelperTest < ActionView::TestCase | ||
end |
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,7 @@ | ||
require 'test_helper' | ||
|
||
class ItemTest < ActiveSupport::TestCase | ||
# test "the truth" do | ||
# assert true | ||
# end | ||
end |