Skip to content

Commit

Permalink
List of character cards + name search.
Browse files Browse the repository at this point in the history
  • Loading branch information
jeandat committed Feb 4, 2016
1 parent 2bc7e91 commit 3d9d251
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 17 deletions.
5 changes: 5 additions & 0 deletions app/characters/_characters.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.crt{
&__form{
width: 100%;
}
}
35 changes: 25 additions & 10 deletions app/characters/characters.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@
.module('app')
.controller('CharactersController', CharactersController);

function CharactersController($log, charactersService, $cordovaToast) {
function CharactersController($log, charactersService, $cordovaToast, throwErr, $scope, $cordovaKeyboard) {

var vm = this;
vm.title = 'CharactersController';
//vm.request = request;
vm.characters = charactersService.getList().$object;
vm.filter = '';
// Let's start with something cool ;)
vm.characters = charactersService.getList({nameStartsWith:'Deadpool'}).$object;
vm.keep = keep;
vm.search = search;
vm.searching = false;

activate();

Expand All @@ -21,16 +24,28 @@
$log.debug(vm.title + ' instantiated');
}

function keep(){
function keep() {
$cordovaToast.showShortBottom('Not implemented yet…');
}

//function request(){
// charactersService.getList().then(function (characters) {
// $log.debug(characters.length + ' characters:', characters);
// $cordovaToast.showLongBottom(characters.length + ' characters in stock');
// }).catch(throwErr);
//}
function search() {
var criteria = vm.filter ? {nameStartsWith: vm.filter} : {};
var promise = charactersService.getList(criteria);
vm.characters = promise.$object;
vm.searching = true;
$cordovaKeyboard.close();
return promise.then(log).catch(throwErr).finally(hideSpinner);

///////////

function log(characters) {
$log.debug(characters.length + ' results:', characters);
}

function hideSpinner(){
vm.searching = false;
}
}

}

Expand Down
21 changes: 14 additions & 7 deletions app/characters/tab-characters.jade
Original file line number Diff line number Diff line change
@@ -1,8 +1,15 @@
ion-view.crt(view-title='Characters')
ion-content.has-tabs
.list.card(ng-repeat="character in vm.characters track by character.id")
.item.item-image
img(ng-src="{{character.getThumbnailUrl()}}")
.item.item-icon-right.assertive
i.icon.ion-android-favorite-outline(ng-click='vm.keep()')
| {{character.name}}
ion-content
.bar.item-input-inset
form.crt__form(name='crtSearchForm', novalidate, ng-submit='vm.search()', autocomplete="off")
label.item-input-wrapper
i.icon.ion-ios-search.placeholder-icon
input(type='search', placeholder='Name starts with…', name='name',
ng-model='vm.filter', spellcheck="false")
ion-spinner.spinner-assertive(ng-if='vm.searching')
.list.card(ng-repeat="character in vm.characters track by character.id")
.item.item-image(ui-sref='tab.character-detail({character:character})')
img(ng-src="{{character.getThumbnailUrl()}}")
.item.item-icon-right.assertive
i.icon.ion-android-favorite-outline(ng-click='vm.keep()')
| {{character.name}}

0 comments on commit 3d9d251

Please sign in to comment.