Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
prodige
ngpr_prodige_table_editeur
Commits
c342e156
Commit
c342e156
authored
Nov 05, 2019
by
ndurand
Browse files
correction typage des fonctions
parent
e1315135
Changes
7
Hide whitespace changes
Inline
Side-by-side
src/app/components/dynamic-template/dynamic-template.component.ts
View file @
c342e156
...
...
@@ -19,7 +19,7 @@ export class DynamicTemplateComponent implements OnInit {
constructor
(
protected
dataService
:
DataService
)
{
}
ngOnInit
()
{
ngOnInit
()
:
void
{
if
(
this
.
type
)
{
this
.
htmlContent
=
''
;
this
.
dataService
.
loadHtmlContent
(
this
.
type
)
...
...
src/app/components/edit-data/edit-data.component.ts
View file @
c342e156
...
...
@@ -48,7 +48,7 @@ export class EditDataComponent implements OnInit {
}
/** */
ngOnInit
()
{
ngOnInit
()
:
void
{
this
.
gid
=
this
.
activatedRoute
.
snapshot
.
paramMap
.
get
(
'
gid
'
);
if
(
this
.
gid
)
{
...
...
@@ -73,7 +73,7 @@ export class EditDataComponent implements OnInit {
}
/** */
saveData
()
{
saveData
()
:
void
{
this
.
dataService
.
postData
([
this
.
feature
]);
}
...
...
src/app/components/main/main.component.ts
View file @
c342e156
...
...
@@ -20,7 +20,7 @@ export class MainComponent implements OnInit {
constructor
(
private
activatedRoute
:
ActivatedRoute
,
private
dataService
:
DataService
,
private
tableViewData
:
TableViewDataService
,
)
{
}
ngOnInit
()
{
ngOnInit
()
:
void
{
/** uuid */
if
(
this
.
activatedRoute
.
snapshot
.
paramMap
.
get
(
'
uuid
'
))
{
this
.
uuid
=
this
.
activatedRoute
.
snapshot
.
paramMap
.
get
(
'
uuid
'
);
...
...
src/app/components/table-view/table-view.component.html
View file @
c342e156
...
...
@@ -3,10 +3,10 @@
<!-- Template pagination -->
<ng-template
#paginationTpl
>
<div
class=
"d-flex justify-content-between p-2"
>
<ngb-pagination
[collectionSize]=
"total$ | async"
[(page)]=
"
s
ta
te
.page"
[maxSize]=
"10"
[pageSize]=
"
s
ta
te
.pageSize"
[rotate]=
"true"
[boundaryLinks]=
"true"
>
<ngb-pagination
[collectionSize]=
"total$ | async"
[(page)]=
"ta
bleViewData
.page"
[maxSize]=
"10"
[pageSize]=
"ta
bleViewData
.pageSize"
[rotate]=
"true"
[boundaryLinks]=
"true"
>
</ngb-pagination>
<select
class=
"custom-select"
style=
"width: auto"
name=
"pageSize"
[(ngModel)]=
"
s
ta
te
.pageSize"
>
<select
class=
"custom-select"
style=
"width: auto"
name=
"pageSize"
[(ngModel)]=
"ta
bleViewData
.pageSize"
>
<option
*ngFor=
"let choiceValue of pageSizeChoice"
[ngValue]=
"choiceValue"
>
{{choiceValue}}
</option>
</select>
</div>
...
...
@@ -14,8 +14,8 @@
<!-- Recherche-->
<div
class=
"form-group form-inline"
>
Recherche :
<input
class=
"form-control ml-2"
type=
"text"
name=
"searchTerm"
[(ngModel)]=
"
s
ta
te
.searchTerm"
/>
<span
class=
"ml-3"
*ngIf=
"tableViewData
Service
.getLoading$() | async"
>
Loading...
</span>
Recherche :
<input
class=
"form-control ml-2"
type=
"text"
name=
"searchTerm"
[(ngModel)]=
"ta
bleViewData
.searchTerm"
/>
<span
class=
"ml-3"
*ngIf=
"tableViewData.getLoading$() | async"
>
Loading...
</span>
</div>
<a
routerLink=
"edit"
class=
"btn btn-primary"
routerLinkActive=
"active"
><i
class=
"fas fa-edit"
></i>
Editer
</a>
...
...
@@ -32,7 +32,7 @@
</thead>
<tbody>
<tr
*ngFor=
"let feature of features$ | async ; index as i"
>
<td
*ngFor=
"let structure of structures$ | async; index as j"
scope=
"row"
>
<td
*ngFor=
"let structure of structures$ | async; index as j"
>
{{feature.properties[structure.column_name]}}
</td>
<td
class=
"table-button-action"
>
...
...
src/app/components/table-view/table-view.component.ts
View file @
c342e156
...
...
@@ -5,7 +5,7 @@ import { ActivatedRoute } from '@angular/router';
import
{
SortableHeaderDirective
,
SortEvent
}
from
'
src/app/directives/sortable-header.directive
'
;
import
{
Observable
}
from
'
rxjs
'
;
import
{
DecimalPipe
}
from
'
@angular/common
'
;
import
{
TableViewDataService
,
State
}
from
'
src/app/services/table-view-data.service
'
;
import
{
TableViewDataService
}
from
'
src/app/services/table-view-data.service
'
;
import
{
EnvService
}
from
'
src/app/services/env.service
'
;
import
{
Structure
}
from
'
src/app/models/structure
'
;
...
...
@@ -28,27 +28,24 @@ export class TableViewComponent implements OnInit {
public
features$
:
Observable
<
Feature
[]
>
;
public
total$
:
Observable
<
number
>
;
public
state
:
State
;
/** Pour le tri */
@
ViewChildren
(
SortableHeaderDirective
)
headers
:
QueryList
<
SortableHeaderDirective
>
;
/** */
constructor
(
public
tableViewData
Service
:
TableViewDataService
,
public
tableViewData
:
TableViewDataService
,
)
{
this
.
features$
=
this
.
tableViewDataService
.
getFeatures$
();
this
.
structures$
=
this
.
tableViewDataService
.
getStructures$
();
this
.
total$
=
this
.
tableViewDataService
.
getTotal$
();
this
.
state
=
this
.
tableViewDataService
.
getState
();
this
.
features$
=
this
.
tableViewData
.
getFeatures$
();
this
.
structures$
=
this
.
tableViewData
.
getStructures$
();
this
.
total$
=
this
.
tableViewData
.
getTotal$
();
}
/** */
ngOnInit
()
{
this
.
tableViewData
Service
.
searchFromUrlParam
();
ngOnInit
()
:
void
{
this
.
tableViewData
.
searchFromUrlParam
();
}
onSort
({
column
,
direction
}:
SortEvent
)
{
onSort
({
column
,
direction
}:
SortEvent
)
:
void
{
// resetting other headers
this
.
headers
.
forEach
(
header
=>
{
if
(
header
.
appSortable
!==
column
)
{
...
...
@@ -56,7 +53,7 @@ export class TableViewComponent implements OnInit {
}
});
this
.
tableViewData
Service
.
setS
ortColumn
(
column
)
;
this
.
tableViewData
Service
.
setS
ortDirection
(
direction
)
;
this
.
tableViewData
.
s
ortColumn
=
column
;
this
.
tableViewData
.
s
ortDirection
=
direction
;
}
}
src/app/directives/sortable-header.directive.ts
View file @
c342e156
...
...
@@ -20,7 +20,7 @@ export class SortableHeaderDirective {
@
Input
()
direction
:
SortDirection
=
''
;
@
Output
()
sort
=
new
EventEmitter
<
SortEvent
>
();
rotate
()
{
rotate
()
:
void
{
this
.
direction
=
rotate
[
this
.
direction
];
this
.
sort
.
emit
({
column
:
this
.
appSortable
,
direction
:
this
.
direction
});
}
...
...
src/app/services/table-view-data.service.ts
View file @
c342e156
...
...
@@ -9,12 +9,12 @@ import { SortDirection, SortEvent } from 'src/app/directives/sortable-header.dir
import
{
EnvService
}
from
'
./env.service
'
;
import
{
Structure
}
from
'
../models/structure
'
;
export
interface
SearchResult
{
interface
SearchResult
{
features
:
Feature
[];
total
:
number
;
}
export
interface
State
{
interface
State
{
page
:
number
;
pageSize
:
number
;
searchTerm
:
string
;
...
...
@@ -64,34 +64,34 @@ export class TableViewDataService {
this
.
search$
.
next
();
}
/** Getter */
getState
()
{
return
this
.
state
;
}
getStructures$
():
Observable
<
Structure
[]
>
{
return
this
.
structures$
.
asObservable
();
}
getEnumerations$
():
Observable
<
{}
>
{
return
this
.
enumerations$
.
asObservable
();
}
getFeatures$
():
Observable
<
Feature
[]
>
{
return
this
.
features$
.
asObservable
();
}
getTotal$
():
Observable
<
number
>
{
return
this
.
total$
.
asObservable
();
}
getLoading$
():
Observable
<
boolean
>
{
return
this
.
loading$
.
asObservable
();
}
getStructures$
()
{
return
this
.
structures$
.
asObservable
();
}
getEnumerations$
()
{
return
this
.
enumerations$
.
asObservable
();
}
getFeatures$
()
{
return
this
.
features$
.
asObservable
();
}
getTotal$
()
{
return
this
.
total$
.
asObservable
();
}
getLoading$
()
{
return
this
.
loading$
.
asObservable
();
}
getPage
()
{
return
this
.
state
.
page
;
}
getPageSize
()
{
return
this
.
state
.
pageSize
;
}
getSearchTerm
()
{
return
this
.
state
.
searchTerm
;
}
getEnumerations
()
{
return
this
.
enumerations
;
}
getStructures
()
{
return
this
.
structures
;
}
getEnumerations
()
:
{}
{
return
this
.
enumerations
;
}
getStructures
()
:
Structure
[]
{
return
this
.
structures
;
}
/** Setter */
setPage
(
page
:
number
)
{
this
.
_set
({
page
});
}
setPageSize
(
pageSize
:
number
)
{
this
.
_set
({
pageSize
});
}
setSearchTerm
(
searchTerm
:
string
)
{
this
.
_set
({
searchTerm
});
}
setSortColumn
(
sortColumn
:
string
)
{
this
.
_set
({
sortColumn
});
}
setSortDirection
(
sortDirection
:
SortDirection
)
{
this
.
_set
({
sortDirection
});
}
get
page
():
number
{
return
this
.
state
.
page
;
}
set
page
(
page
:
number
)
{
this
.
_set
({
page
});
}
setStructures
(
structures
:
Array
<
Structure
>
)
{
this
.
structures
=
structures
;
this
.
structures$
.
next
(
this
.
structures
);
}
setEnumerations
(
enumerations
:
{})
{
this
.
enumerations
=
enumerations
;
this
.
enumerations$
.
next
(
this
.
enumerations
);
}
get
pageSize
():
number
{
return
this
.
state
.
pageSize
;
}
set
pageSize
(
pageSize
:
number
)
{
this
.
_set
({
pageSize
});
}
get
searchTerm
():
string
{
return
this
.
state
.
searchTerm
;
}
set
searchTerm
(
searchTerm
:
string
)
{
this
.
_set
({
searchTerm
});
}
set
sortColumn
(
sortColumn
:
string
)
{
this
.
_set
({
sortColumn
});
}
set
sortDirection
(
sortDirection
:
SortDirection
)
{
this
.
_set
({
sortDirection
});
}
setStructures
(
structures
:
Array
<
Structure
>
):
void
{
this
.
structures
=
structures
;
this
.
structures$
.
next
(
this
.
structures
);
}
setEnumerations
(
enumerations
:
{}):
void
{
this
.
enumerations
=
enumerations
;
this
.
enumerations$
.
next
(
this
.
enumerations
);
}
/** Fonctions */
private
compare
(
v1
,
v2
)
{
private
compare
(
v1
,
v2
)
:
number
{
return
v1
<
v2
?
-
1
:
v1
>
v2
?
1
:
0
;
}
...
...
@@ -108,7 +108,7 @@ export class TableViewDataService {
}
/** */
private
matches
(
feature
:
Feature
,
term
:
string
,
pipe
:
PipeTransform
,
searchField
:
string
)
{
private
matches
(
feature
:
Feature
,
term
:
string
,
pipe
:
PipeTransform
,
searchField
:
string
)
:
boolean
{
let
retour
=
false
;
const
properties
=
feature
.
properties
;
...
...
@@ -124,12 +124,7 @@ export class TableViewDataService {
}
/** */
public
getFeatureByIndex
(
index
:
number
)
{
return
this
.
features
[
index
];
}
/** */
public
searchFromUrlParam
()
{
public
searchFromUrlParam
():
void
{
const
locationUrl
=
new
URL
(
window
.
location
.
href
);
let
searchTerm
=
locationUrl
.
searchParams
.
get
(
this
.
envService
.
fitlerOnAllColumn
);
...
...
@@ -148,13 +143,13 @@ export class TableViewDataService {
}
/** */
public
initFeatures
(
features
:
Array
<
Feature
>
)
{
public
initFeatures
(
features
:
Array
<
Feature
>
)
:
void
{
this
.
features
=
features
;
this
.
search$
.
next
();
}
/** */
private
_set
(
patch
:
Partial
<
State
>
)
{
private
_set
(
patch
:
Partial
<
State
>
)
:
void
{
Object
.
assign
(
this
.
state
,
patch
);
this
.
search$
.
next
();
}
...
...
Write
Preview
Supports
Markdown
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