Skip to content

Commit

Permalink
Fix bug on Approvers/Contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffdaley committed Oct 2, 2023
1 parent b849467 commit 24824f9
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
10 changes: 7 additions & 3 deletions web/app/components/document/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,8 @@
@disabled={{not this.isOwner}}
@isRequired={{true}}
@name="title"
class="mb-1.5"
@tag="h1"
class="mb-1.5"
/>
</div>
</div>
Expand Down Expand Up @@ -183,7 +183,7 @@
<EditableField
data-test-document-contributors
data-test-editable={{this.isOwner}}
@value={{this.contributors}}
@value={{h.users}}
@onChange={{perform this.save "contributors"}}
@isSaving={{this.saveIsRunning}}
@disabled={{not this.isOwner}}
Expand Down Expand Up @@ -224,11 +224,15 @@
<div>
<Document::Sidebar::SectionHeader @title="Approvers" />
<div class="editable-field-container mt-[3px]">
{{!
FIXME: this needs to be a local variable probably
so when people are added their avatars are available
}}
<HermesUsers class="w-full" @emails={{@document.approvers}} as |h|>
<EditableField
data-test-document-approvers
data-test-editable={{this.isOwner}}
@value={{this.approvers}}
@value={{h.users}}
@onChange={{perform this.save "approvers"}}
@isSaving={{this.saveIsRunning}}
@disabled={{not this.isOwner}}
Expand Down
1 change: 0 additions & 1 deletion web/app/components/document/sidebar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ export default class DocumentSidebarComponent extends Component<DocumentSidebarC

@action
updateContributors(contributors: HermesUser[]) {
debugger;
this.contributors = contributors;
}

Expand Down
7 changes: 6 additions & 1 deletion web/app/components/editable-field.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
>
{{#if (and this.editingIsEnabled (not @isSaving))}}

{{! FIXME: ...something here }}
{{on-document "keydown" this.handleKeydown}}

<div {{did-insert this.registerEditingContainer}} class="w-full">
Expand Down Expand Up @@ -72,7 +73,11 @@
{{#if (or @isSaving @isLoading)}}
<div
data-test-spinner
class={{if @isSaving "absolute top-0 right-0" "flex h-5 items-center"}}
class={{if
@isSaving
"absolute top-2.5 right-[9px]"
"flex h-5 items-center"
}}
>
<FlightIcon @name="loading" data-test-loading-spinner />
</div>
Expand Down
2 changes: 2 additions & 0 deletions web/app/components/editable-field.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export default class EditableFieldComponent extends Component<EditableFieldCompo
* On Escape, we disable editing.
*/
@action protected handleKeydown(ev: KeyboardEvent) {
console.log("handleKeydown", ev.key);
switch (ev.key) {
case "Enter":
if (document.activeElement === this.cancelButton) {
Expand All @@ -175,6 +176,7 @@ export default class EditableFieldComponent extends Component<EditableFieldCompo
break;
}
ev.preventDefault();
// FIXME: this is not the value we want
this.maybeUpdateValue(this.value);
break;
case "Escape":
Expand Down
1 change: 1 addition & 0 deletions web/app/components/hermes-users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export default class HermesUsersComponent extends Component<HermesUsersComponent
})) ?? [];

@action updateUsers(users: HermesUser[]) {
console.log("updateUsers", users);
this.serializedUsers = users;
}
}
Expand Down
8 changes: 5 additions & 3 deletions web/app/styles/components/editable-field.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
.editable-field {
@apply relative flex w-full;

&[disabled] {
&[disabled],
&.saving {
cursor: default;
}

.loading,
.saving {
opacity: 0.5;

// disable mouseover stfuf
}

&.button-affordance {
Expand All @@ -38,7 +40,7 @@
@apply cursor-auto items-center;
}

&:not(.disabled, disabled) {
&:not([disabled], .disabled, .saving) {
&:hover,
&:focus-visible &:focus {
@apply bg-color-palette-neutral-175;
Expand Down

0 comments on commit 24824f9

Please sign in to comment.