Skip to content

Commit

Permalink
Added proposal to suggestion.
Browse files Browse the repository at this point in the history
  • Loading branch information
amyjko committed Jul 3, 2024
1 parent 3ae650b commit c4843ca
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 26 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ Dates should be in`YYYY-MM-DD` format and versions are in [semantic versioning](

## 0.5.2

### Added

- Added proposal field to suggestions, to capture draft changes.

### Fixed

- Fixed rendering of numbered lists.
Expand Down
9 changes: 9 additions & 0 deletions src/database/OrganizationsDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -941,6 +941,15 @@ class OrganizationsDB {
return error;
}

async updateSuggestionProposal(suggestion: SuggestionRow, proposal: string) {
if (suggestion.proposal === proposal) return null;
const { error } = await this.supabase
.from('suggestions')
.update({ proposal })
.eq('id', suggestion.id);
return error;
}

async updateSuggestionStatus(suggestion: SuggestionRow, status: Status, who: PersonID) {
if (suggestion.status === status) return null;
const { error } = await this.supabase
Expand Down
34 changes: 26 additions & 8 deletions src/database/database.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -450,6 +450,7 @@ export type Database = {
id: string
orgid: string
processes: string[]
proposal: string
roles: string[]
status: Database["public"]["Enums"]["status"]
visibility: Database["public"]["Enums"]["visibility"]
Expand All @@ -465,6 +466,7 @@ export type Database = {
id?: string
orgid: string
processes?: string[]
proposal?: string
roles?: string[]
status?: Database["public"]["Enums"]["status"]
visibility?: Database["public"]["Enums"]["visibility"]
Expand All @@ -480,6 +482,7 @@ export type Database = {
id?: string
orgid?: string
processes?: string[]
proposal?: string
roles?: string[]
status?: Database["public"]["Enums"]["status"]
visibility?: Database["public"]["Enums"]["visibility"]
Expand Down Expand Up @@ -545,14 +548,25 @@ export type Database = {
[_ in never]: never
}
Functions: {
create_org: {
Args: {
adminname: string
orgname: string
invite: string
}
Returns: string
}
create_org:
| {
Args: {
adminname: string
orgname: string
invite: string
}
Returns: string
}
| {
Args: {
adminname: string
orgname: string
invite: string
uid: string
email: string
}
Returns: string
}
getprofileid: {
Args: {
_orgid: string
Expand Down Expand Up @@ -871,6 +885,10 @@ export type Database = {
updated_at: string
}[]
}
operation: {
Args: Record<PropertyKey, never>
Returns: string
}
search: {
Args: {
prefix: string
Expand Down
53 changes: 35 additions & 18 deletions src/lib/SuggestionView.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import Header from './Header.svelte';
import FormDialog from './FormDialog.svelte';
import Visibility from './Visibility.svelte';
import Subheader from './Subheader.svelte';
export let suggestion: SuggestionRow;
Expand Down Expand Up @@ -83,25 +84,41 @@

<Tip>Use suggestions as a place to capture progress on a change and to document decisions.</Tip>

<Paragraph
>On <TimeView date={timestampToDate(suggestion.when)} />
<PersonLink profile={$org.getProfileWithPersonID(suggestion.who)} /> reported:</Paragraph
<Paragraph>
<PersonLink profile={$org.getProfileWithPersonID(suggestion.who)} /> reported this problem on <TimeView
date={timestampToDate(suggestion.when)}
/>.</Paragraph
>

<Quote
><MarkupView
markup={suggestion.description}
placeholder="No description"
edit={editable
? (text) =>
queryOrError(
errors,
$db.updateSuggestionDescription(suggestion, text),
"Couldn't update suggestion description."
)
: undefined}
/></Quote
>
<Header>Problem</Header>

<MarkupView
markup={suggestion.description}
placeholder="No description"
edit={editable
? (text) =>
queryOrError(
errors,
$db.updateSuggestionDescription(suggestion, text),
"Couldn't update suggestion description."
)
: undefined}
/>

<Header>Proposal</Header>

<MarkupView
markup={suggestion.proposal}
placeholder="No proposal"
edit={editable
? (text) =>
queryOrError(
errors,
$db.updateSuggestionProposal(suggestion, text),
"Couldn't update suggestion description."
)
: undefined}
/>

<Header>Affected roles</Header>
<div class="row">
Expand Down Expand Up @@ -192,7 +209,7 @@
{/if}
</div>

<Header>Comments</Header>
<Header>Discussion</Header>

{#await $db.getComments(suggestion.comments)}
<Loading />
Expand Down
3 changes: 3 additions & 0 deletions supabase/migrations/20240703005756_remote_schema.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
alter table "public"."suggestions" add column "proposal" text not null default ''::text;


0 comments on commit c4843ca

Please sign in to comment.