Skip to content

Commit

Permalink
style(cf): rename
Browse files Browse the repository at this point in the history
  • Loading branch information
Gggpound committed Mar 26, 2024
1 parent 4f4ac79 commit a1064e1
Show file tree
Hide file tree
Showing 33 changed files with 212 additions and 391 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IAverageHighlightCell, IConditionFormatRule } from '../../models/type';
import { CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddAverageCfParams {
ranges: IRange[];
Expand All @@ -33,7 +33,7 @@ interface IAddAverageCfParams {
operator: IAverageHighlightCell['operator'];
}
// { ranges: [{ startRow: 0, endRow: 10, startColumn: 3, endColumn: 3 }, { startRow: 0, endRow: 10, startColumn: 5, endColumn: 5 }], style: { fs: 30 }, operator: 'greaterThan' };
export const addAverageCfCommand: ICommand<IAddAverageCfParams> = {
export const DddAverageCfCommand: ICommand<IAddAverageCfParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-average-conditional-rule',
handler(accessor, params) {
Expand All @@ -57,7 +57,7 @@ export const addAverageCfCommand: ICommand<IAddAverageCfParams> = {
operator,
style,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
return true;
const result = commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
return result;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ import {
IUniverInstanceService,
} from '@univerjs/core';
import type { IConditionFormatRule } from '../../models/type';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import type { MakePropertyOptional } from '../../utils/type';
import { addConditionalRuleMutation, addConditionalRuleMutationUndoFactory } from '../mutations/addConditionalRule.mutation';
import { AddConditionalRuleMutation, AddConditionalRuleMutationUndoFactory } from '../mutations/add-conditional-rule.mutation';
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';

export interface IAddCfCommandParams {
Expand All @@ -33,7 +33,7 @@ export interface IAddCfCommandParams {
rule: MakePropertyOptional<IConditionFormatRule, 'cfId'>;
};

export const addCfCommand: ICommand<IAddCfCommandParams> = {
export const AddCfCommand: ICommand<IAddCfCommandParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-conditional-rule',
handler(accessor, params) {
Expand All @@ -51,16 +51,16 @@ export const addCfCommand: ICommand<IAddCfCommandParams> = {
const subUnitId = params.subUnitId ?? worksheet.getSheetId();
const cfId = conditionalFormatRuleModel.createCfId(unitId, subUnitId);
const config: IAddConditionalRuleMutationParams = { unitId, subUnitId, rule: { ...rule, cfId: rule.cfId || cfId } };
const undo = addConditionalRuleMutationUndoFactory(accessor, config);
const result = commandService.syncExecuteCommand(addConditionalRuleMutation.id, config);
const undo = AddConditionalRuleMutationUndoFactory(accessor, config);
const result = commandService.syncExecuteCommand(AddConditionalRuleMutation.id, config);
if (result) {
undoRedoService.pushUndoRedo({
unitID: unitId,
redoMutations: [{ id: addConditionalRuleMutation.id, params: config }],
redoMutations: [{ id: AddConditionalRuleMutation.id, params: config }],
undoMutations: [undo],
});
}

return true;
return result;
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,16 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IColorScale, IConditionFormatRule } from '../../models/type';
import { CFRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddColorScaleConditionalRuleParams {
ranges: IRange[];
stopIfTrue?: boolean;
config: IColorScale['config'];

}
export const addColorScaleConditionalRuleCommand: ICommand<IAddColorScaleConditionalRuleParams> = {
export const AddColorScaleConditionalRuleCommand: ICommand<IAddColorScaleConditionalRuleParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-color-scale-conditional-rule',
handler(accessor, params) {
Expand All @@ -54,8 +54,6 @@ export const addColorScaleConditionalRuleCommand: ICommand<IAddColorScaleConditi
type: CFRuleType.colorScale,
config,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, IDataBar } from '../../models/type';
import { CFRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddUniqueValuesConditionalRuleParams {
ranges: IRange[];
Expand All @@ -36,7 +36,7 @@ interface IAddUniqueValuesConditionalRuleParams {
isGradient: IDataBar['config']['isGradient'];

}
export const addDataBarConditionalRuleCommand: ICommand<IAddUniqueValuesConditionalRuleParams> = {
export const AddDataBarConditionalRuleCommand: ICommand<IAddUniqueValuesConditionalRuleParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-data-bar-conditional-rule',
handler(accessor, params) {
Expand All @@ -60,8 +60,6 @@ export const addDataBarConditionalRuleCommand: ICommand<IAddUniqueValuesConditio
min, max, nativeColor, positiveColor, isGradient,
},
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, IHighlightCell } from '../../models/type';
import { CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddDuplicateValuesConditionalRuleParams {
ranges: IRange[];
stopIfTrue?: boolean;
style: IHighlightCell['style'];
}
export const addDuplicateValuesCfCommand: ICommand<IAddDuplicateValuesConditionalRuleParams> = {
export const AddDuplicateValuesCfCommand: ICommand<IAddDuplicateValuesConditionalRuleParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-duplicate-values-conditional-rule',
handler(accessor, params) {
Expand All @@ -54,8 +54,6 @@ export const addDuplicateValuesCfCommand: ICommand<IAddDuplicateValuesConditiona
subType: CFSubRuleType.duplicateValues,
style,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, INumberHighlightCell } from '../../models/type';
import { CFNumberOperator, CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddNumberCfParams {
ranges: IRange[];
Expand All @@ -33,7 +33,7 @@ interface IAddNumberCfParams {
operator: INumberHighlightCell['operator'];
value: number | [number, number];
}
export const addNumberCfCommand: ICommand<IAddNumberCfParams> = {
export const AddNumberCfCommand: ICommand<IAddNumberCfParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-number-conditional-rule',
handler(accessor, params) {
Expand Down Expand Up @@ -77,8 +77,6 @@ export const addNumberCfCommand: ICommand<IAddNumberCfParams> = {
value: _value,
} };
}
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, IRankHighlightCell } from '../../models/type';
import { CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddRankCfParams {
ranges: IRange[];
Expand All @@ -35,7 +35,7 @@ interface IAddRankCfParams {
value: number;

}
export const addRankCfCommand: ICommand<IAddRankCfParams> = {
export const AddRankCfCommand: ICommand<IAddRankCfParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-rank-conditional-rule',
handler(accessor, params) {
Expand All @@ -61,8 +61,6 @@ export const addRankCfCommand: ICommand<IAddRankCfParams> = {
style,
value,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, ITextHighlightCell } from '../../models/type';
import { CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddAverageCfParams {
ranges: IRange[];
Expand All @@ -34,7 +34,7 @@ interface IAddAverageCfParams {
operator: ITextHighlightCell['operator'];
value: ITextHighlightCell['value'];
}
export const addTextCfCommand: ICommand<IAddAverageCfParams> = {
export const AddTextCfCommand: ICommand<IAddAverageCfParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-text-conditional-rule',
handler(accessor, params) {
Expand All @@ -59,8 +59,6 @@ export const addTextCfCommand: ICommand<IAddAverageCfParams> = {
style,
value,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, ITimePeriodHighlightCell } from '../../models/type';
import { CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddTimePeriodCf {
ranges: IRange[];
Expand All @@ -33,7 +33,7 @@ interface IAddTimePeriodCf {
operator: ITimePeriodHighlightCell['operator'];

}
export const addTimePeriodCfCommand: ICommand<IAddTimePeriodCf> = {
export const AddTimePeriodCfCommand: ICommand<IAddTimePeriodCf> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-time-period-conditional-rule',
handler(accessor, params) {
Expand All @@ -57,8 +57,6 @@ export const addTimePeriodCfCommand: ICommand<IAddTimePeriodCf> = {
operator,
style,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ import {
import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule, IHighlightCell } from '../../models/type';
import { CFRuleType, CFSubRuleType } from '../../base/const';
import type { IAddConditionalRuleMutationParams } from '../mutations/addConditionalRule.mutation';
import { addConditionalRuleMutation } from '../mutations/addConditionalRule.mutation';
import type { IAddConditionalRuleMutationParams } from '../mutations/add-conditional-rule.mutation';
import { AddConditionalRuleMutation } from '../mutations/add-conditional-rule.mutation';

interface IAddUniqueValuesConditionalRuleParams {
ranges: IRange[];
stopIfTrue?: boolean;
style: IHighlightCell['style'];
}
export const addUniqueValuesCfCommand: ICommand<IAddUniqueValuesConditionalRuleParams> = {
export const AddUniqueValuesCfCommand: ICommand<IAddUniqueValuesConditionalRuleParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.add-uniqueValues-conditional-rule',
handler(accessor, params) {
Expand All @@ -54,8 +54,6 @@ export const addUniqueValuesCfCommand: ICommand<IAddUniqueValuesConditionalRuleP
subType: CFSubRuleType.uniqueValues,
style,
} };
commandService.executeCommand(addConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);

return true;
return commandService.executeCommand(AddConditionalRuleMutation.id, { unitId, subUnitId, rule } as IAddConditionalRuleMutationParams);
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,17 @@ import { createTopMatrixFromMatrix, findAllRectangle, SelectionManagerService }

import { ConditionalFormatRuleModel } from '../../models/conditional-format-rule-model';
import type { IConditionFormatRule } from '../../models/type';
import type { ISetConditionalRuleMutationParams } from '../mutations/setConditionalRule.mutation';
import { setConditionalRuleMutation, setConditionalRuleMutationUndoFactory } from '../mutations/setConditionalRule.mutation';
import type { IDeleteConditionalRuleMutationParams } from '../mutations/deleteConditionalRule.mutation';
import { deleteConditionalRuleMutation, deleteConditionalRuleMutationUndoFactory } from '../mutations/deleteConditionalRule.mutation';
import type { ISetConditionalRuleMutationParams } from '../mutations/set-conditional-rule.mutation';
import { SetConditionalRuleMutation, setConditionalRuleMutationUndoFactory } from '../mutations/set-conditional-rule.mutation';
import type { IDeleteConditionalRuleMutationParams } from '../mutations/delete-conditional-rule.mutation';
import { DeleteConditionalRuleMutation, DeleteConditionalRuleMutationUndoFactory } from '../mutations/delete-conditional-rule.mutation';

export interface IClearRangeCfParams {
ranges?: IRange[];
unitId?: string;
subUnitId?: string;
}
export const clearRangeCfCommand: ICommand<IClearRangeCfParams> = {
export const ClearRangeCfCommand: ICommand<IClearRangeCfParams> = {
type: CommandType.COMMAND,
id: 'sheet.command.clear-range-conditional-rule',
handler(accessor, params) {
Expand Down Expand Up @@ -82,12 +82,12 @@ export const clearRangeCfCommand: ICommand<IClearRangeCfParams> = {
const rule: IConditionFormatRule = { ...oldRule, ranges: newRanges };
const params = { unitId, subUnitId, rule } as ISetConditionalRuleMutationParams;
const undo = setConditionalRuleMutationUndoFactory(accessor, params);
redos.push({ id: setConditionalRuleMutation.id, params });
redos.push({ id: SetConditionalRuleMutation.id, params });
undos.push(...undo);
} else {
const params = { unitId, subUnitId, cfId: oldRule.cfId } as IDeleteConditionalRuleMutationParams;
const undo = deleteConditionalRuleMutationUndoFactory(accessor, params);
redos.push({ id: deleteConditionalRuleMutation.id, params });
const undo = DeleteConditionalRuleMutationUndoFactory(accessor, params);
redos.push({ id: DeleteConditionalRuleMutation.id, params });
undos.push(...undo);
}
});
Expand All @@ -100,6 +100,6 @@ export const clearRangeCfCommand: ICommand<IClearRangeCfParams> = {
undoMutations: undos,
});
}
return true;
return result;
},
};
Loading

0 comments on commit a1064e1

Please sign in to comment.