Skip to content

Commit

Permalink
allow show unsupported criteria
Browse files Browse the repository at this point in the history
  • Loading branch information
LeosPrograms committed Apr 18, 2024
1 parent 9037692 commit 273cba6
Showing 1 changed file with 42 additions and 1 deletion.
43 changes: 42 additions & 1 deletion ui/src/converge/converge/Criteria/AllCriteria.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ let hashes: Array<ActionHash> | undefined;
let loading = true;
let error: any = undefined;
let sortableCriteria = {};
let showUnsupportedCriteria = false;
let numberOfUnsupportedCriteria = 0;
async function sortCriteria() {
// setTimeout(() => {
Expand All @@ -38,17 +40,25 @@ async function sortCriteria() {
return b.myObjections - a.myObjections;
}
});
numberOfUnsupportedCriteria = 0;
sortedCriteriaJoined = sortedCriteriaJoined.filter((c) => {
if (c.supporters > 0) {
return true;
} else {
numberOfUnsupportedCriteria++;
if (showUnsupportedCriteria) {
return true;
} else {
return false;
}
}
});
sortedCriteria = sortedCriteriaJoined.map((c) => c.hash);
console.log(sort, sortedCriteriaJoined)
// }, 4000)
}
$: hashes, loading, error, sortedCriteria, sortableCriteria, sort, filter;
$: hashes, loading, error, sortedCriteria, sortableCriteria, sort, filter, numberOfUnsupportedCriteria;
$: if (sort && sortableCriteria && hashes && Object.values(sortableCriteria).length == hashes.length) {
sortCriteria();
}
Expand Down Expand Up @@ -134,6 +144,37 @@ async function joinSignal() {
<Criterion on:criterion-rated={joinSignal} criterionHash={hash} {deliberationHash} {filter} bind:sortableCriteria on:criterion-deleted={() => fetchCriteria()}></Criterion>
{/each}
{/if}
{#if numberOfUnsupportedCriteria > 0}
{#if showUnsupportedCriteria}
<button
class="show-more-button"
on:click={() => {
showUnsupportedCriteria = false;
sortCriteria();
}}
>Hide {numberOfUnsupportedCriteria} unsupported criteria?</button>
{:else}
<button
class="show-more-button"
on:click={() => {
showUnsupportedCriteria = true;
sortCriteria();
}}
>Show {numberOfUnsupportedCriteria} unsupported criteria?</button>
{/if}
{/if}
</div>
{/if}

<style>
.show-more-button {
background: #dee5ff;
border: 0;
border-radius: 4px;
padding: 6px;
cursor: pointer;
}
.show-more-button:hover {
background: #c4d2ff;
}
</style>

0 comments on commit 273cba6

Please sign in to comment.