From ac3a2fd68b35c7dde698859e9abb4f749ce8977d Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Thu, 14 Nov 2024 12:25:38 +0000
Subject: [PATCH 1/3] Simple partial solution: only load all contributors if
editing (behaviour is OK)
---
thoth-app/src/component/contributions_form.rs | 24 +++++++++----------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/thoth-app/src/component/contributions_form.rs b/thoth-app/src/component/contributions_form.rs
index c9a186c5..8dae8fec 100644
--- a/thoth-app/src/component/contributions_form.rs
+++ b/thoth-app/src/component/contributions_form.rs
@@ -168,21 +168,21 @@ impl Component for ContributionsFormComponent {
self.show_modal_form = show_form;
self.in_edit_mode = c.is_some();
if show_form {
- let body = ContributorsRequestBody {
- variables: Variables {
- // Dropdown shown in modal form must contain full contributor list,
- // in case user is editing and wants to switch between them
- limit: Some(99999),
- ..Default::default()
- },
- ..Default::default()
- };
- let request = ContributorsRequest { body };
- self.fetch_contributors = Fetch::new(request);
- ctx.link().send_message(Msg::GetContributors);
if let Some(contribution) = c {
// Editing existing contribution: load its current values.
self.contribution = contribution;
+ let body = ContributorsRequestBody {
+ variables: Variables {
+ // Dropdown shown in modal form must contain full contributor list,
+ // in case user wants to switch between them when editing
+ limit: Some(99999),
+ ..Default::default()
+ },
+ ..Default::default()
+ };
+ let request = ContributorsRequest { body };
+ self.fetch_contributors = Fetch::new(request);
+ ctx.link().send_message(Msg::GetContributors);
}
}
true
From 4c5ba9065293abef6186f3fd6523e7ec89dc09b8 Mon Sep 17 00:00:00 2001
From: rhigman <73792779+rhigman@users.noreply.github.com>
Date: Thu, 14 Nov 2024 16:18:50 +0000
Subject: [PATCH 2/3] Bring contribution contributor logic in line with
affiliation institution logic (similarly large dataset but runs faster)
---
thoth-app/src/component/contributions_form.rs | 198 ++----------------
thoth-app/src/component/contributor_select.rs | 193 +++++++++++++++++
thoth-app/src/component/mod.rs | 1 +
3 files changed, 216 insertions(+), 176 deletions(-)
create mode 100644 thoth-app/src/component/contributor_select.rs
diff --git a/thoth-app/src/component/contributions_form.rs b/thoth-app/src/component/contributions_form.rs
index 8dae8fec..34c30bbb 100644
--- a/thoth-app/src/component/contributions_form.rs
+++ b/thoth-app/src/component/contributions_form.rs
@@ -1,4 +1,3 @@
-use gloo_timers::callback::Timeout;
use std::str::FromStr;
use thoth_api::model::contribution::Contribution;
use thoth_api::model::contribution::ContributionType;
@@ -18,9 +17,9 @@ use crate::agent::notification_bus::NotificationDispatcher;
use crate::agent::notification_bus::NotificationStatus;
use crate::agent::notification_bus::Request;
use crate::component::affiliations_form::AffiliationsFormComponent;
+use crate::component::contributor_select::ContributorSelectComponent;
use crate::component::utils::FormBooleanSelect;
use crate::component::utils::FormContributionTypeSelect;
-use crate::component::utils::FormContributorSelect;
use crate::component::utils::FormNumberInput;
use crate::component::utils::FormTextInput;
use crate::models::contribution::contribution_types_query::FetchActionContributionTypes;
@@ -41,19 +40,12 @@ use crate::models::contribution::update_contribution_mutation::UpdateContributio
use crate::models::contribution::update_contribution_mutation::UpdateContributionRequestBody;
use crate::models::contribution::update_contribution_mutation::Variables as UpdateVariables;
use crate::models::contribution::ContributionTypeValues;
-use crate::models::contributor::contributors_query::ContributorsRequest;
-use crate::models::contributor::contributors_query::ContributorsRequestBody;
-use crate::models::contributor::contributors_query::FetchActionContributors;
-use crate::models::contributor::contributors_query::FetchContributors;
-use crate::models::contributor::contributors_query::Variables;
-use crate::models::Dropdown;
use crate::string::CANCEL_BUTTON;
use crate::string::EDIT_BUTTON;
use crate::string::EMPTY_CONTRIBUTIONS;
use crate::string::NO;
use crate::string::REMOVE_BUTTON;
use crate::string::YES;
-use crate::DEFAULT_DEBOUNCING_TIMEOUT;
use super::ToElementValue;
use super::ToOption;
@@ -63,33 +55,22 @@ pub struct ContributionsFormComponent {
contribution: Contribution,
show_modal_form: bool,
in_edit_mode: bool,
- show_results: bool,
- fetch_contributors: FetchContributors,
fetch_contribution_types: FetchContributionTypes,
create_contribution: PushCreateContribution,
delete_contribution: PushDeleteContribution,
update_contribution: PushUpdateContribution,
notification_bus: NotificationDispatcher,
- search_callback: Callback<()>,
- search_query: String,
- debounce_timeout: Option