add opponents
This commit is contained in:
@@ -387,4 +387,53 @@ router.get("/:team_id/events", ensureLoggedIn, function (req, res, next) {
|
||||
});
|
||||
});
|
||||
|
||||
router.get("/:team_id/opponents", ensureLoggedIn, function (req, res, next) {
|
||||
authTeamsnap(req.user);
|
||||
team_id = req.params.team_id;
|
||||
teamsnap.loadCollections(function (err) {
|
||||
teamsnap.bulkLoad(team_id, ["team", "opponent"]).then((items) => {
|
||||
res.set("Content-Type", "text/html");
|
||||
res.render("opponents", {
|
||||
team: items.find((i) => i.type == "team" && i.id == team_id),
|
||||
opponents: items.filter((i) => i.type == "opponent"),
|
||||
team_id: team_id,
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
router.get(
|
||||
"/:team_id/opponent/:opponent_id",
|
||||
ensureLoggedIn,
|
||||
function (req, res, next) {
|
||||
authTeamsnap(req.user);
|
||||
team_id = req.params.team_id;
|
||||
opponent_id = req.params.opponent_id;
|
||||
teamsnap.loadCollections(function (err) {
|
||||
teamsnap.enablePersistence();
|
||||
teamsnap
|
||||
.bulkLoad(team_id, ["team", "opponent"])
|
||||
.then(() => {
|
||||
teamsnap.loadTeamMedia(team_id);
|
||||
})
|
||||
.then(() => {
|
||||
items = teamsnap.getAllItems();
|
||||
res.set("Content-Type", "text/html");
|
||||
res.render("opponent", {
|
||||
team: items.find((i) => i.type == "team" && i.id == team_id),
|
||||
opponent: items.find(
|
||||
(i) => i.type == "opponent" && i.id == opponent_id
|
||||
),
|
||||
opponent_logo: items.find(
|
||||
(i) =>
|
||||
i.type == "teamMedium" &&
|
||||
i.description == `team-logo-${opponent_id}.png`
|
||||
),
|
||||
team_id: team_id,
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
|
||||
35
views/opponent.pug
Normal file
35
views/opponent.pug
Normal file
@@ -0,0 +1,35 @@
|
||||
html
|
||||
head
|
||||
meta(charset='utf-8')
|
||||
meta(name='viewport' content='width=device-width, initial-scale=1')
|
||||
title BenchCoach - Teams
|
||||
link(rel='stylesheet' href='/css/bootstrap.min.css')
|
||||
link(rel='stylesheet' href='/font/bootstrap-icons.min.css')
|
||||
link(rel='stylesheet' href='/css/teamsnap-ui.css')
|
||||
|
||||
body
|
||||
.container
|
||||
.Panel
|
||||
.Panel-header
|
||||
.Panel-title #{opponent.name}
|
||||
.Panel-body
|
||||
.Panel-row.Panel-row--withCells
|
||||
.Panel-cell.Panel-cell--header Contact Name
|
||||
.panel-cell #{opponent.contactsName}
|
||||
.Panel-row.Panel-row--withCells
|
||||
.Panel-cell.Panel-cell--header Contact Phone
|
||||
.panel-cell #{opponent.contactsPhone}
|
||||
.Panel-row.Panel-row--withCells
|
||||
.Panel-cell.Panel-cell--header Contact Email
|
||||
.panel-cell #{opponent.contactsEmail}
|
||||
.Panel-row.Panel-row--withCells
|
||||
.Panel-cell.Panel-cell--header Logo
|
||||
.panel-cell
|
||||
if opponent_logo
|
||||
img(src=`${opponent_logo.mediumUrl}` width="64" height="64")
|
||||
else
|
||||
button.Button Upload
|
||||
.Panel-row.Panel-row--withCells
|
||||
.Panel-cell.Panel-cell--header Notes
|
||||
.panel-cell #{opponent.Notes}
|
||||
|
||||
18
views/opponents.pug
Normal file
18
views/opponents.pug
Normal file
@@ -0,0 +1,18 @@
|
||||
html
|
||||
head
|
||||
meta(charset='utf-8')
|
||||
meta(name='viewport' content='width=device-width, initial-scale=1')
|
||||
title BenchCoach - Teams
|
||||
link(rel='stylesheet' href='/css/bootstrap.min.css')
|
||||
link(rel='stylesheet' href='/font/bootstrap-icons.min.css')
|
||||
link(rel='stylesheet' href='/css/teamsnap-ui.css')
|
||||
|
||||
body
|
||||
.container
|
||||
.Panel
|
||||
.Panel-header
|
||||
.Panel-title Opponents
|
||||
.Panel-body
|
||||
each opponent in opponents
|
||||
.Panel-row
|
||||
a(class='opponent' href=`/${team.id}/opponent/${opponent.id}`) #{opponent.name}
|
||||
@@ -9,9 +9,14 @@ html
|
||||
|
||||
body
|
||||
.container
|
||||
h2 #{team.name}
|
||||
p #{team.seasonName}
|
||||
hr
|
||||
ul.list-group
|
||||
a(class="list-group-item" href=`${team.id}/events`) Events
|
||||
a(class="list-group-item" href=`${team.id}/roster`) Roster
|
||||
.Panel
|
||||
.Panel-header
|
||||
h2.Panel-title #{team.name}
|
||||
p #{team.seasonName}
|
||||
.Panel-body
|
||||
.Panel-row
|
||||
a(class="list-group-item" href=`${team.id}/events`) Events
|
||||
.Panel-row
|
||||
a(class="list-group-item" href=`${team.id}/roster`) Roster
|
||||
.Panel-row
|
||||
a(class="list-group-item" href=`${team.id}/opponents`) Opponents
|
||||
Reference in New Issue
Block a user