(2e05015) Show the campaign standing on its picker row, and bump to 0.32.21
This commit is contained in:
Generated
+1
-1
@@ -1503,7 +1503,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "worklane"
|
name = "worklane"
|
||||||
version = "0.32.20"
|
version = "0.32.21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"assert_cmd",
|
"assert_cmd",
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "worklane"
|
name = "worklane"
|
||||||
version = "0.32.20"
|
version = "0.32.21"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|||||||
+85
-3
@@ -5081,12 +5081,14 @@ fn no_campaign_line(count: usize, selected: bool) -> Line<'static> {
|
|||||||
])
|
])
|
||||||
}
|
}
|
||||||
|
|
||||||
/// One picker row: `(1b78a24) ~beaver What the campaign is for`.
|
/// One picker row: `(1b78a24) ~beaver What the campaign is for 0/1`.
|
||||||
///
|
///
|
||||||
/// The highlight is `REVERSED`, the way a selected card is, so the row reads the same
|
/// The highlight is `REVERSED`, the way a selected card is, so the row reads the same
|
||||||
/// whatever colours are already on it. The summary is grey because it is context around the
|
/// whatever colours are already on it. The summary is grey because it is context around the
|
||||||
/// two things being chosen between, and it is cut with an ellipsis rather than dropped: half
|
/// two things being chosen between, and it is cut with an ellipsis rather than dropped: half
|
||||||
/// a sentence still says what a campaign is about, which is not true of half an id.
|
/// a sentence still says what a campaign is about, which is not true of half an id. The
|
||||||
|
/// standing trails it, grey like a card's criteria count, so how far each campaign has got
|
||||||
|
/// is on the list rather than only on the frame.
|
||||||
fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'static> {
|
fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'static> {
|
||||||
let emphasis = match selected {
|
let emphasis = match selected {
|
||||||
true => Modifier::REVERSED,
|
true => Modifier::REVERSED,
|
||||||
@@ -5121,9 +5123,28 @@ fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'stat
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// The standing, `2/3`, is what the reader picks a campaign by, so it is reserved
|
||||||
|
// before the prose is cut, the way a corner is: half a count reads as the wrong
|
||||||
|
// number, so the whole of it drops when the row will not hold it. A campaign with no
|
||||||
|
// members shows nothing, the way a card with no criteria spends no corner on it.
|
||||||
|
let used_base = spans_width(&spans);
|
||||||
|
let standing = match campaign.standing.total {
|
||||||
|
0 => None,
|
||||||
|
_ => {
|
||||||
|
let text = format!("{}/{}", campaign.standing.done, campaign.standing.total);
|
||||||
|
let room = (width as usize).saturating_sub(used_base + 2);
|
||||||
|
if text.chars().count() <= room {
|
||||||
|
Some(text)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
let standing_w = standing.as_ref().map_or(0, |text| text.chars().count() + 2);
|
||||||
|
|
||||||
// What the campaign is *called* takes the row first, and the prose takes what is left.
|
// What the campaign is *called* takes the row first, and the prose takes what is left.
|
||||||
// Under three characters there is nothing left to say, the bargain `project_label` makes.
|
// Under three characters there is nothing left to say, the bargain `project_label` makes.
|
||||||
let used = spans_width(&spans);
|
let used = used_base + standing_w;
|
||||||
let summary = match campaign.summary().is_empty() {
|
let summary = match campaign.summary().is_empty() {
|
||||||
true => campaign.title.as_str(),
|
true => campaign.title.as_str(),
|
||||||
false => campaign.summary(),
|
false => campaign.summary(),
|
||||||
@@ -5140,6 +5161,14 @@ fn picker_line(campaign: &CampaignRow, selected: bool, width: u16) -> Line<'stat
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(text) = standing {
|
||||||
|
spans.push(Span::raw(" "));
|
||||||
|
spans.push(Span::styled(
|
||||||
|
text,
|
||||||
|
Style::default().fg(Color::Grey.into()).add_modifier(emphasis),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
Line::from(spans)
|
Line::from(spans)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -12668,6 +12697,59 @@ approach";
|
|||||||
assert!(footer(&board, 100, 24).contains("↵ view"), "the footer is the board's");
|
assert!(footer(&board, 100, 24).contains("↵ view"), "the footer is the board's");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The list is where a campaign is chosen from, so how far each has got belongs on the
|
||||||
|
/// row rather than only on the frame: `0/2` after the summary, where a card draws its
|
||||||
|
/// criteria count.
|
||||||
|
#[test]
|
||||||
|
fn the_picker_rows_carry_the_standing() {
|
||||||
|
let dir = board_dir();
|
||||||
|
let mut board = campaign_board(&dir);
|
||||||
|
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||||
|
|
||||||
|
let rows = picker_rows(&board, 100, 24);
|
||||||
|
// V1 holds two open members, so two done of two held is not reached.
|
||||||
|
let v1 = &rows[row_with(&rows, short_id(V1))];
|
||||||
|
assert!(v1.contains("0/2"), "{v1:?}");
|
||||||
|
// BEAVER holds one open member.
|
||||||
|
let beaver = &rows[row_with(&rows, short_id(BEAVER))];
|
||||||
|
assert!(beaver.contains("0/1"), "{beaver:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A campaign with no members has no standing to show, the way a card with no criteria
|
||||||
|
/// spends no corner on it: the row ends at the summary.
|
||||||
|
#[test]
|
||||||
|
fn a_picker_row_with_no_members_shows_no_standing() {
|
||||||
|
let dir = board_dir();
|
||||||
|
write_campaign(&dir, V1, "First public release", "v1", "For a public tag.");
|
||||||
|
|
||||||
|
let mut board = one_board(&dir);
|
||||||
|
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||||
|
|
||||||
|
let rows = picker_rows(&board, 100, 24);
|
||||||
|
let row = &rows[row_with(&rows, short_id(V1))];
|
||||||
|
assert!(!row.contains('/'), "a blank campaign claimed a standing: {row:?}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// The standing gives way before the identity and the prose, and goes whole: half a
|
||||||
|
/// count reads as the wrong number, the rule a corner drops itself by.
|
||||||
|
#[test]
|
||||||
|
fn a_campaign_row_drops_the_standing_whole_when_it_will_not_fit() {
|
||||||
|
let dir = board_dir();
|
||||||
|
write_campaign(&dir, V1, "First public release", "v1", "Everything for a public tag.");
|
||||||
|
write_member_card(&dir, "In v1", "cli", V1);
|
||||||
|
|
||||||
|
let mut board = one_board(&dir);
|
||||||
|
board.open_picker(PickerKind::Campaign, SCREEN);
|
||||||
|
|
||||||
|
let full = picker_rows(&board, 100, 24);
|
||||||
|
let wide = &full[row_with(&full, short_id(V1))];
|
||||||
|
assert!(wide.contains('/'), "no standing on a wide row: {wide:?}");
|
||||||
|
|
||||||
|
let narrow = picker_rows(&board, 14, 24);
|
||||||
|
let tight = &narrow[row_with(&narrow, short_id(V1))];
|
||||||
|
assert!(!tight.contains('/'), "a count given up in pieces: {tight:?}");
|
||||||
|
}
|
||||||
|
|
||||||
/// A campaign with no codename shows the id once, not twice: the row already opens
|
/// A campaign with no codename shows the id once, not twice: the row already opens
|
||||||
/// with it, so the card's fallback would say nothing the second time.
|
/// with it, so the card's fallback would say nothing the second time.
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
Reference in New Issue
Block a user