ui functional, filters all added

pull/32/head
unknown 2018-11-19 18:28:15 -05:00
parent 7a9900d8ae
commit 793e6db286
5 changed files with 31 additions and 9 deletions

View File

@ -8,6 +8,7 @@ const ACTIONS = {
edit_url: 'edit_url', edit_url: 'edit_url',
delete_url: 'delete_url', delete_url: 'delete_url',
list_url: 'list_url', list_url: 'list_url',
set_editing: 'set_editing',
error: 'error' error: 'error'
} }
@ -28,6 +29,11 @@ export const addUrl = url => ({
data: url data: url
}) })
export const setEditing = id => ({
type: ACTIONS.set_editing,
data: id
})
export const changeUrlField = (id, what, value) => ({ export const changeUrlField = (id, what, value) => ({
type: ACTIONS.edit_url, type: ACTIONS.edit_url,
data: { data: {

View File

@ -4,7 +4,7 @@ import React from 'react'
import IconButton from '../components/IconButton' import IconButton from '../components/IconButton'
import UnderlineInput from '../components/UnderlineInput' import UnderlineInput from '../components/UnderlineInput'
import '../../styles/shared/urilistitem.scss' import '../../styles/shared/urilistitem.scss'
import { changeUrlField, setUrl, removeUrl } from '../actions/targets' import { changeUrlField, setUrl, removeUrl, setEditing } from '../actions/targets'
const uriRegex = /(.+:\/\/)?(.+\.)*(.+\.).{1,}(:\d+)?(.+)?/i const uriRegex = /(.+:\/\/)?(.+\.)*(.+\.).{1,}(:\d+)?(.+)?/i
const isbnRegex = /^(97(8|9))?\d{9}(\d|X)$/ const isbnRegex = /^(97(8|9))?\d{9}(\d|X)$/
@ -14,17 +14,23 @@ class UriListItem extends React.Component {
super() super()
this.getView = this.getView.bind(this) this.getView = this.getView.bind(this)
this.getEditing = this.getEditing.bind(this) this.getEditing = this.getEditing.bind(this)
this.cancelEvent = this.cancelEvent.bind(this)
}
cancelEvent (e, id) {
e.stopPropagation()
if (id === false) return
this.props.dispatch(setEditing(id))
} }
getView () { getView () {
return ( return (
<li className='uri-list-item flex-container'> <li className='uri-list-item flex-container' onClick={(e) => this.cancelEvent(e, this.props.item.id)}>
<div className='stack flex flex-container flex-vertical'> <div className='stack flex flex-container flex-vertical'>
<span className='label'>Destination URL</span> <span className='label'>Destination URL</span>
<span className='value'>{this.props.item.url}</span> <span className='value'>{this.props.item.url}</span>
</div> </div>
<div className='stack flex flex-container flex-vertical'> <div className='stack flex flex-container flex-vertical'>
<span className='label'>Filters</span> <span className='label'>Filters</span>
<span className='value'>{this.props.item.url}</span> <span className='value'>{['publisher', 'title', 'author', 'isbn'].reduce((a, x) => a + (this.props.item[x] ? 1 : 0), 0) || 'None'}</span>
</div> </div>
<IconButton icon='delete' onClick={() => this.props.dispatch(removeUrl(this.props.item.id))} /> <IconButton icon='delete' onClick={() => this.props.dispatch(removeUrl(this.props.item.id))} />
</li> </li>
@ -32,9 +38,9 @@ class UriListItem extends React.Component {
} }
getEditing () { getEditing () {
return ( return (
<li className='uri-list-item flex-container flex-vertical editing'> <li className='uri-list-item flex-container flex-vertical editing' onClick={(e) => this.cancelEvent(e, false)}>
<header className='flex-container'> <header className='flex-container' onClick={(e) => this.cancelEvent(e, null)}>
<h3 className='flex'>Editing: {this.props.url}</h3> <h3 className='flex'>Editing: {this.props.item.url}</h3>
<IconButton icon='delete' onClick={() => this.props.dispatch(removeUrl(this.props.item.id))} /> <IconButton icon='delete' onClick={() => this.props.dispatch(removeUrl(this.props.item.id))} />
</header> </header>
<div className='settings'> <div className='settings'>
@ -45,7 +51,7 @@ class UriListItem extends React.Component {
placeholder='Destination URL' placeholder='Destination URL'
value={'' + this.props.item.url} value={'' + this.props.item.url}
pattern={uriRegex} pattern={uriRegex}
onChange={(e) => this.props.dispatch(changeUrlField(this.props.item.id, 'uri', e.target.value))} onChange={(e) => this.props.dispatch(changeUrlField(this.props.item.id, 'url', e.target.value))}
onBlur={(e) => this.props.dispatch(setUrl(this.props.item))} /> onBlur={(e) => this.props.dispatch(setUrl(this.props.item))} />
<h4>Filters</h4> <h4>Filters</h4>
<UnderlineInput <UnderlineInput

View File

@ -30,6 +30,10 @@ const reducer = (state = {}, action) => {
return { return {
urls: urls urls: urls
} }
case Actions.set_editing:
return {
editingUrl: data
}
case Actions.error: case Actions.error:
return { return {
error: data.message error: data.message

View File

@ -5,7 +5,7 @@ import ReactDOM from 'react-dom'
import Progress from './components/Progress' import Progress from './components/Progress'
import UriListItem from './containers/UriListItem' import UriListItem from './containers/UriListItem'
import reducer from './reducers/targets' import reducer from './reducers/targets'
import { fetchUrls, createNewUrl } from './actions/targets' import { fetchUrls, createNewUrl, setEditing } from './actions/targets'
import '../styles/targets.scss' import '../styles/targets.scss'
class App extends React.Component { class App extends React.Component {
@ -72,7 +72,7 @@ class App extends React.Component {
} }
render () { render () {
return ( return (
<div className='root-container flex-container'> <div className='root-container flex-container' onClick={() => this.dispatch(setEditing(null))}>
<aside className='nav nav-left'> <aside className='nav nav-left'>
<header> <header>
<h1>RoE</h1> <h1>RoE</h1>

View File

@ -6,6 +6,10 @@
background: white; background: white;
box-shadow: $shadow-0; box-shadow: $shadow-0;
padding: 0 0 0 14px; padding: 0 0 0 14px;
cursor: pointer;
transition: margin 0.15s $transition,
padding 0.15s $transition,
border-radius 0.15s $transition;
.button.icon { .button.icon {
margin: 7px 5px 3px 5px; margin: 7px 5px 3px 5px;
@ -16,12 +20,14 @@
line-height: initial; line-height: initial;
padding: 10px 0 10px 14px; padding: 10px 0 10px 14px;
border-radius: 3px; border-radius: 3px;
cursor: default;
header { header {
h3 { h3 {
display: inline-block; display: inline-block;
margin: 10px 0 0 0; margin: 10px 0 0 0;
font-weight: normal; font-weight: normal;
cursor: pointer;
} }
} }
.settings { .settings {