forked from adalal/openxer
Release v0.1.1: delete open projects, richer RIVERBEND sample, picker menu
- Enable Delete on open projects (including RIVERBEND), add Close Project to the Projects context menu, support empty workspace state, and keep emptied workspaces empty on restart. - Expand RIVERBEND default project to 365 activities across 6 plant areas with a second baseline, risks, documents, issues, thresholds, LOE and WBS summary activities, OBS, project/resource/assignment codes, funding, budget log, spending plan, financial periods with past period actuals, and typed UDFs. - Add right-click context menu (Copy, Columns, Table Font and Row, Filter By, Group and Sort By, Expand All, Collapse All) and keyboard shortcuts to Assign Predecessors and Assign Successors. - Bump workspace version to 0.1.1 and update README download links and CHANGELOG.
This commit is contained in:
12
CHANGELOG.md
12
CHANGELOG.md
@@ -4,7 +4,17 @@ All notable changes to OpenXER are recorded here. The format follows
|
||||
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and versions follow
|
||||
[Semantic Versioning](https://semver.org/). The newest release is at the top.
|
||||
|
||||
## [Unreleased]
|
||||
## [0.1.1] - 2026-11-25
|
||||
|
||||
### Added
|
||||
- **Close Project** in the Projects view right-click menu, plus a true empty-workspace state when the last open project is closed or deleted.
|
||||
- Full right-click context menu in **Assign Predecessors** and **Assign Successors**: Copy (`Ctrl+C`), Columns, Table Font and Row, Filter By, Group and Sort By, Expand All (`Ctrl+Num +`), and Collapse All (`Ctrl+Num -`).
|
||||
- Expanded the default `RIVERBEND` sample project to 365 activities across six plant areas with a second baseline (Mid-August Rebaseline), Risks, Work Products & Documents, Issues, Thresholds, LOE and WBS Summary activities, WBS Milestones, OBS, Project/Resource/Assignment Codes, Funding, Budget Log, Spending Plan, Financial Periods with past period actuals, and typed UDFs.
|
||||
|
||||
### Fixed
|
||||
- Enabled **Delete** directly on open projects (including the default `RIVERBEND` sample project) in the Projects view, saving and closing before deletion and keeping the workspace empty on restart instead of re-seeding the sample.
|
||||
|
||||
## [0.1.0] - 2026-11-25
|
||||
|
||||
The first public release.
|
||||
|
||||
|
||||
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -2429,7 +2429,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openxer-automation"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"encoding_rs",
|
||||
@@ -2449,7 +2449,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openxer-chat"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"native-tls",
|
||||
"openssl",
|
||||
@@ -2461,7 +2461,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openxer-desktop"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"eframe",
|
||||
@@ -2482,11 +2482,11 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openxer-engine"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
|
||||
[[package]]
|
||||
name = "openxer-interchange"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"calamine",
|
||||
"chrono",
|
||||
@@ -2499,7 +2499,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "openxer-xer"
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
dependencies = [
|
||||
"chrono",
|
||||
"encoding_rs",
|
||||
|
||||
@@ -4,7 +4,7 @@ default-members = ["desktop"]
|
||||
resolver = "2"
|
||||
|
||||
[workspace.package]
|
||||
version = "0.1.0"
|
||||
version = "0.1.1"
|
||||
edition = "2021"
|
||||
license = "MIT OR Apache-2.0"
|
||||
publish = false
|
||||
|
||||
@@ -16,11 +16,11 @@
|
||||
</p>
|
||||
|
||||
<p align="center">
|
||||
<a href="https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.0-setup.exe">
|
||||
<a href="https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.1-setup.exe">
|
||||
<img alt="Download for Windows (.exe)" src="https://img.shields.io/badge/Download%20for%20Windows-.exe%20installer-0078d7?style=for-the-badge&logo=windows">
|
||||
</a>
|
||||
|
||||
<a href="https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.0-x86_64.AppImage">
|
||||
<a href="https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.1-x86_64.AppImage">
|
||||
<img alt="Download for Linux (AppImage)" src="https://img.shields.io/badge/Download%20for%20Linux-AppImage-e95420?style=for-the-badge&logo=linux&logoColor=white">
|
||||
</a>
|
||||
</p>
|
||||
@@ -240,8 +240,8 @@ Download directly from the **[Latest Release](https://github.com/OpenXER/openxer
|
||||
|
||||
| Platform | Recommended download | Portable download |
|
||||
|---|---|---|
|
||||
| **Windows 10/11 (64-bit)** | [**OpenXER-0.1.0-setup.exe**](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.0-setup.exe) (installer, no admin needed) | [OpenXER-0.1.0-windows-x64.zip](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.0-windows-x64.zip) |
|
||||
| **Linux (x86_64, X11/Wayland)** | [**OpenXER-0.1.0-x86_64.AppImage**](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.0-x86_64.AppImage) (single file, `chmod +x` and run) | [OpenXER-0.1.0-linux-x86_64.tar.gz](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.0-linux-x86_64.tar.gz) |
|
||||
| **Windows 10/11 (64-bit)** | [**OpenXER-0.1.1-setup.exe**](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.1-setup.exe) (installer, no admin needed) | [OpenXER-0.1.1-windows-x64.zip](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.1-windows-x64.zip) |
|
||||
| **Linux (x86_64, X11/Wayland)** | [**OpenXER-0.1.1-x86_64.AppImage**](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.1-x86_64.AppImage) (single file, `chmod +x` and run) | [OpenXER-0.1.1-linux-x86_64.tar.gz](https://github.com/OpenXER/openxer/releases/latest/download/OpenXER-0.1.1-linux-x86_64.tar.gz) |
|
||||
|
||||
Verify checksums with [SHA256SUMS.txt](https://github.com/OpenXER/openxer/releases/latest/download/SHA256SUMS.txt).
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -4,7 +4,7 @@ Picks activities to link to the selected activity. A predecessor is an activity
|
||||
|
||||
## What is on it
|
||||
- **Find**: type part of an activity ID or name to shorten the list.
|
||||
- **The activity list**: **Activity ID** and **Activity Name** of every other activity. With several projects open it also shows **Project ID** and lists the activities of every open project.
|
||||
- **The activity list**: **Activity ID** and **Activity Name** of every other activity, grouped under WBS bands. With several projects open it also shows **Project ID** and lists the activities of every open project. Right-click the list for **Copy** (`Ctrl+C`), **Columns**, **Table Font and Row...**, **Filter By**, **Group and Sort By**, **Expand All** (`Ctrl+Num +`) and **Collapse All** (`Ctrl+Num -`).
|
||||
- **Relationship Type**: **FS** (finish to start, the usual type), **SS** (start to start), **FF** (finish to finish) or **SF** (start to finish). New links start as FS.
|
||||
- **Lag**: a wait added to the link, typed like a duration. It starts at 0.
|
||||
- **Assign**: adds a relationship to each activity selected in the list. Click one activity, `Ctrl`+click to add or drop more, or `Shift`+click to select a run of them.
|
||||
|
||||
@@ -5,11 +5,16 @@ make a change, schedule, and send the file back out.
|
||||
|
||||
## The sample project
|
||||
A new workspace opens on **RIVERBEND**, a made-up process water upgrade in
|
||||
progress: about 190 activities with logic, three calendars, crews and
|
||||
equipment with rates, costs, expenses, codes, notebook topics and an
|
||||
as-planned baseline. Use it to try the views. To remove it, and the
|
||||
calendars, resources, codes and notebook topics only it uses, delete it in
|
||||
the Projects view once another project is open. See [Projects](view-projects).
|
||||
progress: about 365 activities across six plant areas with logic, Level of
|
||||
Effort and WBS summary activities, three calendars, hierarchical crews and
|
||||
equipment with rates and curves, costs, expenses, activity/project/resource/assignment
|
||||
codes, risks, documents, issues, thresholds, WBS milestones, funding, budget log,
|
||||
spending plan, financial periods, notebook topics and two baselines (as-planned
|
||||
and mid-August rebaseline). Use it to try every view. To remove it - along with
|
||||
the calendars, resources, codes, topics and other shared rows only it uses -
|
||||
right-click **RIVERBEND** in the Projects view and choose **Delete**. Deleting
|
||||
the last project leaves an empty workspace ready for your own schedule. See
|
||||
[Projects](view-projects).
|
||||
|
||||
## Bring a project in
|
||||
1. To start from an XER file, use `File > Import...`. The wizard reads the file
|
||||
|
||||
@@ -7,7 +7,7 @@ The Projects view lists every project in your workspace, filed under the folders
|
||||
- **Project table**: EPS folders with their projects under them. A project not yet placed sits under the first top-level folder. Each folder row shows the rollup of every project under it, child folders included.
|
||||
- **Columns**: **Project ID**, **Project Name**, **Total Activities** and **Strategic Priority** at first, leaving most of the width to the chart. **Customize Columns...** lists the others by group: **Status**, **Responsible Manager** and **Project Leveling Priority**; **Start**, **Finish**, **Planned Start**, **Actual Start**, **Actual Finish**, **Anticipated Start** and **Finish**, **Data Date**, **Must Finish By**, **Late Start**, **Late Finish** and **Baseline Finish**; **Finish Variance** and **Total Float**; **Schedule % Complete (duration)**; **Budgeted**, **Actual** and **Remaining Labor Units** and **Total Cost**; **Original**, **Current** and **Proposed Budget** with the spending and benefit plan totals; the **Not Started**, **In Progress** and **Completed** activity counts; a column for each project code (the value assigned on the **Codes** tab, read here); and the user defined fields.
|
||||
- **Project Gantt**: beside the table, one bar per project from its start to its finish, the part already worked (actual start to the data date, or to the actual finish) in a darker shade, a thin baseline bar under it when the project has a baseline, and a blue line at the project's data date. Folder rows get a summary bar over their projects. Drag the splitter between the table and the chart to share the width. The chart scrolls and zooms like the Activities Gantt: drag the top timescale band to pan, the lower band to zoom, or use the scroll bar, the wheel and `Ctrl`+wheel.
|
||||
- **Command bar**: the buttons on the right edge: **Open Project**, **Close Project**, **Add**, **Delete**, **Cut**, **Copy** and **Paste**. **Close Project** is available only while more than one project is open.
|
||||
- **Command bar**: the buttons on the right edge: **Open Project**, **Close Project**, **Add**, **Delete**, **Cut**, **Copy** and **Paste**. **Close Project** closes the selected open project (closing the last open project leaves no project open).
|
||||
- **Project Details**: tabs for the selected project: **General**, **Notebook**, **Budget Log**, **Spending Plan**, **Budget Summary**, **Dates**, **Funding**, **Codes**, **Defaults**, **Resources**, **Settings** and **Calculations**. Select an EPS folder instead and the tabs show its totals. The project **Status** (Planned, Active, Inactive, What-If, Requested) is set on the **General** tab.
|
||||
|
||||
## How the rollups are worked out
|
||||
@@ -27,7 +27,7 @@ The Projects view lists every project in your workspace, filed under the folders
|
||||
5. Click a column title to sort the projects inside each folder by it; click again for the reverse order, a third time to go back to Project ID order.
|
||||
6. To see all jobs of one status together, choose **Group by Status** on the **Layout** menu; to leave out, say, inactive projects, clear **Inactive** under **Show Status**.
|
||||
|
||||
Right-click a row or a column title for the same commands except **Close Project**, plus **Project Details** (shows or hides the details), **Edit Project Details** (opens the **General** tab), **Columns**, **Table Font and Row...**, **Filter By**, **Group and Sort By**, **Expand All**, **Collapse All** and **Collapse To...**. Right-click the chart or its date header for **Project Details**.
|
||||
Right-click a row or a column title for the same commands (including **Open Project**, **Close Project** and **Delete**), plus **Project Details** (shows or hides the details), **Edit Project Details** (opens the **General** tab), **Columns**, **Table Font and Row...**, **Filter By**, **Group and Sort By**, **Expand All**, **Collapse All** and **Collapse To...**. Right-click the chart or its date header for **Project Details**.
|
||||
- **Filter By**: **All**, **Currently Open** (the projects open now), or under **Status** one status at a time, or **Non What-if** (every project but the what-if ones).
|
||||
- **Group and Sort By**: **EPS** (the folder tree), **List** (no bands), **Responsible Manager**, **Status** or **Project Leveling Priority**.
|
||||
- **Table Font and Row...** sets this table's own font, cell colour and row height, with the same window as the Activities table. `View > Expand All`, `Collapse All` and `Collapse To...` work here too.
|
||||
@@ -41,7 +41,7 @@ In the open project's row, click a selected cell or press `F2` to type **Project
|
||||
> On the **Funding** tab of the open project, **Add** and **Delete** list which funding sources pay for it, with an **Amount** and **Fund Share** for each; click a cell to edit it. Each change is one undo step. If no funding sources exist yet, **Add** opens Funding Sources first.
|
||||
> Only the details of the project you are working on can be edited. Other projects' tabs are shown read-only, and their **Funding** tab is empty.
|
||||
> Fill Down (`Ctrl+E`, `Edit > Fill Down` or the right-click menu) works on the **Project Name** column: select two or more projects with `Shift` or `Ctrl`, and the name of the row you clicked first goes to the others as one undo step. Only the project you are working on takes a new name; the others are skipped and the status bar says so. On the other columns Fill Down is greyed.
|
||||
> A project must be closed before it can be deleted. **Delete** on a folder row deletes the folder with the folders and projects under it, after one question ([Project Folders (EPS)](project-folders)).
|
||||
> **Delete** works on both open and closed projects: an open project is saved and closed after confirmation before removal. Deleting the last project in the workspace leaves an empty workspace (no project open) without re-creating the sample on restart. **Delete** on a folder row deletes the folder with the folders and projects under it, after one question ([Project Folders (EPS)](project-folders)).
|
||||
> Deleting the sample project RIVERBEND that a new workspace starts on also removes the calendars, resources, codes, notebook topics and other shared rows only the sample uses. A row another project uses stays, and a row of yours that was named `<name>_1` because the sample held `<name>` gets its own name back. Undo puts all of it back.
|
||||
> The **Data Date** on the **Dates** tab can be typed or picked here, as in the Schedule dialog (`F9`). Any date is accepted, earlier than the current one included; nothing asks or refuses. The change is one undo step and moves no activity: schedule afterwards to recalculate the dates from it.
|
||||
> On the **Settings** tab, **Define Critical Activities** decides which activities count as critical: those with total float at or below the value you type, or those on the longest path. It is the same setting as in Schedule Options; the activity table, the bars, the critical filters and reports all follow it. Each change is one undo step.
|
||||
|
||||
@@ -215,6 +215,53 @@ pub(crate) fn add_plan_baseline(
|
||||
Ok(row.id)
|
||||
}
|
||||
|
||||
/// Store a second baseline (e.g. a mid-project rebaseline of the first-run
|
||||
/// sample) and assign it as the Secondary user baseline alongside `primary`.
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(crate) fn add_secondary_baseline(
|
||||
c: &rusqlite::Connection,
|
||||
parent: i64,
|
||||
project: &ProjectData,
|
||||
primary: i64,
|
||||
revision: &Document,
|
||||
name: &str,
|
||||
baseline_type: &str,
|
||||
stamp: &str,
|
||||
) -> Result<i64, String> {
|
||||
store::ensure(c)?;
|
||||
let pid = project.model.project.proj_id;
|
||||
let rows = store::list(c, parent)?;
|
||||
let key = next_key(&project.updated_document(), pid, &rows);
|
||||
let short = format!("{} - B2", project.model.project.name);
|
||||
let copy = xb::copy_as_baseline(revision, pid, key, &short, name, stamp);
|
||||
let info = xb::baseline_info(©, key);
|
||||
let mut row = BaselineRow {
|
||||
id: 0,
|
||||
parent,
|
||||
project_key: key,
|
||||
short_name: short,
|
||||
name: name.into(),
|
||||
baseline_type: baseline_type.into(),
|
||||
data_date: info.data_date,
|
||||
added: stamp.into(),
|
||||
updated: stamp.into(),
|
||||
xer: copy.text(),
|
||||
windows_encoding: project.document.windows_encoding,
|
||||
import_batch: None,
|
||||
};
|
||||
row.id = store::put(c, &row)?;
|
||||
store::set_user_baselines(
|
||||
c,
|
||||
parent,
|
||||
UserBaselines([
|
||||
Choice::Baseline(primary),
|
||||
Choice::Baseline(row.id),
|
||||
Choice::None,
|
||||
]),
|
||||
)?;
|
||||
Ok(row.id)
|
||||
}
|
||||
|
||||
/// Store the baselines that a file carries for project `pid` (PROJECT rows
|
||||
/// whose `orig_proj_id` is `pid`) under workspace project `parent`. Baselines
|
||||
/// already stored with the same project id are kept as they are. Returns how
|
||||
@@ -344,6 +391,9 @@ impl App {
|
||||
|
||||
/// The open project's workspace row, if it has been saved.
|
||||
pub(crate) fn workspace_row(&self) -> Option<i64> {
|
||||
if self.open_set.empty {
|
||||
return None;
|
||||
}
|
||||
let key = (
|
||||
self.project.source_name.clone(),
|
||||
self.project.model.project.proj_id,
|
||||
@@ -360,6 +410,9 @@ impl App {
|
||||
}
|
||||
|
||||
fn ensure_workspace_row(&mut self) -> Result<i64, String> {
|
||||
if self.open_set.empty {
|
||||
return Err("No project is open.".into());
|
||||
}
|
||||
if let Some(id) = self.workspace_row() {
|
||||
return Ok(id);
|
||||
}
|
||||
|
||||
@@ -121,6 +121,34 @@ impl App {
|
||||
selected: &mut Option<i64>,
|
||||
size: Vec2,
|
||||
paint: &mut dyn FnMut(&mut egui::Ui, usize, usize, bool),
|
||||
) -> ListOut {
|
||||
self.assign_list_with_menu(
|
||||
ui,
|
||||
dialog,
|
||||
grid_id,
|
||||
cols,
|
||||
keys,
|
||||
selected,
|
||||
size,
|
||||
paint,
|
||||
&mut |_, _| {},
|
||||
)
|
||||
}
|
||||
|
||||
/// [`Self::assign_list`] with a right-click context menu handler (`row` is
|
||||
/// the clicked line, or `None` for the empty area).
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub(super) fn assign_list_with_menu(
|
||||
&mut self,
|
||||
ui: &mut egui::Ui,
|
||||
dialog: &'static str,
|
||||
grid_id: &str,
|
||||
cols: &[(&str, f32)],
|
||||
keys: &[Option<i64>],
|
||||
selected: &mut Option<i64>,
|
||||
size: Vec2,
|
||||
paint: &mut dyn FnMut(&mut egui::Ui, usize, usize, bool),
|
||||
menu: &mut dyn FnMut(&mut egui::Ui, Option<usize>),
|
||||
) -> ListOut {
|
||||
let rows = self.detail.assign_rows.entry(dialog).or_default();
|
||||
let shown = rows.shown(selected, keys);
|
||||
@@ -132,10 +160,9 @@ impl App {
|
||||
shown.current,
|
||||
&shown.rows,
|
||||
size,
|
||||
&mut |ui, ev, sel| {
|
||||
if let Ev::Cell(r, c) = ev {
|
||||
paint(ui, r, c, sel);
|
||||
}
|
||||
&mut |ui, ev, sel| match ev {
|
||||
Ev::Cell(r, c) => paint(ui, r, c, sel),
|
||||
Ev::Menu(row) => menu(ui, row),
|
||||
},
|
||||
);
|
||||
if let Some(Some(key)) = out.clicked.and_then(|r| keys.get(r)) {
|
||||
|
||||
@@ -269,14 +269,91 @@ pub struct Customize {
|
||||
/// Step fields copied with the Steps context menu.
|
||||
pub use openxer_xer::edit::steps::StepCopy;
|
||||
|
||||
/// Filter applied inside Assign Predecessors / Successors.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum PickerFilter {
|
||||
#[default]
|
||||
All,
|
||||
CurrentProject,
|
||||
NotStarted,
|
||||
InProgress,
|
||||
Completed,
|
||||
Critical,
|
||||
}
|
||||
|
||||
/// Grouping mode inside Assign Predecessors / Successors.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
pub enum PickerGroup {
|
||||
/// Follow the activity table's WBS/band layout (default).
|
||||
#[default]
|
||||
Wbs,
|
||||
/// Flat activity list with no grouping bands.
|
||||
List,
|
||||
/// Grouped by Activity Status.
|
||||
Status,
|
||||
}
|
||||
|
||||
/// Optional extra columns toggled from the Assign Predecessors / Successors
|
||||
/// right-click Columns submenu.
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub enum PickerColumn {
|
||||
Status,
|
||||
OriginalDuration,
|
||||
Start,
|
||||
Finish,
|
||||
TotalFloat,
|
||||
}
|
||||
|
||||
impl PickerColumn {
|
||||
pub const ALL: [Self; 5] = [
|
||||
Self::Status,
|
||||
Self::OriginalDuration,
|
||||
Self::Start,
|
||||
Self::Finish,
|
||||
Self::TotalFloat,
|
||||
];
|
||||
|
||||
pub fn key(self) -> &'static str {
|
||||
match self {
|
||||
Self::Status => "col_status",
|
||||
Self::OriginalDuration => "col_orig_dur",
|
||||
Self::Start => "col_start",
|
||||
Self::Finish => "col_finish",
|
||||
Self::TotalFloat => "col_total_float",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn label(self) -> &'static str {
|
||||
match self {
|
||||
Self::Status => "Activity Status",
|
||||
Self::OriginalDuration => "Original Duration",
|
||||
Self::Start => "Start",
|
||||
Self::Finish => "Finish",
|
||||
Self::TotalFloat => "Total Float",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn width(self) -> f32 {
|
||||
match self {
|
||||
Self::Status => 85.,
|
||||
Self::OriginalDuration => 78.,
|
||||
Self::Start => 84.,
|
||||
Self::Finish => 84.,
|
||||
Self::TotalFloat => 72.,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// What the relationship picker's lines depend on: the search text, the
|
||||
/// project's undo snapshot, the table's Group and Sort, and the activities
|
||||
/// that take the relationship.
|
||||
/// project's undo snapshot, the table's Group and Sort, the picker's own
|
||||
/// filter/grouping, and the activities that take the relationship.
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PickerLinesKey {
|
||||
pub query: String,
|
||||
pub serial: u64,
|
||||
pub group_sort: crate::grid::layout::GroupSort,
|
||||
pub filter: PickerFilter,
|
||||
pub group: PickerGroup,
|
||||
pub targets: Vec<usize>,
|
||||
pub collapsed: BTreeSet<String>,
|
||||
}
|
||||
@@ -289,11 +366,21 @@ pub struct DetailState {
|
||||
pub rows: [Option<usize>; 2],
|
||||
context: Option<(i64, DetailTab)>,
|
||||
pub picker: Option<Picker>,
|
||||
/// Assign Predecessors / Successors: the lines of the last build and
|
||||
/// what they were built for (see `relationship_picker`).
|
||||
pub picker_lines: Option<(PickerLinesKey, std::rc::Rc<Vec<crate::grid::PickLine>>)>,
|
||||
/// Assign Predecessors / Successors: the lines of the last build, all
|
||||
/// band keys (for Collapse All), and what they were built for.
|
||||
pub picker_lines: Option<(
|
||||
PickerLinesKey,
|
||||
std::rc::Rc<Vec<crate::grid::PickLine>>,
|
||||
Vec<String>,
|
||||
)>,
|
||||
/// Bands folded shut in Assign Predecessors / Successors (band keys).
|
||||
pub picker_collapsed: BTreeSet<String>,
|
||||
/// Filter By choice in Assign Predecessors / Successors.
|
||||
pub picker_filter: PickerFilter,
|
||||
/// Group and Sort By choice in Assign Predecessors / Successors.
|
||||
pub picker_group: PickerGroup,
|
||||
/// Optional extra columns shown in Assign Predecessors / Successors.
|
||||
pub picker_columns: BTreeSet<PickerColumn>,
|
||||
/// The Activity Codes dictionary was opened from Assign: when it closes
|
||||
/// with code values to assign, the code picker opens.
|
||||
pub assign_codes_after: bool,
|
||||
@@ -356,6 +443,9 @@ impl Default for DetailState {
|
||||
picker: None,
|
||||
picker_lines: None,
|
||||
picker_collapsed: BTreeSet::new(),
|
||||
picker_filter: PickerFilter::All,
|
||||
picker_group: PickerGroup::Wbs,
|
||||
picker_columns: BTreeSet::new(),
|
||||
assign_codes_after: false,
|
||||
assign: None,
|
||||
assign_for: None,
|
||||
|
||||
@@ -1455,43 +1455,90 @@ impl App {
|
||||
// the search text, the project, Group and Sort and the selection stay
|
||||
// as they are; with several projects open they are built each frame.
|
||||
let multi = self.open_set.multi();
|
||||
let active_rows = self.active_rows();
|
||||
let filter = self.detail.picker_filter;
|
||||
let group_mode = self.detail.picker_group;
|
||||
let extra_cols: Vec<PickerColumn> = self.detail.picker_columns.iter().copied().collect();
|
||||
// Find looks inside folded bands too.
|
||||
let folded = if query.trim().is_empty() {
|
||||
self.detail.picker_collapsed.clone()
|
||||
} else {
|
||||
let searching = !query.trim().is_empty();
|
||||
let folded = if searching {
|
||||
BTreeSet::new()
|
||||
} else {
|
||||
self.detail.picker_collapsed.clone()
|
||||
};
|
||||
let group_override = match group_mode {
|
||||
PickerGroup::Wbs => None,
|
||||
PickerGroup::List => {
|
||||
let mut g = self.grid.layout.group_sort.clone();
|
||||
g.levels.clear();
|
||||
Some(g)
|
||||
}
|
||||
PickerGroup::Status => {
|
||||
let mut g = self.grid.layout.group_sort.clone();
|
||||
g.levels = vec![crate::grid::layout::GroupLevel {
|
||||
column: "status".into(),
|
||||
to_level: None,
|
||||
indent: true,
|
||||
interval: String::new(),
|
||||
}];
|
||||
Some(g)
|
||||
}
|
||||
};
|
||||
let key = self.shown_serial().map(|serial| PickerLinesKey {
|
||||
query: query.clone(),
|
||||
collapsed: folded.clone(),
|
||||
serial,
|
||||
group_sort: self.grid.layout.group_sort.clone(),
|
||||
filter,
|
||||
group: group_mode,
|
||||
targets: std::iter::once(activity)
|
||||
.chain(targets.iter().copied())
|
||||
.collect(),
|
||||
});
|
||||
let kept = match (&key, &self.detail.picker_lines) {
|
||||
(Some(key), Some((built_for, lines))) if key == built_for => Some(lines.clone()),
|
||||
(Some(key), Some((built_for, lines, bands))) if key == built_for => {
|
||||
Some((lines.clone(), bands.clone()))
|
||||
}
|
||||
_ => None,
|
||||
};
|
||||
let lines = kept.unwrap_or_else(|| {
|
||||
let lines = std::rc::Rc::new(
|
||||
self.picker_lines(query, &folded, &|k| k == activity || targets.contains(&k)),
|
||||
);
|
||||
self.detail.picker_lines = key.map(|key| (key, lines.clone()));
|
||||
lines
|
||||
let (lines, all_band_keys) = kept.unwrap_or_else(|| {
|
||||
let shown_data = self.shown();
|
||||
let crit_def = self.critical_definition();
|
||||
let (built_lines, bands) =
|
||||
self.picker_lines_with(query, &folded, group_override.clone(), &|k| {
|
||||
if k == activity || targets.contains(&k) {
|
||||
return true;
|
||||
}
|
||||
let a = &shown_data.model.activities[k];
|
||||
match filter {
|
||||
PickerFilter::All => false,
|
||||
PickerFilter::CurrentProject => active_rows.is_some_and(|n| k >= n),
|
||||
PickerFilter::NotStarted => a.status != StatusType::NotStarted,
|
||||
PickerFilter::InProgress => a.status != StatusType::InProgress,
|
||||
PickerFilter::Completed => a.status != StatusType::Completed,
|
||||
PickerFilter::Critical => !crate::grid::columns::is_critical(a, crit_def),
|
||||
}
|
||||
});
|
||||
let lines = std::rc::Rc::new(built_lines);
|
||||
self.detail.picker_lines = key.map(|key| (key, lines.clone(), bands.clone()));
|
||||
(lines, bands)
|
||||
});
|
||||
let all = self.shown();
|
||||
let origin = all.model.origin_serial;
|
||||
let leveled = all.model.options.do_level;
|
||||
let projects: Vec<String> = self
|
||||
.open_projects()
|
||||
.iter()
|
||||
.map(|p| p.model.project.name.clone())
|
||||
.collect();
|
||||
let texts: Vec<[String; 3]> = lines
|
||||
let texts: Vec<Vec<String>> = lines
|
||||
.iter()
|
||||
.map(|line| match line {
|
||||
PickLine::Band { label, .. } => [String::new(), label.clone(), String::new()],
|
||||
PickLine::Band { label, .. } => vec![label.clone()],
|
||||
PickLine::Activity(k) => {
|
||||
let a = &all.model.activities[*k];
|
||||
let mut row = Vec::with_capacity(3 + extra_cols.len());
|
||||
if multi {
|
||||
let project = self
|
||||
.open_set
|
||||
.composite
|
||||
@@ -1499,11 +1546,39 @@ impl App {
|
||||
.and_then(|c| c.origin.get(*k))
|
||||
.and_then(|&(slot, _)| projects.get(slot).cloned())
|
||||
.unwrap_or_default();
|
||||
[
|
||||
project,
|
||||
all.model.activities[*k].task_code.clone(),
|
||||
all.name(*k).to_string(),
|
||||
]
|
||||
row.push(project);
|
||||
}
|
||||
row.push(a.task_code.clone());
|
||||
row.push(all.name(*k).to_string());
|
||||
let periods = format::activity_periods(all, *k);
|
||||
for col in &extra_cols {
|
||||
let value = match col {
|
||||
PickerColumn::Status => match a.status {
|
||||
StatusType::NotStarted => "Not Started".into(),
|
||||
StatusType::InProgress => "In Progress".into(),
|
||||
StatusType::Completed => "Completed".into(),
|
||||
},
|
||||
PickerColumn::OriginalDuration => {
|
||||
let orig = all
|
||||
.details
|
||||
.get(&a.task_id)
|
||||
.map_or(a.rem, |d| d.original_duration);
|
||||
format::duration(orig, periods)
|
||||
}
|
||||
PickerColumn::Start => {
|
||||
format::date(origin, displayed_start(a, leveled))
|
||||
}
|
||||
PickerColumn::Finish => {
|
||||
format::date(origin, displayed_finish(a, leveled))
|
||||
}
|
||||
PickerColumn::TotalFloat => a
|
||||
.total_float
|
||||
.map(|f| format::duration(f, periods))
|
||||
.unwrap_or_default(),
|
||||
};
|
||||
row.push(value);
|
||||
}
|
||||
row
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -1525,6 +1600,23 @@ impl App {
|
||||
let boxes = std::cell::RefCell::new(Vec::<(usize, Rect)>::new());
|
||||
let mut fold = None;
|
||||
let mut double = None;
|
||||
let mut expand_all = false;
|
||||
let mut collapse_all = false;
|
||||
let mut copy_rows = false;
|
||||
let mut open_table_font = false;
|
||||
let mut next_filter = None;
|
||||
let mut next_group = None;
|
||||
let mut toggle_col = None;
|
||||
let mut search_focused = false;
|
||||
let has_bands = !all_band_keys.is_empty() && !searching;
|
||||
let can_expand = has_bands
|
||||
&& all_band_keys
|
||||
.iter()
|
||||
.any(|k| self.detail.picker_collapsed.contains(k));
|
||||
let can_collapse = has_bands
|
||||
&& all_band_keys
|
||||
.iter()
|
||||
.any(|k| !self.detail.picker_collapsed.contains(k));
|
||||
const DIALOG: &str = "assign_relationship";
|
||||
let title = if *predecessor {
|
||||
"Assign Predecessors"
|
||||
@@ -1550,11 +1642,26 @@ impl App {
|
||||
PickLine::Band { .. } => None,
|
||||
})
|
||||
.collect();
|
||||
let mut columns: Vec<(&str, f32)> = if multi {
|
||||
vec![
|
||||
("Project ID", 90.),
|
||||
("Activity ID", 90.),
|
||||
("Activity Name", 240.),
|
||||
]
|
||||
} else {
|
||||
vec![("Activity ID", 90.), ("Activity Name", 240.)]
|
||||
};
|
||||
for col in &extra_cols {
|
||||
columns.push((col.label(), col.width()));
|
||||
}
|
||||
let extra_width: f32 = extra_cols.iter().map(|c| c.width()).sum();
|
||||
let list_width = (if multi { 530. } else { 440. } + extra_width).min(780.);
|
||||
let mut choice = selected.map(|k| k as i64);
|
||||
let (open, clicked) = self.assign_window(ctx, &window, |app, ui| {
|
||||
ui.horizontal(|ui| {
|
||||
ui.label("Find");
|
||||
let response = ui.add(egui::TextEdit::singleline(query).desired_width(220.));
|
||||
search_focused = response.has_focus();
|
||||
app.action("picker_search", &response);
|
||||
if targets.len() > 1 {
|
||||
ui.label(format!(
|
||||
@@ -1563,26 +1670,20 @@ impl App {
|
||||
));
|
||||
}
|
||||
});
|
||||
let columns: &[(&str, f32)] = if multi {
|
||||
&[
|
||||
("Project ID", 90.),
|
||||
("Activity ID", 90.),
|
||||
("Activity Name", 240.),
|
||||
]
|
||||
} else {
|
||||
&[("Activity ID", 90.), ("Activity Name", 240.)]
|
||||
};
|
||||
let out = app.assign_list(
|
||||
let current_choice = choice;
|
||||
let out = app.assign_list_with_menu(
|
||||
ui,
|
||||
DIALOG,
|
||||
"relationship_picker",
|
||||
columns,
|
||||
&columns,
|
||||
&keys,
|
||||
&mut choice,
|
||||
Vec2::new(if multi { 530. } else { 440. }, 210.),
|
||||
Vec2::new(list_width, 210.),
|
||||
&mut |ui, r, c, _| {
|
||||
let Some((fill, ink)) = band_colors[r] else {
|
||||
cell(ui, &texts[r][c + usize::from(!multi)]);
|
||||
if let Some(t) = texts[r].get(c) {
|
||||
cell(ui, t);
|
||||
}
|
||||
return;
|
||||
};
|
||||
// A band: its color across the row and its caption
|
||||
@@ -1618,12 +1719,106 @@ impl App {
|
||||
.text(
|
||||
Pos2::new(band_left.get() + 16. + indent, rect.center().y),
|
||||
Align2::LEFT_CENTER,
|
||||
&texts[r][1],
|
||||
&texts[r][0],
|
||||
form::font(),
|
||||
ink,
|
||||
);
|
||||
}
|
||||
},
|
||||
&mut |ui, row| {
|
||||
use crate::chrome::{Icon, Item};
|
||||
let mut m = crate::context_menu::Menu::on(ui, "picker_menu");
|
||||
let row_is_activity =
|
||||
row.and_then(|r| keys.get(r)).is_some_and(Option::is_some);
|
||||
let can_copy = current_choice.is_some() || row_is_activity;
|
||||
if m.item_if(
|
||||
"copy",
|
||||
Item::new("Copy").key("Ctrl+C").icon(Icon::Copy),
|
||||
can_copy,
|
||||
) {
|
||||
copy_rows = true;
|
||||
}
|
||||
m.submenu("columns", Item::new("Columns").icon(Icon::Columns), |m| {
|
||||
for col in PickerColumn::ALL {
|
||||
if m.check(col.key(), col.label(), extra_cols.contains(&col)) {
|
||||
toggle_col = Some(col);
|
||||
}
|
||||
}
|
||||
});
|
||||
if m.item(
|
||||
"table_font",
|
||||
Item::new("Table Font and Row...").icon(Icon::TableFont),
|
||||
) {
|
||||
open_table_font = true;
|
||||
}
|
||||
m.separator();
|
||||
m.submenu(
|
||||
"filter_by",
|
||||
Item::new("Filter By").icon(Icon::Filter),
|
||||
|m| {
|
||||
let choices = [
|
||||
("filter_all", "All Activities", PickerFilter::All),
|
||||
(
|
||||
"filter_current_project",
|
||||
"Current Project's Activities",
|
||||
PickerFilter::CurrentProject,
|
||||
),
|
||||
(
|
||||
"filter_not_started",
|
||||
"Not Started",
|
||||
PickerFilter::NotStarted,
|
||||
),
|
||||
(
|
||||
"filter_in_progress",
|
||||
"In Progress",
|
||||
PickerFilter::InProgress,
|
||||
),
|
||||
("filter_completed", "Completed", PickerFilter::Completed),
|
||||
("filter_critical", "Critical", PickerFilter::Critical),
|
||||
];
|
||||
for (k, label, f) in choices {
|
||||
if m.check(k, label, filter == f) {
|
||||
next_filter = Some(f);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
m.submenu(
|
||||
"group_by",
|
||||
Item::new("Group and Sort By").icon(Icon::GroupSort),
|
||||
|m| {
|
||||
let choices = [
|
||||
("group_wbs", "WBS", PickerGroup::Wbs),
|
||||
("group_list", "List", PickerGroup::List),
|
||||
("group_status", "Activity Status", PickerGroup::Status),
|
||||
];
|
||||
for (k, label, g) in choices {
|
||||
if m.check(k, label, group_mode == g) {
|
||||
next_group = Some(g);
|
||||
}
|
||||
}
|
||||
},
|
||||
);
|
||||
m.separator();
|
||||
if m.item_if(
|
||||
"expand_all",
|
||||
Item::new("Expand All")
|
||||
.key("Ctrl+Num +")
|
||||
.icon(Icon::ExpandAll),
|
||||
can_expand,
|
||||
) {
|
||||
expand_all = true;
|
||||
}
|
||||
if m.item_if(
|
||||
"collapse_all",
|
||||
Item::new("Collapse All")
|
||||
.key("Ctrl+Num -")
|
||||
.icon(Icon::CollapseAll),
|
||||
can_collapse,
|
||||
) {
|
||||
collapse_all = true;
|
||||
}
|
||||
},
|
||||
);
|
||||
double = out.double;
|
||||
// A click on a band's box, or a double click on the band, folds
|
||||
@@ -1664,12 +1859,68 @@ impl App {
|
||||
}
|
||||
});
|
||||
});
|
||||
// Keyboard shortcuts for Expand All, Collapse All and Copy while open.
|
||||
if open && !search_focused {
|
||||
let (k_expand, k_collapse, k_copy) = ctx.input(|i| {
|
||||
let cmd = i.modifiers.command && !i.modifiers.alt;
|
||||
(
|
||||
cmd && (i.key_pressed(Key::Plus) || i.key_pressed(Key::Equals)),
|
||||
cmd && i.key_pressed(Key::Minus),
|
||||
cmd && i.key_pressed(Key::C),
|
||||
)
|
||||
});
|
||||
if k_expand && can_expand {
|
||||
expand_all = true;
|
||||
}
|
||||
if k_collapse && can_collapse {
|
||||
collapse_all = true;
|
||||
}
|
||||
if k_copy && choice.is_some() {
|
||||
copy_rows = true;
|
||||
}
|
||||
}
|
||||
*selected = choice.map(|k| k as usize);
|
||||
if let Some(key) = fold {
|
||||
if expand_all {
|
||||
self.detail.picker_collapsed.clear();
|
||||
} else if collapse_all {
|
||||
self.detail.picker_collapsed = all_band_keys.into_iter().collect();
|
||||
} else if let Some(key) = fold {
|
||||
if !self.detail.picker_collapsed.remove(&key) {
|
||||
self.detail.picker_collapsed.insert(key);
|
||||
}
|
||||
}
|
||||
if let Some(f) = next_filter {
|
||||
self.detail.picker_filter = f;
|
||||
}
|
||||
if let Some(g) = next_group {
|
||||
if self.detail.picker_group != g {
|
||||
self.detail.picker_group = g;
|
||||
self.detail.picker_collapsed.clear();
|
||||
}
|
||||
}
|
||||
if let Some(col) = toggle_col {
|
||||
if !self.detail.picker_columns.remove(&col) {
|
||||
self.detail.picker_columns.insert(col);
|
||||
}
|
||||
}
|
||||
if copy_rows {
|
||||
let picked = self.assign_picked(DIALOG, choice);
|
||||
let mut out_lines = Vec::with_capacity(picked.len());
|
||||
for k in picked {
|
||||
if let Some(row_idx) = keys.iter().position(|x| *x == Some(k)) {
|
||||
if let Some(cells) = texts.get(row_idx) {
|
||||
out_lines.push(cells.join("\t"));
|
||||
}
|
||||
}
|
||||
}
|
||||
if !out_lines.is_empty() {
|
||||
ctx.copy_text(out_lines.join("\n"));
|
||||
self.status = "Copied to clipboard".into();
|
||||
}
|
||||
}
|
||||
if open_table_font {
|
||||
self.open_table_font_for(crate::layout_opts::TableTarget::Activities);
|
||||
}
|
||||
// Assign takes every selected activity; a double click the one.
|
||||
let mut picks: Vec<usize> = match clicked {
|
||||
Some("picker_assign") => self
|
||||
|
||||
@@ -11,6 +11,23 @@
|
||||
use super::*;
|
||||
|
||||
const NOTED_KEY: &str = "first_run_noted";
|
||||
/// Set once the workspace has been initialized (seeded with the sample or had
|
||||
/// a project deleted), so emptying the workspace does not re-seed the sample
|
||||
/// on the next start.
|
||||
pub(crate) const WORKSPACE_SEEDED_KEY: &str = "workspace_seeded";
|
||||
|
||||
pub(crate) fn mark_seeded(store: &Store) {
|
||||
let _ = store.set_preference(WORKSPACE_SEEDED_KEY, "1");
|
||||
}
|
||||
|
||||
pub(crate) fn was_seeded(store: &Store) -> bool {
|
||||
store
|
||||
.preference(WORKSPACE_SEEDED_KEY)
|
||||
.ok()
|
||||
.flatten()
|
||||
.is_some()
|
||||
|| store.preference(NOTED_KEY).ok().flatten().is_some()
|
||||
}
|
||||
/// The status message of the first start. It stays short enough to fit in
|
||||
/// the status bar's message panel beside the AI agents hint on a 1366 px
|
||||
/// wide window (`ai_agents::tests::hint_fits_beside_the_first_run_note`):
|
||||
@@ -21,20 +38,22 @@ const NOTED_KEY: &str = "first_run_noted";
|
||||
pub(crate) const SAMPLE_NOTE: &str =
|
||||
"RIVERBEND is a sample project. Use File > Import... or drop an XER file.";
|
||||
|
||||
/// Store the first-run sample's as-planned copy `plan` as its baseline and
|
||||
/// note which dictionary rows are the sample's: those the workspace
|
||||
/// dictionary has now and had not `before` the sample was stored.
|
||||
/// Store the first-run sample's as-planned copy `plan` (Project and Primary
|
||||
/// baseline) and mid-project copy `revision` (Secondary baseline), and note
|
||||
/// which dictionary rows are the sample's: those the workspace dictionary has
|
||||
/// now and had not `before` the sample was stored.
|
||||
pub(crate) fn install_sample(
|
||||
store: &mut Store,
|
||||
project: &mut ProjectData,
|
||||
plan: &ProjectData,
|
||||
revision: &ProjectData,
|
||||
before: &openxer_xer::Document,
|
||||
) -> Result<(), String> {
|
||||
let row = store
|
||||
.id_of(&project.source_name, project.model.project.proj_id)
|
||||
.ok_or("the sample is not in the workspace")?;
|
||||
let start = openxer_xer::date_string(plan.model.origin_serial, plan.model.project.plan_start);
|
||||
crate::baselines::add_plan_baseline(
|
||||
let primary = crate::baselines::add_plan_baseline(
|
||||
store.connection(),
|
||||
row,
|
||||
project,
|
||||
@@ -42,6 +61,20 @@ pub(crate) fn install_sample(
|
||||
"As planned at notice to proceed",
|
||||
&start,
|
||||
)?;
|
||||
let rev_date = openxer_xer::date_string(
|
||||
revision.model.origin_serial,
|
||||
revision.model.project.data_date,
|
||||
);
|
||||
crate::baselines::add_secondary_baseline(
|
||||
store.connection(),
|
||||
row,
|
||||
project,
|
||||
primary,
|
||||
&revision.updated_document(),
|
||||
"Mid-August Rebaseline (Aug 2026)",
|
||||
"2",
|
||||
&rev_date,
|
||||
)?;
|
||||
if store.shared()? {
|
||||
openxer_automation::workspace_db::record_sample(store.connection(), row, before)?;
|
||||
}
|
||||
@@ -73,6 +106,9 @@ impl App {
|
||||
/// The sample is the only project in a workspace that has not shown the
|
||||
/// note yet: say what it is, once.
|
||||
fn note_first_run(&mut self) {
|
||||
if !self.has_open_project() {
|
||||
return;
|
||||
}
|
||||
if self.store.preference(NOTED_KEY).ok().flatten().is_some() {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -67,11 +67,15 @@ impl App {
|
||||
}
|
||||
/// `OpenXER : <project ID> (<project name>)`, sent only when it changes.
|
||||
fn window_title(&mut self, ctx: &egui::Context) {
|
||||
let title = format!(
|
||||
let title = if self.open_set.empty {
|
||||
"OpenXER".to_string()
|
||||
} else {
|
||||
format!(
|
||||
"OpenXER : {} ({})",
|
||||
self.project.model.project.name,
|
||||
views::project_title(&self.project)
|
||||
);
|
||||
)
|
||||
};
|
||||
let key = egui::Id::new("openxer_window_title");
|
||||
if ctx.data(|d| d.get_temp::<String>(key)).as_ref() != Some(&title) {
|
||||
ctx.send_viewport_cmd(egui::ViewportCommand::Title(title.clone()));
|
||||
@@ -368,10 +372,6 @@ impl App {
|
||||
|
||||
/// Texts of the fixed status panels, in order.
|
||||
pub(super) fn status_panels(&self) -> Vec<String> {
|
||||
let data_date = format::date(
|
||||
self.project.model.origin_serial,
|
||||
self.project.model.project.data_date,
|
||||
);
|
||||
let user = std::env::var("USERNAME")
|
||||
.or_else(|_| std::env::var("USER"))
|
||||
.unwrap_or_else(|_| "local".into());
|
||||
@@ -381,6 +381,17 @@ impl App {
|
||||
.file_name()
|
||||
.map(|name| name.to_string_lossy().into_owned())
|
||||
.unwrap_or_else(|| "workspace".into());
|
||||
if self.open_set.empty {
|
||||
return vec![
|
||||
"No project open".into(),
|
||||
format!("User: {user}"),
|
||||
format!("Workspace: {db}"),
|
||||
];
|
||||
}
|
||||
let data_date = format::date(
|
||||
self.project.model.origin_serial,
|
||||
self.project.model.project.data_date,
|
||||
);
|
||||
let mut panels = vec![
|
||||
format!("Data Date: {data_date}"),
|
||||
format!("Baseline: {}", self.baseline_label()),
|
||||
|
||||
@@ -335,23 +335,37 @@ impl App {
|
||||
)
|
||||
}
|
||||
|
||||
/// The lines of an activity picker: every activity whose ID or name
|
||||
/// contains `query`, under the bands and in the order the table's Group
|
||||
/// and Sort put them now. A picker offers every activity, so the
|
||||
/// layout's filter, the WBS filter and the table's collapsed bands do
|
||||
/// not apply; `collapsed` holds the bands folded in the picker itself.
|
||||
/// Activities `skip` names are left out, and so is a band left empty.
|
||||
#[cfg(test)]
|
||||
pub(crate) fn picker_lines(
|
||||
&self,
|
||||
query: &str,
|
||||
collapsed: &BTreeSet<String>,
|
||||
skip: &dyn Fn(usize) -> bool,
|
||||
) -> Vec<PickLine> {
|
||||
self.picker_lines_with(query, collapsed, None, skip).0
|
||||
}
|
||||
|
||||
/// The lines of an activity picker: every activity whose ID or name
|
||||
/// contains `query`, under the bands and in the order of `group_override`
|
||||
/// (or the table's Group and Sort when `None`). A picker offers every
|
||||
/// activity, so the layout's filter, the WBS filter and the table's
|
||||
/// collapsed bands do not apply; `collapsed` holds the bands folded in
|
||||
/// the picker itself. Activities `skip` names are left out, and so is a
|
||||
/// band left empty. Also returns every band key in the uncollapsed tree
|
||||
/// (for Collapse All).
|
||||
pub(crate) fn picker_lines_with(
|
||||
&self,
|
||||
query: &str,
|
||||
collapsed: &BTreeSet<String>,
|
||||
group_override: Option<layout::GroupSort>,
|
||||
skip: &dyn Fn(usize) -> bool,
|
||||
) -> (Vec<PickLine>, Vec<String>) {
|
||||
let shown = self.shown();
|
||||
let catalog = columns::catalog(shown);
|
||||
let ix = self.shared_index_at(self.shown_serial());
|
||||
let layout = layout::Layout {
|
||||
filter: filters::FilterSelection::default(),
|
||||
group_sort: group_override.unwrap_or_else(|| self.grid.layout.group_sort.clone()),
|
||||
..self.grid.layout.clone()
|
||||
};
|
||||
let built = group::build(
|
||||
@@ -366,7 +380,7 @@ impl App {
|
||||
users: &self.grid.user_filters,
|
||||
},
|
||||
);
|
||||
built
|
||||
let lines: Vec<PickLine> = built
|
||||
.rows
|
||||
.iter()
|
||||
.filter_map(|row| match *row {
|
||||
@@ -384,7 +398,47 @@ impl App {
|
||||
})
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
// Every non-empty band key (including nested bands inside folded
|
||||
// parents), so Collapse All collapses every level cleanly.
|
||||
let all_bands: Vec<String> = if collapsed.is_empty() {
|
||||
lines
|
||||
.iter()
|
||||
.filter_map(|l| match l {
|
||||
PickLine::Band { key, .. } => Some(key.clone()),
|
||||
PickLine::Activity(_) => None,
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
let empty = BTreeSet::new();
|
||||
let uncollapsed = group::build(
|
||||
shown,
|
||||
&ix,
|
||||
&catalog,
|
||||
&layout,
|
||||
&Scope {
|
||||
query,
|
||||
wbs_filter: None,
|
||||
collapsed: &empty,
|
||||
users: &self.grid.user_filters,
|
||||
},
|
||||
);
|
||||
uncollapsed
|
||||
.rows
|
||||
.iter()
|
||||
.filter_map(|row| match *row {
|
||||
Row::Group(b) => {
|
||||
let band = &uncollapsed.bands[b];
|
||||
band.members
|
||||
.iter()
|
||||
.any(|&m| !skip(m))
|
||||
.then(|| band.key.clone())
|
||||
}
|
||||
Row::Activity(_) => None,
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
(lines, all_bands)
|
||||
}
|
||||
|
||||
/// Table rows of the active project in display order (rows of other open
|
||||
|
||||
@@ -476,7 +476,12 @@ fn whats_new_shows_the_changelog_newest_release_first() {
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
assert_eq!(headings.first(), Some(&"Unreleased"), "{headings:?}");
|
||||
assert!(
|
||||
headings
|
||||
.first()
|
||||
.is_some_and(|h| *h == "Unreleased" || h.starts_with(env!("CARGO_PKG_VERSION"))),
|
||||
"{headings:?}"
|
||||
);
|
||||
let bullets = t
|
||||
.blocks
|
||||
.iter()
|
||||
|
||||
@@ -485,6 +485,7 @@ fn main() -> eframe::Result<()> {
|
||||
lock,
|
||||
store,
|
||||
project,
|
||||
empty,
|
||||
pending,
|
||||
replace_prompt,
|
||||
error: initial_error,
|
||||
@@ -493,11 +494,15 @@ fn main() -> eframe::Result<()> {
|
||||
std::process::exit(1)
|
||||
};
|
||||
chrome::preload_fonts();
|
||||
let initial_title = format!(
|
||||
let initial_title = if empty {
|
||||
"OpenXER".to_string()
|
||||
} else {
|
||||
format!(
|
||||
"OpenXER : {} ({})",
|
||||
project.model.project.name,
|
||||
views::project_title(&project)
|
||||
);
|
||||
)
|
||||
};
|
||||
let saved_place = window_place::load(&store);
|
||||
window_place::seed(saved_place);
|
||||
// On Windows, winit 0.30 calls ShowWindow(SW_MAXIMIZE) -> ShowWindow(SW_HIDE)
|
||||
@@ -521,8 +526,15 @@ fn main() -> eframe::Result<()> {
|
||||
let cloak = window_place::StartupCloak::engage(defer_maximize);
|
||||
let mut app = App::new(&cc.egui_ctx, store, project);
|
||||
app.startup_cloak = cloak;
|
||||
if empty {
|
||||
app.enter_empty_workspace();
|
||||
app.status =
|
||||
"No project open. Use File > New... or File > Import... to add a project."
|
||||
.into();
|
||||
} else {
|
||||
app.adopt_file_baselines();
|
||||
app.restore_open_set();
|
||||
}
|
||||
#[cfg(debug_assertions)]
|
||||
{
|
||||
app.capture_dir = args
|
||||
@@ -566,6 +578,9 @@ struct Startup {
|
||||
lock: store::WorkspaceLock,
|
||||
store: Store,
|
||||
project: ProjectData,
|
||||
/// The workspace has no project to open (its projects were deleted); start
|
||||
/// in the empty-workspace state on the Projects view.
|
||||
empty: bool,
|
||||
pending: Option<(Document, String)>,
|
||||
/// A project read from a file the workspace already has a copy of (the
|
||||
/// copy's workspace id), waiting for the user to choose.
|
||||
@@ -622,22 +637,28 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
||||
let mut initial_error = None;
|
||||
let mut pending = None;
|
||||
let mut replace_prompt = None;
|
||||
// The as-planned copy of the sample, while the window starts on a fresh
|
||||
// sample (it becomes its baseline once the sample is stored).
|
||||
// The as-planned and mid-project rebaseline copies of the sample, while
|
||||
// the window starts on a fresh sample (stored as its two baselines).
|
||||
let mut fresh_sample = None;
|
||||
let mut empty = false;
|
||||
let mut project = match store.last() {
|
||||
Ok(Some(saved)) => saved,
|
||||
Ok(None) if file.is_none() && first_run::was_seeded(&store) => {
|
||||
empty = true;
|
||||
open_set::empty_placeholder()
|
||||
}
|
||||
Ok(None) => {
|
||||
let (current, plan) = fallback_sample(&store);
|
||||
fresh_sample = Some(plan);
|
||||
first_run::mark_seeded(&store);
|
||||
let (current, plan, revision) = fallback_sample(&store);
|
||||
fresh_sample = Some((plan, revision));
|
||||
current
|
||||
}
|
||||
Err(error) => {
|
||||
initial_error = Some(format!(
|
||||
"The project open when OpenXER last closed could not be opened, so the sample project is shown instead. That project is still in the workspace: {error}"
|
||||
));
|
||||
let (current, plan) = fallback_sample(&store);
|
||||
fresh_sample = Some(plan);
|
||||
let (current, plan, revision) = fallback_sample(&store);
|
||||
fresh_sample = Some((plan, revision));
|
||||
current
|
||||
}
|
||||
};
|
||||
@@ -665,6 +686,7 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
||||
store.forget_mark(&key);
|
||||
project = imported;
|
||||
fresh_sample = None;
|
||||
empty = false;
|
||||
}
|
||||
}
|
||||
Err(error) => initial_error = Some(error),
|
||||
@@ -678,6 +700,7 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
||||
Err(error) => initial_error = Some(error),
|
||||
}
|
||||
}
|
||||
if !empty {
|
||||
if project
|
||||
.model
|
||||
.activities
|
||||
@@ -707,18 +730,22 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
||||
format!("The project could not be saved to the workspace: {error}"),
|
||||
),
|
||||
}
|
||||
if let (Some(plan), Some(before)) = (fresh_sample, dictionary_before) {
|
||||
if let Err(error) = first_run::install_sample(&mut store, &mut project, &plan, &before) {
|
||||
if let (Some((plan, revision)), Some(before)) = (fresh_sample, dictionary_before) {
|
||||
if let Err(error) =
|
||||
first_run::install_sample(&mut store, &mut project, &plan, &revision, &before)
|
||||
{
|
||||
note(
|
||||
&mut initial_error,
|
||||
format!("The sample project's baseline could not be stored: {error}"),
|
||||
format!("The sample project's baselines could not be stored: {error}"),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
Some(Startup {
|
||||
lock,
|
||||
store,
|
||||
project,
|
||||
empty,
|
||||
pending,
|
||||
replace_prompt,
|
||||
error: initial_error,
|
||||
@@ -730,7 +757,7 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
||||
/// under the sample's name and key (a schedule built in the sample, which
|
||||
/// may have failed to load), the sample gets a name of its own, so saving it
|
||||
/// can never replace that project.
|
||||
fn fallback_sample(store: &Store) -> (ProjectData, ProjectData) {
|
||||
fn fallback_sample(store: &Store) -> (ProjectData, ProjectData, ProjectData) {
|
||||
let sample = openxer_xer::sample_project::sample_project();
|
||||
let mut p = sample.current;
|
||||
let key = p.model.project.proj_id;
|
||||
@@ -748,7 +775,7 @@ fn fallback_sample(store: &Store) -> (ProjectData, ProjectData) {
|
||||
}
|
||||
p.source_name = name;
|
||||
}
|
||||
(p, sample.plan)
|
||||
(p, sample.plan, sample.revision)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
@@ -56,6 +56,11 @@ pub struct Composite {
|
||||
|
||||
#[derive(Default)]
|
||||
pub struct OpenSet {
|
||||
/// No project is currently open (the user closed or deleted the last open
|
||||
/// project, or restarted an emptied workspace). `App.project` holds an
|
||||
/// unsaved empty placeholder until a project is opened, created or
|
||||
/// imported.
|
||||
pub empty: bool,
|
||||
/// Workspace id of the active project (`App.project`).
|
||||
pub active: Option<i64>,
|
||||
/// Workspace id of the Default Project.
|
||||
@@ -93,11 +98,70 @@ pub struct OpenSet {
|
||||
impl OpenSet {
|
||||
/// More than one project is open.
|
||||
pub fn multi(&self) -> bool {
|
||||
!self.parked.is_empty()
|
||||
!self.empty && !self.parked.is_empty()
|
||||
}
|
||||
}
|
||||
|
||||
/// An unsaved empty `ProjectData` kept in `App.project` while no project is
|
||||
/// open (`OpenSet::empty`). It has no activities and is never written to the
|
||||
/// workspace database.
|
||||
pub(crate) fn empty_placeholder() -> ProjectData {
|
||||
let mut cal = openxer_xer::calendar_data::CalendarData::default();
|
||||
for day in 1..=5 {
|
||||
cal.week[day] = vec![(8 * 60, 12 * 60), (13 * 60, 17 * 60)];
|
||||
}
|
||||
let cal_text = cal.serialize();
|
||||
let text = format!(
|
||||
"ERMHDR\t25.12\t2026-01-01\tProject\tOpenXER\tOpenXER\tdbxDatabaseNoName\tProject Management\tUSD\n\
|
||||
%T\tCALENDAR\n\
|
||||
%F\tclndr_id\tdefault_flag\tclndr_name\tclndr_type\tday_hr_cnt\tweek_hr_cnt\tmonth_hr_cnt\tyear_hr_cnt\trsrc_private\tclndr_data\n\
|
||||
%R\t1\tY\tStandard\tCA_Base\t8\t40\t172\t2000\tN\t{cal_text}\n\
|
||||
%T\tPROJECT\n\
|
||||
%F\tproj_id\tproj_short_name\tclndr_id\tplan_start_date\tlast_recalc_date\n\
|
||||
%R\t1\t\t1\t2026-01-01 08:00\t2026-01-01 08:00\n\
|
||||
%E\n"
|
||||
);
|
||||
let doc = openxer_xer::Document::parse(&text).expect("empty placeholder XER");
|
||||
ProjectData::from_document(doc, 1, String::new()).expect("empty placeholder loads")
|
||||
}
|
||||
|
||||
impl App {
|
||||
/// True when at least one project is open.
|
||||
pub(crate) fn has_open_project(&self) -> bool {
|
||||
!self.open_set.empty
|
||||
}
|
||||
|
||||
/// Leave the active project open state and enter an empty workspace
|
||||
/// (Projects view, no project open). The caller saves or discards the
|
||||
/// closing project first.
|
||||
pub(crate) fn enter_empty_workspace(&mut self) {
|
||||
self.project = empty_placeholder();
|
||||
self.open_set.empty = true;
|
||||
self.open_set.active = None;
|
||||
self.open_set.default = None;
|
||||
self.open_set.parked.clear();
|
||||
self.open_set.composite = None;
|
||||
self.open_set.undo.clear();
|
||||
self.open_set.redo.clear();
|
||||
self.open_set.steps_seen = 0;
|
||||
self.open_set.version += 1;
|
||||
self.history = history::History::new(&self.project);
|
||||
self.records_revision = 0;
|
||||
self.dirty = false;
|
||||
self.reset_project_ui();
|
||||
self.selected = None;
|
||||
self.query.clear();
|
||||
self.wbs_filter = None;
|
||||
self.collapsed.clear();
|
||||
self.date_edits.clear();
|
||||
self.data_date.clear();
|
||||
self.must_finish.clear();
|
||||
self.saved_projects = self.store.list().unwrap_or_default();
|
||||
self.views.projects.invalidate();
|
||||
self.show_view(views::MainView::Projects);
|
||||
self.store.clear_last();
|
||||
self.save_open_set();
|
||||
}
|
||||
/// What the activity table and the Gantt show: every open project.
|
||||
pub(crate) fn shown(&self) -> &ProjectData {
|
||||
self.open_set
|
||||
@@ -130,6 +194,9 @@ impl App {
|
||||
|
||||
/// The open projects, the active one first (slot order).
|
||||
pub(crate) fn open_projects(&self) -> Vec<&ProjectData> {
|
||||
if self.open_set.empty {
|
||||
return vec![];
|
||||
}
|
||||
std::iter::once(&self.project)
|
||||
.chain(self.open_set.parked.iter().map(|p| &p.project))
|
||||
.collect()
|
||||
@@ -180,6 +247,9 @@ impl App {
|
||||
|
||||
/// The workspace id of the active project, saving it first if needed.
|
||||
fn ensure_active_id(&mut self) -> Option<i64> {
|
||||
if self.open_set.empty {
|
||||
return None;
|
||||
}
|
||||
if self.open_set.active.is_none() {
|
||||
self.open_set.active = self.store.id_of(
|
||||
&self.project.source_name,
|
||||
@@ -483,6 +553,9 @@ impl App {
|
||||
|
||||
/// Reopen the projects that were open with the active one last time.
|
||||
pub(crate) fn restore_open_set(&mut self) {
|
||||
if self.open_set.empty {
|
||||
return;
|
||||
}
|
||||
let Some(active) = self.ensure_active_id() else {
|
||||
return;
|
||||
};
|
||||
@@ -501,6 +574,11 @@ impl App {
|
||||
.as_array()
|
||||
.map(|a| a.iter().filter_map(|v| v.as_i64()).collect())
|
||||
.unwrap_or_default();
|
||||
if ids.is_empty() && value["active"].is_null() {
|
||||
self.enter_empty_workspace();
|
||||
self.status = "No project open. Open a project from the Projects view.".into();
|
||||
return;
|
||||
}
|
||||
let mut notes = vec![];
|
||||
if ids.contains(&active) {
|
||||
notes = self.clear_number_clashes(&ids, &[active]);
|
||||
@@ -606,11 +684,11 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// File > Close Project: close the active project; another open project
|
||||
/// (the default one first) becomes active.
|
||||
/// Close the active project: another open project (the default one first)
|
||||
/// becomes active, or the workspace enters the empty (no open project)
|
||||
/// state on the Projects view.
|
||||
pub(crate) fn close_active_project(&mut self) {
|
||||
if self.open_set.parked.is_empty() {
|
||||
self.status = "The last open project stays open".into();
|
||||
if self.open_set.empty {
|
||||
return;
|
||||
}
|
||||
if self.dirty {
|
||||
@@ -619,6 +697,13 @@ impl App {
|
||||
return;
|
||||
}
|
||||
}
|
||||
let name = self.project.model.project.name.clone();
|
||||
if self.open_set.parked.is_empty() {
|
||||
self.keep_closing_history();
|
||||
self.enter_empty_workspace();
|
||||
self.status = format!("{name} closed");
|
||||
return;
|
||||
}
|
||||
let closing = self.open_set.active;
|
||||
let next = self
|
||||
.open_set
|
||||
@@ -626,7 +711,6 @@ impl App {
|
||||
.iter()
|
||||
.position(|p| Some(p.id) == self.open_set.default)
|
||||
.unwrap_or(0);
|
||||
let name = self.project.model.project.name.clone();
|
||||
self.activate_parked(next);
|
||||
self.open_set.parked.retain(|p| Some(p.id) != closing);
|
||||
if self.open_set.default == closing || self.open_set.default.is_none() {
|
||||
|
||||
@@ -18,6 +18,10 @@ impl App {
|
||||
/// [`App::save`], returning the failure instead of showing it.
|
||||
pub(crate) fn try_save(&mut self) -> Result<(), String> {
|
||||
self.save_view();
|
||||
if self.open_set.empty {
|
||||
self.dirty = false;
|
||||
return Ok(());
|
||||
}
|
||||
// Other open projects first, so the active one is the workspace's last project.
|
||||
self.save_parked()?;
|
||||
match self.store.save_stored(&self.project) {
|
||||
@@ -58,6 +62,7 @@ impl App {
|
||||
self.load_from(p, true);
|
||||
}
|
||||
fn load_from(&mut self, p: ProjectData, file: bool) {
|
||||
if !self.open_set.empty {
|
||||
if self.any_dirty() {
|
||||
self.save();
|
||||
if self.any_dirty() {
|
||||
@@ -67,6 +72,8 @@ impl App {
|
||||
self.keep_closing_history();
|
||||
// Loading one project replaces the open set.
|
||||
self.close_parked();
|
||||
}
|
||||
self.open_set.empty = false;
|
||||
if file {
|
||||
// Only now: the projects saved and closed above still needed it.
|
||||
self.store
|
||||
@@ -291,6 +298,10 @@ impl App {
|
||||
/// Add without the wizard: the row goes in at once and its name cell
|
||||
/// opens for typing.
|
||||
pub(crate) fn new_activity(&mut self) {
|
||||
if self.open_set.empty {
|
||||
self.status = "Open or create a project first.".into();
|
||||
return;
|
||||
}
|
||||
let place = self.new_activity_place();
|
||||
let i = self.insert_new_activity(&place);
|
||||
// The name cell opens with the new name selected: typing replaces
|
||||
@@ -349,7 +360,7 @@ impl App {
|
||||
}
|
||||
if changed {
|
||||
self.records_revision = self.history.revision();
|
||||
self.dirty = true;
|
||||
self.dirty = !self.open_set.empty;
|
||||
self.status = if redo { "Redo" } else { "Undo" }.into();
|
||||
self.date_edits.clear();
|
||||
self.edit_cell = None;
|
||||
|
||||
@@ -99,8 +99,9 @@ const WBS_TABLE: [&str; 23] = [
|
||||
const WBS_CHART: [&str; 1] = ["WBS Details"];
|
||||
|
||||
/// The Projects table menu of a project row.
|
||||
const PROJECTS_TABLE: [&str; 21] = [
|
||||
const PROJECTS_TABLE: [&str; 22] = [
|
||||
"Open Project",
|
||||
"Close Project",
|
||||
"Project Details",
|
||||
"Edit Project Details",
|
||||
SEP,
|
||||
|
||||
@@ -303,6 +303,10 @@ impl App {
|
||||
|
||||
/// F9 and Tools > Schedule: open the Schedule dialog.
|
||||
pub(crate) fn open_schedule_dialog(&mut self) {
|
||||
if self.open_set.empty {
|
||||
self.status = "Open or create a project before scheduling.".into();
|
||||
return;
|
||||
}
|
||||
if let Some((activity, field)) = self.edit_cell.take() {
|
||||
if !self.apply_cell(activity, field, &self.edit_text.clone()) {
|
||||
return;
|
||||
|
||||
@@ -100,7 +100,7 @@ fn a_new_workspace_starts_on_the_sample() {
|
||||
let row = started.store.list().unwrap()[0].0;
|
||||
let c = started.store.connection();
|
||||
let baselines = crate::baselines::store::list(c, row).unwrap();
|
||||
assert_eq!(baselines.len(), 1);
|
||||
assert_eq!(baselines.len(), 2);
|
||||
assert_eq!(
|
||||
openxer_interchange::baseline::project_value(
|
||||
&started.project.document,
|
||||
@@ -109,11 +109,16 @@ fn a_new_workspace_starts_on_the_sample() {
|
||||
),
|
||||
baselines[0].project_key.to_string()
|
||||
);
|
||||
let ub = crate::baselines::store::user_baselines(c, row).0;
|
||||
assert_eq!(
|
||||
crate::baselines::store::user_baselines(c, row).0[0],
|
||||
ub[0],
|
||||
crate::baselines::store::Choice::Baseline(baselines[0].id)
|
||||
);
|
||||
// Reopened, it is the same sample with its baseline (no second copy).
|
||||
assert_eq!(
|
||||
ub[1],
|
||||
crate::baselines::store::Choice::Baseline(baselines[1].id)
|
||||
);
|
||||
// Reopened, it is the same sample with its two baselines (no second copy).
|
||||
drop(started);
|
||||
let (again, _) = start(&args(&db));
|
||||
let again = again.unwrap();
|
||||
@@ -122,10 +127,39 @@ fn a_new_workspace_starts_on_the_sample() {
|
||||
crate::baselines::store::list(again.store.connection(), row)
|
||||
.unwrap()
|
||||
.len(),
|
||||
1
|
||||
2
|
||||
);
|
||||
}
|
||||
|
||||
/// Deleting the default sample project while it is open and the only project
|
||||
/// in the workspace leaves an empty workspace, cleans up its dictionary rows,
|
||||
/// and restarting does not re-create the sample.
|
||||
#[test]
|
||||
fn deleting_the_only_sample_project_stays_empty_on_restart() {
|
||||
let db = temp_db("delete-only-sample");
|
||||
let (started, _) = start(&args(&db));
|
||||
let started = started.unwrap();
|
||||
let sample_row = started.store.list().unwrap()[0].0;
|
||||
let ctx = egui::Context::default();
|
||||
let mut app = App::new(&ctx, started.store, started.project);
|
||||
app.request_project_delete(sample_row);
|
||||
let confirm = app.views.projects.delete.as_ref().unwrap();
|
||||
assert!(confirm.sample);
|
||||
assert!(confirm.open);
|
||||
app.views.projects.delete = None;
|
||||
app.delete_workspace_project(sample_row, 1.).unwrap();
|
||||
assert!(app.open_set.empty);
|
||||
assert!(app.store.list().unwrap().is_empty());
|
||||
drop(app);
|
||||
drop(started.lock);
|
||||
// Restarting an emptied workspace opens empty, without re-seeding RIVERBEND.
|
||||
let (again, told) = start(&args(&db));
|
||||
assert_eq!(told, None);
|
||||
let again = again.unwrap();
|
||||
assert!(again.empty);
|
||||
assert!(again.store.list().unwrap().is_empty());
|
||||
}
|
||||
|
||||
/// A workspace made by the first start holds the sample project, the
|
||||
/// starter reports and nothing else: no other project, no dictionary row
|
||||
/// the sample did not bring, no imported notebook topic.
|
||||
@@ -161,9 +195,12 @@ fn a_new_workspace_holds_only_the_sample_and_the_starter_reports() {
|
||||
let baselines: i64 = c
|
||||
.query_row("SELECT COUNT(*) FROM baselines", [], |r| r.get(0))
|
||||
.unwrap();
|
||||
assert_eq!(baselines, 1, "the sample's as-planned copy only");
|
||||
assert_eq!(
|
||||
baselines, 2,
|
||||
"the sample's as-planned and rebaseline copies"
|
||||
);
|
||||
// The dictionary is the sample's: every row is noted as the sample's,
|
||||
// and its notebook topics are the sample's own seven.
|
||||
// and its notebook topics are the sample's own eight.
|
||||
let (dict, _) = workspace_db::read_dictionary(c).unwrap();
|
||||
let record = workspace_db::read_sample(c).unwrap().unwrap();
|
||||
assert_eq!(record.row, started.store.list().unwrap()[0].0);
|
||||
@@ -179,7 +216,8 @@ fn a_new_workspace_holds_only_the_sample_and_the_starter_reports() {
|
||||
"Safety",
|
||||
"Quality and Inspection",
|
||||
"Field Notes",
|
||||
"Change Notes"
|
||||
"Change Notes",
|
||||
"Commissioning Notes"
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -549,7 +587,24 @@ fn the_sample_passes_check_schedule() {
|
||||
let failed: Vec<String> = results
|
||||
.iter()
|
||||
.filter(|r| r.passed == Some(false))
|
||||
.map(|r| format!("{} {:?}", r.check.name(), r.value))
|
||||
.map(|r| {
|
||||
let codes: Vec<String> = r
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
crate::schedule_check::Item::Activity(i) => {
|
||||
let a = ¤t.model.activities[*i];
|
||||
Some(format!(
|
||||
"{}(tf={}d)",
|
||||
a.task_code,
|
||||
a.total_float.unwrap_or(0) / 480
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
format!("{} {:?} {:?}", r.check.name(), r.value, codes)
|
||||
})
|
||||
.collect();
|
||||
assert!(failed.is_empty(), "{failed:?}");
|
||||
assert!(results.iter().filter(|r| r.passed == Some(true)).count() >= 13);
|
||||
|
||||
@@ -784,6 +784,11 @@ impl Store {
|
||||
project.model.options.do_level = level;
|
||||
Ok(project)
|
||||
}
|
||||
pub fn clear_last(&self) {
|
||||
let _ = self
|
||||
.connection
|
||||
.execute("DELETE FROM preferences WHERE key='last_project'", []);
|
||||
}
|
||||
pub fn last(&self) -> Result<Option<ProjectData>, String> {
|
||||
let id: Option<String> = self
|
||||
.connection
|
||||
@@ -794,8 +799,20 @@ impl Store {
|
||||
)
|
||||
.optional()
|
||||
.map_err(|e| e.to_string())?;
|
||||
id.map(|s| self.load(s.parse().map_err(|_| "Invalid saved project ID")?))
|
||||
.transpose()
|
||||
let Some(s) = id else {
|
||||
return Ok(None);
|
||||
};
|
||||
let row_id: i64 = s.parse().map_err(|_| "Invalid saved project ID")?;
|
||||
let exists: Option<i64> = self
|
||||
.connection
|
||||
.query_row("SELECT 1 FROM projects WHERE id=?1", [row_id], |r| r.get(0))
|
||||
.optional()
|
||||
.map_err(|e| e.to_string())?;
|
||||
if exists.is_none() {
|
||||
self.clear_last();
|
||||
return Ok(None);
|
||||
}
|
||||
self.load(row_id).map(Some)
|
||||
}
|
||||
}
|
||||
/// One running app's hold on a workspace, so a second app on the same
|
||||
|
||||
@@ -69,8 +69,8 @@ fn projects_and_wbs_show_each_edit_command_once() {
|
||||
}
|
||||
// The WBS shift buttons stay with the Move bar, still shown.
|
||||
assert!(!d.has("wbs_cmd_Shift up") && d.has("dock_move_up"));
|
||||
// The dock's Projects commands follow the view's own rules: the open
|
||||
// project cannot be deleted.
|
||||
// The dock's Projects commands follow the view's own rules: an open
|
||||
// project can be copied or deleted (saving and closing first).
|
||||
d.app.views.hidden_toolbars.remove("Edit");
|
||||
d.app.show_view(MainView::Projects);
|
||||
let row = d
|
||||
@@ -82,7 +82,7 @@ fn projects_and_wbs_show_each_edit_command_once() {
|
||||
+ 1;
|
||||
d.click(&format!("projects_row_{row}"));
|
||||
d.frames(2);
|
||||
assert_eq!(d.app.view_edit_enabled(ViewEdit::Delete), Some(false));
|
||||
assert_eq!(d.app.view_edit_enabled(ViewEdit::Delete), Some(true));
|
||||
assert_eq!(d.app.view_edit_enabled(ViewEdit::Copy), Some(true));
|
||||
assert!(d.app.error.is_none(), "{:?}", d.app.error);
|
||||
}
|
||||
|
||||
@@ -78,6 +78,8 @@ pub struct DeleteConfirm {
|
||||
pub title: String,
|
||||
pub activities: usize,
|
||||
pub baselines: usize,
|
||||
/// The project is currently open and will be closed first.
|
||||
pub open: bool,
|
||||
/// The project is the first-run sample: its own dictionary rows go too.
|
||||
pub sample: bool,
|
||||
}
|
||||
@@ -357,16 +359,18 @@ impl App {
|
||||
Ok(id)
|
||||
}
|
||||
|
||||
/// Projects view Delete: ask first. Open projects are refused.
|
||||
/// Projects view Delete: ask first. Open projects are closed before removal.
|
||||
pub(crate) fn request_project_delete(&mut self, id: i64) {
|
||||
if self.is_open(id) || self.workspace_row() == Some(id) {
|
||||
self.error("An open project cannot be deleted. Close it first.".into());
|
||||
return;
|
||||
}
|
||||
let open = self.is_open(id) || self.workspace_row() == Some(id);
|
||||
let Ok(Some(row)) = bstore::project_row(self.store.connection(), id) else {
|
||||
return;
|
||||
};
|
||||
let activities = Document::parse(&row.xer)
|
||||
let activities = if self.open_set.active == Some(id) || self.workspace_row() == Some(id) {
|
||||
self.project.model.activities.len()
|
||||
} else if let Some(p) = self.open_set.parked.iter().find(|p| p.id == id) {
|
||||
p.project.model.activities.len()
|
||||
} else {
|
||||
Document::parse(&row.xer)
|
||||
.ok()
|
||||
.and_then(|d| {
|
||||
d.table("TASK").map(|t| {
|
||||
@@ -376,7 +380,8 @@ impl App {
|
||||
.count()
|
||||
})
|
||||
})
|
||||
.unwrap_or(0);
|
||||
.unwrap_or(0)
|
||||
};
|
||||
let sample = openxer_automation::workspace_db::read_sample(self.store.connection())
|
||||
.ok()
|
||||
.flatten()
|
||||
@@ -386,14 +391,35 @@ impl App {
|
||||
title: row.title,
|
||||
activities,
|
||||
baselines: bstore::count(self.store.connection(), id),
|
||||
open,
|
||||
sample,
|
||||
});
|
||||
}
|
||||
|
||||
/// Remove workspace project `id` with its baselines, as one undo step.
|
||||
/// If the project is open, it is saved and closed first; closing the last
|
||||
/// open project leaves the workspace in the empty state on Projects view.
|
||||
pub(crate) fn delete_workspace_project(&mut self, id: i64, time: f64) -> Result<(), String> {
|
||||
crate::first_run::mark_seeded(&self.store);
|
||||
if self.open_set.parked.iter().any(|p| p.id == id) {
|
||||
self.close_project_id(id);
|
||||
}
|
||||
if !self.open_set.empty
|
||||
&& (self.open_set.active == Some(id) || self.workspace_row() == Some(id))
|
||||
{
|
||||
if self.dirty {
|
||||
self.try_save()?;
|
||||
}
|
||||
if !self.open_set.parked.is_empty() {
|
||||
self.close_active_project();
|
||||
} else {
|
||||
self.enter_empty_workspace();
|
||||
}
|
||||
}
|
||||
if self.is_open(id) || self.workspace_row() == Some(id) {
|
||||
return Err("An open project cannot be deleted. Close it first.".into());
|
||||
return Err(
|
||||
"The project could not be saved and closed, so nothing was deleted.".into(),
|
||||
);
|
||||
}
|
||||
let c = self.store.connection();
|
||||
let row = bstore::project_row(c, id)?.ok_or("The project no longer exists")?;
|
||||
@@ -444,8 +470,7 @@ impl App {
|
||||
|
||||
/// What deleting EPS node `eps` takes: the node and the nodes under it,
|
||||
/// the workspace projects filed in them and their baselines. Refused
|
||||
/// for the last top-level node, and when every workspace project is in
|
||||
/// the node while one of them is open (one project always stays open).
|
||||
/// for the last top-level node.
|
||||
fn folder_delete_plan(&mut self, eps: i64) -> Result<FolderPlan, String> {
|
||||
let ws = self.workspace().clone();
|
||||
if !ws.eps().iter().any(|n| n.id == eps) {
|
||||
@@ -456,15 +481,6 @@ impl App {
|
||||
}
|
||||
let ids = self.workspace_ids();
|
||||
let (nodes, projects) = ws.folder_contents(eps, &ids);
|
||||
let open_inside = projects
|
||||
.iter()
|
||||
.any(|p| self.is_open(*p) || self.workspace_row() == Some(*p));
|
||||
if open_inside && ids.iter().all(|p| projects.contains(p)) {
|
||||
return Err(format!(
|
||||
"Every project of the workspace is filed under {}, and one project always stays open. Add or move a project to another EPS node first.",
|
||||
ws.eps_value(eps, "eps_name")
|
||||
));
|
||||
}
|
||||
let c = self.store.connection();
|
||||
let baselines = projects.iter().map(|p| bstore::count(c, *p)).sum();
|
||||
Ok(FolderPlan {
|
||||
@@ -519,13 +535,19 @@ impl App {
|
||||
|| self.workspace_row().is_some_and(|a| going.contains(&a));
|
||||
if active_inside {
|
||||
if self.open_set.parked.is_empty() {
|
||||
let other = self
|
||||
if self.dirty {
|
||||
self.try_save()?;
|
||||
}
|
||||
if let Some(other) = self
|
||||
.workspace_ids()
|
||||
.into_iter()
|
||||
.find(|id| !going.contains(id))
|
||||
.ok_or("No project outside this EPS node can stay open.")?;
|
||||
{
|
||||
let p = self.store.load(other)?;
|
||||
self.load(p);
|
||||
} else {
|
||||
self.enter_empty_workspace();
|
||||
}
|
||||
} else {
|
||||
self.close_active_project();
|
||||
}
|
||||
@@ -549,6 +571,7 @@ impl App {
|
||||
/// current afterwards brings back the nodes, the projects (closed), their
|
||||
/// baselines and baseline choices.
|
||||
pub(crate) fn delete_folder(&mut self, eps: i64, time: f64) -> Result<(), String> {
|
||||
crate::first_run::mark_seeded(&self.store);
|
||||
let plan = self.folder_delete_plan(eps)?;
|
||||
let name = self.workspace().eps_value(eps, "eps_name");
|
||||
self.close_for_folder_delete(&plan.projects)?;
|
||||
@@ -615,8 +638,10 @@ impl App {
|
||||
let Some(record) = workspace_db::read_sample(c)?.filter(|s| s.row == id) else {
|
||||
return Ok(None);
|
||||
};
|
||||
let mut open: Vec<(Option<i64>, &Document)> =
|
||||
vec![(self.open_set.active, &self.project.document)];
|
||||
let mut open: Vec<(Option<i64>, &Document)> = vec![];
|
||||
if !self.open_set.empty {
|
||||
open.push((self.open_set.active, &self.project.document));
|
||||
}
|
||||
open.extend(
|
||||
self.open_set
|
||||
.parked
|
||||
@@ -750,6 +775,11 @@ impl App {
|
||||
}
|
||||
if let Some(d) = self.views.projects.delete.take() {
|
||||
let mut rects = vec![];
|
||||
let open_note = if d.open {
|
||||
"It is currently open and will be closed first. "
|
||||
} else {
|
||||
""
|
||||
};
|
||||
let clicked = crate::kit_window::message_box(
|
||||
ctx,
|
||||
"delete_project",
|
||||
@@ -757,12 +787,12 @@ impl App {
|
||||
crate::kit_window::MessageIcon::Question,
|
||||
&if d.sample {
|
||||
format!(
|
||||
"Remove the sample project {}?\nIts {} activities and {} baseline(s) are removed from the workspace, with the calendars, resources, codes and notebook topics only the sample uses.",
|
||||
"Remove the sample project {}?\n{open_note}Its {} activities and {} baseline(s) are removed from the workspace, with the calendars, resources, codes and notebook topics only the sample uses.",
|
||||
d.title, d.activities, d.baselines
|
||||
)
|
||||
} else {
|
||||
format!(
|
||||
"Delete project {}?\n{} activities and {} baseline(s) are removed from the workspace.",
|
||||
"Delete project {}?\n{open_note}{} activities and {} baseline(s) are removed from the workspace.",
|
||||
d.title, d.activities, d.baselines
|
||||
)
|
||||
},
|
||||
|
||||
@@ -207,9 +207,14 @@ fn projects_view_copy_paste_add_and_delete_undo_and_redo() {
|
||||
d.app.history_move(&ctx, false);
|
||||
assert_eq!(rows(&d).len(), start + 2);
|
||||
assert_eq!(d.app.store.load(copy).unwrap().model.project.name, title);
|
||||
// The open project is refused.
|
||||
// Deleting the open project closes it first and enters the empty workspace;
|
||||
// Undo brings it back.
|
||||
let open = d.app.workspace_row().unwrap();
|
||||
assert!(d.app.delete_workspace_project(open, 9.).is_err());
|
||||
d.app.delete_workspace_project(open, 9.).unwrap();
|
||||
assert!(d.app.open_set.empty);
|
||||
assert_eq!(rows(&d).len(), start + 1);
|
||||
d.app.history_move(&ctx, false);
|
||||
assert_eq!(rows(&d).len(), start + 2);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -92,11 +92,13 @@ const MONTHS: [(&str, &str); 12] = [
|
||||
pub struct ProjectsMenu {
|
||||
/// The row is a project, not an EPS node.
|
||||
pub on_project: bool,
|
||||
/// The project row is currently open (Close Project applies).
|
||||
pub is_open: bool,
|
||||
/// Add and Paste have an EPS node to go under.
|
||||
pub can_add: bool,
|
||||
/// The project is kept in the workspace (Cut and Copy apply).
|
||||
pub stored: bool,
|
||||
/// The project is closed and kept in the workspace.
|
||||
/// The project is kept in the workspace, or the row is an EPS node.
|
||||
pub deletable: bool,
|
||||
/// A project was cut or copied.
|
||||
pub clipboard: bool,
|
||||
@@ -153,6 +155,13 @@ pub fn projects_menu(m: &ProjectsMenu) -> Vec<Entry> {
|
||||
Icon::ProjectOpen,
|
||||
m.on_project,
|
||||
),
|
||||
item(
|
||||
"close_project",
|
||||
"Close Project",
|
||||
"",
|
||||
Icon::ProjectClosed,
|
||||
m.is_open,
|
||||
),
|
||||
details_item(m.details),
|
||||
Entry::Item(Spec::new("edit_details", "Edit Project Details").enabled(m.on_project)),
|
||||
Entry::Separator,
|
||||
@@ -741,8 +750,12 @@ impl App {
|
||||
let stamps = self.store.stamps().unwrap_or_default();
|
||||
self.drop_stale_rollups();
|
||||
let shared = self.dictionary_shared();
|
||||
let live = summarize_live(&self.project);
|
||||
let is_live = |c: &Cached| c.source == live.source && c.key == live.key;
|
||||
let has_open = !self.open_set.empty;
|
||||
let live = has_open.then(|| summarize_live(&self.project));
|
||||
let is_live = |c: &Cached| {
|
||||
live.as_ref()
|
||||
.is_some_and(|l| c.source == l.source && c.key == l.key)
|
||||
};
|
||||
let mut out = vec![];
|
||||
let mut found_current = false;
|
||||
let cache = &mut self.views.projects.cache;
|
||||
@@ -783,10 +796,12 @@ impl App {
|
||||
let entry = &cache[&id];
|
||||
if is_live(entry) {
|
||||
found_current = true;
|
||||
if let Some(live) = live.as_ref() {
|
||||
out.push(ProjectSummary {
|
||||
store_id: Some(id),
|
||||
..live.clone()
|
||||
});
|
||||
}
|
||||
} else if let Some(s) = &entry.summary {
|
||||
out.push(ProjectSummary {
|
||||
store_id: Some(id),
|
||||
@@ -795,8 +810,10 @@ impl App {
|
||||
}
|
||||
}
|
||||
if !found_current {
|
||||
if let Some(live) = live {
|
||||
out.push(live);
|
||||
}
|
||||
}
|
||||
out.sort_by(|a, b| a.id.cmp(&b.id).then(a.source.cmp(&b.source)));
|
||||
for s in &mut out {
|
||||
self.attach_baseline(s);
|
||||
@@ -914,10 +931,14 @@ impl App {
|
||||
};
|
||||
match self.store.load(id) {
|
||||
Ok(p) => {
|
||||
let was_empty = self.open_set.empty;
|
||||
let before = self.project.source_name.clone();
|
||||
let key = self.project.model.project.proj_id;
|
||||
self.load(p);
|
||||
if self.project.source_name != before || self.project.model.project.proj_id != key {
|
||||
if was_empty
|
||||
|| self.project.source_name != before
|
||||
|| self.project.model.project.proj_id != key
|
||||
{
|
||||
self.saved_projects = self.store.list().unwrap_or_default();
|
||||
self.show_view(MainView::Activities);
|
||||
}
|
||||
@@ -1089,10 +1110,7 @@ impl App {
|
||||
let has_store = selected.as_ref().is_some_and(|s| s.store_id.is_some());
|
||||
self.views.projects.edit_enabled = Some([
|
||||
target.is_some(),
|
||||
folder.is_some()
|
||||
|| selected
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.store_id.is_some() && !is_open(s)),
|
||||
folder.is_some() || has_store,
|
||||
has_store,
|
||||
has_store,
|
||||
(pending.is_some() || copied.is_some()) && target.is_some(),
|
||||
@@ -1118,7 +1136,7 @@ impl App {
|
||||
if response.clicked() {
|
||||
open = selected.clone();
|
||||
}
|
||||
let closable = open_ids.len() > 1 && selected.as_ref().is_some_and(is_open);
|
||||
let closable = selected.as_ref().is_some_and(is_open);
|
||||
let response =
|
||||
sheet::side_button(ui, chrome::Icon::ProjectClosed, "Close Project", closable);
|
||||
self.action("projects_cmd_close", &response);
|
||||
@@ -1141,14 +1159,11 @@ impl App {
|
||||
if response.clicked() {
|
||||
add = target;
|
||||
}
|
||||
let deletable = folder.is_some()
|
||||
|| selected
|
||||
.as_ref()
|
||||
.is_some_and(|s| s.store_id.is_some() && !is_open(s));
|
||||
let deletable = folder.is_some() || has_store;
|
||||
let response = sheet::side_button(
|
||||
ui,
|
||||
chrome::Icon::Delete,
|
||||
"Delete (a closed project, or an EPS node with everything under it)",
|
||||
"Delete (a project, or an EPS node with everything under it)",
|
||||
deletable,
|
||||
);
|
||||
self.action("projects_cmd_delete", &response);
|
||||
@@ -1389,12 +1404,13 @@ impl App {
|
||||
let collapsed = &self.views.projects.collapsed;
|
||||
let any_collapsed = groups.iter().any(|g| collapsed.contains(&g.0));
|
||||
let any_open = groups.iter().any(|g| !collapsed.contains(&g.0));
|
||||
let deletable_row = |s: &ProjectSummary| s.store_id.is_some() && !is_open(s);
|
||||
let deletable_row = |s: &ProjectSummary| s.store_id.is_some();
|
||||
let fill_ready = self.view_fill_ready();
|
||||
let menu = |row: usize| {
|
||||
let project = lines.get(row).and_then(project_line);
|
||||
projects_menu(&ProjectsMenu {
|
||||
on_project: project.is_some(),
|
||||
is_open: project.is_some_and(is_open),
|
||||
can_add: match lines.get(row) {
|
||||
Some(EpsLine::Eps(id, _)) => *id > 0,
|
||||
Some(_) => project.is_some_and(|p| p.store_id.is_some()),
|
||||
@@ -1578,6 +1594,7 @@ impl App {
|
||||
if let Some((i, key)) = response.menu {
|
||||
match key {
|
||||
"open_project" => open = project_at(i),
|
||||
"close_project" => close = project_at(i).and_then(|p| p.store_id),
|
||||
"add" | "cut" | "copy" | "paste" | "delete" => {
|
||||
self.views.projects.command = Some(key);
|
||||
}
|
||||
@@ -1666,7 +1683,7 @@ impl App {
|
||||
self.view_fill_down(time);
|
||||
}
|
||||
|
||||
let deletable = |s: &ProjectSummary| s.store_id.is_some() && !is_open(s);
|
||||
let deletable = |s: &ProjectSummary| s.store_id.is_some();
|
||||
match self.views.projects.command.take() {
|
||||
Some("add") => add = target,
|
||||
Some("delete") => {
|
||||
|
||||
@@ -104,6 +104,7 @@ fn the_projects_menu_lists_its_items_in_order_and_selects_the_row() {
|
||||
);
|
||||
let order = [
|
||||
"projects_menu_open_project",
|
||||
"projects_menu_close_project",
|
||||
"projects_menu_details",
|
||||
"projects_menu_edit_details",
|
||||
"projects_menu_cut",
|
||||
@@ -225,6 +226,7 @@ fn the_projects_menu_opens_a_project_and_serves_the_empty_area() {
|
||||
assert!(d.has("projects_menu_add"), "the empty area has a menu");
|
||||
for key in [
|
||||
"projects_menu_open_project",
|
||||
"projects_menu_close_project",
|
||||
"projects_menu_cut",
|
||||
"projects_menu_copy",
|
||||
"projects_menu_delete",
|
||||
@@ -236,6 +238,113 @@ fn the_projects_menu_opens_a_project_and_serves_the_empty_area() {
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn projects_menu_closes_and_deletes_an_open_project_into_empty_workspace() {
|
||||
let mut d = Driver::new("vm-projects-close-del", starter());
|
||||
open_projects(&mut d);
|
||||
// Close Project from right-click menu closes the last open project.
|
||||
right_click_project_row(&mut d);
|
||||
assert!(closes_on_click(
|
||||
&mut d,
|
||||
"projects_menu_add",
|
||||
"projects_menu_close_project"
|
||||
));
|
||||
d.frames(2);
|
||||
assert!(
|
||||
d.app.open_set.empty,
|
||||
"closing the last project enters empty workspace"
|
||||
);
|
||||
assert!(d.app.open_ids().is_empty());
|
||||
// Reopen it, then right-click Delete directly while open.
|
||||
right_click_project_row(&mut d);
|
||||
assert!(closes_on_click(
|
||||
&mut d,
|
||||
"projects_menu_add",
|
||||
"projects_menu_open_project"
|
||||
));
|
||||
d.frames(2);
|
||||
assert!(!d.app.open_set.empty);
|
||||
open_projects(&mut d);
|
||||
right_click_project_row(&mut d);
|
||||
assert!(closes_on_click(
|
||||
&mut d,
|
||||
"projects_menu_add",
|
||||
"projects_menu_delete"
|
||||
));
|
||||
d.frames(2);
|
||||
assert!(
|
||||
d.app.views.projects.delete.as_ref().is_some_and(|c| c.open),
|
||||
"Delete opens confirmation noting the project is open"
|
||||
);
|
||||
d.click("delete_project_yes");
|
||||
d.frames(2);
|
||||
assert!(
|
||||
d.app.open_set.empty,
|
||||
"deleting the last project enters empty workspace"
|
||||
);
|
||||
assert!(d.app.store.list().unwrap().is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn assign_predecessors_right_click_menu_expands_and_collapses_wbs() {
|
||||
let mut d = Driver::new("vm-picker-menu", starter());
|
||||
d.frames(2);
|
||||
d.app.selected = Some(0);
|
||||
d.app.detail.picker = Some(crate::details::Picker::Relationship {
|
||||
predecessor: true,
|
||||
query: String::new(),
|
||||
selected: None,
|
||||
kind: openxer_engine::model::LinkType::FS,
|
||||
lag: 0.,
|
||||
});
|
||||
d.frames(2);
|
||||
assert!(d.app.detail.picker.is_some());
|
||||
let search = d.rect("picker_search");
|
||||
let list_pos = Pos2::new(search.left() + 40., search.bottom() + 45.);
|
||||
right_click(&mut d, list_pos);
|
||||
let order = [
|
||||
"picker_menu_copy",
|
||||
"picker_menu_columns",
|
||||
"picker_menu_table_font",
|
||||
"picker_menu_filter_by",
|
||||
"picker_menu_group_by",
|
||||
"picker_menu_expand_all",
|
||||
"picker_menu_collapse_all",
|
||||
];
|
||||
for key in order {
|
||||
assert!(d.has(key), "{key} is listed");
|
||||
}
|
||||
assert_order(&d, &order);
|
||||
// Nothing is collapsed yet: Expand All is disabled, Collapse All is enabled.
|
||||
assert!(!closes_on_click(
|
||||
&mut d,
|
||||
"picker_menu_collapse_all",
|
||||
"picker_menu_expand_all"
|
||||
));
|
||||
assert!(closes_on_click(
|
||||
&mut d,
|
||||
"picker_menu_table_font",
|
||||
"picker_menu_collapse_all"
|
||||
));
|
||||
d.frames(2);
|
||||
assert!(
|
||||
!d.app.detail.picker_collapsed.is_empty(),
|
||||
"Collapse All folds every WBS band"
|
||||
);
|
||||
// Now Expand All is enabled and clears the collapsed set.
|
||||
right_click(&mut d, list_pos);
|
||||
assert!(closes_on_click(
|
||||
&mut d,
|
||||
"picker_menu_table_font",
|
||||
"picker_menu_expand_all"
|
||||
));
|
||||
d.frames(2);
|
||||
assert!(
|
||||
d.app.detail.picker_collapsed.is_empty(),
|
||||
"Expand All unfolds every WBS band"
|
||||
);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------- resources
|
||||
|
||||
fn with_resources() -> Driver {
|
||||
|
||||
@@ -80,7 +80,7 @@ impl App {
|
||||
/// them, and bring the other open projects up to the dictionary when it
|
||||
/// changed.
|
||||
pub(crate) fn sync_dictionary(&mut self, time: f64) {
|
||||
if !self.dictionary_shared() {
|
||||
if self.open_set.empty || !self.dictionary_shared() {
|
||||
return;
|
||||
}
|
||||
let key = key_of(&self.project);
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -231,7 +231,7 @@ fn the_sample_is_a_mid_size_job() {
|
||||
let s = sample();
|
||||
let m = &s.current.model;
|
||||
assert!(
|
||||
(150..=250).contains(&m.activities.len()),
|
||||
(350..=450).contains(&m.activities.len()),
|
||||
"{}",
|
||||
m.activities.len()
|
||||
);
|
||||
@@ -265,8 +265,11 @@ fn every_task_is_labor_and_cost_loaded() {
|
||||
.iter()
|
||||
.filter(|r| num(t.value(r, "task_id")) == a.task_id)
|
||||
.collect();
|
||||
if a.task_type != TaskType::Task {
|
||||
assert!(mine.is_empty(), "{} is a milestone", a.task_code);
|
||||
if matches!(
|
||||
a.task_type,
|
||||
TaskType::Mile | TaskType::FinMile | TaskType::Wbs
|
||||
) {
|
||||
assert!(mine.is_empty(), "{} has no assignments", a.task_code);
|
||||
continue;
|
||||
}
|
||||
assert!(
|
||||
@@ -284,18 +287,26 @@ fn every_task_is_labor_and_cost_loaded() {
|
||||
|
||||
#[test]
|
||||
fn only_the_start_and_finish_are_open_ends() {
|
||||
for p in [&sample().plan, &sample().current] {
|
||||
for p in [&sample().plan, &sample().revision, &sample().current] {
|
||||
let m = &p.model;
|
||||
let starts: Vec<&str> = m
|
||||
.activities
|
||||
.iter()
|
||||
.filter(|a| a.preds.is_empty())
|
||||
.filter(|a| !matches!(a.task_type, TaskType::Loe | TaskType::Wbs) && a.preds.is_empty())
|
||||
.map(|a| a.task_code.as_str())
|
||||
.collect();
|
||||
let finishes: Vec<&str> = m
|
||||
.activities
|
||||
.iter()
|
||||
.filter(|a| a.succs.is_empty())
|
||||
.filter(|a| {
|
||||
!matches!(a.task_type, TaskType::Loe | TaskType::Wbs)
|
||||
&& a.succs.iter().all(|&l| {
|
||||
matches!(
|
||||
m.activities[m.links[l].succ].task_type,
|
||||
TaskType::Loe | TaskType::Wbs
|
||||
)
|
||||
})
|
||||
})
|
||||
.map(|a| a.task_code.as_str())
|
||||
.collect();
|
||||
assert_eq!((starts, finishes), (vec!["MS0000"], vec!["PM0920"]));
|
||||
@@ -389,7 +400,7 @@ fn budgets_add_up() {
|
||||
}
|
||||
}
|
||||
let budget: f64 = rows.iter().map(|r| float(t.value(r, "target_cost"))).sum();
|
||||
assert!((2_000_000. ..3_000_000.).contains(&budget), "{budget}");
|
||||
assert!((4_000_000. ..6_000_000.).contains(&budget), "{budget}");
|
||||
}
|
||||
// The plan carries no actuals; the budget is the same in both.
|
||||
let total = |p: &ProjectData, column: &str| -> f64 {
|
||||
@@ -540,8 +551,58 @@ fn the_sample_has_codes_fields_steps_expenses_curves_and_notes() {
|
||||
] {
|
||||
assert!(topics.contains(&topic), "{topics:?}");
|
||||
}
|
||||
assert!(count("TASKMEMO") >= 12);
|
||||
assert!(count("WBSMEMO") >= 6);
|
||||
assert!(count("TASKMEMO") >= 20);
|
||||
assert!(count("WBSMEMO") >= 12);
|
||||
// Rich enterprise and project registers are all populated.
|
||||
assert!(count("OBS") >= 5);
|
||||
assert!(count("ROLERATE") >= 4);
|
||||
assert!(count("BASETYPE") >= 3);
|
||||
assert!(count("PCATTYPE") >= 4);
|
||||
assert!(count("PROJPCAT") >= 4);
|
||||
assert!(count("FUNDSRC") >= 3);
|
||||
assert!(count("PROJFUND") >= 3);
|
||||
assert!(count("RCATTYPE") >= 2);
|
||||
assert!(count("RSRCRCAT") >= 20);
|
||||
assert!(count("ASGNMNTCATTYPE") >= 3);
|
||||
assert!(count("ASGNMNTACAT") >= 100);
|
||||
assert!(count("WBSSTEP") >= 15);
|
||||
assert!(count("BUDGCHNG") >= 6);
|
||||
assert!(count("WBSBUDG") >= 10);
|
||||
assert!(count("DOCCATG") >= 5);
|
||||
assert!(count("DOCSTAT") >= 4);
|
||||
assert!(count("DOCUMENT") >= 18);
|
||||
assert!(count("TASKDOC") >= 25);
|
||||
assert!(count("RISKTYPE") >= 5);
|
||||
assert!(count("PROJRISK") >= 10);
|
||||
assert!(count("TASKRISK") >= 20);
|
||||
assert!(count("THRSPARM") >= 14);
|
||||
assert!(count("PROJTHRS") >= 5);
|
||||
assert!(count("PROJISSU") >= 6);
|
||||
assert!(count("ISSUHIST") >= 6);
|
||||
assert!(count("FINTMPL") >= 1);
|
||||
assert!(count("FINDATES") >= 12);
|
||||
assert!(count("TASKFIN") >= 40);
|
||||
assert!(count("TRSRCFIN") >= 80);
|
||||
assert!(p
|
||||
.model
|
||||
.activities
|
||||
.iter()
|
||||
.any(|a| a.task_type == TaskType::Loe));
|
||||
assert!(p
|
||||
.model
|
||||
.activities
|
||||
.iter()
|
||||
.any(|a| a.task_type == TaskType::Wbs));
|
||||
// Hierarchical resources: parent folders exist and children point to them.
|
||||
let (rt, rrows) = table_rows(p, "RSRC");
|
||||
assert!(rrows
|
||||
.iter()
|
||||
.any(|r| !rt.value(r, "parent_rsrc_id").is_empty()));
|
||||
// Second baseline (mid-project rebaseline) sits between plan and current.
|
||||
let rev_dd = sample().revision.model.project.data_date.unwrap();
|
||||
let plan_dd = sample().plan.model.project.data_date.unwrap();
|
||||
let cur_dd = p.model.project.data_date.unwrap();
|
||||
assert!(plan_dd < rev_dd && rev_dd < cur_dd);
|
||||
// Codes are the project's own, calendars and resources are named for it.
|
||||
let (t, rows) = table_rows(p, "ACTVTYPE");
|
||||
assert!(rows
|
||||
@@ -695,3 +756,60 @@ fn the_s_curve_and_earned_hours_reports_run_on_the_sample() {
|
||||
assert!(hours.rows.iter().any(|r| r.key == "ENGR" && r.earned > 0.));
|
||||
assert!(hours.rows.iter().all(|r| r.budgeted > 0.));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn the_sample_passes_schedule_check() {
|
||||
use crate::schedule_check::{run_checks_with, CheckParams, Item};
|
||||
let s = sample();
|
||||
let (plan, current) = (&s.plan, &s.current);
|
||||
let shift = (plan.model.origin_serial - current.model.origin_serial) * 1440;
|
||||
let baseline: Vec<Option<i64>> = current
|
||||
.model
|
||||
.activities
|
||||
.iter()
|
||||
.map(|a| {
|
||||
plan.model
|
||||
.activities
|
||||
.iter()
|
||||
.find(|b| b.task_id == a.task_id)
|
||||
.and_then(|b| b.early_finish)
|
||||
.map(|f| f + shift)
|
||||
})
|
||||
.collect();
|
||||
let t = current.document.table("PROJCOST").unwrap();
|
||||
let with_expenses = t
|
||||
.rows
|
||||
.iter()
|
||||
.map(|r| t.value(r, "task_id").parse().unwrap())
|
||||
.collect();
|
||||
let results = run_checks_with(
|
||||
¤t.model,
|
||||
&CheckParams::default(),
|
||||
&with_expenses,
|
||||
Some(&baseline),
|
||||
);
|
||||
let failed: Vec<String> = results
|
||||
.iter()
|
||||
.filter(|r| r.passed == Some(false))
|
||||
.map(|r| {
|
||||
let codes: Vec<String> = r
|
||||
.items
|
||||
.iter()
|
||||
.filter_map(|item| match item {
|
||||
Item::Activity(i) => {
|
||||
let a = ¤t.model.activities[*i];
|
||||
Some(format!(
|
||||
"{}(tf={}d)",
|
||||
a.task_code,
|
||||
a.total_float.unwrap_or(0) / 480
|
||||
))
|
||||
}
|
||||
_ => None,
|
||||
})
|
||||
.collect();
|
||||
format!("{} {:?} {:?}", r.check.name(), r.value, codes)
|
||||
})
|
||||
.collect();
|
||||
assert!(failed.is_empty(), "{failed:?}");
|
||||
assert!(results.iter().filter(|r| r.passed == Some(true)).count() >= 13);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user