Match XLSX headers to the official Ontime template
This commit is contained in:
parent
9a9be38af4
commit
2b70b6272e
|
|
@ -14,6 +14,17 @@ use std::{
|
|||
};
|
||||
use zip::{ZipWriter, write::SimpleFileOptions};
|
||||
|
||||
// Match the official Ontime v4 spreadsheet template (not the JSON property names).
|
||||
const SPREADSHEET_HEADERS: [&str; 7] = [
|
||||
"Time Start",
|
||||
"Time End",
|
||||
"Duration",
|
||||
"Cue",
|
||||
"Title",
|
||||
"Note",
|
||||
"Timer Type",
|
||||
];
|
||||
|
||||
fn entry_values(entry: &Entry, rundown: &Rundown, usage: &str, column: Option<&str>) -> String {
|
||||
entry
|
||||
.source_rows
|
||||
|
|
@ -51,18 +62,10 @@ fn metadata_columns(rundown: &Rundown) -> Vec<(String, String)> {
|
|||
})
|
||||
.collect::<Vec<_>>();
|
||||
columns.sort_by_key(|(column, _)| column_index(column).unwrap_or(usize::MAX));
|
||||
let mut used = [
|
||||
"start",
|
||||
"end",
|
||||
"duration",
|
||||
"cue",
|
||||
"title",
|
||||
"note",
|
||||
"timer type",
|
||||
]
|
||||
.into_iter()
|
||||
.map(str::to_string)
|
||||
.collect::<BTreeSet<_>>();
|
||||
let mut used = SPREADSHEET_HEADERS
|
||||
.iter()
|
||||
.map(|header| header.to_lowercase())
|
||||
.collect::<BTreeSet<_>>();
|
||||
for (column, label) in &mut columns {
|
||||
let base = if label.trim().is_empty() {
|
||||
format!("Metadata {column}")
|
||||
|
|
@ -104,15 +107,12 @@ fn xml_text(value: &str) -> String {
|
|||
|
||||
fn worksheet(rundown: &Rundown) -> String {
|
||||
let metadata = metadata_columns(rundown);
|
||||
let mut rows = vec![vec![
|
||||
"Start".into(),
|
||||
"End".into(),
|
||||
"Duration".into(),
|
||||
"Cue".into(),
|
||||
"Title".into(),
|
||||
"Note".into(),
|
||||
"Timer type".into(),
|
||||
]];
|
||||
let mut rows = vec![
|
||||
SPREADSHEET_HEADERS
|
||||
.iter()
|
||||
.map(|header| (*header).to_string())
|
||||
.collect::<Vec<_>>(),
|
||||
];
|
||||
rows[0].extend(metadata.iter().map(|(_, label)| label.clone()));
|
||||
for entry in rundown.entries.iter().filter(|entry| entry.kind == "event") {
|
||||
let mut row = vec![
|
||||
|
|
|
|||
|
|
@ -686,13 +686,13 @@ fn xlsx_export_has_ontime_columns_notes_metadata_and_clock_strings() {
|
|||
.map(|cell| cell.text.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
[
|
||||
"Start",
|
||||
"End",
|
||||
"Time Start",
|
||||
"Time End",
|
||||
"Duration",
|
||||
"Cue",
|
||||
"Title",
|
||||
"Note",
|
||||
"Timer type",
|
||||
"Timer Type",
|
||||
"Video",
|
||||
]
|
||||
);
|
||||
|
|
@ -703,6 +703,17 @@ fn xlsx_export_has_ontime_columns_notes_metadata_and_clock_strings() {
|
|||
assert_eq!(tables[0].rows[1][6].text, "count-down");
|
||||
assert_eq!(tables[0].rows[1][7].text, "Slides");
|
||||
assert_eq!(tables[0].rows[2][0].text, "09:10:00");
|
||||
|
||||
// Metadata must not shadow Ontime's standard timing fields.
|
||||
let mut rundown = analysis.rundown.unwrap();
|
||||
rundown
|
||||
.mapping
|
||||
.column_labels
|
||||
.insert("E".into(), "Time Start".into());
|
||||
std::fs::write(&path, export::xlsx(&rundown).unwrap()).unwrap();
|
||||
let tables = reader::read(&path).unwrap();
|
||||
assert_eq!(tables[0].rows[0][0].text, "Time Start");
|
||||
assert_eq!(tables[0].rows[0][7].text, "Time Start (E)");
|
||||
}
|
||||
#[test]
|
||||
fn invalid_or_cancelled_analysis_never_exports() {
|
||||
|
|
|
|||
|
|
@ -272,8 +272,10 @@ operator will start an event on time.
|
|||
|
||||
Native Ontime JSON is the primary target: it lets the exporter control time
|
||||
relationships and project structure without a second column-mapping step.
|
||||
XLSX export writes one `Ontime` worksheet with `Start`, `End`, `Duration`, `Cue`,
|
||||
`Title`, `Note` and `Timer type` columns, followed by selected metadata columns.
|
||||
XLSX export writes one `Ontime` worksheet with `Time Start`, `Time End`, `Duration`, `Cue`,
|
||||
`Title`, `Note` and `Timer Type` columns, followed by selected metadata columns.
|
||||
These headers match the [official Ontime v4 template](https://docs.google.com/spreadsheets/d/1zT6yRgQUaICEiAFR85VEL-E9hAUDujKg6DaWR0iDYmY/edit).
|
||||
Native JSON uses Ontime's schema keys such as `timeStart`, `timeEnd` and `timerType`.
|
||||
Times use `HH:MM:SS` strings accepted by Ontime. Import the file with Ontime's
|
||||
[spreadsheet importer](https://docs.getontime.no/features/import-spreadsheet/)
|
||||
and map the displayed columns. Schedule gaps remain visible through absolute
|
||||
|
|
|
|||
Loading…
Reference in New Issue