Skip to content

Commit

Permalink
Merge pull request #532 from substance/fix-entity-editing
Browse files Browse the repository at this point in the history
Fix broken entity editing.
  • Loading branch information
Michael Aufreiter authored May 24, 2018
2 parents 45c2e8e + 8a3f9f4 commit 8d259bd
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/DesktopAppChrome.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class DesktopAppChrome extends AppChrome {
}

_archiveChanged() {
if (!this.state.archive) return
const hasPendingChanges = this.state.archive.hasPendingChanges()
if (hasPendingChanges) {
this.props.ipc.send('document:unsaved')
Expand Down
13 changes: 7 additions & 6 deletions src/entities/EntityForm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, forEach, isArray } from 'substance'
import { Component, isArray } from 'substance'

import FormLabel from './FormLabel'
import RelationshipInput from './RelationshipInput'
Expand Down Expand Up @@ -43,7 +43,7 @@ export default class EntityForm extends Component {
targetTypes
}).ref(name)
)
} else if (isArray(type) && targetTypes === 'object') {
} else if (isArray(type) && targetTypes[0] === 'object') {
// HACK: we render a special Author Editor if the targetType is object
el.append(
$$(FormLabel, { name }),
Expand All @@ -65,12 +65,13 @@ export default class EntityForm extends Component {
let result = {}
let schema = this._getSchema()

forEach(schema, (property, propertyName) => {
let input = this.refs[propertyName]
for (let property of schema) {
const name = property.name
let input = this.refs[name]
if (input) {
result[propertyName] = input.getValue()
result[name] = input.getValue()
}
})
}
return result
}

Expand Down

0 comments on commit 8d259bd

Please sign in to comment.