Merge pull request #531 from orangemug/fix/issue-509

Ability to delete properties completely
This commit is contained in:
Orange Mug 2019-06-21 17:42:09 +01:00 committed by GitHub
commit ff0ece5149
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 829 additions and 2187 deletions

2976
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -35,7 +35,7 @@
"lodash.get": "^4.4.2",
"lodash.isequal": "^4.5.0",
"lodash.throttle": "^4.1.1",
"mapbox-gl": "^0.53.1",
"mapbox-gl": "^1.1.0-beta.1",
"mapbox-gl-inspect": "^1.3.1",
"maputnik-design": "github:maputnik/design",
"ol": "^6.0.0-beta.8",

View file

@ -57,6 +57,10 @@ class ColorField extends React.Component {
}
}
onChange (v) {
this.props.onChange(v === "" ? undefined : v);
}
render() {
const offset = this.calcPickerOffset()
var currentColor = this.color.object()
@ -110,7 +114,7 @@ class ColorField extends React.Component {
name={this.props.name}
placeholder={this.props.default}
value={this.props.value ? this.props.value : ""}
onChange={(e) => this.props.onChange(e.target.value)}
onChange={(e) => this.onChange(e.target.value)}
/>
</div>
}

View file

@ -44,6 +44,10 @@ class AutocompleteInput extends React.Component {
this.calcMaxHeight();
}
onChange (v) {
this.props.onChange(v === "" ? undefined : v);
}
render() {
return <div
ref={(el) => {
@ -68,8 +72,8 @@ class AutocompleteInput extends React.Component {
value={this.props.value}
items={this.props.options}
getItemValue={(item) => item[0]}
onSelect={v => this.props.onChange(v)}
onChange={(e, v) => this.props.onChange(v)}
onSelect={v => this.onChange(v)}
onChange={(e, v) => this.onChange(v)}
shouldItemRender={(item, value="") => {
if (typeof(value) === "string") {
return item[0].toLowerCase().indexOf(value.toLowerCase()) > -1

View file

@ -16,13 +16,25 @@ class FontInput extends React.Component {
}
get values() {
return this.props.value || this.props.default.slice(1) || []
const out = this.props.value || this.props.default.slice(1) || [""];
// Always put a "" in the last field to you can keep adding entries
if (out[out.length-1] !== ""){
return out.concat("");
}
else {
return out;
}
}
changeFont(idx, newValue) {
const changedValues = this.values.slice(0)
changedValues[idx] = newValue
this.props.onChange(changedValues)
const filteredValues = changedValues
.filter(v => v !== undefined)
.filter(v => v !== "")
this.props.onChange(filteredValues);
}
render() {

View file

@ -20,7 +20,7 @@ class InputBlock extends React.Component {
onChange(e) {
const value = e.target.value
return this.props.onChange(value === "" ? null: value)
return this.props.onChange(value === "" ? undefined : value)
}
render() {

View file

@ -31,7 +31,11 @@ export function changeProperty(layer, group, property, newValue) {
if(newValue === undefined) {
if(group) {
const newLayer = {
...layer
...layer,
// Change object so the diff works in ./src/components/map/MapboxGlMap.jsx
[group]: {
...layer[group]
}
};
delete newLayer[group][property];