diff options
author | Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu> | 2022-08-10 13:45:19 -0400 |
---|---|---|
committer | Michael Foiani <sotech117@michaels-mbp-5.devices.brown.edu> | 2022-08-10 13:45:19 -0400 |
commit | f573b7a8e0764f6fdfec637810f6e5b699c33053 (patch) | |
tree | 3a66fa34db31e83c95cc72cf13515f6c018b3a88 /src/fields/util.ts | |
parent | 57a2713e1219b58e7ad08b697a23ea3f9b962a84 (diff) | |
parent | a63f017c213563728f45f2caa7415843f50f3559 (diff) |
Merge branch 'master' into report-bug-mfoiani
casual merge with master to keep local branch updated
Diffstat (limited to 'src/fields/util.ts')
-rw-r--r-- | src/fields/util.ts | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/fields/util.ts b/src/fields/util.ts index 41e723119..d87bb6656 100644 --- a/src/fields/util.ts +++ b/src/fields/util.ts @@ -33,6 +33,7 @@ import { ObjectField } from './ObjectField'; import { PrefetchProxy, ProxyField } from './Proxy'; import { RefField } from './RefField'; import { RichTextField } from './RichTextField'; +import { SchemaHeaderField } from './SchemaHeaderField'; import { ComputedField } from './ScriptField'; import { ScriptCast, StrCast } from './Types'; @@ -455,7 +456,7 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any ? { redo: action(() => { diff.items.forEach((item: any) => { - const ind = receiver[prop].indexOf(item.value ? item.value() : item); + const ind = item instanceof SchemaHeaderField ? receiver[prop].findIndex((ele: any) => ele instanceof SchemaHeaderField && ele.heading === item.heading) : receiver[prop].indexOf(item.value ? item.value() : item); ind !== -1 && receiver[prop].splice(ind, 1); }); lastValue = ObjectField.MakeCopy(receiver[prop]); @@ -463,8 +464,13 @@ export function updateFunction(target: any, prop: any, value: any, receiver: any undo: () => { // console.log("undo $rem: " + prop, diff.items) // bcz: uncomment to log undo diff.items.forEach((item: any) => { - const ind = (prevValue as List<any>).indexOf(item.value ? item.value() : item); - ind !== -1 && receiver[prop].indexOf(item.value ? item.value() : item) === -1 && receiver[prop].splice(ind, 0, item); + if (item instanceof SchemaHeaderField) { + const ind = (prevValue as List<any>).findIndex((ele: any) => ele instanceof SchemaHeaderField && ele.heading === item.heading); + ind !== -1 && receiver[prop].findIndex((ele: any) => ele instanceof SchemaHeaderField && ele.heading === item.heading) === -1 && receiver[prop].splice(ind, 0, item); + } else { + const ind = (prevValue as List<any>).indexOf(item.value ? item.value() : item); + ind !== -1 && receiver[prop].indexOf(item.value ? item.value() : item) === -1 && receiver[prop].splice(ind, 0, item); + } }); lastValue = ObjectField.MakeCopy(receiver[prop]); }, |