A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/markerikson/project-minimek/commit/d5da05b7951b9d1e50275f4b25d540d13699c93a below:

Only stop editing if the current pilot is deleted · markerikson/project-minimek@d5da05b · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+25

-2

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+25

-2

lines changed Original file line number Diff line number Diff line change

@@ -59,10 +59,17 @@ const PilotsListRow = ({pilot={}, onPilotClicked=_.noop, selected, deleteEntity}

59 59

mechType = "",

60 60

} = pilot;

61 61 62 -

const onDeleteClicked = () => deleteEntity("Pilot", id);

62 +

const onDeleteClicked = (e) => {

63 +

e.stopPropagation();

64 +

e.preventDefault();

65 +

deleteEntity("Pilot", id);

66 +

}

67 + 68 +

const onRowClicked = () => onPilotClicked(id);

69 + 63 70 64 71

return (

65 -

<Table.Row onClick={() => onPilotClicked(id)} active={selected}>

72 +

<Table.Row onClick={onRowClicked} active={selected}>

66 73

<Table.Cell>

67 74

{name}

68 75

</Table.Cell>

Original file line number Diff line number Diff line change

@@ -6,6 +6,10 @@ import {

6 6

PILOT_EDIT_STOP,

7 7

} from "./pilotsConstants";

8 8 9 +

import {

10 +

ENTITY_DELETE,

11 +

} from "features/entities/entityConstants";

12 + 9 13

const initialState = {

10 14

currentPilot : null,

11 15

isEditing : false,

@@ -41,9 +45,21 @@ export function stopEditingPilot(state, payload) {

41 45

};

42 46

}

43 47 48 +

export function stopEditingIfDeleted(state, payload) {

49 +

const {itemType, itemID} = payload;

50 +

const {isEditing, currentPilot} = state;

51 + 52 +

if(isEditing && itemType === "Pilot" && itemID === currentPilot) {

53 +

return stopEditingPilot(state, payload);

54 +

}

55 + 56 +

return state;

57 +

}

58 + 44 59 45 60

export default createReducer(initialState, {

46 61

[PILOT_SELECT] : selectPilot,

47 62

[PILOT_EDIT_START] : startEditingPilot,

48 63

[PILOT_EDIT_STOP] : stopEditingPilot,

64 +

[ENTITY_DELETE] : stopEditingIfDeleted,

49 65

});

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4