Skip to content

Commit

Permalink
Merge pull request #105 from l123wx/place-optional-argument-at-the-end
Browse files Browse the repository at this point in the history
place optional parameters of functions at the end(#104)
  • Loading branch information
1ilit committed May 14, 2024
2 parents 9de091c + a33b68b commit 30886ac
Show file tree
Hide file tree
Showing 14 changed files with 32 additions and 32 deletions.
2 changes: 1 addition & 1 deletion src/components/EditorCanvas/Area.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ function EditPopoverContent({ data }) {
block
onClick={() => {
Toast.success(`Area deleted!`);
deleteArea(data.id, true);
deleteArea(data.id);
}}
>
Delete
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorCanvas/Canvas.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export default function Canvas() {
delete newRelationship.startY;
delete newRelationship.endX;
delete newRelationship.endY;
addRelationship(newRelationship, true);
addRelationship(newRelationship);
};

const handleMouseWheel = (e) => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorCanvas/Note.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default function Note({ data, onMouseDown }) {
block
onClick={() => {
Toast.success(`Note deleted!`);
deleteNote(data.id, true);
deleteNote(data.id);
}}
>
Delete
Expand Down
38 changes: 19 additions & 19 deletions src/components/EditorHeader/ControlPanel.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export default function ControlPanel({
...prev,
{ ...a, x: tables[a.id].x, y: tables[a.id].y },
]);
updateTable(a.id, { x: a.x, y: a.y }, true);
updateTable(a.id, { x: a.x, y: a.y });
} else if (a.element === ObjectType.AREA) {
setRedoStack((prev) => [
...prev,
Expand All @@ -144,15 +144,15 @@ export default function ControlPanel({
}
} else if (a.action === Action.DELETE) {
if (a.element === ObjectType.TABLE) {
addTable(false, a.data);
addTable(a.data, false);
} else if (a.element === ObjectType.RELATIONSHIP) {
addRelationship(a.data, false);
} else if (a.element === ObjectType.NOTE) {
addNote(false, a.data);
addNote(a.data, false);
} else if (a.element === ObjectType.AREA) {
addArea(false, a.data);
addArea(a.data, false);
} else if (a.element === ObjectType.TYPE) {
addType(false, { id: a.id, ...a.data });
addType({ id: a.id, ...a.data }, false);
}
setRedoStack((prev) => [...prev, a]);
} else if (a.action === Action.EDIT) {
Expand Down Expand Up @@ -280,15 +280,15 @@ export default function ControlPanel({
setRedoStack((prev) => prev.filter((e, i) => i !== prev.length - 1));
if (a.action === Action.ADD) {
if (a.element === ObjectType.TABLE) {
addTable(false);
addTable(null, false);
} else if (a.element === ObjectType.AREA) {
addArea(false);
addArea(null, false);
} else if (a.element === ObjectType.NOTE) {
addNote(false);
addNote(null, false);
} else if (a.element === ObjectType.RELATIONSHIP) {
addRelationship(a.data, false);
} else if (a.element === ObjectType.TYPE) {
addType(false);
addType(null, false);
}
setUndoStack((prev) => [...prev, a]);
} else if (a.action === Action.MOVE) {
Expand All @@ -297,7 +297,7 @@ export default function ControlPanel({
...prev,
{ ...a, x: tables[a.id].x, y: tables[a.id].y },
]);
updateTable(a.id, { x: a.x, y: a.y }, true);
updateTable(a.id, { x: a.x, y: a.y });
} else if (a.element === ObjectType.AREA) {
setUndoStack((prev) => [
...prev,
Expand Down Expand Up @@ -560,13 +560,13 @@ export default function ControlPanel({
const del = () => {
switch (selectedElement.element) {
case ObjectType.TABLE:
deleteTable(selectedElement.id, true);
deleteTable(selectedElement.id);
break;
case ObjectType.NOTE:
deleteNote(selectedElement.id, true);
deleteNote(selectedElement.id);
break;
case ObjectType.AREA:
deleteArea(selectedElement.id, true);
deleteArea(selectedElement.id);
break;
default:
break;
Expand All @@ -575,23 +575,23 @@ export default function ControlPanel({
const duplicate = () => {
switch (selectedElement.element) {
case ObjectType.TABLE:
addTable(true, {
addTable({
...tables[selectedElement.id],
x: tables[selectedElement.id].x + 20,
y: tables[selectedElement.id].y + 20,
id: tables.length,
});
break;
case ObjectType.NOTE:
addNote(true, {
addNote({
...notes[selectedElement.id],
x: notes[selectedElement.id].x + 20,
y: notes[selectedElement.id].y + 20,
id: notes.length,
});
break;
case ObjectType.AREA:
addArea(true, {
addArea({
...areas[selectedElement.id],
x: areas[selectedElement.id].x + 20,
y: areas[selectedElement.id].y + 20,
Expand Down Expand Up @@ -639,21 +639,21 @@ export default function ControlPanel({
}
const v = new Validator();
if (v.validate(obj, tableSchema).valid) {
addTable(true, {
addTable({
...obj,
x: obj.x + 20,
y: obj.y + 20,
id: tables.length,
});
} else if (v.validate(obj, areaSchema).valid) {
addArea(true, {
addArea({
...obj,
x: obj.x + 20,
y: obj.y + 20,
id: areas.length,
});
} else if (v.validate(obj, noteSchema)) {
addNote(true, {
addNote({
...obj,
x: obj.x + 20,
y: obj.y + 20,
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/AreasTab/AreaDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function AreaInfo({ data, i }) {
type="danger"
onClick={() => {
Toast.success(`Area deleted!`);
deleteArea(i, true);
deleteArea(i);
}}
/>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/AreasTab/AreasTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function AreasTab() {
<SearchBar />
</Col>
<Col span={8}>
<Button icon={<IconPlus />} block onClick={addArea}>
<Button icon={<IconPlus />} block onClick={() => addArea()}>
Add area
</Button>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/NotesTab/NoteInfo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default function NoteInfo({ data, nid }) {
type="danger"
onClick={() => {
Toast.success(`Note deleted!`);
deleteNote(nid, true);
deleteNote(nid);
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default function RelationshipInfo({ data }) {
icon={<IconDeleteStroked />}
block
type="danger"
onClick={() => deleteRelationship(data.id, true)}
onClick={() => deleteRelationship(data.id)}
>
Delete
</Button>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/TablesTab/TablesTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function TablesTab() {
<SearchBar tables={tables} />
</Col>
<Col span={8}>
<Button icon={<IconPlus />} block onClick={() => addTable(true)}>
<Button icon={<IconPlus />} block onClick={() => addTable()}>
Add table
</Button>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/components/EditorSidePanel/TypesTab/TypesTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function TypesTab() {
<Searchbar />
</Col>
<Col span={8}>
<Button icon={<IconPlus />} block onClick={() => addType(true)}>
<Button icon={<IconPlus />} block onClick={() => addType()}>
Add type
</Button>
</Col>
Expand Down
2 changes: 1 addition & 1 deletion src/context/AreasContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function AreasContextProvider({ children }) {
const { selectedElement, setSelectedElement } = useSelect();
const { setUndoStack, setRedoStack } = useUndoRedo();

const addArea = (addToHistory = true, data) => {
const addArea = (data, addToHistory = true) => {
if (data) {
setAreas((prev) => {
const temp = prev.slice();
Expand Down
2 changes: 1 addition & 1 deletion src/context/NotesContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function NotesContextProvider({ children }) {
const { setUndoStack, setRedoStack } = useUndoRedo();
const { selectedElement, setSelectedElement } = useSelect();

const addNote = (addToHistory = true, data) => {
const addNote = (data, addToHistory = true) => {
if (data) {
setNotes((prev) => {
const temp = prev.slice();
Expand Down
2 changes: 1 addition & 1 deletion src/context/TablesContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function TablesContextProvider({ children }) {
const { setUndoStack, setRedoStack } = useUndoRedo();
const { selectedElement, setSelectedElement } = useSelect();

const addTable = (addToHistory = true, data) => {
const addTable = (data, addToHistory = true) => {
if (data) {
setTables((prev) => {
const temp = prev.slice();
Expand Down
2 changes: 1 addition & 1 deletion src/context/TypesContext.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export default function TypesContextProvider({ children }) {
const [types, setTypes] = useState([]);
const { setUndoStack, setRedoStack } = useUndoRedo();

const addType = (addToHistory = true, data) => {
const addType = (data, addToHistory = true) => {
if (data) {
setTypes((prev) => {
const temp = prev.slice();
Expand Down

0 comments on commit 30886ac

Please sign in to comment.