Skip to content

Commit

Permalink
problem: can't filter problems by status
Browse files Browse the repository at this point in the history
  • Loading branch information
gsovereignty committed Nov 11, 2023
1 parent 6501243 commit 627c944
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 30 deletions.
8 changes: 0 additions & 8 deletions src/lib/constants.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/lib/stores/nostrocket_state/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,5 @@ export type ProblemStatus =
| "claimed"
| "closed"
| "patched"
| "solved";
export type RocketID = EventID; //rocketID in hex
export type Sha256 = string;
24 changes: 14 additions & 10 deletions src/routes/problems/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script lang="ts">
import { problemStatuses } from "$lib/constants";
import { consensusTipState } from "$lib/stores/nostrocket_state/master_state";
import type {
Account,
Expand All @@ -20,7 +19,7 @@
let rootNodes: Map<string, Problem>;
let value: string;
let selected: ProblemStatus;
let selectedStatus: ProblemStatus = "open"
const queryInput = writable("");
const problemStatus = writable<ProblemStatus | undefined>();
Expand Down Expand Up @@ -53,15 +52,13 @@
return filterText.includes(filterQuery);
});
}
//remove any problems that don't have a title yet and return
return new Map(
problemArray.filter(([_, { Title, Status }]) => {
problemArray.filter(([_, { Status }]) => {
if (Boolean($problemStatus)) {
return Boolean(Title) && Status === $problemStatus;
return Status === $problemStatus;
} else {
return true
}
return Boolean(Title);
})
);
}
Expand All @@ -75,7 +72,7 @@
}
$: {
handleStatusChange(selected);
handleStatusChange(selectedStatus);
}
$: {
Expand All @@ -86,6 +83,13 @@
)
);
}
const problemStatuses: Map<string, ProblemStatus> = new Map(
["open", "claimed", "closed", "patched"].map((v) => [
v,
v as ProblemStatus,
])
);
</script>

<Row>
Expand All @@ -96,7 +100,7 @@

<Row padding>
<Column lg={3}>
<Select hideLabel size="xl" labelText="Status" bind:selected fullWidth>
<Select hideLabel size="xl" labelText="Status" bind:selected={selectedStatus} fullWidth>
<SelectItem value={0} text={"Status"} hidden disabled />
<SelectItemGroup label="Status">
{#each problemStatuses as [key, value]}
Expand Down
38 changes: 27 additions & 11 deletions src/routes/problems/[id]/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@
} from "carbon-components-svelte";
import {
Chat,
Close,
DeliveryParcel,
InProgressWarning,
PlayFilledAlt,
Time,
Unlocked
PlayFilledAlt
} from "carbon-icons-svelte";
import { AcceleratedComputing, DesignLeadership, DoNot, Idea, Management } from "carbon-pictograms-svelte";
import { get } from "svelte/store";
import LogNewProblemModal from "../../../components/problems/LogNewProblemModal.svelte";
Expand Down Expand Up @@ -133,23 +129,23 @@
>
{#if problem?.Status == "open" && problem.Children.size > 0}<span
style="color:blueviolet"
><InProgressWarning /> HAS OPEN CHILDREN</span
><Management /> HAS OPEN CHILDREN</span
>
{/if}
{#if problem?.Status == "open" && problem.Children.size == 0}<span
style="color:green"><Unlocked /> OPEN AND CAN BE CLAIMED</span
style="color:green"><Idea /> OPEN AND CAN BE CLAIMED</span
>
{/if}
{#if problem?.Status == "claimed"}<span style="color:orange"
><Time /> CLAIMED AND IN PROGRESS</span
><AcceleratedComputing /> CLAIMED AND IN PROGRESS</span
>
{/if}
{#if problem?.Status == "patched"}<span style="color:orange"
><DeliveryParcel /> PATCHED AND WAITING FOR VALIDATION</span
><DesignLeadership /> PATCHED AND WAITING FOR VALIDATION</span
>
{/if}
{#if problem?.Status == "closed"}<span style="color:red"
><Close /> CLOSED</span
><DoNot /> CLOSED</span
>
{/if}
</p>
Expand Down Expand Up @@ -229,6 +225,26 @@
>
{/if}

{#if problem?.Status == "patched"}
<br /><br />
<Button
disabled={!(problem?.CreatedBy == $currentUser?.pubkey)}
icon={PlayFilledAlt}
size="small"
kind="primary"
on:click={() => {
updateStatus("closed")
.then((response) => {
console.log(response);
})
.catch((response) => {
console.log(response);
statusErrorText = response;
});
}}>Close this problem</Button
>
{/if}


{#if statusErrorText}
<InlineNotification
Expand Down

0 comments on commit 627c944

Please sign in to comment.