diff --git a/ui/src/views/Forecast.jsx b/ui/src/views/Forecast.jsx index cd30251..f1a4635 100644 --- a/ui/src/views/Forecast.jsx +++ b/ui/src/views/Forecast.jsx @@ -1058,10 +1058,24 @@ export default function Forecast({ sources = [], sourceId, versions = [], versio .some(k => body[k] !== undefined) if (!has) { flash('Enter a target or increment', 'error'); return } } - if ((op === 'recode' || op === 'clone') && !Object.keys(body.set || {}).length) { - flash(op === 'recode' ? 'Enter at least one new dimension value' : 'Enter at least one override value', 'error') + // Recode with nothing set would rewrite rows as themselves. Clone would not: + // copying a segment forward in time changes the dates and the period + // dimensions, which is the whole point of cloning from prior year, so it needs + // no dimension override at all. It only needs to be doing *something* -- + // an override, a shift, or a factor. + if (op === 'recode' && !Object.keys(body.set || {}).length) { + flash('Enter at least one new dimension value', 'error') return } + if (op === 'clone') { + const shifts = body.date_offset && body.date_offset !== '0 days' + const scales = body.scale != null && body.scale !== 1 + const changes = Object.keys(body.set || {}).length > 0 + if (!shifts && !scales && !changes) { + flash('A clone with no override, no date shift and a factor of 1 would just duplicate the rows', 'error') + return + } + } try { const res = await fetch(`/api/versions/${versionId}/${op}`, {