Skip to content

Commit

Permalink
feat: add exercise selector support when editing workouts
Browse files Browse the repository at this point in the history
  • Loading branch information
Wassup789 committed Apr 23, 2024
1 parent 7047dc6 commit 2fd36ce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/Observers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { takeoverExerciseContainer } from "./enhancements/ExerciseSelectorEnhanc
import { monitorWeightContainer } from "./enhancements/ExerciseSetWeightEnhancement";
import { OnObserverDestroyFunct } from "./models/OnObserverDestroyFunct";

const CHOSEN_PARENT_CONTAINER_SELECTOR = ".workout-name",
const CHOSEN_PARENT_CONTAINER_SELECTOR = ".workout-name, .workout-step-exercises",
WEIGHT_CONTAINER_SELECTOR = ".input-append.weight-entry",
CONTAINER_MAPPINGS: ReadonlyArray<[string, (parent: HTMLElement) => void]> = [
[CHOSEN_PARENT_CONTAINER_SELECTOR, addExerciseContainersFromParent],
Expand Down
2 changes: 2 additions & 0 deletions src/components/ExerciseSelector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export default class ExerciseSelector extends LitElement {
readonly parentSelectElem: HTMLSelectElement;
readonly suggestedGroup: ExerciseGroup;

readonly fromWorkoutEditor: boolean;
readonly type: string;

readonly popupInstance: ExerciseSelectorPopup;
Expand All @@ -71,6 +72,7 @@ export default class ExerciseSelector extends LitElement {
constructor(readonly parentElem: HTMLElement) {
super();

this.fromWorkoutEditor = parentElem.matches(".workout-step-exercises");
this.parentSelectElem = parentElem.querySelector("select.chosen-select")!;
this.suggestedGroup = this.generateSuggestedGroup();
this.type = ExerciseSelector.getType(this);
Expand Down
7 changes: 5 additions & 2 deletions src/components/ExerciseSelectorPopup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { customElement, property, query } from "lit/decorators.js";
import SearchHelper, { SubstringRange } from "../helpers/SearchHelper";
import ExerciseSelector from "./ExerciseSelector";
import { ApplyMode } from "./ExerciseSelectorFilterApplies";
import { styleMap } from "lit/directives/style-map.js";

@customElement(ExerciseSelectorPopup.NAME)
export default class ExerciseSelectorPopup extends LitElement {
Expand Down Expand Up @@ -40,7 +41,7 @@ export default class ExerciseSelectorPopup extends LitElement {
:host {
position: absolute;
width: 100%;
z-index: 1;
z-index: 10;
top: 0;
left: 0;
}
Expand Down Expand Up @@ -176,7 +177,9 @@ export default class ExerciseSelectorPopup extends LitElement {
<div class="empty-state" ?active=${this.optionsEmpty}>No exercises found</div>
</div>
<div class="filters-container">
<exercise-selector-filter-applies @on-input=${(evt: CustomEvent<ApplyMode>) => this.applyMode = evt.detail}></exercise-selector-filter-applies>
<exercise-selector-filter-applies
style=${styleMap({ display: this.host && !this.host.fromWorkoutEditor ? "" : "none" })}
@on-input=${(evt: CustomEvent<ApplyMode>) => this.applyMode = evt.detail}></exercise-selector-filter-applies>
<exercise-selector-filter-preview
.overlayTitle=${this.selectedOption?.text || ""}
.muscleMap=${this.selectedOption?.getExerciseMuscleMap() || null}></exercise-selector-filter-preview>
Expand Down

0 comments on commit 2fd36ce

Please sign in to comment.