Skip to content

Commit

Permalink
fix: Changing page label input
Browse files Browse the repository at this point in the history
  • Loading branch information
TimSusa committed May 11, 2019
1 parent 22bbc3f commit 2b85771
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { STRIP_TYPE } from '../../reducers/slider-list'
const { BUTTON, BUTTON_TOGGLE, PAGE } = STRIP_TYPE

MidiSettings.propTypes = {
isSettingsMode: PropTypes.bool,
actions: PropTypes.object,
idx: PropTypes.number,
inputs: PropTypes.object,
Expand All @@ -36,6 +37,7 @@ MidiSettings.propTypes = {
function MidiSettings(props) {
const classes = makeStyles(styles, { withTheme: true })()
const {
isSettingsMode,
actions,
inputs = {},
outputs = {},
Expand All @@ -54,12 +56,12 @@ function MidiSettings(props) {
<MidiSettingsLabelInput
classes={classes}
idx={idx}
label={label}
label={(type === undefined) ? pageTarget.label : label}
i={i}
actions={actions}
type={type}
/>
{type === undefined && (
{(type === undefined && isSettingsMode) && (
<DriverExpansionPanel label='View' isEmpty={false}>
<MidiSettingsView
pageTarget={pageTarget}
Expand Down Expand Up @@ -258,11 +260,12 @@ function mapDispatchToProps(dispatch) {
}

function mapStateToProps({
viewSettings: { pageTargets, lastFocusedPage, availableDrivers: { inputs = {}, outputs = {} } = {} },
viewSettings: { isSettingsMode, pageTargets, lastFocusedPage, availableDrivers: { inputs = {}, outputs = {} } = {} },
sliders: { sliderList }
}) {
const pageTarget = pageTargets.find(item => item.id === lastFocusedPage)
return {
isSettingsMode,
sliderList,
pageTarget,
inputs,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,8 @@ function handleLabelChange(i, idx, actions, type, e) {
idx,
val: e.target.value
})
if (type === 'PAGE') {
actions.changeFooterPage({
i,
if (type === undefined) {
actions.setPageTargetSettings({
label: e.target.value
})
}
Expand Down
8 changes: 7 additions & 1 deletion packages/midi-bricks/src/reducers/view-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export const reducers = {
},

[ActionTypeViewSettings.SET_PAGE_TARGET_SETTINGS](state = initState, action) {
const { color, colorFont } = action.payload
const { color, colorFont, label } = action.payload
let newPageTargets = state.pageTargets
const idx = newPageTargets.findIndex(
(item) => item.id === state.lastFocusedPage
Expand All @@ -355,6 +355,12 @@ export const reducers = {
}
}
}
if (label) {
newPageTargets[idx] = {
...newPageTargets[idx],
label
}
}
return { ...state, pageTargets: newPageTargets }
},

Expand Down

0 comments on commit 2b85771

Please sign in to comment.