Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TP3 - API DOM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Victor Mougel
TP3 - API DOM
Commits
bf11b07a
Commit
bf11b07a
authored
3 years ago
by
Thomas Fritsch
Browse files
Options
Downloads
Patches
Plain Diff
ajout commentaires et jsdoc
parent
25dba9b2
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Router.js
+10
-0
10 additions, 0 deletions
src/Router.js
src/main.js
+1
-1
1 addition, 1 deletion
src/main.js
src/pages/PizzaList.js
+7
-1
7 additions, 1 deletion
src/pages/PizzaList.js
with
18 additions
and
2 deletions
src/Router.js
+
10
−
0
View file @
bf11b07a
export
default
class
Router
{
static
titleElement
;
static
contentElement
;
/**
* Tableau des routes/pages de l'application.
* @example `Router.routes = [{ path: '/', page: pizzaList, title: 'La carte' }]`
*/
static
routes
=
[];
/**
* Affiche la page correspondant à `path` dans le tableau `routes`
* @param {String} path URL de la page à afficher
*/
static
navigate
(
path
)
{
const
route
=
this
.
routes
.
find
(
route
=>
route
.
path
===
path
);
if
(
route
)
{
// affichage du titre de la page
this
.
titleElement
.
innerHTML
=
`<h1>
${
route
.
title
}
</h1>`
;
// affichage de la page elle même
this
.
contentElement
.
innerHTML
=
route
.
page
.
render
();
}
}
...
...
This diff is collapsed.
Click to expand it.
src/main.js
+
1
−
1
View file @
bf11b07a
...
...
@@ -9,5 +9,5 @@ const pizzaList = new PizzaList([]);
Router
.
routes
=
[{
path
:
'
/
'
,
page
:
pizzaList
,
title
:
'
La carte
'
}];
Router
.
navigate
(
'
/
'
);
// affiche une page vide
pizzaList
.
pizzas
=
data
;
pizzaList
.
pizzas
=
data
;
// appel du setter
Router
.
navigate
(
'
/
'
);
// affiche la liste des pizzas
This diff is collapsed.
Click to expand it.
src/pages/PizzaList.js
+
7
−
1
View file @
bf11b07a
...
...
@@ -2,13 +2,19 @@ import Component from '../components/Component.js';
import
PizzaThumbnail
from
'
../components/PizzaThumbnail.js
'
;
export
default
class
PizzaList
extends
Component
{
#pizzas
;
#pizzas
;
// propriété privée
constructor
(
pizzas
)
{
super
(
'
section
'
,
{
name
:
'
class
'
,
value
:
'
pizzaList
'
});
this
.
pizzas
=
pizzas
;
}
/**
* setter de la liste des pizzas.
* Génère autant de composants `PizzaThumbnail` que de pizzas dans le tableau
* et les stocke dans `this.children`
* @param {Array} value Tableau d'objets pizza à afficher
*/
set
pizzas
(
value
)
{
this
.
#pizzas
=
value
;
this
.
children
=
this
.
#pizzas
.
map
(
pizza
=>
new
PizzaThumbnail
(
pizza
));
...
...
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