Skip to content

Commit

Permalink
dueDate Bug fix (#47)
Browse files Browse the repository at this point in the history
  • Loading branch information
soujash-mandal authored Aug 5, 2023
1 parent 1960194 commit a1bc58f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 42 deletions.
49 changes: 12 additions & 37 deletions web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@
<p
class="hds-typography-body-200 hds-font-weight-medium hds-foreground-primary"
>
{{dateformat @document.dueDate}}</p>
{{dateformat this.dueDate}}</p>
{{else}}
<p
class="hds-typography-body-200 hds-font-weight-medium hds-foreground-faint"
Expand All @@ -330,7 +330,9 @@
<Hds::Form::TextInput::Field
id="user-question"
@type="date"
@value={{F.value}}
@renderInPlace={{true}}
@value={{this.dueDate}}
{{on "change" this.updateDueDate}}
{{on "blur" F.update}}
as |F|
/>
Expand Down Expand Up @@ -597,41 +599,14 @@
</Hds::Form::Field>
<Hds::Form::Field @layout="vertical" as |F|>
<F.Control>
{{#if this.editingIsDisabled}}
<p
class="hds-typography-body-200 hds-font-weight-medium hds-foreground-primary"
>{{dateformat @document.dueDate}}</p>
{{else}}
<EditableField
@value={{@document.dueDate}}
@onChange={{perform this.updateDueDate}}
@loading={{this.save.isRunning}}
@disabled={{this.editingIsDisabled}}
>
<:default>
{{#unless (is-empty @document.dueDate)}}
<p
class="hds-typography-body-200 hds-font-weight-medium hds-foreground-primary"
>
{{dateformat @document.dueDate}}</p>
{{else}}
<p
class="hds-typography-body-200 hds-font-weight-medium hds-foreground-faint"
>
Enter due date here</p>
{{/unless}}
</:default>
<:editing as |F|>
<Hds::Form::TextInput::Field
id="user-question"
@type="date"
@value={{F.value}}
{{on "blur" F.update}}
as |F|
/>
</:editing>
</EditableField>
{{/if}}
<Hds::Form::TextInput::Field
id="user-question"
@type="date"
@renderInPlace={{true}}
@value={{this.dueDate}}
{{on "change" this.updateDueDate}}
@disabled={{M.taskIsRunning}}
/>
</F.Control>
<F.Label>Add Due Date <Hds::Badge @text="Required" /></F.Label>
</Hds::Form::Field>
Expand Down
19 changes: 14 additions & 5 deletions web/app/components/document/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,11 @@ export default class DocumentSidebarComponent extends Component<DocumentSidebarC
await this.save.perform("project", this.project);
});

updateDueDate = task(async (date: string) => {
this.dueDate = date;
await this.save.perform("dueDate", this.dueDate);
// productAbbreviation is computed by the back end
});
// updateDueDate = task(async (date: string) => {
// this.dueDate = date;
// await this.save.perform("dueDate", this.dueDate);
// // productAbbreviation is computed by the back end
// });

isAllReviewersReviewed(
reviewedReviewers: string[],
Expand Down Expand Up @@ -527,6 +527,7 @@ export default class DocumentSidebarComponent extends Component<DocumentSidebarC
// Update reviewers.
await this.patchDocument.perform({
reviewers: this.reviewers.compact().mapBy("email"),
dueDate: this.dueDate,
});
await this.fetchSvc.fetch(`/api/v1/reviews/${this.docID}`, {
method: "POST",
Expand Down Expand Up @@ -566,6 +567,14 @@ export default class DocumentSidebarComponent extends Component<DocumentSidebarC
updateReviewers(reviewers: HermesUser[]) {
this.reviewers = reviewers;
}
@action
updateDueDate(event:Event) {
const target = event.target as HTMLInputElement;
// Get the selected date value from the input field
const dueDate = target.value;
// Update the dueDate property in the component
this.dueDate = dueDate;
}

@action
updateContributors(contributors: HermesUser[]) {
Expand Down

0 comments on commit a1bc58f

Please sign in to comment.