Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Formation Angular
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Aneo Web Talents
Angular
Formation Angular
Commits
71b753b8
Commit
71b753b8
authored
Aug 01, 2019
by
Emile TAVERNE
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ajout recherche et tri des personnes
parent
a7f74ad2
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
67 additions
and
3 deletions
+67
-3
app.module.ts
src/app/app.module.ts
+5
-1
page-trombinoscope.component.html
...ents/page-trombinoscope/page-trombinoscope.component.html
+7
-2
page-trombinoscope.component.scss
...ents/page-trombinoscope/page-trombinoscope.component.scss
+20
-0
page-trombinoscope.component.ts
...onents/page-trombinoscope/page-trombinoscope.component.ts
+1
-0
index.ts
src/app/pipes/index.ts
+2
-0
order-by-full-name.pipe.ts
src/app/pipes/order-by-full-name.pipe.ts
+17
-0
search-person.pipe.ts
src/app/pipes/search-person.pipe.ts
+15
-0
No files found.
src/app/app.module.ts
View file @
71b753b8
import
{
BrowserModule
}
from
'@angular/platform-browser'
;
import
{
BrowserModule
}
from
'@angular/platform-browser'
;
import
{
NgModule
}
from
'@angular/core'
;
import
{
NgModule
}
from
'@angular/core'
;
import
{
HttpClientModule
}
from
'@angular/common/http'
;
import
{
HttpClientModule
}
from
'@angular/common/http'
;
import
{
FormsModule
}
from
'@angular/forms'
;
import
{
AppComponent
}
from
'./app.component'
;
import
{
AppComponent
}
from
'./app.component'
;
...
@@ -16,10 +17,13 @@ import * as Pipes from './pipes';
...
@@ -16,10 +17,13 @@ import * as Pipes from './pipes';
Components
.
PageTrombinoscopeComponent
,
Components
.
PageTrombinoscopeComponent
,
Components
.
TrombinoscopeCardComponent
,
Components
.
TrombinoscopeCardComponent
,
Pipes
.
CapitalizePipe
,
Pipes
.
CapitalizePipe
,
Pipes
.
OrderByFullNamePipe
,
Pipes
.
SearchPersonPipe
,
],
],
imports
:
[
imports
:
[
BrowserModule
,
BrowserModule
,
HttpClientModule
HttpClientModule
,
FormsModule
],
],
providers
:
[
providers
:
[
Services
.
PersonService
Services
.
PersonService
...
...
src/app/components/page-trombinoscope/page-trombinoscope.component.html
View file @
71b753b8
<main
bp=
"grid
3
"
>
<main
bp=
"grid"
>
<ng-container
*
ngIf=
"persons; else loading"
>
<ng-container
*
ngIf=
"persons; else loading"
>
<div
bp=
"12"
>
<input
[(
ngModel
)]="
searchField
"
placeholder=
"Rechercher..."
type=
"text"
>
</div>
<app-trombinoscope-card
<app-trombinoscope-card
*
ngFor=
"let person of persons"
*
ngFor=
"let person of persons | searchPerson:searchField | orderByFullName"
bp=
"3"
[
person
]="
person
"
>
[
person
]="
person
"
>
</app-trombinoscope-card>
</app-trombinoscope-card>
</ng-container>
</ng-container>
...
...
src/app/components/page-trombinoscope/page-trombinoscope.component.scss
View file @
71b753b8
...
@@ -3,4 +3,24 @@ main {
...
@@ -3,4 +3,24 @@ main {
margin
:
0
auto
30px
;
margin
:
0
auto
30px
;
padding-top
:
30px
;
padding-top
:
30px
;
grid-gap
:
30px
;
grid-gap
:
30px
;
input
[
type
=
text
]
{
color
:
#333
;
border
:
none
;
border-radius
:
100px
;
background-color
:
#e0e0e0
;
padding
:
5px
16px
;
margin-left
:
8px
;
width
:
180px
;
max-width
:
300px
;
transition
:
width
.7s
ease-in-out
;
line-height
:
30px
;
letter-spacing
:
0
.4px
;
float
:
right
;
&
:focus
{
width
:
100%
;
outline-width
:
0
;
}
}
}
}
src/app/components/page-trombinoscope/page-trombinoscope.component.ts
View file @
71b753b8
...
@@ -9,6 +9,7 @@ import {PersonService} from '../../services';
...
@@ -9,6 +9,7 @@ import {PersonService} from '../../services';
})
})
export
class
PageTrombinoscopeComponent
implements
OnInit
{
export
class
PageTrombinoscopeComponent
implements
OnInit
{
persons
:
PersonModel
[];
persons
:
PersonModel
[];
searchField
:
string
;
constructor
(
private
personService
:
PersonService
)
{
constructor
(
private
personService
:
PersonService
)
{
}
}
...
...
src/app/pipes/index.ts
View file @
71b753b8
export
*
from
'./capitalize.pipe'
;
export
*
from
'./capitalize.pipe'
;
export
*
from
'./order-by-full-name.pipe'
;
export
*
from
'./search-person.pipe'
;
src/app/pipes/order-by-full-name.pipe.ts
0 → 100644
View file @
71b753b8
import
{
Pipe
,
PipeTransform
}
from
'@angular/core'
;
import
{
PersonModel
}
from
'../models'
;
@
Pipe
({
name
:
'orderByFullName'
})
export
class
OrderByFullNamePipe
implements
PipeTransform
{
transform
(
value
:
PersonModel
[]):
PersonModel
[]
{
return
value
.
sort
((
a
:
PersonModel
,
b
:
PersonModel
):
number
=>
{
if
(
a
.
fullName
<
b
.
fullName
)
{
return
-
1
;
}
if
(
a
.
fullName
>
b
.
fullName
)
{
return
1
;
}
return
0
;
});
}
}
src/app/pipes/search-person.pipe.ts
0 → 100644
View file @
71b753b8
import
{
Pipe
,
PipeTransform
}
from
'@angular/core'
;
import
{
PersonModel
}
from
'../models'
;
@
Pipe
({
name
:
'searchPerson'
})
export
class
SearchPersonPipe
implements
PipeTransform
{
transform
(
value
:
PersonModel
[],
search
:
string
):
PersonModel
[]
{
if
(
!
search
||
search
.
length
===
0
)
{
return
value
;
}
return
value
.
filter
((
item
:
PersonModel
):
boolean
=>
{
return
item
.
fullName
.
toLowerCase
().
includes
(
search
.
toLowerCase
());
});
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment