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
|
[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.
|
[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.
|
The first public release.
|
||||||
|
|
||||||
|
|||||||
12
Cargo.lock
generated
12
Cargo.lock
generated
@@ -2429,7 +2429,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openxer-automation"
|
name = "openxer-automation"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
@@ -2449,7 +2449,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openxer-chat"
|
name = "openxer-chat"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"native-tls",
|
"native-tls",
|
||||||
"openssl",
|
"openssl",
|
||||||
@@ -2461,7 +2461,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openxer-desktop"
|
name = "openxer-desktop"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"eframe",
|
"eframe",
|
||||||
@@ -2482,11 +2482,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openxer-engine"
|
name = "openxer-engine"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openxer-interchange"
|
name = "openxer-interchange"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"calamine",
|
"calamine",
|
||||||
"chrono",
|
"chrono",
|
||||||
@@ -2499,7 +2499,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "openxer-xer"
|
name = "openxer-xer"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"encoding_rs",
|
"encoding_rs",
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ default-members = ["desktop"]
|
|||||||
resolver = "2"
|
resolver = "2"
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
license = "MIT OR Apache-2.0"
|
license = "MIT OR Apache-2.0"
|
||||||
publish = false
|
publish = false
|
||||||
|
|||||||
@@ -16,11 +16,11 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p align="center">
|
<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">
|
<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>
|
||||||
|
|
||||||
<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">
|
<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>
|
</a>
|
||||||
</p>
|
</p>
|
||||||
@@ -240,8 +240,8 @@ Download directly from the **[Latest Release](https://github.com/OpenXER/openxer
|
|||||||
|
|
||||||
| Platform | Recommended download | Portable download |
|
| 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) |
|
| **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.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) |
|
| **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).
|
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
|
## What is on it
|
||||||
- **Find**: type part of an activity ID or name to shorten the list.
|
- **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.
|
- **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.
|
- **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.
|
- **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
|
## The sample project
|
||||||
A new workspace opens on **RIVERBEND**, a made-up process water upgrade in
|
A new workspace opens on **RIVERBEND**, a made-up process water upgrade in
|
||||||
progress: about 190 activities with logic, three calendars, crews and
|
progress: about 365 activities across six plant areas with logic, Level of
|
||||||
equipment with rates, costs, expenses, codes, notebook topics and an
|
Effort and WBS summary activities, three calendars, hierarchical crews and
|
||||||
as-planned baseline. Use it to try the views. To remove it, and the
|
equipment with rates and curves, costs, expenses, activity/project/resource/assignment
|
||||||
calendars, resources, codes and notebook topics only it uses, delete it in
|
codes, risks, documents, issues, thresholds, WBS milestones, funding, budget log,
|
||||||
the Projects view once another project is open. See [Projects](view-projects).
|
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
|
## Bring a project in
|
||||||
1. To start from an XER file, use `File > Import...`. The wizard reads the file
|
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.
|
- **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.
|
- **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.
|
- **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.
|
- **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
|
## 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.
|
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**.
|
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).
|
- **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**.
|
- **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.
|
- **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.
|
> 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.
|
> 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.
|
> 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.
|
> 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.
|
> 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.
|
> 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)
|
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
|
/// Store the baselines that a file carries for project `pid` (PROJECT rows
|
||||||
/// whose `orig_proj_id` is `pid`) under workspace project `parent`. Baselines
|
/// 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
|
/// 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.
|
/// The open project's workspace row, if it has been saved.
|
||||||
pub(crate) fn workspace_row(&self) -> Option<i64> {
|
pub(crate) fn workspace_row(&self) -> Option<i64> {
|
||||||
|
if self.open_set.empty {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
let key = (
|
let key = (
|
||||||
self.project.source_name.clone(),
|
self.project.source_name.clone(),
|
||||||
self.project.model.project.proj_id,
|
self.project.model.project.proj_id,
|
||||||
@@ -360,6 +410,9 @@ impl App {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn ensure_workspace_row(&mut self) -> Result<i64, String> {
|
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() {
|
if let Some(id) = self.workspace_row() {
|
||||||
return Ok(id);
|
return Ok(id);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -121,6 +121,34 @@ impl App {
|
|||||||
selected: &mut Option<i64>,
|
selected: &mut Option<i64>,
|
||||||
size: Vec2,
|
size: Vec2,
|
||||||
paint: &mut dyn FnMut(&mut egui::Ui, usize, usize, bool),
|
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 {
|
) -> ListOut {
|
||||||
let rows = self.detail.assign_rows.entry(dialog).or_default();
|
let rows = self.detail.assign_rows.entry(dialog).or_default();
|
||||||
let shown = rows.shown(selected, keys);
|
let shown = rows.shown(selected, keys);
|
||||||
@@ -132,10 +160,9 @@ impl App {
|
|||||||
shown.current,
|
shown.current,
|
||||||
&shown.rows,
|
&shown.rows,
|
||||||
size,
|
size,
|
||||||
&mut |ui, ev, sel| {
|
&mut |ui, ev, sel| match ev {
|
||||||
if let Ev::Cell(r, c) = ev {
|
Ev::Cell(r, c) => paint(ui, r, c, sel),
|
||||||
paint(ui, r, c, sel);
|
Ev::Menu(row) => menu(ui, row),
|
||||||
}
|
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
if let Some(Some(key)) = out.clicked.and_then(|r| keys.get(r)) {
|
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.
|
/// Step fields copied with the Steps context menu.
|
||||||
pub use openxer_xer::edit::steps::StepCopy;
|
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
|
/// 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
|
/// project's undo snapshot, the table's Group and Sort, the picker's own
|
||||||
/// that take the relationship.
|
/// filter/grouping, and the activities that take the relationship.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq)]
|
||||||
pub struct PickerLinesKey {
|
pub struct PickerLinesKey {
|
||||||
pub query: String,
|
pub query: String,
|
||||||
pub serial: u64,
|
pub serial: u64,
|
||||||
pub group_sort: crate::grid::layout::GroupSort,
|
pub group_sort: crate::grid::layout::GroupSort,
|
||||||
|
pub filter: PickerFilter,
|
||||||
|
pub group: PickerGroup,
|
||||||
pub targets: Vec<usize>,
|
pub targets: Vec<usize>,
|
||||||
pub collapsed: BTreeSet<String>,
|
pub collapsed: BTreeSet<String>,
|
||||||
}
|
}
|
||||||
@@ -289,11 +366,21 @@ pub struct DetailState {
|
|||||||
pub rows: [Option<usize>; 2],
|
pub rows: [Option<usize>; 2],
|
||||||
context: Option<(i64, DetailTab)>,
|
context: Option<(i64, DetailTab)>,
|
||||||
pub picker: Option<Picker>,
|
pub picker: Option<Picker>,
|
||||||
/// Assign Predecessors / Successors: the lines of the last build and
|
/// Assign Predecessors / Successors: the lines of the last build, all
|
||||||
/// what they were built for (see `relationship_picker`).
|
/// band keys (for Collapse All), and what they were built for.
|
||||||
pub picker_lines: Option<(PickerLinesKey, std::rc::Rc<Vec<crate::grid::PickLine>>)>,
|
pub picker_lines: Option<(
|
||||||
|
PickerLinesKey,
|
||||||
|
std::rc::Rc<Vec<crate::grid::PickLine>>,
|
||||||
|
Vec<String>,
|
||||||
|
)>,
|
||||||
/// Bands folded shut in Assign Predecessors / Successors (band keys).
|
/// Bands folded shut in Assign Predecessors / Successors (band keys).
|
||||||
pub picker_collapsed: BTreeSet<String>,
|
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
|
/// The Activity Codes dictionary was opened from Assign: when it closes
|
||||||
/// with code values to assign, the code picker opens.
|
/// with code values to assign, the code picker opens.
|
||||||
pub assign_codes_after: bool,
|
pub assign_codes_after: bool,
|
||||||
@@ -356,6 +443,9 @@ impl Default for DetailState {
|
|||||||
picker: None,
|
picker: None,
|
||||||
picker_lines: None,
|
picker_lines: None,
|
||||||
picker_collapsed: BTreeSet::new(),
|
picker_collapsed: BTreeSet::new(),
|
||||||
|
picker_filter: PickerFilter::All,
|
||||||
|
picker_group: PickerGroup::Wbs,
|
||||||
|
picker_columns: BTreeSet::new(),
|
||||||
assign_codes_after: false,
|
assign_codes_after: false,
|
||||||
assign: None,
|
assign: None,
|
||||||
assign_for: None,
|
assign_for: None,
|
||||||
|
|||||||
@@ -1455,55 +1455,130 @@ impl App {
|
|||||||
// the search text, the project, Group and Sort and the selection stay
|
// the search text, the project, Group and Sort and the selection stay
|
||||||
// as they are; with several projects open they are built each frame.
|
// as they are; with several projects open they are built each frame.
|
||||||
let multi = self.open_set.multi();
|
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.
|
// Find looks inside folded bands too.
|
||||||
let folded = if query.trim().is_empty() {
|
let searching = !query.trim().is_empty();
|
||||||
self.detail.picker_collapsed.clone()
|
let folded = if searching {
|
||||||
} else {
|
|
||||||
BTreeSet::new()
|
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 {
|
let key = self.shown_serial().map(|serial| PickerLinesKey {
|
||||||
query: query.clone(),
|
query: query.clone(),
|
||||||
collapsed: folded.clone(),
|
collapsed: folded.clone(),
|
||||||
serial,
|
serial,
|
||||||
group_sort: self.grid.layout.group_sort.clone(),
|
group_sort: self.grid.layout.group_sort.clone(),
|
||||||
|
filter,
|
||||||
|
group: group_mode,
|
||||||
targets: std::iter::once(activity)
|
targets: std::iter::once(activity)
|
||||||
.chain(targets.iter().copied())
|
.chain(targets.iter().copied())
|
||||||
.collect(),
|
.collect(),
|
||||||
});
|
});
|
||||||
let kept = match (&key, &self.detail.picker_lines) {
|
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,
|
_ => None,
|
||||||
};
|
};
|
||||||
let lines = kept.unwrap_or_else(|| {
|
let (lines, all_band_keys) = kept.unwrap_or_else(|| {
|
||||||
let lines = std::rc::Rc::new(
|
let shown_data = self.shown();
|
||||||
self.picker_lines(query, &folded, &|k| k == activity || targets.contains(&k)),
|
let crit_def = self.critical_definition();
|
||||||
);
|
let (built_lines, bands) =
|
||||||
self.detail.picker_lines = key.map(|key| (key, lines.clone()));
|
self.picker_lines_with(query, &folded, group_override.clone(), &|k| {
|
||||||
lines
|
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 all = self.shown();
|
||||||
|
let origin = all.model.origin_serial;
|
||||||
|
let leveled = all.model.options.do_level;
|
||||||
let projects: Vec<String> = self
|
let projects: Vec<String> = self
|
||||||
.open_projects()
|
.open_projects()
|
||||||
.iter()
|
.iter()
|
||||||
.map(|p| p.model.project.name.clone())
|
.map(|p| p.model.project.name.clone())
|
||||||
.collect();
|
.collect();
|
||||||
let texts: Vec<[String; 3]> = lines
|
let texts: Vec<Vec<String>> = lines
|
||||||
.iter()
|
.iter()
|
||||||
.map(|line| match line {
|
.map(|line| match line {
|
||||||
PickLine::Band { label, .. } => [String::new(), label.clone(), String::new()],
|
PickLine::Band { label, .. } => vec![label.clone()],
|
||||||
PickLine::Activity(k) => {
|
PickLine::Activity(k) => {
|
||||||
let project = self
|
let a = &all.model.activities[*k];
|
||||||
.open_set
|
let mut row = Vec::with_capacity(3 + extra_cols.len());
|
||||||
.composite
|
if multi {
|
||||||
.as_ref()
|
let project = self
|
||||||
.and_then(|c| c.origin.get(*k))
|
.open_set
|
||||||
.and_then(|&(slot, _)| projects.get(slot).cloned())
|
.composite
|
||||||
.unwrap_or_default();
|
.as_ref()
|
||||||
[
|
.and_then(|c| c.origin.get(*k))
|
||||||
project,
|
.and_then(|&(slot, _)| projects.get(slot).cloned())
|
||||||
all.model.activities[*k].task_code.clone(),
|
.unwrap_or_default();
|
||||||
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();
|
.collect();
|
||||||
@@ -1525,6 +1600,23 @@ impl App {
|
|||||||
let boxes = std::cell::RefCell::new(Vec::<(usize, Rect)>::new());
|
let boxes = std::cell::RefCell::new(Vec::<(usize, Rect)>::new());
|
||||||
let mut fold = None;
|
let mut fold = None;
|
||||||
let mut double = 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";
|
const DIALOG: &str = "assign_relationship";
|
||||||
let title = if *predecessor {
|
let title = if *predecessor {
|
||||||
"Assign Predecessors"
|
"Assign Predecessors"
|
||||||
@@ -1550,11 +1642,26 @@ impl App {
|
|||||||
PickLine::Band { .. } => None,
|
PickLine::Band { .. } => None,
|
||||||
})
|
})
|
||||||
.collect();
|
.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 mut choice = selected.map(|k| k as i64);
|
||||||
let (open, clicked) = self.assign_window(ctx, &window, |app, ui| {
|
let (open, clicked) = self.assign_window(ctx, &window, |app, ui| {
|
||||||
ui.horizontal(|ui| {
|
ui.horizontal(|ui| {
|
||||||
ui.label("Find");
|
ui.label("Find");
|
||||||
let response = ui.add(egui::TextEdit::singleline(query).desired_width(220.));
|
let response = ui.add(egui::TextEdit::singleline(query).desired_width(220.));
|
||||||
|
search_focused = response.has_focus();
|
||||||
app.action("picker_search", &response);
|
app.action("picker_search", &response);
|
||||||
if targets.len() > 1 {
|
if targets.len() > 1 {
|
||||||
ui.label(format!(
|
ui.label(format!(
|
||||||
@@ -1563,26 +1670,20 @@ impl App {
|
|||||||
));
|
));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
let columns: &[(&str, f32)] = if multi {
|
let current_choice = choice;
|
||||||
&[
|
let out = app.assign_list_with_menu(
|
||||||
("Project ID", 90.),
|
|
||||||
("Activity ID", 90.),
|
|
||||||
("Activity Name", 240.),
|
|
||||||
]
|
|
||||||
} else {
|
|
||||||
&[("Activity ID", 90.), ("Activity Name", 240.)]
|
|
||||||
};
|
|
||||||
let out = app.assign_list(
|
|
||||||
ui,
|
ui,
|
||||||
DIALOG,
|
DIALOG,
|
||||||
"relationship_picker",
|
"relationship_picker",
|
||||||
columns,
|
&columns,
|
||||||
&keys,
|
&keys,
|
||||||
&mut choice,
|
&mut choice,
|
||||||
Vec2::new(if multi { 530. } else { 440. }, 210.),
|
Vec2::new(list_width, 210.),
|
||||||
&mut |ui, r, c, _| {
|
&mut |ui, r, c, _| {
|
||||||
let Some((fill, ink)) = band_colors[r] else {
|
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;
|
return;
|
||||||
};
|
};
|
||||||
// A band: its color across the row and its caption
|
// A band: its color across the row and its caption
|
||||||
@@ -1618,12 +1719,106 @@ impl App {
|
|||||||
.text(
|
.text(
|
||||||
Pos2::new(band_left.get() + 16. + indent, rect.center().y),
|
Pos2::new(band_left.get() + 16. + indent, rect.center().y),
|
||||||
Align2::LEFT_CENTER,
|
Align2::LEFT_CENTER,
|
||||||
&texts[r][1],
|
&texts[r][0],
|
||||||
form::font(),
|
form::font(),
|
||||||
ink,
|
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;
|
double = out.double;
|
||||||
// A click on a band's box, or a double click on the band, folds
|
// 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);
|
*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) {
|
if !self.detail.picker_collapsed.remove(&key) {
|
||||||
self.detail.picker_collapsed.insert(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.
|
// Assign takes every selected activity; a double click the one.
|
||||||
let mut picks: Vec<usize> = match clicked {
|
let mut picks: Vec<usize> = match clicked {
|
||||||
Some("picker_assign") => self
|
Some("picker_assign") => self
|
||||||
|
|||||||
@@ -11,6 +11,23 @@
|
|||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
const NOTED_KEY: &str = "first_run_noted";
|
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 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
|
/// 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`):
|
/// 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 =
|
pub(crate) const SAMPLE_NOTE: &str =
|
||||||
"RIVERBEND is a sample project. Use File > Import... or drop an XER file.";
|
"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
|
/// Store the first-run sample's as-planned copy `plan` (Project and Primary
|
||||||
/// note which dictionary rows are the sample's: those the workspace
|
/// baseline) and mid-project copy `revision` (Secondary baseline), and note
|
||||||
/// dictionary has now and had not `before` the sample was stored.
|
/// 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(
|
pub(crate) fn install_sample(
|
||||||
store: &mut Store,
|
store: &mut Store,
|
||||||
project: &mut ProjectData,
|
project: &mut ProjectData,
|
||||||
plan: &ProjectData,
|
plan: &ProjectData,
|
||||||
|
revision: &ProjectData,
|
||||||
before: &openxer_xer::Document,
|
before: &openxer_xer::Document,
|
||||||
) -> Result<(), String> {
|
) -> Result<(), String> {
|
||||||
let row = store
|
let row = store
|
||||||
.id_of(&project.source_name, project.model.project.proj_id)
|
.id_of(&project.source_name, project.model.project.proj_id)
|
||||||
.ok_or("the sample is not in the workspace")?;
|
.ok_or("the sample is not in the workspace")?;
|
||||||
let start = openxer_xer::date_string(plan.model.origin_serial, plan.model.project.plan_start);
|
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(),
|
store.connection(),
|
||||||
row,
|
row,
|
||||||
project,
|
project,
|
||||||
@@ -42,6 +61,20 @@ pub(crate) fn install_sample(
|
|||||||
"As planned at notice to proceed",
|
"As planned at notice to proceed",
|
||||||
&start,
|
&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()? {
|
if store.shared()? {
|
||||||
openxer_automation::workspace_db::record_sample(store.connection(), row, before)?;
|
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
|
/// The sample is the only project in a workspace that has not shown the
|
||||||
/// note yet: say what it is, once.
|
/// note yet: say what it is, once.
|
||||||
fn note_first_run(&mut self) {
|
fn note_first_run(&mut self) {
|
||||||
|
if !self.has_open_project() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if self.store.preference(NOTED_KEY).ok().flatten().is_some() {
|
if self.store.preference(NOTED_KEY).ok().flatten().is_some() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,11 +67,15 @@ impl App {
|
|||||||
}
|
}
|
||||||
/// `OpenXER : <project ID> (<project name>)`, sent only when it changes.
|
/// `OpenXER : <project ID> (<project name>)`, sent only when it changes.
|
||||||
fn window_title(&mut self, ctx: &egui::Context) {
|
fn window_title(&mut self, ctx: &egui::Context) {
|
||||||
let title = format!(
|
let title = if self.open_set.empty {
|
||||||
"OpenXER : {} ({})",
|
"OpenXER".to_string()
|
||||||
self.project.model.project.name,
|
} else {
|
||||||
views::project_title(&self.project)
|
format!(
|
||||||
);
|
"OpenXER : {} ({})",
|
||||||
|
self.project.model.project.name,
|
||||||
|
views::project_title(&self.project)
|
||||||
|
)
|
||||||
|
};
|
||||||
let key = egui::Id::new("openxer_window_title");
|
let key = egui::Id::new("openxer_window_title");
|
||||||
if ctx.data(|d| d.get_temp::<String>(key)).as_ref() != Some(&title) {
|
if ctx.data(|d| d.get_temp::<String>(key)).as_ref() != Some(&title) {
|
||||||
ctx.send_viewport_cmd(egui::ViewportCommand::Title(title.clone()));
|
ctx.send_viewport_cmd(egui::ViewportCommand::Title(title.clone()));
|
||||||
@@ -368,10 +372,6 @@ impl App {
|
|||||||
|
|
||||||
/// Texts of the fixed status panels, in order.
|
/// Texts of the fixed status panels, in order.
|
||||||
pub(super) fn status_panels(&self) -> Vec<String> {
|
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")
|
let user = std::env::var("USERNAME")
|
||||||
.or_else(|_| std::env::var("USER"))
|
.or_else(|_| std::env::var("USER"))
|
||||||
.unwrap_or_else(|_| "local".into());
|
.unwrap_or_else(|_| "local".into());
|
||||||
@@ -381,6 +381,17 @@ impl App {
|
|||||||
.file_name()
|
.file_name()
|
||||||
.map(|name| name.to_string_lossy().into_owned())
|
.map(|name| name.to_string_lossy().into_owned())
|
||||||
.unwrap_or_else(|| "workspace".into());
|
.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![
|
let mut panels = vec![
|
||||||
format!("Data Date: {data_date}"),
|
format!("Data Date: {data_date}"),
|
||||||
format!("Baseline: {}", self.baseline_label()),
|
format!("Baseline: {}", self.baseline_label()),
|
||||||
|
|||||||
@@ -335,23 +335,37 @@ impl App {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// The lines of an activity picker: every activity whose ID or name
|
#[cfg(test)]
|
||||||
/// 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.
|
|
||||||
pub(crate) fn picker_lines(
|
pub(crate) fn picker_lines(
|
||||||
&self,
|
&self,
|
||||||
query: &str,
|
query: &str,
|
||||||
collapsed: &BTreeSet<String>,
|
collapsed: &BTreeSet<String>,
|
||||||
skip: &dyn Fn(usize) -> bool,
|
skip: &dyn Fn(usize) -> bool,
|
||||||
) -> Vec<PickLine> {
|
) -> 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 shown = self.shown();
|
||||||
let catalog = columns::catalog(shown);
|
let catalog = columns::catalog(shown);
|
||||||
let ix = self.shared_index_at(self.shown_serial());
|
let ix = self.shared_index_at(self.shown_serial());
|
||||||
let layout = layout::Layout {
|
let layout = layout::Layout {
|
||||||
filter: filters::FilterSelection::default(),
|
filter: filters::FilterSelection::default(),
|
||||||
|
group_sort: group_override.unwrap_or_else(|| self.grid.layout.group_sort.clone()),
|
||||||
..self.grid.layout.clone()
|
..self.grid.layout.clone()
|
||||||
};
|
};
|
||||||
let built = group::build(
|
let built = group::build(
|
||||||
@@ -366,7 +380,7 @@ impl App {
|
|||||||
users: &self.grid.user_filters,
|
users: &self.grid.user_filters,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
built
|
let lines: Vec<PickLine> = built
|
||||||
.rows
|
.rows
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|row| match *row {
|
.filter_map(|row| match *row {
|
||||||
@@ -384,7 +398,47 @@ impl App {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.collect()
|
.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
|
/// 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,
|
_ => None,
|
||||||
})
|
})
|
||||||
.collect();
|
.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
|
let bullets = t
|
||||||
.blocks
|
.blocks
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -485,6 +485,7 @@ fn main() -> eframe::Result<()> {
|
|||||||
lock,
|
lock,
|
||||||
store,
|
store,
|
||||||
project,
|
project,
|
||||||
|
empty,
|
||||||
pending,
|
pending,
|
||||||
replace_prompt,
|
replace_prompt,
|
||||||
error: initial_error,
|
error: initial_error,
|
||||||
@@ -493,11 +494,15 @@ fn main() -> eframe::Result<()> {
|
|||||||
std::process::exit(1)
|
std::process::exit(1)
|
||||||
};
|
};
|
||||||
chrome::preload_fonts();
|
chrome::preload_fonts();
|
||||||
let initial_title = format!(
|
let initial_title = if empty {
|
||||||
"OpenXER : {} ({})",
|
"OpenXER".to_string()
|
||||||
project.model.project.name,
|
} else {
|
||||||
views::project_title(&project)
|
format!(
|
||||||
);
|
"OpenXER : {} ({})",
|
||||||
|
project.model.project.name,
|
||||||
|
views::project_title(&project)
|
||||||
|
)
|
||||||
|
};
|
||||||
let saved_place = window_place::load(&store);
|
let saved_place = window_place::load(&store);
|
||||||
window_place::seed(saved_place);
|
window_place::seed(saved_place);
|
||||||
// On Windows, winit 0.30 calls ShowWindow(SW_MAXIMIZE) -> ShowWindow(SW_HIDE)
|
// 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 cloak = window_place::StartupCloak::engage(defer_maximize);
|
||||||
let mut app = App::new(&cc.egui_ctx, store, project);
|
let mut app = App::new(&cc.egui_ctx, store, project);
|
||||||
app.startup_cloak = cloak;
|
app.startup_cloak = cloak;
|
||||||
app.adopt_file_baselines();
|
if empty {
|
||||||
app.restore_open_set();
|
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)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
app.capture_dir = args
|
app.capture_dir = args
|
||||||
@@ -566,6 +578,9 @@ struct Startup {
|
|||||||
lock: store::WorkspaceLock,
|
lock: store::WorkspaceLock,
|
||||||
store: Store,
|
store: Store,
|
||||||
project: ProjectData,
|
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)>,
|
pending: Option<(Document, String)>,
|
||||||
/// A project read from a file the workspace already has a copy of (the
|
/// A project read from a file the workspace already has a copy of (the
|
||||||
/// copy's workspace id), waiting for the user to choose.
|
/// 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 initial_error = None;
|
||||||
let mut pending = None;
|
let mut pending = None;
|
||||||
let mut replace_prompt = None;
|
let mut replace_prompt = None;
|
||||||
// The as-planned copy of the sample, while the window starts on a fresh
|
// The as-planned and mid-project rebaseline copies of the sample, while
|
||||||
// sample (it becomes its baseline once the sample is stored).
|
// the window starts on a fresh sample (stored as its two baselines).
|
||||||
let mut fresh_sample = None;
|
let mut fresh_sample = None;
|
||||||
|
let mut empty = false;
|
||||||
let mut project = match store.last() {
|
let mut project = match store.last() {
|
||||||
Ok(Some(saved)) => saved,
|
Ok(Some(saved)) => saved,
|
||||||
|
Ok(None) if file.is_none() && first_run::was_seeded(&store) => {
|
||||||
|
empty = true;
|
||||||
|
open_set::empty_placeholder()
|
||||||
|
}
|
||||||
Ok(None) => {
|
Ok(None) => {
|
||||||
let (current, plan) = fallback_sample(&store);
|
first_run::mark_seeded(&store);
|
||||||
fresh_sample = Some(plan);
|
let (current, plan, revision) = fallback_sample(&store);
|
||||||
|
fresh_sample = Some((plan, revision));
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
Err(error) => {
|
Err(error) => {
|
||||||
initial_error = Some(format!(
|
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}"
|
"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);
|
let (current, plan, revision) = fallback_sample(&store);
|
||||||
fresh_sample = Some(plan);
|
fresh_sample = Some((plan, revision));
|
||||||
current
|
current
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -665,6 +686,7 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
|||||||
store.forget_mark(&key);
|
store.forget_mark(&key);
|
||||||
project = imported;
|
project = imported;
|
||||||
fresh_sample = None;
|
fresh_sample = None;
|
||||||
|
empty = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(error) => initial_error = Some(error),
|
Err(error) => initial_error = Some(error),
|
||||||
@@ -678,47 +700,52 @@ fn launch(args: &[std::ffi::OsString], fatal: impl FnOnce(&str)) -> Option<Start
|
|||||||
Err(error) => initial_error = Some(error),
|
Err(error) => initial_error = Some(error),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if project
|
if !empty {
|
||||||
.model
|
if project
|
||||||
.activities
|
.model
|
||||||
.iter()
|
.activities
|
||||||
.all(|a| a.early_start.is_none())
|
.iter()
|
||||||
{
|
.all(|a| a.early_start.is_none())
|
||||||
if let Err(error) = schedule_model(&mut project.model, &project.resources) {
|
{
|
||||||
initial_error = Some(error);
|
if let Err(error) = schedule_model(&mut project.model, &project.resources) {
|
||||||
}
|
initial_error = Some(error);
|
||||||
}
|
|
||||||
// The dictionary before the sample joins it: what the sample adds is
|
|
||||||
// the sample's own, and goes when the sample is removed.
|
|
||||||
let dictionary_before = fresh_sample
|
|
||||||
.as_ref()
|
|
||||||
.and_then(|_| store.dictionary().ok().map(|(d, _)| d));
|
|
||||||
// The project starts as the workspace stores it; a failed save is shown
|
|
||||||
// when the window opens rather than lost.
|
|
||||||
match store.save_stored(&project) {
|
|
||||||
Ok((_, Some(doc))) => {
|
|
||||||
if let Err(error) = store::adopt_document(&mut project, doc) {
|
|
||||||
note(&mut initial_error, error);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(_) => {}
|
// The dictionary before the sample joins it: what the sample adds is
|
||||||
Err(error) => note(
|
// the sample's own, and goes when the sample is removed.
|
||||||
&mut initial_error,
|
let dictionary_before = fresh_sample
|
||||||
format!("The project could not be saved to the workspace: {error}"),
|
.as_ref()
|
||||||
),
|
.and_then(|_| store.dictionary().ok().map(|(d, _)| d));
|
||||||
}
|
// The project starts as the workspace stores it; a failed save is shown
|
||||||
if let (Some(plan), Some(before)) = (fresh_sample, dictionary_before) {
|
// when the window opens rather than lost.
|
||||||
if let Err(error) = first_run::install_sample(&mut store, &mut project, &plan, &before) {
|
match store.save_stored(&project) {
|
||||||
note(
|
Ok((_, Some(doc))) => {
|
||||||
|
if let Err(error) = store::adopt_document(&mut project, doc) {
|
||||||
|
note(&mut initial_error, error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Ok(_) => {}
|
||||||
|
Err(error) => note(
|
||||||
&mut initial_error,
|
&mut initial_error,
|
||||||
format!("The sample project's baseline could not be stored: {error}"),
|
format!("The project could not be saved to the workspace: {error}"),
|
||||||
);
|
),
|
||||||
|
}
|
||||||
|
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 baselines could not be stored: {error}"),
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Some(Startup {
|
Some(Startup {
|
||||||
lock,
|
lock,
|
||||||
store,
|
store,
|
||||||
project,
|
project,
|
||||||
|
empty,
|
||||||
pending,
|
pending,
|
||||||
replace_prompt,
|
replace_prompt,
|
||||||
error: initial_error,
|
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
|
/// 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
|
/// may have failed to load), the sample gets a name of its own, so saving it
|
||||||
/// can never replace that project.
|
/// 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 sample = openxer_xer::sample_project::sample_project();
|
||||||
let mut p = sample.current;
|
let mut p = sample.current;
|
||||||
let key = p.model.project.proj_id;
|
let key = p.model.project.proj_id;
|
||||||
@@ -748,7 +775,7 @@ fn fallback_sample(store: &Store) -> (ProjectData, ProjectData) {
|
|||||||
}
|
}
|
||||||
p.source_name = name;
|
p.source_name = name;
|
||||||
}
|
}
|
||||||
(p, sample.plan)
|
(p, sample.plan, sample.revision)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
|
|||||||
@@ -56,6 +56,11 @@ pub struct Composite {
|
|||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct OpenSet {
|
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`).
|
/// Workspace id of the active project (`App.project`).
|
||||||
pub active: Option<i64>,
|
pub active: Option<i64>,
|
||||||
/// Workspace id of the Default Project.
|
/// Workspace id of the Default Project.
|
||||||
@@ -93,11 +98,70 @@ pub struct OpenSet {
|
|||||||
impl OpenSet {
|
impl OpenSet {
|
||||||
/// More than one project is open.
|
/// More than one project is open.
|
||||||
pub fn multi(&self) -> bool {
|
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 {
|
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.
|
/// What the activity table and the Gantt show: every open project.
|
||||||
pub(crate) fn shown(&self) -> &ProjectData {
|
pub(crate) fn shown(&self) -> &ProjectData {
|
||||||
self.open_set
|
self.open_set
|
||||||
@@ -130,6 +194,9 @@ impl App {
|
|||||||
|
|
||||||
/// The open projects, the active one first (slot order).
|
/// The open projects, the active one first (slot order).
|
||||||
pub(crate) fn open_projects(&self) -> Vec<&ProjectData> {
|
pub(crate) fn open_projects(&self) -> Vec<&ProjectData> {
|
||||||
|
if self.open_set.empty {
|
||||||
|
return vec![];
|
||||||
|
}
|
||||||
std::iter::once(&self.project)
|
std::iter::once(&self.project)
|
||||||
.chain(self.open_set.parked.iter().map(|p| &p.project))
|
.chain(self.open_set.parked.iter().map(|p| &p.project))
|
||||||
.collect()
|
.collect()
|
||||||
@@ -180,6 +247,9 @@ impl App {
|
|||||||
|
|
||||||
/// The workspace id of the active project, saving it first if needed.
|
/// The workspace id of the active project, saving it first if needed.
|
||||||
fn ensure_active_id(&mut self) -> Option<i64> {
|
fn ensure_active_id(&mut self) -> Option<i64> {
|
||||||
|
if self.open_set.empty {
|
||||||
|
return None;
|
||||||
|
}
|
||||||
if self.open_set.active.is_none() {
|
if self.open_set.active.is_none() {
|
||||||
self.open_set.active = self.store.id_of(
|
self.open_set.active = self.store.id_of(
|
||||||
&self.project.source_name,
|
&self.project.source_name,
|
||||||
@@ -483,6 +553,9 @@ impl App {
|
|||||||
|
|
||||||
/// Reopen the projects that were open with the active one last time.
|
/// Reopen the projects that were open with the active one last time.
|
||||||
pub(crate) fn restore_open_set(&mut self) {
|
pub(crate) fn restore_open_set(&mut self) {
|
||||||
|
if self.open_set.empty {
|
||||||
|
return;
|
||||||
|
}
|
||||||
let Some(active) = self.ensure_active_id() else {
|
let Some(active) = self.ensure_active_id() else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -501,6 +574,11 @@ impl App {
|
|||||||
.as_array()
|
.as_array()
|
||||||
.map(|a| a.iter().filter_map(|v| v.as_i64()).collect())
|
.map(|a| a.iter().filter_map(|v| v.as_i64()).collect())
|
||||||
.unwrap_or_default();
|
.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![];
|
let mut notes = vec![];
|
||||||
if ids.contains(&active) {
|
if ids.contains(&active) {
|
||||||
notes = self.clear_number_clashes(&ids, &[active]);
|
notes = self.clear_number_clashes(&ids, &[active]);
|
||||||
@@ -606,11 +684,11 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// File > Close Project: close the active project; another open project
|
/// Close the active project: another open project (the default one first)
|
||||||
/// (the default one first) becomes active.
|
/// becomes active, or the workspace enters the empty (no open project)
|
||||||
|
/// state on the Projects view.
|
||||||
pub(crate) fn close_active_project(&mut self) {
|
pub(crate) fn close_active_project(&mut self) {
|
||||||
if self.open_set.parked.is_empty() {
|
if self.open_set.empty {
|
||||||
self.status = "The last open project stays open".into();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if self.dirty {
|
if self.dirty {
|
||||||
@@ -619,6 +697,13 @@ impl App {
|
|||||||
return;
|
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 closing = self.open_set.active;
|
||||||
let next = self
|
let next = self
|
||||||
.open_set
|
.open_set
|
||||||
@@ -626,7 +711,6 @@ impl App {
|
|||||||
.iter()
|
.iter()
|
||||||
.position(|p| Some(p.id) == self.open_set.default)
|
.position(|p| Some(p.id) == self.open_set.default)
|
||||||
.unwrap_or(0);
|
.unwrap_or(0);
|
||||||
let name = self.project.model.project.name.clone();
|
|
||||||
self.activate_parked(next);
|
self.activate_parked(next);
|
||||||
self.open_set.parked.retain(|p| Some(p.id) != closing);
|
self.open_set.parked.retain(|p| Some(p.id) != closing);
|
||||||
if self.open_set.default == closing || self.open_set.default.is_none() {
|
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.
|
/// [`App::save`], returning the failure instead of showing it.
|
||||||
pub(crate) fn try_save(&mut self) -> Result<(), String> {
|
pub(crate) fn try_save(&mut self) -> Result<(), String> {
|
||||||
self.save_view();
|
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.
|
// Other open projects first, so the active one is the workspace's last project.
|
||||||
self.save_parked()?;
|
self.save_parked()?;
|
||||||
match self.store.save_stored(&self.project) {
|
match self.store.save_stored(&self.project) {
|
||||||
@@ -58,15 +62,18 @@ impl App {
|
|||||||
self.load_from(p, true);
|
self.load_from(p, true);
|
||||||
}
|
}
|
||||||
fn load_from(&mut self, p: ProjectData, file: bool) {
|
fn load_from(&mut self, p: ProjectData, file: bool) {
|
||||||
if self.any_dirty() {
|
if !self.open_set.empty {
|
||||||
self.save();
|
|
||||||
if self.any_dirty() {
|
if self.any_dirty() {
|
||||||
return;
|
self.save();
|
||||||
|
if self.any_dirty() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
self.keep_closing_history();
|
||||||
|
// Loading one project replaces the open set.
|
||||||
|
self.close_parked();
|
||||||
}
|
}
|
||||||
self.keep_closing_history();
|
self.open_set.empty = false;
|
||||||
// Loading one project replaces the open set.
|
|
||||||
self.close_parked();
|
|
||||||
if file {
|
if file {
|
||||||
// Only now: the projects saved and closed above still needed it.
|
// Only now: the projects saved and closed above still needed it.
|
||||||
self.store
|
self.store
|
||||||
@@ -291,6 +298,10 @@ impl App {
|
|||||||
/// Add without the wizard: the row goes in at once and its name cell
|
/// Add without the wizard: the row goes in at once and its name cell
|
||||||
/// opens for typing.
|
/// opens for typing.
|
||||||
pub(crate) fn new_activity(&mut self) {
|
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 place = self.new_activity_place();
|
||||||
let i = self.insert_new_activity(&place);
|
let i = self.insert_new_activity(&place);
|
||||||
// The name cell opens with the new name selected: typing replaces
|
// The name cell opens with the new name selected: typing replaces
|
||||||
@@ -349,7 +360,7 @@ impl App {
|
|||||||
}
|
}
|
||||||
if changed {
|
if changed {
|
||||||
self.records_revision = self.history.revision();
|
self.records_revision = self.history.revision();
|
||||||
self.dirty = true;
|
self.dirty = !self.open_set.empty;
|
||||||
self.status = if redo { "Redo" } else { "Undo" }.into();
|
self.status = if redo { "Redo" } else { "Undo" }.into();
|
||||||
self.date_edits.clear();
|
self.date_edits.clear();
|
||||||
self.edit_cell = None;
|
self.edit_cell = None;
|
||||||
|
|||||||
@@ -99,8 +99,9 @@ const WBS_TABLE: [&str; 23] = [
|
|||||||
const WBS_CHART: [&str; 1] = ["WBS Details"];
|
const WBS_CHART: [&str; 1] = ["WBS Details"];
|
||||||
|
|
||||||
/// The Projects table menu of a project row.
|
/// The Projects table menu of a project row.
|
||||||
const PROJECTS_TABLE: [&str; 21] = [
|
const PROJECTS_TABLE: [&str; 22] = [
|
||||||
"Open Project",
|
"Open Project",
|
||||||
|
"Close Project",
|
||||||
"Project Details",
|
"Project Details",
|
||||||
"Edit Project Details",
|
"Edit Project Details",
|
||||||
SEP,
|
SEP,
|
||||||
|
|||||||
@@ -303,6 +303,10 @@ impl App {
|
|||||||
|
|
||||||
/// F9 and Tools > Schedule: open the Schedule dialog.
|
/// F9 and Tools > Schedule: open the Schedule dialog.
|
||||||
pub(crate) fn open_schedule_dialog(&mut self) {
|
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 let Some((activity, field)) = self.edit_cell.take() {
|
||||||
if !self.apply_cell(activity, field, &self.edit_text.clone()) {
|
if !self.apply_cell(activity, field, &self.edit_text.clone()) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ fn a_new_workspace_starts_on_the_sample() {
|
|||||||
let row = started.store.list().unwrap()[0].0;
|
let row = started.store.list().unwrap()[0].0;
|
||||||
let c = started.store.connection();
|
let c = started.store.connection();
|
||||||
let baselines = crate::baselines::store::list(c, row).unwrap();
|
let baselines = crate::baselines::store::list(c, row).unwrap();
|
||||||
assert_eq!(baselines.len(), 1);
|
assert_eq!(baselines.len(), 2);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
openxer_interchange::baseline::project_value(
|
openxer_interchange::baseline::project_value(
|
||||||
&started.project.document,
|
&started.project.document,
|
||||||
@@ -109,11 +109,16 @@ fn a_new_workspace_starts_on_the_sample() {
|
|||||||
),
|
),
|
||||||
baselines[0].project_key.to_string()
|
baselines[0].project_key.to_string()
|
||||||
);
|
);
|
||||||
|
let ub = crate::baselines::store::user_baselines(c, row).0;
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
crate::baselines::store::user_baselines(c, row).0[0],
|
ub[0],
|
||||||
crate::baselines::store::Choice::Baseline(baselines[0].id)
|
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);
|
drop(started);
|
||||||
let (again, _) = start(&args(&db));
|
let (again, _) = start(&args(&db));
|
||||||
let again = again.unwrap();
|
let again = again.unwrap();
|
||||||
@@ -122,10 +127,39 @@ fn a_new_workspace_starts_on_the_sample() {
|
|||||||
crate::baselines::store::list(again.store.connection(), row)
|
crate::baselines::store::list(again.store.connection(), row)
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.len(),
|
.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
|
/// A workspace made by the first start holds the sample project, the
|
||||||
/// starter reports and nothing else: no other project, no dictionary row
|
/// starter reports and nothing else: no other project, no dictionary row
|
||||||
/// the sample did not bring, no imported notebook topic.
|
/// 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
|
let baselines: i64 = c
|
||||||
.query_row("SELECT COUNT(*) FROM baselines", [], |r| r.get(0))
|
.query_row("SELECT COUNT(*) FROM baselines", [], |r| r.get(0))
|
||||||
.unwrap();
|
.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,
|
// 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 (dict, _) = workspace_db::read_dictionary(c).unwrap();
|
||||||
let record = workspace_db::read_sample(c).unwrap().unwrap();
|
let record = workspace_db::read_sample(c).unwrap().unwrap();
|
||||||
assert_eq!(record.row, started.store.list().unwrap()[0].0);
|
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",
|
"Safety",
|
||||||
"Quality and Inspection",
|
"Quality and Inspection",
|
||||||
"Field Notes",
|
"Field Notes",
|
||||||
"Change Notes"
|
"Change Notes",
|
||||||
|
"Commissioning Notes"
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -549,7 +587,24 @@ fn the_sample_passes_check_schedule() {
|
|||||||
let failed: Vec<String> = results
|
let failed: Vec<String> = results
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|r| r.passed == Some(false))
|
.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();
|
.collect();
|
||||||
assert!(failed.is_empty(), "{failed:?}");
|
assert!(failed.is_empty(), "{failed:?}");
|
||||||
assert!(results.iter().filter(|r| r.passed == Some(true)).count() >= 13);
|
assert!(results.iter().filter(|r| r.passed == Some(true)).count() >= 13);
|
||||||
|
|||||||
@@ -784,6 +784,11 @@ impl Store {
|
|||||||
project.model.options.do_level = level;
|
project.model.options.do_level = level;
|
||||||
Ok(project)
|
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> {
|
pub fn last(&self) -> Result<Option<ProjectData>, String> {
|
||||||
let id: Option<String> = self
|
let id: Option<String> = self
|
||||||
.connection
|
.connection
|
||||||
@@ -794,8 +799,20 @@ impl Store {
|
|||||||
)
|
)
|
||||||
.optional()
|
.optional()
|
||||||
.map_err(|e| e.to_string())?;
|
.map_err(|e| e.to_string())?;
|
||||||
id.map(|s| self.load(s.parse().map_err(|_| "Invalid saved project ID")?))
|
let Some(s) = id else {
|
||||||
.transpose()
|
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
|
/// 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.
|
// The WBS shift buttons stay with the Move bar, still shown.
|
||||||
assert!(!d.has("wbs_cmd_Shift up") && d.has("dock_move_up"));
|
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
|
// The dock's Projects commands follow the view's own rules: an open
|
||||||
// project cannot be deleted.
|
// project can be copied or deleted (saving and closing first).
|
||||||
d.app.views.hidden_toolbars.remove("Edit");
|
d.app.views.hidden_toolbars.remove("Edit");
|
||||||
d.app.show_view(MainView::Projects);
|
d.app.show_view(MainView::Projects);
|
||||||
let row = d
|
let row = d
|
||||||
@@ -82,7 +82,7 @@ fn projects_and_wbs_show_each_edit_command_once() {
|
|||||||
+ 1;
|
+ 1;
|
||||||
d.click(&format!("projects_row_{row}"));
|
d.click(&format!("projects_row_{row}"));
|
||||||
d.frames(2);
|
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_eq!(d.app.view_edit_enabled(ViewEdit::Copy), Some(true));
|
||||||
assert!(d.app.error.is_none(), "{:?}", d.app.error);
|
assert!(d.app.error.is_none(), "{:?}", d.app.error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -78,6 +78,8 @@ pub struct DeleteConfirm {
|
|||||||
pub title: String,
|
pub title: String,
|
||||||
pub activities: usize,
|
pub activities: usize,
|
||||||
pub baselines: 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.
|
/// The project is the first-run sample: its own dictionary rows go too.
|
||||||
pub sample: bool,
|
pub sample: bool,
|
||||||
}
|
}
|
||||||
@@ -357,26 +359,29 @@ impl App {
|
|||||||
Ok(id)
|
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) {
|
pub(crate) fn request_project_delete(&mut self, id: i64) {
|
||||||
if self.is_open(id) || self.workspace_row() == Some(id) {
|
let open = self.is_open(id) || self.workspace_row() == Some(id);
|
||||||
self.error("An open project cannot be deleted. Close it first.".into());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
let Ok(Some(row)) = bstore::project_row(self.store.connection(), id) else {
|
let Ok(Some(row)) = bstore::project_row(self.store.connection(), id) else {
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
let activities = Document::parse(&row.xer)
|
let activities = if self.open_set.active == Some(id) || self.workspace_row() == Some(id) {
|
||||||
.ok()
|
self.project.model.activities.len()
|
||||||
.and_then(|d| {
|
} else if let Some(p) = self.open_set.parked.iter().find(|p| p.id == id) {
|
||||||
d.table("TASK").map(|t| {
|
p.project.model.activities.len()
|
||||||
t.rows
|
} else {
|
||||||
.iter()
|
Document::parse(&row.xer)
|
||||||
.filter(|r| t.value(r, "proj_id").trim() == row.project_key.to_string())
|
.ok()
|
||||||
.count()
|
.and_then(|d| {
|
||||||
|
d.table("TASK").map(|t| {
|
||||||
|
t.rows
|
||||||
|
.iter()
|
||||||
|
.filter(|r| t.value(r, "proj_id").trim() == row.project_key.to_string())
|
||||||
|
.count()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
})
|
.unwrap_or(0)
|
||||||
.unwrap_or(0);
|
};
|
||||||
let sample = openxer_automation::workspace_db::read_sample(self.store.connection())
|
let sample = openxer_automation::workspace_db::read_sample(self.store.connection())
|
||||||
.ok()
|
.ok()
|
||||||
.flatten()
|
.flatten()
|
||||||
@@ -386,14 +391,35 @@ impl App {
|
|||||||
title: row.title,
|
title: row.title,
|
||||||
activities,
|
activities,
|
||||||
baselines: bstore::count(self.store.connection(), id),
|
baselines: bstore::count(self.store.connection(), id),
|
||||||
|
open,
|
||||||
sample,
|
sample,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Remove workspace project `id` with its baselines, as one undo step.
|
/// 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> {
|
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) {
|
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 c = self.store.connection();
|
||||||
let row = bstore::project_row(c, id)?.ok_or("The project no longer exists")?;
|
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,
|
/// What deleting EPS node `eps` takes: the node and the nodes under it,
|
||||||
/// the workspace projects filed in them and their baselines. Refused
|
/// the workspace projects filed in them and their baselines. Refused
|
||||||
/// for the last top-level node, and when every workspace project is in
|
/// for the last top-level node.
|
||||||
/// the node while one of them is open (one project always stays open).
|
|
||||||
fn folder_delete_plan(&mut self, eps: i64) -> Result<FolderPlan, String> {
|
fn folder_delete_plan(&mut self, eps: i64) -> Result<FolderPlan, String> {
|
||||||
let ws = self.workspace().clone();
|
let ws = self.workspace().clone();
|
||||||
if !ws.eps().iter().any(|n| n.id == eps) {
|
if !ws.eps().iter().any(|n| n.id == eps) {
|
||||||
@@ -456,15 +481,6 @@ impl App {
|
|||||||
}
|
}
|
||||||
let ids = self.workspace_ids();
|
let ids = self.workspace_ids();
|
||||||
let (nodes, projects) = ws.folder_contents(eps, &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 c = self.store.connection();
|
||||||
let baselines = projects.iter().map(|p| bstore::count(c, *p)).sum();
|
let baselines = projects.iter().map(|p| bstore::count(c, *p)).sum();
|
||||||
Ok(FolderPlan {
|
Ok(FolderPlan {
|
||||||
@@ -519,13 +535,19 @@ impl App {
|
|||||||
|| self.workspace_row().is_some_and(|a| going.contains(&a));
|
|| self.workspace_row().is_some_and(|a| going.contains(&a));
|
||||||
if active_inside {
|
if active_inside {
|
||||||
if self.open_set.parked.is_empty() {
|
if self.open_set.parked.is_empty() {
|
||||||
let other = self
|
if self.dirty {
|
||||||
|
self.try_save()?;
|
||||||
|
}
|
||||||
|
if let Some(other) = self
|
||||||
.workspace_ids()
|
.workspace_ids()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.find(|id| !going.contains(id))
|
.find(|id| !going.contains(id))
|
||||||
.ok_or("No project outside this EPS node can stay open.")?;
|
{
|
||||||
let p = self.store.load(other)?;
|
let p = self.store.load(other)?;
|
||||||
self.load(p);
|
self.load(p);
|
||||||
|
} else {
|
||||||
|
self.enter_empty_workspace();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
self.close_active_project();
|
self.close_active_project();
|
||||||
}
|
}
|
||||||
@@ -549,6 +571,7 @@ impl App {
|
|||||||
/// current afterwards brings back the nodes, the projects (closed), their
|
/// current afterwards brings back the nodes, the projects (closed), their
|
||||||
/// baselines and baseline choices.
|
/// baselines and baseline choices.
|
||||||
pub(crate) fn delete_folder(&mut self, eps: i64, time: f64) -> Result<(), String> {
|
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 plan = self.folder_delete_plan(eps)?;
|
||||||
let name = self.workspace().eps_value(eps, "eps_name");
|
let name = self.workspace().eps_value(eps, "eps_name");
|
||||||
self.close_for_folder_delete(&plan.projects)?;
|
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 {
|
let Some(record) = workspace_db::read_sample(c)?.filter(|s| s.row == id) else {
|
||||||
return Ok(None);
|
return Ok(None);
|
||||||
};
|
};
|
||||||
let mut open: Vec<(Option<i64>, &Document)> =
|
let mut open: Vec<(Option<i64>, &Document)> = vec![];
|
||||||
vec![(self.open_set.active, &self.project.document)];
|
if !self.open_set.empty {
|
||||||
|
open.push((self.open_set.active, &self.project.document));
|
||||||
|
}
|
||||||
open.extend(
|
open.extend(
|
||||||
self.open_set
|
self.open_set
|
||||||
.parked
|
.parked
|
||||||
@@ -750,6 +775,11 @@ impl App {
|
|||||||
}
|
}
|
||||||
if let Some(d) = self.views.projects.delete.take() {
|
if let Some(d) = self.views.projects.delete.take() {
|
||||||
let mut rects = vec![];
|
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(
|
let clicked = crate::kit_window::message_box(
|
||||||
ctx,
|
ctx,
|
||||||
"delete_project",
|
"delete_project",
|
||||||
@@ -757,12 +787,12 @@ impl App {
|
|||||||
crate::kit_window::MessageIcon::Question,
|
crate::kit_window::MessageIcon::Question,
|
||||||
&if d.sample {
|
&if d.sample {
|
||||||
format!(
|
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
|
d.title, d.activities, d.baselines
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
format!(
|
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
|
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);
|
d.app.history_move(&ctx, false);
|
||||||
assert_eq!(rows(&d).len(), start + 2);
|
assert_eq!(rows(&d).len(), start + 2);
|
||||||
assert_eq!(d.app.store.load(copy).unwrap().model.project.name, title);
|
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();
|
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]
|
#[test]
|
||||||
|
|||||||
@@ -92,11 +92,13 @@ const MONTHS: [(&str, &str); 12] = [
|
|||||||
pub struct ProjectsMenu {
|
pub struct ProjectsMenu {
|
||||||
/// The row is a project, not an EPS node.
|
/// The row is a project, not an EPS node.
|
||||||
pub on_project: bool,
|
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.
|
/// Add and Paste have an EPS node to go under.
|
||||||
pub can_add: bool,
|
pub can_add: bool,
|
||||||
/// The project is kept in the workspace (Cut and Copy apply).
|
/// The project is kept in the workspace (Cut and Copy apply).
|
||||||
pub stored: bool,
|
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,
|
pub deletable: bool,
|
||||||
/// A project was cut or copied.
|
/// A project was cut or copied.
|
||||||
pub clipboard: bool,
|
pub clipboard: bool,
|
||||||
@@ -153,6 +155,13 @@ pub fn projects_menu(m: &ProjectsMenu) -> Vec<Entry> {
|
|||||||
Icon::ProjectOpen,
|
Icon::ProjectOpen,
|
||||||
m.on_project,
|
m.on_project,
|
||||||
),
|
),
|
||||||
|
item(
|
||||||
|
"close_project",
|
||||||
|
"Close Project",
|
||||||
|
"",
|
||||||
|
Icon::ProjectClosed,
|
||||||
|
m.is_open,
|
||||||
|
),
|
||||||
details_item(m.details),
|
details_item(m.details),
|
||||||
Entry::Item(Spec::new("edit_details", "Edit Project Details").enabled(m.on_project)),
|
Entry::Item(Spec::new("edit_details", "Edit Project Details").enabled(m.on_project)),
|
||||||
Entry::Separator,
|
Entry::Separator,
|
||||||
@@ -741,8 +750,12 @@ impl App {
|
|||||||
let stamps = self.store.stamps().unwrap_or_default();
|
let stamps = self.store.stamps().unwrap_or_default();
|
||||||
self.drop_stale_rollups();
|
self.drop_stale_rollups();
|
||||||
let shared = self.dictionary_shared();
|
let shared = self.dictionary_shared();
|
||||||
let live = summarize_live(&self.project);
|
let has_open = !self.open_set.empty;
|
||||||
let is_live = |c: &Cached| c.source == live.source && c.key == live.key;
|
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 out = vec![];
|
||||||
let mut found_current = false;
|
let mut found_current = false;
|
||||||
let cache = &mut self.views.projects.cache;
|
let cache = &mut self.views.projects.cache;
|
||||||
@@ -783,10 +796,12 @@ impl App {
|
|||||||
let entry = &cache[&id];
|
let entry = &cache[&id];
|
||||||
if is_live(entry) {
|
if is_live(entry) {
|
||||||
found_current = true;
|
found_current = true;
|
||||||
out.push(ProjectSummary {
|
if let Some(live) = live.as_ref() {
|
||||||
store_id: Some(id),
|
out.push(ProjectSummary {
|
||||||
..live.clone()
|
store_id: Some(id),
|
||||||
});
|
..live.clone()
|
||||||
|
});
|
||||||
|
}
|
||||||
} else if let Some(s) = &entry.summary {
|
} else if let Some(s) = &entry.summary {
|
||||||
out.push(ProjectSummary {
|
out.push(ProjectSummary {
|
||||||
store_id: Some(id),
|
store_id: Some(id),
|
||||||
@@ -795,7 +810,9 @@ impl App {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if !found_current {
|
if !found_current {
|
||||||
out.push(live);
|
if let Some(live) = live {
|
||||||
|
out.push(live);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
out.sort_by(|a, b| a.id.cmp(&b.id).then(a.source.cmp(&b.source)));
|
out.sort_by(|a, b| a.id.cmp(&b.id).then(a.source.cmp(&b.source)));
|
||||||
for s in &mut out {
|
for s in &mut out {
|
||||||
@@ -914,10 +931,14 @@ impl App {
|
|||||||
};
|
};
|
||||||
match self.store.load(id) {
|
match self.store.load(id) {
|
||||||
Ok(p) => {
|
Ok(p) => {
|
||||||
|
let was_empty = self.open_set.empty;
|
||||||
let before = self.project.source_name.clone();
|
let before = self.project.source_name.clone();
|
||||||
let key = self.project.model.project.proj_id;
|
let key = self.project.model.project.proj_id;
|
||||||
self.load(p);
|
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.saved_projects = self.store.list().unwrap_or_default();
|
||||||
self.show_view(MainView::Activities);
|
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());
|
let has_store = selected.as_ref().is_some_and(|s| s.store_id.is_some());
|
||||||
self.views.projects.edit_enabled = Some([
|
self.views.projects.edit_enabled = Some([
|
||||||
target.is_some(),
|
target.is_some(),
|
||||||
folder.is_some()
|
folder.is_some() || has_store,
|
||||||
|| selected
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|s| s.store_id.is_some() && !is_open(s)),
|
|
||||||
has_store,
|
has_store,
|
||||||
has_store,
|
has_store,
|
||||||
(pending.is_some() || copied.is_some()) && target.is_some(),
|
(pending.is_some() || copied.is_some()) && target.is_some(),
|
||||||
@@ -1118,7 +1136,7 @@ impl App {
|
|||||||
if response.clicked() {
|
if response.clicked() {
|
||||||
open = selected.clone();
|
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 =
|
let response =
|
||||||
sheet::side_button(ui, chrome::Icon::ProjectClosed, "Close Project", closable);
|
sheet::side_button(ui, chrome::Icon::ProjectClosed, "Close Project", closable);
|
||||||
self.action("projects_cmd_close", &response);
|
self.action("projects_cmd_close", &response);
|
||||||
@@ -1141,14 +1159,11 @@ impl App {
|
|||||||
if response.clicked() {
|
if response.clicked() {
|
||||||
add = target;
|
add = target;
|
||||||
}
|
}
|
||||||
let deletable = folder.is_some()
|
let deletable = folder.is_some() || has_store;
|
||||||
|| selected
|
|
||||||
.as_ref()
|
|
||||||
.is_some_and(|s| s.store_id.is_some() && !is_open(s));
|
|
||||||
let response = sheet::side_button(
|
let response = sheet::side_button(
|
||||||
ui,
|
ui,
|
||||||
chrome::Icon::Delete,
|
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,
|
deletable,
|
||||||
);
|
);
|
||||||
self.action("projects_cmd_delete", &response);
|
self.action("projects_cmd_delete", &response);
|
||||||
@@ -1389,12 +1404,13 @@ impl App {
|
|||||||
let collapsed = &self.views.projects.collapsed;
|
let collapsed = &self.views.projects.collapsed;
|
||||||
let any_collapsed = groups.iter().any(|g| collapsed.contains(&g.0));
|
let any_collapsed = groups.iter().any(|g| collapsed.contains(&g.0));
|
||||||
let any_open = 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 fill_ready = self.view_fill_ready();
|
||||||
let menu = |row: usize| {
|
let menu = |row: usize| {
|
||||||
let project = lines.get(row).and_then(project_line);
|
let project = lines.get(row).and_then(project_line);
|
||||||
projects_menu(&ProjectsMenu {
|
projects_menu(&ProjectsMenu {
|
||||||
on_project: project.is_some(),
|
on_project: project.is_some(),
|
||||||
|
is_open: project.is_some_and(is_open),
|
||||||
can_add: match lines.get(row) {
|
can_add: match lines.get(row) {
|
||||||
Some(EpsLine::Eps(id, _)) => *id > 0,
|
Some(EpsLine::Eps(id, _)) => *id > 0,
|
||||||
Some(_) => project.is_some_and(|p| p.store_id.is_some()),
|
Some(_) => project.is_some_and(|p| p.store_id.is_some()),
|
||||||
@@ -1578,6 +1594,7 @@ impl App {
|
|||||||
if let Some((i, key)) = response.menu {
|
if let Some((i, key)) = response.menu {
|
||||||
match key {
|
match key {
|
||||||
"open_project" => open = project_at(i),
|
"open_project" => open = project_at(i),
|
||||||
|
"close_project" => close = project_at(i).and_then(|p| p.store_id),
|
||||||
"add" | "cut" | "copy" | "paste" | "delete" => {
|
"add" | "cut" | "copy" | "paste" | "delete" => {
|
||||||
self.views.projects.command = Some(key);
|
self.views.projects.command = Some(key);
|
||||||
}
|
}
|
||||||
@@ -1666,7 +1683,7 @@ impl App {
|
|||||||
self.view_fill_down(time);
|
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() {
|
match self.views.projects.command.take() {
|
||||||
Some("add") => add = target,
|
Some("add") => add = target,
|
||||||
Some("delete") => {
|
Some("delete") => {
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ fn the_projects_menu_lists_its_items_in_order_and_selects_the_row() {
|
|||||||
);
|
);
|
||||||
let order = [
|
let order = [
|
||||||
"projects_menu_open_project",
|
"projects_menu_open_project",
|
||||||
|
"projects_menu_close_project",
|
||||||
"projects_menu_details",
|
"projects_menu_details",
|
||||||
"projects_menu_edit_details",
|
"projects_menu_edit_details",
|
||||||
"projects_menu_cut",
|
"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");
|
assert!(d.has("projects_menu_add"), "the empty area has a menu");
|
||||||
for key in [
|
for key in [
|
||||||
"projects_menu_open_project",
|
"projects_menu_open_project",
|
||||||
|
"projects_menu_close_project",
|
||||||
"projects_menu_cut",
|
"projects_menu_cut",
|
||||||
"projects_menu_copy",
|
"projects_menu_copy",
|
||||||
"projects_menu_delete",
|
"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
|
// ------------------------------------------------------------- resources
|
||||||
|
|
||||||
fn with_resources() -> Driver {
|
fn with_resources() -> Driver {
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ impl App {
|
|||||||
/// them, and bring the other open projects up to the dictionary when it
|
/// them, and bring the other open projects up to the dictionary when it
|
||||||
/// changed.
|
/// changed.
|
||||||
pub(crate) fn sync_dictionary(&mut self, time: f64) {
|
pub(crate) fn sync_dictionary(&mut self, time: f64) {
|
||||||
if !self.dictionary_shared() {
|
if self.open_set.empty || !self.dictionary_shared() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
let key = key_of(&self.project);
|
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 s = sample();
|
||||||
let m = &s.current.model;
|
let m = &s.current.model;
|
||||||
assert!(
|
assert!(
|
||||||
(150..=250).contains(&m.activities.len()),
|
(350..=450).contains(&m.activities.len()),
|
||||||
"{}",
|
"{}",
|
||||||
m.activities.len()
|
m.activities.len()
|
||||||
);
|
);
|
||||||
@@ -265,8 +265,11 @@ fn every_task_is_labor_and_cost_loaded() {
|
|||||||
.iter()
|
.iter()
|
||||||
.filter(|r| num(t.value(r, "task_id")) == a.task_id)
|
.filter(|r| num(t.value(r, "task_id")) == a.task_id)
|
||||||
.collect();
|
.collect();
|
||||||
if a.task_type != TaskType::Task {
|
if matches!(
|
||||||
assert!(mine.is_empty(), "{} is a milestone", a.task_code);
|
a.task_type,
|
||||||
|
TaskType::Mile | TaskType::FinMile | TaskType::Wbs
|
||||||
|
) {
|
||||||
|
assert!(mine.is_empty(), "{} has no assignments", a.task_code);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
assert!(
|
assert!(
|
||||||
@@ -284,18 +287,26 @@ fn every_task_is_labor_and_cost_loaded() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn only_the_start_and_finish_are_open_ends() {
|
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 m = &p.model;
|
||||||
let starts: Vec<&str> = m
|
let starts: Vec<&str> = m
|
||||||
.activities
|
.activities
|
||||||
.iter()
|
.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())
|
.map(|a| a.task_code.as_str())
|
||||||
.collect();
|
.collect();
|
||||||
let finishes: Vec<&str> = m
|
let finishes: Vec<&str> = m
|
||||||
.activities
|
.activities
|
||||||
.iter()
|
.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())
|
.map(|a| a.task_code.as_str())
|
||||||
.collect();
|
.collect();
|
||||||
assert_eq!((starts, finishes), (vec!["MS0000"], vec!["PM0920"]));
|
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();
|
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.
|
// The plan carries no actuals; the budget is the same in both.
|
||||||
let total = |p: &ProjectData, column: &str| -> f64 {
|
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!(topics.contains(&topic), "{topics:?}");
|
||||||
}
|
}
|
||||||
assert!(count("TASKMEMO") >= 12);
|
assert!(count("TASKMEMO") >= 20);
|
||||||
assert!(count("WBSMEMO") >= 6);
|
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.
|
// Codes are the project's own, calendars and resources are named for it.
|
||||||
let (t, rows) = table_rows(p, "ACTVTYPE");
|
let (t, rows) = table_rows(p, "ACTVTYPE");
|
||||||
assert!(rows
|
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().any(|r| r.key == "ENGR" && r.earned > 0.));
|
||||||
assert!(hours.rows.iter().all(|r| r.budgeted > 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