-
-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: allow to disable questions (and to enable them again), fix #256
- Loading branch information
1 parent
f8ef32f
commit 93ebdd8
Showing
8 changed files
with
238 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<script lang="ts"> | ||
import DisabledQuestionsLayer from "./DisabledQuestionsLayer.svelte" | ||
import { Stores } from "../../Logic/UIEventSource" | ||
/** | ||
* Shows _all_ disabled questions | ||
*/ | ||
export let state | ||
let layers = state.layout.layers.filter(l => l.isNormal()) | ||
let allDisabled = Stores.concat<string>(layers.map(l => state.userRelatedState.getThemeDisabled(state.layout.id, l.id))).map(l => [].concat(...l)) | ||
</script> | ||
|
||
<h3>Disabled questions</h3> | ||
{#if $allDisabled.length === 0} | ||
To disable a question, click the three dots in the upper-right corner | ||
{:else} | ||
To enable a question again, click it | ||
{#each layers as layer (layer.id)} | ||
<DisabledQuestionsLayer {state} {layer} /> | ||
{/each} | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<script lang="ts">/** | ||
* Gives an overview of questions which are disabled for the given theme | ||
*/ | ||
import UserRelatedState from "../../Logic/State/UserRelatedState" | ||
import LayerConfig from "../../Models/ThemeConfig/LayerConfig" | ||
import ThemeViewState from "../../Models/ThemeViewState" | ||
import Tr from "../Base/Tr.svelte" | ||
import { Translation } from "../i18n/Translation" | ||
import { XMarkIcon } from "@babeard/svelte-heroicons/mini" | ||
import ToSvelte from "../Base/ToSvelte.svelte" | ||
export let layer: LayerConfig | ||
export let state: ThemeViewState | ||
let disabledQuestions = state.userRelatedState.getThemeDisabled(state.layout.id, layer.id) | ||
function getQuestion(id: string): Translation { | ||
return layer.tagRenderings.find(q => q.id === id).question.Subs({}) | ||
} | ||
function enable(idToEnable: string) { | ||
const newList = disabledQuestions.data.filter(id => id !== idToEnable) | ||
disabledQuestions.set(newList) | ||
} | ||
</script> | ||
|
||
{#if $disabledQuestions.length > 0} | ||
<div class="low-interaction p-2"> | ||
|
||
<h4 class="flex my-2"> | ||
<div class="no-image-background block h-6 w-6"> | ||
<ToSvelte construct={() => layer.defaultIcon()} /> | ||
</div> | ||
<Tr t={layer.name} /> | ||
</h4> | ||
<div class="flex"> | ||
{#each $disabledQuestions as id} | ||
<button class="badge button-unstyled" on:click={() => enable(id)}> | ||
<Tr cls="ml-2" t={getQuestion(id)} /> | ||
<XMarkIcon class="w-4 h-4 mr-2" /> | ||
</button> | ||
{/each} | ||
</div> | ||
</div> | ||
{/if} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.