Switch to JSON in URL for copy
In preparation for multi-attribute copy.
This commit is contained in:
parent
4105ad93a8
commit
00687dbaed
@ -118,16 +118,22 @@ class App extends React.Component {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Colour building
|
||||||
|
*
|
||||||
|
* Used in multi-edit mode to colour buildings on map click
|
||||||
|
*
|
||||||
|
* Pulls data from URL to form update
|
||||||
|
*
|
||||||
|
* @param {object} building
|
||||||
|
*/
|
||||||
colourBuilding(building) {
|
colourBuilding(building) {
|
||||||
const cat = parseCategoryURL(window.location.pathname);
|
const cat = parseCategoryURL(window.location.pathname);
|
||||||
const q = parse(window.location.search);
|
const q = parse(window.location.search);
|
||||||
let data;
|
const data = (cat === 'like')? {like: true}: JSON.parse(q.data);
|
||||||
if (cat === 'like'){
|
if (cat === 'like'){
|
||||||
data = {like: true}
|
|
||||||
this.likeBuilding(building.building_id)
|
this.likeBuilding(building.building_id)
|
||||||
} else {
|
} else {
|
||||||
data = {}
|
|
||||||
data[q.k] = q.v;
|
|
||||||
this.updateBuilding(building.building_id, data)
|
this.updateBuilding(building.building_id, data)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -564,21 +564,26 @@ LikeButton.propTypes = {
|
|||||||
handleLike: PropTypes.func
|
handleLike: PropTypes.func
|
||||||
}
|
}
|
||||||
|
|
||||||
const Label = (props) => (
|
const Label = (props) => {
|
||||||
|
const data = {};
|
||||||
|
data[props.slug] = props.value;
|
||||||
|
const data_string = JSON.stringify(data);
|
||||||
|
return (
|
||||||
<label htmlFor={props.slug}>
|
<label htmlFor={props.slug}>
|
||||||
{props.title}
|
{props.title}
|
||||||
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
||||||
{ (props.cat && props.slug && !props.disabled)?
|
{ (props.cat && props.slug && !props.disabled)?
|
||||||
<div className="icon-buttons">
|
<div className="icon-buttons">
|
||||||
<NavLink
|
<NavLink
|
||||||
to={`/multi-edit/${props.cat}.html?k=${props.slug}&v=${props.value}`}
|
to={`/multi-edit/${props.cat}.html?data=${data_string}`}
|
||||||
className="icon-button copy">
|
className="icon-button copy">
|
||||||
Copy
|
Copy
|
||||||
</NavLink>
|
</NavLink>
|
||||||
</div> : null
|
</div> : null
|
||||||
}
|
}
|
||||||
</label>
|
</label>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Label.propTypes = {
|
Label.propTypes = {
|
||||||
slug: PropTypes.string,
|
slug: PropTypes.string,
|
||||||
|
@ -135,7 +135,11 @@ DataSection.propTypes = {
|
|||||||
children: PropTypes.node
|
children: PropTypes.node
|
||||||
}
|
}
|
||||||
|
|
||||||
const DataEntry = (props) => (
|
const DataEntry = (props) => {
|
||||||
|
const data = {};
|
||||||
|
data[props.slug] = props.value;
|
||||||
|
const data_string = JSON.stringify(data);
|
||||||
|
return (
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<dt>
|
<dt>
|
||||||
{ props.title }
|
{ props.title }
|
||||||
@ -143,7 +147,7 @@ const DataEntry = (props) => (
|
|||||||
{ (props.cat && props.slug && !props.disabled)?
|
{ (props.cat && props.slug && !props.disabled)?
|
||||||
<div className="icon-buttons">
|
<div className="icon-buttons">
|
||||||
<NavLink
|
<NavLink
|
||||||
to={`/multi-edit/${props.cat}.html?k=${props.slug}&v=${props.value}`}
|
to={`/multi-edit/${props.cat}.html?data=${data_string}`}
|
||||||
className="icon-button copy">
|
className="icon-button copy">
|
||||||
Copy
|
Copy
|
||||||
</NavLink>
|
</NavLink>
|
||||||
@ -158,7 +162,8 @@ const DataEntry = (props) => (
|
|||||||
: props.value
|
: props.value
|
||||||
: '\u00A0'}</dd>
|
: '\u00A0'}</dd>
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
DataEntry.propTypes = {
|
DataEntry.propTypes = {
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
@ -169,14 +174,16 @@ DataEntry.propTypes = {
|
|||||||
value: PropTypes.any
|
value: PropTypes.any
|
||||||
}
|
}
|
||||||
|
|
||||||
const LikeDataEntry = (props) => (
|
const LikeDataEntry = (props) => {
|
||||||
|
const data_string = JSON.stringify({like: true});
|
||||||
|
(
|
||||||
<Fragment>
|
<Fragment>
|
||||||
<dt>
|
<dt>
|
||||||
{ props.title }
|
{ props.title }
|
||||||
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
{ props.tooltip? <Tooltip text={ props.tooltip } /> : null }
|
||||||
<div className="icon-buttons">
|
<div className="icon-buttons">
|
||||||
<NavLink
|
<NavLink
|
||||||
to={`/multi-edit/${props.cat}.html?k=like&v=${true}`}
|
to={`/multi-edit/${props.cat}.html?data=${data_string}`}
|
||||||
className="icon-button copy">
|
className="icon-button copy">
|
||||||
Copy
|
Copy
|
||||||
</NavLink>
|
</NavLink>
|
||||||
@ -195,7 +202,8 @@ const LikeDataEntry = (props) => (
|
|||||||
(props.user_building_like)? <dd>…including you!</dd> : null
|
(props.user_building_like)? <dd>…including you!</dd> : null
|
||||||
}
|
}
|
||||||
</Fragment>
|
</Fragment>
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
LikeDataEntry.propTypes = {
|
LikeDataEntry.propTypes = {
|
||||||
title: PropTypes.string,
|
title: PropTypes.string,
|
||||||
|
@ -34,7 +34,7 @@ const MultiEdit = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const q = parse(props.location.search);
|
const q = parse(props.location.search);
|
||||||
const label = fieldTitleFromSlug(q.k);
|
const data = JSON.parse(q.data)
|
||||||
const title = sectionTitleFromCat(cat);
|
const title = sectionTitleFromCat(cat);
|
||||||
return (
|
return (
|
||||||
<Sidebar
|
<Sidebar
|
||||||
@ -44,7 +44,14 @@ const MultiEdit = (props) => {
|
|||||||
<header className={`section-header view ${cat} active`}>
|
<header className={`section-header view ${cat} active`}>
|
||||||
<a><h3 className="h3">{title}</h3></a>
|
<a><h3 className="h3">{title}</h3></a>
|
||||||
</header>
|
</header>
|
||||||
<p class='data-intro'>Set <strong>{label}</strong> to <strong>{q.v}</strong></p>
|
{
|
||||||
|
Object.keys(data).map((key => {
|
||||||
|
const label = fieldTitleFromSlug(key);
|
||||||
|
return (<p className='data-intro' key={key}>
|
||||||
|
Set <strong>{label}</strong> to <strong>{data[key]}</strong>
|
||||||
|
</p>)
|
||||||
|
}))
|
||||||
|
}
|
||||||
<form className='buttons-container'>
|
<form className='buttons-container'>
|
||||||
<InfoBox msg='Click buildings to colour' />
|
<InfoBox msg='Click buildings to colour' />
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user