Skip to content

Commit

Permalink
feat: update
Browse files Browse the repository at this point in the history
  • Loading branch information
weird94 committed Sep 19, 2024
1 parent 13105e0 commit 2572a49
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ export const UpdateSheetDataValidationRangeCommand: ICommand<IUpdateSheetDataVal
if (!currentRule) {
return false;
}
const oldRanges = currentRule.ranges;
const matrix = sheetDataValidationModel.getRuleObjectMatrix(unitId, subUnitId).clone();
matrix.updateRange(ruleId, oldRanges, ranges);
matrix.updateRange(ruleId, ranges);
const diffs = matrix.diff(sheetDataValidationModel.getRules(unitId, subUnitId));

const { redoMutations, undoMutations } = getDataValidationDiffMutations(unitId, subUnitId, diffs, accessor);
Expand Down
4 changes: 2 additions & 2 deletions packages/sheets-data-validation/src/models/rule-matrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class RuleMatrix {
this._map.delete(rule.uid);
}

updateRange(ruleId: string, _oldRanges: IRange[], _newRanges: IRange[]) {
updateRange(ruleId: string, _newRanges: IRange[]) {
this._map.delete(ruleId);
const ranges = _newRanges.map((range) => Range.transformRange(range, this._worksheet));
this._map.forEach((value, key) => {
Expand All @@ -85,7 +85,7 @@ export class RuleMatrix {
}
});

this._map.set(ruleId, _newRanges);
this._map.set(ruleId, ranges);
}

diff(rules: ISheetDataValidationRule[]) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class SheetDataValidationModel extends Disposable {
private _updateRule(unitId: string, subUnitId: string, ruleId: string, oldRule: ISheetDataValidationRule, payload: IUpdateRulePayload) {
const ruleMatrix = this._ensureRuleMatrix(unitId, subUnitId);
if (payload.type === UpdateRuleType.RANGE) {
ruleMatrix.updateRange(ruleId, oldRule.ranges, payload.payload);
ruleMatrix.updateRange(ruleId, payload.payload);
this._dataValidationCacheService.updateRuleRanges(unitId, subUnitId, ruleId, payload.payload, oldRule.ranges);
this._dataValidationCustomFormulaService.updateRuleRanges(unitId, subUnitId, ruleId, oldRule.ranges, payload.payload);
} else if (payload.type === UpdateRuleType.SETTING) {
Expand Down

0 comments on commit 2572a49

Please sign in to comment.