Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
nghyd
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Admin message
A compter du 1er avril, attention à vos pipelines :
Nouvelles limitations de Docker Hub
Show more breadcrumbs
Cassiopée
nghyd
Commits
3e609701
Commit
3e609701
authored
7 years ago
by
francois.grand
Browse files
Options
Downloads
Patches
Plain Diff
création d'un composant générique de gestion de liste déroulante (GenericSelectComponent)
parent
6e6a2bf5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!7
Resolve "Paramètres à varier : liste libre de paramètres"
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/app/components/generic-select/generic-select.component.html
+8
-0
8 additions, 0 deletions
...p/components/generic-select/generic-select.component.html
src/app/components/generic-select/generic-select.component.ts
+58
-0
58 additions, 0 deletions
...app/components/generic-select/generic-select.component.ts
with
66 additions
and
0 deletions
src/app/components/generic-select/generic-select.component.html
0 → 100644
+
8
−
0
View file @
3e609701
<div
class=
"btn-group"
dropdown
(click)=
"onSelect($event)"
>
<button
dropdownToggle
class=
"btn btn-primary dropdown-toggle waves-light my-1"
type=
"button"
mdbRippleRadius
>
{{currentLabel}}
</button>
<div
class=
"dropdown-menu"
>
<a
class=
"dropdown-item"
*ngFor=
"let e of entries"
[value]=
entryValue(e)
>
{{entryLabel(e)}}
</a>
</div>
</div>
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/app/components/generic-select/generic-select.component.ts
0 → 100644
+
58
−
0
View file @
3e609701
import
{
Component
,
Input
,
Output
,
EventEmitter
}
from
"
@angular/core
"
;
import
{
SelectField
,
}
from
"
../../formulaire/select-field
"
;
import
{
SelectEntry
}
from
"
../../formulaire/select-entry
"
;
import
{
FormulaireService
}
from
"
../../services/formulaire/formulaire.service
"
;
/*
exemple de template :
<div class="btn-group col-12 col-sm-9" dropdown (click)="onSelect($event)">
<button dropdownToggle class="btn btn-primary dropdown-toggle waves-light my-1" type="button" mdbRippleRadius>
{{currentLabel}}
</button>
<div class="dropdown-menu">
<a class="dropdown-item" *ngFor="let e of entries" [value]=e.value>{{e.label}}</a>
</div>
</div>
*/
export
abstract
class
GenericSelectComponent
{
// valeur actuellement sélectionnée
// la valeur est le code non affiché repérant une entrée de la liste (cf. [value] dans le templace)
private
_selectedValue
:
any
;
/**
* selected value event
*/
@
Output
()
private
selectChange
=
new
EventEmitter
<
string
>
();
private
get
currentLabel
():
string
{
if
(
this
.
_selectedValue
!=
undefined
)
for
(
let
e
of
this
.
entries
)
if
(
this
.
entryValue
(
e
)
==
this
.
_selectedValue
)
return
this
.
entryLabel
(
e
);
return
"
<no selection>
"
;
}
private
onSelect
(
event
:
any
)
{
this
.
_selectedValue
=
event
.
target
.
value
;
this
.
selectChange
.
emit
(
this
.
_selectedValue
);
}
/**
* liste des objets sélectionnables
*/
protected
abstract
get
entries
():
any
[];
/**
* calcule la "valeur" d'une entrée
*/
protected
abstract
entryValue
(
entry
:
any
):
string
;
/**
* calcule l'étiquette d'une entrée (ce qui est affiché dans la liste déroulante)
*/
protected
abstract
entryLabel
(
entry
:
any
):
string
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment