Fix editor bug

This commit is contained in:
micialware committed 2026-09-23 14:37:42 +03:00
1 parent 824a868d73
commit 8603e9b981
1 file changed
+6 -6
+6 -6
View File
@@ -11,7 +11,7 @@ use iced::widget::{button, column, row, rule, scrollable, text};
use iced::{Element, Fill}; use iced::{Element, Fill};
use iced_core::Padding; use iced_core::Padding;
pub struct WordEditor<Message> { pub struct WordEditor<Message : Clone> {
state: AppState, state: AppState,
pub word_handle: EntityHandle<WordData>, pub word_handle: EntityHandle<WordData>,
on_delete: Option<Message>, on_delete: Option<Message>,
@@ -19,13 +19,13 @@ pub struct WordEditor<Message> {
fields: Vec<CustomField>, fields: Vec<CustomField>,
} }
impl<Message> WordEditor<Message> { impl<Message: std::clone::Clone> WordEditor<Message> {
pub(crate) fn update(&mut self, message: WordMessage) -> Option<Message> { pub(crate) fn update(&mut self, message: WordMessage) -> Option<Message> {
let dictionary = &mut self.state.dictionary.write(); let dictionary = &mut self.state.dictionary.write();
let word = dictionary.get_mut(&mut self.word_handle).unwrap(); let word = dictionary.get_mut(&mut self.word_handle).unwrap();
match message { match message {
Delete => { Delete => {
return self.on_delete.take(); return self.on_delete.clone();
} }
SetTags(n) => word.tags = n, SetTags(n) => word.tags = n,
SetKey(n) => { SetKey(n) => {
@@ -44,7 +44,7 @@ impl<Message> WordEditor<Message> {
word.additional.remove(&key); word.additional.remove(&key);
} }
} }
self.on_edit.take() self.on_edit.clone()
} }
pub(crate) fn view(&self) -> Element<'_, WordMessage> { pub(crate) fn view(&self) -> Element<'_, WordMessage> {
@@ -108,7 +108,7 @@ impl<Message> WordEditor<Message> {
} }
} }
impl<Message> WordEditor<Message> { impl<Message: std::clone::Clone> WordEditor<Message> {
pub fn new(handle: EntityHandle<WordData>, state: AppState) -> Self { pub fn new(handle: EntityHandle<WordData>, state: AppState) -> Self {
let fields = state let fields = state
.custom_fields .custom_fields
@@ -135,7 +135,7 @@ impl<Message> WordEditor<Message> {
} }
} }
impl<Message> WordEditor<Message> { impl<Message: std::clone::Clone> WordEditor<Message> {
fn get_view_for_more(&self, value: (&Id, &String)) -> Element<'_, WordMessage> { fn get_view_for_more(&self, value: (&Id, &String)) -> Element<'_, WordMessage> {
let field = self.fields.iter().find(|f| f.id == *value.0).unwrap(); let field = self.fields.iter().find(|f| f.id == *value.0).unwrap();
match value.0 { match value.0 {