Skip to content

Commit

Permalink
feat: custom pages setup - change label support
Browse files Browse the repository at this point in the history
  • Loading branch information
olzzon authored and olzzon committed Oct 21, 2020
1 parent 329014a commit 93b8451
Showing 1 changed file with 37 additions and 10 deletions.
47 changes: 37 additions & 10 deletions client/components/PagesSettings.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react'
import React, { ChangeEvent } from 'react'
//@ts-ignore
import * as ClassNames from 'classnames'

Expand All @@ -9,7 +9,10 @@ import { storeShowPagesSetup } from '../../server/reducers/settingsActions'
import { IFader } from '../../server/reducers/fadersReducer'
import Select from 'react-select'
import { ICustomPages } from '..'
import { SOCKET_GET_PAGES_LIST, SOCKET_SET_PAGES_LIST } from '../../server/constants/SOCKET_IO_DISPATCHERS'
import {
SOCKET_GET_PAGES_LIST,
SOCKET_SET_PAGES_LIST,
} from '../../server/constants/SOCKET_IO_DISPATCHERS'

interface IPagesSettingsInjectProps {
fader: IFader[]
Expand All @@ -19,7 +22,7 @@ class PagesSettings extends React.PureComponent<
IPagesSettingsInjectProps & Store
> {
pageList: { label: string; value: number }[]
state = { pageIndex: 0}
state = { pageIndex: 0, label: window.customPagesList[0].label }

constructor(props: any) {
super(props)
Expand All @@ -32,7 +35,10 @@ class PagesSettings extends React.PureComponent<
}

handleSelectPage(event: any) {
this.setState({pageIndex: event.value})
this.setState({ pageIndex: event.value })
this.setState({
label: window.customPagesList[event.value].label,
})
console.log('PAGE SELECTED', this.state.pageIndex)
}

Expand Down Expand Up @@ -66,13 +72,22 @@ class PagesSettings extends React.PureComponent<
)
) {
window.customPagesList[this.state.pageIndex].faders.push(fader)
window.customPagesList[this.state.pageIndex].faders.sort((a, b) => {
return a - b
})
window.customPagesList[this.state.pageIndex].faders.sort(
(a, b) => {
return a - b
}
)
}
}
}

handleLabel = (event: ChangeEvent<HTMLInputElement>) => {
this.setState({ label: event.target.value })
this.pageList[this.state.pageIndex].label =
window.customPagesList[this.state.pageIndex].label
window.customPagesList[this.state.pageIndex].label = event.target.value
}

handleClearRouting() {
if (window.confirm('REMOVE ALL FADER ASSIGNMENTS????')) {
window.customPagesList[this.state.pageIndex].faders = []
Expand All @@ -85,7 +100,10 @@ class PagesSettings extends React.PureComponent<
}

handleSave = () => {
window.socketIoClient.emit(SOCKET_SET_PAGES_LIST, window.customPagesList)
window.socketIoClient.emit(
SOCKET_SET_PAGES_LIST,
window.customPagesList
)
this.props.dispatch(storeShowPagesSetup())
}

Expand Down Expand Up @@ -149,15 +167,24 @@ class PagesSettings extends React.PureComponent<
<Select
value={{
label:
window.customPagesList[this.state.pageIndex].label ||
window.customPagesList[this.state.pageIndex]
.label ||
'Page : ' + (this.state.pageIndex + 1),
value: this.state.pageIndex,
}}
onChange={(event: any) => this.handleSelectPage(event)}
options={this.pageList}
/>
<label className="settings-input-field">
LABEL :
<input
name="label"
type="text"
value={this.state.label}
onChange={(event) => this.handleLabel(event)}
/>
</label>
{this.renderFaderList()}

</div>
)
}
Expand Down

0 comments on commit 93b8451

Please sign in to comment.