mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-17 06:24:39 +00:00
ConditionBuilder rule rows and the FieldListPane footer wrap where the room is short, so selects and buttons keep their labels whole; a range's two ends and its "and" wrap as one
This commit is contained in:
@@ -332,7 +332,8 @@ impl Rows<'_> {
|
||||
fn rule(&self, ui: &mut Ui, rule: &mut Condition, path: &[usize], depth: usize, (at, remove, insert): Pending<'_>) {
|
||||
let words = self.words;
|
||||
Row::new().fill_width().align(RowAlign::SpaceBetween).show(ui, |ui, _| {
|
||||
Row::new().show(ui, |ui, _| {
|
||||
// Field and operator keep their labels whole; what does not fit on the line goes to the next one.
|
||||
Row::new().wrap(true).show(ui, |ui, _| {
|
||||
self.pick_field(ui, rule, path);
|
||||
self.pick_operator(ui, rule, path);
|
||||
self.edit_value(ui, rule, path);
|
||||
@@ -430,9 +431,15 @@ impl Rows<'_> {
|
||||
}
|
||||
}
|
||||
ConditionValue::Range(low, high) => {
|
||||
let new_low = self.number(ui, path, "low", low);
|
||||
Text::new(words.and.clone()).show(ui);
|
||||
let new_high = self.number(ui, path, "high", high);
|
||||
// The two ends and the "and" between them wrap as one.
|
||||
let (new_low, new_high) = Row::new()
|
||||
.show(ui, |ui, _| {
|
||||
let new_low = self.number(ui, path, "low", low);
|
||||
Text::new(words.and.clone()).show(ui);
|
||||
(new_low, self.number(ui, path, "high", high))
|
||||
})
|
||||
.inner
|
||||
.unwrap_or_default();
|
||||
if new_low.is_some() || new_high.is_some() {
|
||||
rule.value = ConditionValue::Range(new_low.unwrap_or(low), new_high.unwrap_or(high));
|
||||
}
|
||||
@@ -447,9 +454,11 @@ impl Rows<'_> {
|
||||
ConditionValue::DateRange(low, high) => {
|
||||
// Each picker stops at the other date.
|
||||
let (mut low_picked, mut high_picked) = (Some(low), Some(high));
|
||||
DatePicker::new(words.value.clone(), Bind::bound(&mut low_picked)).max(high).id_salt(salt("low")).show(ui);
|
||||
Text::new(words.and.clone()).show(ui);
|
||||
DatePicker::new(words.value.clone(), Bind::bound(&mut high_picked)).min(low).id_salt(salt("high")).show(ui);
|
||||
Row::new().show(ui, |ui, _| {
|
||||
DatePicker::new(words.value.clone(), Bind::bound(&mut low_picked)).max(high).id_salt(salt("low")).show(ui);
|
||||
Text::new(words.and.clone()).show(ui);
|
||||
DatePicker::new(words.value.clone(), Bind::bound(&mut high_picked)).min(low).id_salt(salt("high")).show(ui);
|
||||
});
|
||||
let (new_low, new_high) = (low_picked.unwrap_or(low), high_picked.unwrap_or(high));
|
||||
if (new_low, new_high) != (low, high) {
|
||||
rule.value = ConditionValue::DateRange(new_low, new_high);
|
||||
|
||||
@@ -9,9 +9,10 @@ use craft_behavior::{ColumnKey, ColumnWidth, DisplayOrder, EditEvent, IconId, It
|
||||
use craft_ui::buttons::Button;
|
||||
use craft_ui::contract::{
|
||||
CollectionEvent, ColumnKind, ColumnSpec, DropAt, DropKind, DropPlace, ListDrag, Pattern, Props as _, Remember, ReorderMove, ReorderRule,
|
||||
Show as _, ShowCollection as _, ShowContainer as _, SweepApply, SweepStep, ToggleColumn, Trigger, clicked,
|
||||
RowAlign, Show as _, ShowCollection as _, ShowContainer as _, SweepApply, SweepStep, ToggleColumn, Trigger, clicked,
|
||||
};
|
||||
use craft_ui::display::{Divider, Shade, Text};
|
||||
use craft_ui::layout_components::Row;
|
||||
use craft_ui::list::{List, ListRow, ToggleCell, ToggleState};
|
||||
use craft_ui::menu::{Menu, MenuItem};
|
||||
use craft_ui::primitives::IconSpec;
|
||||
@@ -673,8 +674,13 @@ impl Model<'_> {
|
||||
})
|
||||
}
|
||||
|
||||
/// Refresh, Calculated Field… and the Report Layout menu.
|
||||
/// Refresh, Calculated Field… and the Report Layout menu, whole: in a narrow panel the buttons that do not fit go on
|
||||
/// a second line.
|
||||
fn footer(&self, ui: &mut Ui, edits: &Edits) {
|
||||
Row::new().fill_width().wrap(true).align(RowAlign::End).show(ui, |ui, _| self.footer_buttons(ui, edits));
|
||||
}
|
||||
|
||||
fn footer_buttons(&self, ui: &mut Ui, edits: &Edits) {
|
||||
let words = self.words;
|
||||
if clicked(&Button::new(words.refresh.clone()).show(ui)) {
|
||||
edits.borrow_mut().push(FieldListEdit::Refresh);
|
||||
|
||||
Reference in New Issue
Block a user