31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
function extractProcessesForStatus(processes, status) {
|
|
return processes.filter((p) => p.CurrentStatus === status || p.CurrentStatus === -1);
|
|
}
|
|
|
|
function matchProcessByLabel(processes, text) {
|
|
const trimmed = String(text ?? "").trim();
|
|
return processes.find((p) => (p.DisplayName || p.Name) === trimmed) || null;
|
|
}
|
|
|
|
function getValidationColumnNames(process) {
|
|
if (!Array.isArray(process.ValidateInputs)) return [];
|
|
return process.ValidateInputs.map((v) => v.ColumnName).filter(Boolean);
|
|
}
|
|
|
|
function classifyAwaitInput(process) {
|
|
const columnNames = getValidationColumnNames(process);
|
|
if (columnNames.length === 0) {
|
|
return { awaitInput: "none", column: null };
|
|
}
|
|
const column = columnNames[0];
|
|
if (column.startsWith("Date")) {
|
|
return { awaitInput: "date", column };
|
|
}
|
|
if (column.startsWith("Attachments")) {
|
|
return { awaitInput: "file", column };
|
|
}
|
|
return { awaitInput: "none", column: null };
|
|
}
|
|
|
|
module.exports = { extractProcessesForStatus, matchProcessByLabel, classifyAwaitInput };
|