Skip to content

Commit

Permalink
remove checks and make default template comment
Browse files Browse the repository at this point in the history
  • Loading branch information
tsaxking committed Oct 28, 2024
1 parent 15c1e34 commit c5fd267
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 7 deletions.
60 changes: 56 additions & 4 deletions client/views/components/strategy/Comment.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,75 @@
onMount(() => {
strategy.on('update', update);
comment = strategy.comment;
if (!comment) defaultComment();
return () => {
strategy.off('update', update);
};
});
onMount(() => {
comment = strategy.comment;
});
const defaultComment = async () => {
const res = await strategy.getTeams();
if (res.isErr()) return console.error(res.error);
const teams = res.value.filter(Boolean);
const templates = [
'Auto Starting Location',
'Auto Routine',
'Main Teleop Role',
'Endgame',
];
const red = teams.slice(0, 3);
const blue = teams.slice(3, 6);
let str: string;
if (red.some(t => t.number === 2122)) {
str = `Red Alliance:
${red[0].number} - ${red[0].name}
${templates.join(':\n ')}:
${red[1].number} - ${red[1].name}
${templates.join(':\n ')}:
${red[2].number} - ${red[2].name}
${templates.join(':\n ')}:
Blue Alliance:
${blue[0].number} - ${blue[0].name}
${templates.join(':\n ')}:
${blue[1].number} - ${blue[1].name}
${templates.join(':\n ')}:
${blue[2].number} - ${blue[2].name}
${templates.join(':\n ')}:`;
} else {
str = `Blue Alliance:
${blue[0].number} - ${blue[0].name}
${templates.join(':\n ')}:
${blue[1].number} - ${blue[1].name}
${templates.join(':\n ')}:
${blue[2].number} - ${blue[2].name}
${templates.join(':\n ')}:
Red Alliance:
${red[0].number} - ${red[0].name}
${templates.join(':\n ')}:
${red[1].number} - ${red[1].name}
${templates.join(':\n ')}:
${red[2].number} - ${red[2].name}
${templates.join(':\n ')}:`;
}
comment = str.trim();
};
</script>

<div class="mb-3 bg-gray-light flex-fill p-3 rounded w-75 position-relative">
<div class="d-flex flex-column justify-content-between align-items-center">
<h4 class="text-black">Comment</h4>
<textarea
class="form-control"
rows="5"
rows="30"
on:input="{e => {
comment = e.currentTarget.value;
}}">{comment}</textarea
Expand Down
5 changes: 2 additions & 3 deletions client/views/pages/strategy/Strategy.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,7 @@
<div class="row mb-3">
<Comment bind:strategy />
</div>
<div class="row mb-3">
<!-- Checks -->
<!-- <div class="row mb-3">
<div class="col-md-6">
<Checks checks="{checks[0]}" />
<hr />
Expand All @@ -173,7 +172,7 @@
<hr />
<Checks checks="{checks[5]}" />
</div>
</div>
</div> -->
{:else}
<p>No strategy selected</p>
{/if}
Expand Down

0 comments on commit c5fd267

Please sign in to comment.