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/b08a2482bb2b6b990582d2bd939a901c88b185f6 below:

Update unit info form to display current Unit details · markerikson/project-minimek@b08a248 · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+33

-6

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+33

-6

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

@@ -13,7 +13,7 @@ import ColorPickerButton from "common/components/ColorPicker/ColorPickerButton";

13 13 14 14

import {getEntitiesSession} from "features/entities/entitySelectors";

15 15 16 -

import {selectUnitInfo} from "../unitInfoSelectors";

16 +

import {selectCurrentUnitInfo} from "../unitInfoSelectors";

17 17

import {updateUnitInfo, setUnitColor} from "../unitInfoActions";

18 18 19 19

@@ -24,7 +24,7 @@ const mapState = (state) => {

24 24 25 25

const factions = Faction.all().toRefArray();

26 26 27 -

const unitInfo = selectUnitInfo(state);

27 +

const unitInfo = selectCurrentUnitInfo(state);

28 28 29 29

return {

30 30

factions,

@@ -59,8 +59,13 @@ class UnitInfoForm extends Component {

59 59 60 60 61 61

render() {

62 -

const {unitInfo, updateUnitInfo, factions} = this.props;

63 -

const {name, affiliation, color} = unitInfo;

62 +

const {unitInfo, factions} = this.props;

63 +

const isDisplayingUnit = Boolean(unitInfo);

64 +

let name = "", affiliation = null, color = null;

65 + 66 +

if(isDisplayingUnit) {

67 +

({name, affiliation, color} = unitInfo);

68 +

}

64 69 65 70

const displayFactions = factions.map(faction => {

66 71

return {

@@ -77,12 +82,13 @@ class UnitInfoForm extends Component {

77 82

<FormEditWrapper

78 83

singleValue={true}

79 84

value={ {name} }

80 -

onChange={updateUnitInfo}

85 +

onChange={this.onNameChanged}

81 86

passIsEditing={false}

82 87

>

83 88

<input

84 89

placeholder="Name"

85 90

name="name"

91 +

disabled={!isDisplayingUnit}

86 92

/>

87 93

</FormEditWrapper>

88 94

</Form.Field>

@@ -94,13 +100,15 @@ class UnitInfoForm extends Component {

94 100

selection

95 101

options={displayFactions}

96 102

value={affiliation}

103 +

disabled={!isDisplayingUnit}

97 104

onChange={this.onAffiliationChanged}

98 105

/>

99 106

</Form.Field>

100 107

<Form.Field name="color">

101 108

<label>Color</label>

102 109

<ColorPickerButton

103 110

value={color}

111 +

disabled={!isDisplayingUnit}

104 112

onClick={this.onColorClicked}

105 113

/>

106 114

</Form.Field>

Original file line number Diff line number Diff line change

@@ -1,2 +1,21 @@

1 +

import {createSelector} from "reselect";

2 +

import {getEntitiesSession} from "features/entities/entitySelectors";

1 3 2 -

export const selectUnitInfo = state => state.unitInfo;

4 +

export const selectUnitInfo = state => state.unitInfo;

5 + 6 + 7 +

export const selectCurrentUnitInfo = createSelector(

8 +

getEntitiesSession,

9 +

(session) => {

10 +

const {Unit} = session;

11 +

const currentUnitModel = Unit.all().first();

12 + 13 +

let currentUnitInfo = null;

14 + 15 +

if(currentUnitModel) {

16 +

currentUnitInfo = currentUnitModel.ref;

17 +

}

18 + 19 +

return currentUnitInfo;

20 +

}

21 +

)

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