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
DLCM
UI
DLCM-Portal
Commits
fa33cd5f
Commit
fa33cd5f
authored
Mar 17, 2020
by
William Arsac
Committed by
Florent POITTEVIN
Mar 18, 2020
Browse files
perf: first pass with simple changes
parent
88cab571
Changes
2
Hide whitespace changes
Inline
Side-by-side
src/app/shared/components/presentationals/shared-data-table/shared-data-table.presentational.html
View file @
fa33cd5f
...
...
@@ -5,6 +5,7 @@
}"
>
</ng-template>
<ng-template
#tableTemplate
let-isSmallerOrEqualThanMd=
"isSmallerOrEqualThanMd"
let-isBiggerThanMd=
"isBiggerThanMd"
...
...
@@ -43,7 +44,7 @@
</button>
</ng-template>
</div>
<div
*ngIf=
"(isColumnFilterable() && isFilterApplied())
|| (queryParameters && isDatasPresent === true)
"
<div
*ngIf=
"
(queryParameters && isDatasPresent) ||
(isColumnFilterable() && isFilterApplied())"
class=
"header-button-and-pagination"
>
<div
class=
"button-wrapper"
>
...
...
@@ -402,4 +403,4 @@
<span
class=
"message"
>
{{'table.nodata' | translate}}
</span>
</div>
</div>
</ng-template>
\ No newline at end of file
</ng-template>
src/app/shared/components/presentationals/shared-data-table/shared-data-table.presentational.ts
View file @
fa33cd5f
...
...
@@ -7,6 +7,7 @@ import {
OnChanges
,
Output
,
SimpleChanges
,
TrackByFunction
,
ViewChild
,
ViewEncapsulation
,
}
from
"
@angular/core
"
;
...
...
@@ -37,7 +38,10 @@ import {
DateUtil
,
isEmptyArray
,
isEmptyString
,
isNonEmptyArray
,
isNonEmptyString
,
isNullOrUndefined
,
isString
,
isTrue
,
MappingObject
,
MappingObjectUtil
,
...
...
@@ -86,7 +90,7 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
return
this
.
_datas
;
}
trackByFunction
=
(
index
:
number
,
item
:
TResource
)
=>
index
;
trackByFunction
:
TrackByFunction
<
TResource
>
=
(
index
:
number
,
item
:
TResource
)
=>
index
;
@
Input
()
isMultiSelectable
:
boolean
=
false
;
...
...
@@ -262,7 +266,7 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
return
;
}
this
.
actions
.
forEach
(
action
=>
{
this
.
context
.
mapAtLeastOneActionToDisplay
.
set
(
action
,
this
.
_datas
.
some
(
data
=>
!
isNullOrUndefined
(
action
.
displayOnCondition
)
&&
isTrue
(
action
.
displayOnCondition
(
data
)))
)
;
this
.
context
.
mapAtLeastOneActionToDisplay
.
set
(
action
,
this
.
_datas
.
some
(
data
=>
action
.
displayOnCondition
&&
action
.
displayOnCondition
(
data
)));
});
}
...
...
@@ -299,7 +303,8 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
getCellData
(
row
:
TResource
,
column
:
DataTableColumns
):
any
{
const
data
=
this
.
getData
(
row
,
column
);
if
(
column
.
translate
&&
column
.
filterEnum
)
{
const
enumValue
=
column
.
filterEnum
.
find
(
f
=>
f
.
key
===
data
+
""
);
const
dataStr
=
data
+
""
;
const
enumValue
=
column
.
filterEnum
.
find
(
f
=>
f
.
key
===
dataStr
);
if
(
enumValue
)
{
return
enumValue
.
value
;
}
...
...
@@ -407,18 +412,15 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
getValue
(
col
:
DataTableColumns
<
TResource
>
):
string
|
null
{
const
value
=
MappingObjectUtil
.
get
(
this
.
queryParameters
.
search
.
searchItems
,
this
.
getFilterableField
(
col
));
if
(
value
===
null
||
value
===
undefined
||
value
===
StringUtil
.
stringEmpty
)
{
return
null
;
}
return
value
;
return
isNonEmptyString
(
value
)
?
value
:
null
;
}
private
getFilterableField
(
col
:
DataTableColumns
<
TResource
>
):
string
{
return
is
NullOrUndefined
(
col
.
filterableField
)
?
col
.
field
:
col
.
fi
lterableFi
eld
;
return
is
String
(
col
.
filterableField
)
?
col
.
fi
lterableFi
eld
:
col
.
field
;
}
private
getSortableField
(
col
:
DataTableColumns
):
string
{
return
is
NullOrUndefined
(
col
.
sort
ableField
)
?
col
.
field
:
col
.
sortableF
ield
;
return
is
String
(
col
.
filter
ableField
)
?
col
.
fi
lterableFi
eld
:
col
.
f
ield
;
}
getSortableFieldByFieldName
(
fieldName
:
string
):
string
{
...
...
@@ -434,7 +436,7 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
}
const
searchItems
:
Map
<
string
,
string
>
=
MappingObjectUtil
.
toMap
(
this
.
queryParameters
.
search
.
searchItems
);
searchItems
.
forEach
((
value
:
string
,
key
:
string
)
=>
{
if
(
this
.
columnsSkippedToClear
.
some
(
c
=>
c
.
includes
(
key
))
===
false
)
{
if
(
!
toSkip
&&
this
.
columnsSkippedToClear
.
some
(
c
=>
c
.
includes
(
key
))
===
false
)
{
toSkip
=
true
;
}
});
...
...
@@ -489,33 +491,27 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
}
isHighlighting
(
rowData
:
TResource
):
boolean
{
if
(
isEmptyArray
(
this
.
listHighlightingId
)
&&
isEmptyArray
(
this
.
multiSelectionValueOnAllPages
))
{
return
false
;
}
if
(
this
.
listHighlightingId
.
includes
(
rowData
.
resId
))
{
return
true
;
}
return
this
.
multiSelectionValueOnAllPages
.
includes
(
rowData
.
resId
);
return
this
.
listHighlightingId
.
includes
(
rowData
.
resId
)
||
this
.
multiSelectionValueOnAllPages
.
includes
(
rowData
.
resId
);
}
displayActionOnCondition
(
action
:
DataTableActions
<
TResource
>
,
resource
:
TResource
=
undefined
):
boolean
|
Observable
<
boolean
>
{
// console.error("TEST");
// return true;
if
(
isNullOrUndefined
(
resource
)
||
isNullOrUndefined
(
action
.
displayOnCondition
)
)
{
if
(
!
resource
||
!
action
.
displayOnCondition
)
{
return
this
.
atLeastOneActionRowDisplayed
(
action
);
}
return
action
.
displayOnCondition
(
resource
);
}
private
atLeastOneActionRowDisplayed
(
action
:
DataTableActions
<
TResource
>
):
boolean
|
Observable
<
boolean
>
{
if
(
isN
ullOrUndefined
(
this
.
_datas
)
||
is
EmptyArray
(
this
.
_datas
))
{
if
(
!
isN
on
EmptyArray
(
this
.
_datas
))
{
return
false
;
}
if
(
isNullOrUndefined
(
action
.
displayOnCondition
))
{
return
true
;
}
const
atLeastOnActionToDisplay
=
this
.
context
.
mapAtLeastOneActionToDisplay
.
get
(
action
);
if
(
isTrue
(
atLeastOnActionToDisplay
)
)
{
if
(
atLeastOnActionToDisplay
)
{
return
true
;
}
// TODO Find a way to merge all observable
...
...
@@ -523,7 +519,7 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
}
getWidth
(
column
:
DataTableColumns
<
TResource
>
):
string
{
if
(
!
is
NullOrUndefined
(
column
.
width
))
{
if
(
is
String
(
column
.
width
))
{
return
column
.
width
;
}
if
(
column
.
component
===
DataTableComponentEnum
.
conformityLevelStar
)
{
...
...
@@ -540,7 +536,7 @@ export class SharedDataTablePresentational<TResource extends BaseResource> exten
}
isColumnFilterable
():
boolean
{
return
!
isNullOrUndefined
(
this
.
columns
.
find
(
c
=>
isTrue
(
c
.
isFilterable
)
))
;
return
this
.
columns
.
some
(
c
=>
c
.
isFilterable
);
}
toggleCheckbox
(
$event
:
MatCheckboxChange
,
rowData
:
TResource
):
void
{
...
...
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