Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Log pitches #432

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/activity/activity.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import { MatPaginatorModule } from '@angular/material/paginator';
import { ActivityEntryRoutesComponent } from './partials/activity-entry-routes/activity-entry-routes.component';
import { DryRunActivityDialogComponent } from './forms/activity-form/dry-run-activity-dialog/dry-run-activity-dialog.component';
import { MatDialogModule } from '@angular/material/dialog';
import { MatExpansionModule } from '@angular/material/expansion';

@NgModule({
declarations: [
Expand Down Expand Up @@ -70,6 +71,7 @@ import { MatDialogModule } from '@angular/material/dialog';
ReactiveFormsModule,
ActivityRoutingModule,
MatDialogModule,
MatExpansionModule,
],
providers: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,86 @@
</mat-select>
</mat-form-field>
</div>
<div *ngIf="route.value.pitches.length">
<mat-expansion-panel>
<mat-expansion-panel-header>
Zabeleži posamezne raztežaje
</mat-expansion-panel-header>
<div
fxLayout="row"
fxLayoutAlign="start center"
fxLayoutGap="16px"
fxLayout.lt-md="column"
fxLayoutAlign.lt-md="start stretch"
class="mt-16"
*ngFor="let pitch of route.controls.pitches.controls"
>
<div fxFlex="240px" fxFlex.lt-md fxLayout="row">
<div fxFlex="160px">
<mat-checkbox [formControl]="pitch.controls.add"
>{{ pitch.value.number }}. raztežaj</mat-checkbox
>
</div>
<div fxFlex="80px">
<app-grade
[difficulty]="pitch.value.difficulty"
[gradingSystemId]="route.value.defaultGradingSystemId"
>
</app-grade>
</div>
</div>
<div
fxFlex="100"
fxLayout="row"
fxLayout.lt-sm="column"
fxLayoutGap="16px"
>
<mat-form-field
class="no-hint"
fxFlex="100"
*ngIf="pitch.value.add"
>
<mat-label>Vrsta vzpona</mat-label>
<mat-select [formControl]="pitch.controls.ascentType">
<mat-select-trigger>{{
mapAscentTypeValueToFullLabel(pitch.value.ascentType)
}}</mat-select-trigger>
<ng-container *ngFor="let type of nonTopRopeAscentTypes">
<mat-option
*ngIf="logPossibleEver(type.value)"
[value]="type.value"
>{{ type.label }}
</mat-option>
</ng-container>
<mat-optgroup label="Top rope">
<ng-container *ngFor="let type of topRopeAscentTypes">
<mat-option
*ngIf="logPossibleEver(type.value)"
[value]="type.value"
>{{ type.label }}
</mat-option>
</ng-container>
</mat-optgroup>
</mat-select>
</mat-form-field>
<mat-form-field
class="no-hint"
fxFlex="100"
*ngIf="pitch.value.add"
>
<mat-label>Vidnost</mat-label>
<mat-select [formControl]="pitch.controls.publish">
<mat-option
*ngFor="let option of publishOptions"
[value]="option.value"
>{{ option.label }}
</mat-option>
</mat-select>
</mat-form-field>
</div>
</div>
</mat-expansion-panel>
</div>
<div
fxFlex
fxLayout="row"
Expand Down
22 changes: 22 additions & 0 deletions src/app/activity/forms/activity-form/activity-form.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
DryRunCreateActivityGQL,
DryRunUpdateActivityGQL,
StarRatingVotesGQL,
Pitch,
} from 'src/generated/graphql';
import dayjs from 'dayjs';
import { Router } from '@angular/router';
Expand Down Expand Up @@ -301,6 +302,19 @@ export class ActivityFormComponent implements OnInit, OnDestroy {
tried: new FormControl(route.tried),
trTicked: new FormControl(route.trTicked),
type: new FormControl(route.routeType.id),
pitches: new FormArray(
route.pitches.map(
(pitch: Pitch) =>
new FormGroup({
add: new FormControl(false),
id: new FormControl(pitch.id),
ascentType: new FormControl({ value: null }),
publish: new FormControl('public'),
difficulty: new FormControl(pitch.difficulty),
number: new FormControl(pitch.number),
})
)
),
})
);
}
Expand All @@ -320,6 +334,14 @@ export class ActivityFormComponent implements OnInit, OnDestroy {
votedStarRating: route.votedStarRating,
publish: route.publish,
votedDifficulty: route.votedDifficulty,
pitches: route.pitches
.filter(({ add }) => add)
.map(({ id, ascentType, publish, number }) => ({
pitchId: id,
ascentType,
publish,
position: number,
})),
position: i, // position of the route within the same activity of ones log
};
});
Expand Down
1 change: 1 addition & 0 deletions src/app/pages/crag/crag-by-slug.query.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ query CragBySlug($crag: String!) {
id
}
pitches {
id
difficulty
isProject
number
Expand Down