Dictionary edit bug fix
This commit is contained in:
+13
-10
@@ -344,23 +344,25 @@ impl DictionaryState {
|
|||||||
value: word.value.clone(),
|
value: word.value.clone(),
|
||||||
tags: word.tags.clone(),
|
tags: word.tags.clone(),
|
||||||
id: word.id,
|
id: word.id,
|
||||||
|
index: i
|
||||||
};
|
};
|
||||||
|
|
||||||
let lazy_line = lazy(word_line_data, move |data| {
|
let lazy_line = lazy(word_line_data, move |data| {
|
||||||
|
let index = data.index;
|
||||||
let mut line = Row::new().width(Length::Fill).align_y(Center);
|
let mut line = Row::new().width(Length::Fill).align_y(Center);
|
||||||
line = line.push(
|
line = line.push(
|
||||||
checkbox(data.is_included)
|
checkbox(data.is_included)
|
||||||
.label("")
|
.label("")
|
||||||
.spacing(15)
|
.spacing(15)
|
||||||
.on_toggle(move |b| Include(i, b)),
|
.on_toggle(move |b| Include(index, b)),
|
||||||
);
|
);
|
||||||
|
|
||||||
line = line.push(
|
line = line.push(
|
||||||
text_input("Слово", &data.key)
|
text_input("Слово", &data.key)
|
||||||
.size(ACCENT_FONT_SIZE)
|
.size(ACCENT_FONT_SIZE)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_input(move |string| SetKey(i, string))
|
.on_input(move |string| SetKey(index, string))
|
||||||
.on_submit(SubmitWord(i))
|
.on_submit(SubmitWord(index))
|
||||||
.style(|x, status| {
|
.style(|x, status| {
|
||||||
let mut default_style = default(x, status);
|
let mut default_style = default(x, status);
|
||||||
default_style.border.radius = 0.0.into();
|
default_style.border.radius = 0.0.into();
|
||||||
@@ -371,8 +373,8 @@ impl DictionaryState {
|
|||||||
text_input("Перевод", &data.value)
|
text_input("Перевод", &data.value)
|
||||||
.size(ACCENT_FONT_SIZE)
|
.size(ACCENT_FONT_SIZE)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_input(move |string| SetValue(i, string))
|
.on_input(move |string| SetValue(index, string))
|
||||||
.on_submit(SubmitWord(i))
|
.on_submit(SubmitWord(index))
|
||||||
.style(|x, status| {
|
.style(|x, status| {
|
||||||
let mut default_style = default(x, status);
|
let mut default_style = default(x, status);
|
||||||
default_style.border.radius = 0.0.into();
|
default_style.border.radius = 0.0.into();
|
||||||
@@ -384,8 +386,8 @@ impl DictionaryState {
|
|||||||
text_input("Теги", &data.tags)
|
text_input("Теги", &data.tags)
|
||||||
.size(ACCENT_FONT_SIZE)
|
.size(ACCENT_FONT_SIZE)
|
||||||
.width(Length::Fill)
|
.width(Length::Fill)
|
||||||
.on_input(move |string| SetTags(i, string))
|
.on_input(move |string| SetTags(index, string))
|
||||||
.on_submit(SubmitWord(i))
|
.on_submit(SubmitWord(index))
|
||||||
.style(|x, status| {
|
.style(|x, status| {
|
||||||
let mut default_style = default(x, status);
|
let mut default_style = default(x, status);
|
||||||
default_style.border.radius = 0.0.into();
|
default_style.border.radius = 0.0.into();
|
||||||
@@ -394,7 +396,7 @@ impl DictionaryState {
|
|||||||
);
|
);
|
||||||
|
|
||||||
let line_button = || {
|
let line_button = || {
|
||||||
let action = WordAction(i);
|
let action = WordAction(index);
|
||||||
|
|
||||||
if data.id == 0 {
|
if data.id == 0 {
|
||||||
return button("-").on_press(action).style(|_x, _status| Style {
|
return button("-").on_press(action).style(|_x, _status| Style {
|
||||||
@@ -406,7 +408,7 @@ impl DictionaryState {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
button("").on_press(WordAction(i)).width(15)
|
button("").on_press(WordAction(index)).width(15)
|
||||||
};
|
};
|
||||||
line = line.push(line_button()).push(space().width(10));
|
line = line.push(line_button()).push(space().width(10));
|
||||||
line
|
line
|
||||||
@@ -593,5 +595,6 @@ struct WordLineState{
|
|||||||
key: String,
|
key: String,
|
||||||
value: String,
|
value: String,
|
||||||
tags: String,
|
tags: String,
|
||||||
id: u32
|
id: u32,
|
||||||
|
index: usize,
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user