Commit 4875b846 authored by Jakob Moser's avatar Jakob Moser
Browse files

Revert "Don't show confirm button when no confirmation is requested"

This reverts commit cbaac325.
parent cbaac325
Loading
Loading
Loading
Loading
+0 −8
Original line number Diff line number Diff line
@@ -49,14 +49,6 @@ export class Exercise {
        this.#context._confirmExerciseCompletion()
    }

    /**
     * Returns true if the user should be able to click a button
     * to manually confirm they completed this exercise
     */
    get awaitsManualConfirmation() {
        return this.#context._confirmExerciseCompletion !== null
    }

    /**
     * Set the handler that is called every time the exercise executor
     * sets the description of the exercise.
+7 −15
Original line number Diff line number Diff line
@@ -36,27 +36,21 @@ export function displayAsNonCurrent(cardEl) {
}

/**
 * Create an (optional) confirm and a reset button that can be appended to the actions section of
 * Create a confirm and a reset button that can be appended to the actions section of
 * an exercise card.
 * @param {Function} manuallyConfirm Function to call to manually confirm this exercise. If falsy, no confirm button is created.
 * @param {Function} manuallyConfirm Function to call to manually confirm this exercise
 * @returns List of buttons
 */
function createExerciseCardActionButtons(manuallyConfirm) {
    const ret = []

    if(manuallyConfirm) {
    const confirmButton = createElementWithClass("button", "primary")
    confirmButton.textContent = "Ich denke, ich bin fertig."
    confirmButton.onclick = () => manuallyConfirm()
        ret.push(confirmButton)
    }

    const resetButton = document.createElement("button")
    resetButton.textContent = "Aufgabe neu beginnen"
    resetButton.onclick = () => location.reload()
    ret.push(resetButton)

    return ret
    return [confirmButton, resetButton]
}

/**
@@ -77,9 +71,7 @@ export function createExerciseCard(exercise, onTitleClick) {
    const descriptionEl = createElementWithClass("p", "description")
    const actionsEl = createElementWithClass("div", "actions")
    actionsEl.append(...createExerciseCardActionButtons(
        exercise.awaitsManualConfirmation ?
        exercise.manuallyConfirm.bind(exercise) :
        null
        exercise.manuallyConfirm.bind(exercise)
    ))
    cardEl.querySelector(".content").append(descriptionEl, actionsEl)