Default Challenge.canStart to true

This commit is contained in:
thepaperpilot 2022-03-22 23:04:49 -05:00
parent cfb3acea92
commit e867a9e89e
2 changed files with 8 additions and 3 deletions

View file

@ -12,12 +12,16 @@
feature: true,
challenge: true,
done: unref(completed),
canStart: unref(canStart),
canStart: unref(canStart) && !unref(maxed),
maxed: unref(maxed),
...unref(classes)
}"
>
<button class="toggleChallenge" @click="toggle">
<button
class="toggleChallenge"
@click="toggle"
:disabled="!unref(canStart) || unref(maxed)"
>
{{ buttonText }}
</button>
<component v-if="unref(comp)" :is="unref(comp)" />

View file

@ -73,7 +73,7 @@ export type Challenge<T extends ChallengeOptions> = Replace<
T & BaseChallenge,
{
visibility: GetComputableTypeWithDefault<T["visibility"], Visibility.Visible>;
canStart: GetComputableTypeWithDefault<T["canStart"], Ref<boolean>>;
canStart: GetComputableTypeWithDefault<T["canStart"], true>;
canComplete: GetComputableTypeWithDefault<T["canComplete"], Ref<boolean>>;
completionLimit: GetComputableTypeWithDefault<T["completionLimit"], 1>;
mark: GetComputableTypeWithDefault<T["mark"], Ref<boolean>>;
@ -209,6 +209,7 @@ export function createChallenge<T extends ChallengeOptions>(
}
processComputable(challenge as T, "canStart");
setDefault(challenge, "canStart", true);
processComputable(challenge as T, "canComplete");
processComputable(challenge as T, "completionLimit");
setDefault(challenge, "completionLimit", 1);