Let a clone proceed on a date shift with no dimension override
The panel required at least one override for both recode and clone. For recode that is right -- rewriting rows as themselves does nothing. For clone it is not: copying prior year forward changes the dates and, through dim_period, the season and month dimensions, which is the entire point of cloning from a reference segment. The server-side requirement was dropped when from_logid went in; this one was missed, so the operation was blocked in the UI with "Enter at least one override value". Clone now only has to be doing something -- an override, a shift, or a factor other than 1 -- and says so when it is doing none of the three. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
5acac2738a
commit
0a50122add
@ -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}`, {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user