Skip to content

Commit

Permalink
added user preference editor vs json mode
Browse files Browse the repository at this point in the history
  • Loading branch information
justenPalmer committed Apr 28, 2020
1 parent 850ef6b commit 247a4d3
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 24 deletions.
4 changes: 4 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ label .badge{position:relative;top:2px;}

.field-border-bottom{border-bottom:1px solid #BDBDBD;}
.focus .field-border-bottom{border-bottom:1px solid #0687D1;}
.focus-layer-features{font-size:0.65rem;}

.flex-2{flex:2;}

Expand Down Expand Up @@ -293,6 +294,9 @@ label .badge{position:relative;top:2px;}
.row-icon-right{position:absolute;right:0.25rem;top:0;}
.row-icon-right-second{right:1.3rem;}

.search-option{color:#EDEFF1;padding:2px 2px 1px 2px;cursor:pointer;}
.search-option:hover{color:#FFF;}

.swatch{width:22px;height:22px;cursor:pointer;}
.swatch:hover{border:1px solid #AEAEAE;}
.swatch-flex{flex:1;height:18px;border:1px solid transparent;}
Expand Down
2 changes: 2 additions & 0 deletions src/Store.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { applyMiddleware, combineReducers, createStore } from 'redux'

import {reducer as app} from './model/app/reducer'
import {reducer as map} from './model/map/reducer'
import {reducer as preference} from './model/preference/reducer'
import {reducer as source} from './model/source/reducer'
import {reducer as style} from './model/style/reducer'

export const reducers = combineReducers({
app,
map,
preference,
source,
style,
})
Expand Down
30 changes: 16 additions & 14 deletions src/component/Home/HomeStyles.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,26 +43,28 @@ class HomeStyles extends React.Component {
const {styles} = this.props,
{search, searchShow} = this.state

const handle = {
change: this.handleSearchChange
}

return (
<div className="content-body content-body-flex">
<div className="content-body-left">
{searchShow ?
<div className="d-flex">
<div className="d-flex p-1">
<div className="property flex-fill">
<Field field={{
type:'string',
name:'search',
value: search,
placeholder:'Search for style',
controlled:false,
inputClass:'form-control-sm font-sm',
inputNoAC:true,
autoFocus:true
}} key="type" handle={{
change:this.handleSearchChange
}}/>
<Field
autoFocus={true}
handle={handle}
name={'search'}
placeholder={'Search for style'}
inputClass={'form-control-sm font-sm'}
inputNoAC={true}
type={'string'}
value={search}
/>
</div>
<div className="content-title-option" onClick={()=>this.handleSearchShowSet({show:false})}>
<div className="search-option" onClick={()=>this.handleSearchShowSet({show:false})}>
<Icon icon={'close'}/>
</div>
</div>
Expand Down
9 changes: 9 additions & 0 deletions src/component/LayerEdit/LayerEditJson.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,18 @@ import {withRouter} from 'react-router-dom'
import Field from '../Field'

import modelStyle from '../../model/style'
import modelPreference from '../../model/preference'

class LayerEditJson extends React.Component {

componentDidMount (){
// set user preference to json
modelPreference.actions.setIn({
path: ['editMode'],
value: 'json',
})
}

handleChange = async ({value})=>{
const {history, path, layer} = this.props,
{pathname} = this.props.location
Expand Down
9 changes: 9 additions & 0 deletions src/component/LayerEdit/LayerEditView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,17 @@ import React from 'react'
import PropTypes from 'prop-types'

import LayerEditGroup from './LayerEditGroup'
import modelPreference from '../../model/preference'

class LayerEditView extends React.Component {

componentDidMount (){
// set user preference to json
modelPreference.actions.setIn({
path: ['editMode'],
value: 'editor',
})
}

render (){
const {error, layer, path, style} = this.props
Expand Down
15 changes: 13 additions & 2 deletions src/component/LayerEdit/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import LayerEditJson from './LayerEditJson'
import LayerEditView from './LayerEditView'
import Tooltip from '../Tooltip'
import modelMap from '../../model/map'
import modelPreference from '../../model/preference'
import modelStyle from '../../model/style'

class LayerEdit extends React.Component {
Expand All @@ -30,9 +31,17 @@ class LayerEdit extends React.Component {
}

renderSection (){
const {focusFeatures, error, match, layer, path, style} = this.props
const {editMode, focusFeatures, error, match, layer, path, style} = this.props

let redirect
if (focusFeatures.length > 0){
redirect = `${match.url}/features`
} else if (editMode === 'json'){
redirect = `${match.url}/json`
} else {
redirect = `${match.url}/editor`
}

const redirect = (focusFeatures.length > 0)? `${match.url}/features` :`${match.url}/editor`
return (
<Switch>
<Route path={`${match.url}/actions`}
Expand Down Expand Up @@ -126,6 +135,7 @@ class LayerEdit extends React.Component {
*/

LayerEdit.propTypes = {
editMode: PropTypes.string,
error: PropTypes.object, // map
layer: PropTypes.object,
layerId: PropTypes.string,
Expand All @@ -138,6 +148,7 @@ LayerEdit.propTypes = {
const mapStateToProps = (state, props) => {
const {layerId} = props
return {
editMode: modelPreference.selectors.getIn(state, {path:['editMode']}),
focusFeatures: modelMap.selectors.focusFeaturesByLayerId(state, {layerId}),
layer: modelStyle.selectors.getIn(state, {path: props.path}),
}
Expand Down
7 changes: 4 additions & 3 deletions src/component/Map/MapMapbox.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ class MapMapbox extends React.Component {

buildMap (){
const {accessTokens, style} = this.props
if (!style) return <div/>

if (this.map){
// tear down map
Expand Down Expand Up @@ -386,10 +387,10 @@ MapMapbox.propTypes = {
const mapStoreToProps = (store, props)=>{
const {style} = props
return {
accessTokens: modelStyle.selectors.accessTokens(store, {styleId: style.get('id')}),
accessTokens: modelStyle.selectors.accessTokens(store, {styleId: style && style.get('id')}),
accessTokenDeploy: modelMap.selectors.accessTokenDeploy(store),
domainHeaders: modelStyle.selectors.domainHeaders(store, {styleId: style.get('id')}),
featureStates: modelStyle.selectors.featureStates(store, {styleId: style.get('id')}),
domainHeaders: modelStyle.selectors.domainHeaders(store, {styleId: style && style.get('id')}),
featureStates: modelStyle.selectors.featureStates(store, {styleId: style && style.get('id')}),
featureStateDeploy: modelMap.selectors.featureStateDeploy(store),
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/component/Page/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import Nav from './Nav'
import Route from './Route'

import modelApp from '../../model/app'
import modelPreference from '../../model/preference'
import modelSource from '../../model/source'
import modelStyle from '../../model/style'

Expand All @@ -17,6 +18,7 @@ class Page extends React.Component {
async componentDidMount(){
try{
await modelApp.actions.setLoading(true)
await modelPreference.actions.init()
await modelStyle.actions.init()
await modelSource.actions.init()
await modelApp.actions.setLoading(false)
Expand Down
4 changes: 2 additions & 2 deletions src/component/Style/StyleLayers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ class StyleLayers extends React.Component {
value={search}
/>
</div>
<div className="content-title-option" onClick={()=>this.handleSearchShowSet({show:false})}>
<div className="search-option" onClick={()=>this.handleSearchShowSet({show:false})}>
<Icon icon={'close'}/>
</div>
</div>
Expand Down Expand Up @@ -200,7 +200,7 @@ class StyleLayers extends React.Component {
return (
<div className="row-icon-right">
<Icon className="md-shadow text-info" icon={'map-focus'} weight={'solid'}/>
<b className="text-info">{focusLayers[layerId]}</b>
<b className="text-info focus-layer-features">{focusLayers[layerId]}</b>
</div>
)
}
Expand Down
2 changes: 1 addition & 1 deletion src/component/Style/StyleSources.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class StyleSources extends React.Component {
value={search}
/>
</div>
<div className="content-title-option" onClick={()=>this.handleSearchShowSet({show:false})}>
<div className="search-option" onClick={()=>this.handleSearchShowSet({show:false})}>
<Icon icon={'close'}/>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/component/Style/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class Style extends React.Component {
<Tooltip message={'sources'}/>
</NavLink>
<NavLink className={`content-title-option interactive tooltip-trigger ${error && error.hasIn(['current','layers'])? 'error': ''}`} to={`${match.url}/layers`}>
{focusLayers && focusLayers.length > 0 && (
{focusLayers && Object.keys(focusLayers).length > 0 && (
<Icon className="text-info content-title-option-super" icon={'map-focus'} weight={'solid'}/>
)}
<Icon icon={'layer'}/>
Expand Down
2 changes: 1 addition & 1 deletion src/model/style/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export const reducer = (st = state, action)=>{
})
}
case 'STYLE_REMOVEIN':{
const {path, value} = action.payload
const {path} = action.payload
const styles = st.styles.removeIn(path)

if (path.length < 3){ // changed whole style, no updated needed
Expand Down

0 comments on commit 247a4d3

Please sign in to comment.