Skip to content

Commit

Permalink
feat(ZNTA-2275): Allow user to update external IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
djansen-redhat committed Feb 15, 2018
1 parent f3e92ee commit 1906bc2
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 2 deletions.
15 changes: 14 additions & 1 deletion server/zanata-frontend/src/app/containers/Glossary/EntryModal.js
Expand Up @@ -25,7 +25,6 @@ class EntryModal extends Component {
if (term) {
const person = term.lastModifiedBy
const date = term.lastModifiedDate

const isPersonEmpty = isEmpty(person)
const isDateEmpty = isEmpty(date)

Expand Down Expand Up @@ -153,6 +152,20 @@ class EntryModal extends Component {
</EditableText>
</div>
) : ''}
{!transSelected ? (
<div className='modal-section'>
<label className='text-bold'>External ID</label>
<EditableText
editable
editing
maxLength={100}
placeholder='Optional: Set an ID for external tools'
emptyReadOnlyText='No external ID'
onChange={(e) => handleTermFieldUpdate('externalId', e)}>
{entry.externalId}
</EditableText>
</div>
) : ''}
{!isEmpty(info) &&
<div className='modalText-muted'>{info}</div>
}
Expand Down
Expand Up @@ -57,6 +57,16 @@ class NewEntryModal extends Component {
})
}

handleExIdChanged = (e) => {
const { entry } = this.state
this.setState({
entry: {
...entry,
externalId: e.target.value
}
})
}

handleCancel = () => {
this.resetFields()
this.props.handleNewEntryDisplay(false)
Expand Down Expand Up @@ -123,6 +133,18 @@ class NewEntryModal extends Component {
{this.state.entry.description}
</EditableText>
</div>
<div className='modal-section'>
<label className='text-bold'>External ID</label>
<EditableText
className='textInput'
editable
editing
placeholder='Optional: for use in external tools'
maxLength={100}
onChange={this.handleExIdChanged.bind(this)}>
{this.state.entry.externalId}
</EditableText>
</div>
</Modal.Body>
<Modal.Footer>
<div className='u-pullRight'>
Expand Down
3 changes: 3 additions & 0 deletions server/zanata-frontend/src/app/reducers/glossary-reducer.js
Expand Up @@ -348,6 +348,9 @@ const glossary = handleActions({
case 'description':
newSelectedTerm.description = action.payload.value
break
case 'externalId':
newSelectedTerm.externalId = action.payload.value
break
case 'comment':
if (newSelectedTerm.transTerm) {
newSelectedTerm.transTerm.comment = action.payload.value
Expand Down
7 changes: 6 additions & 1 deletion server/zanata-frontend/src/app/utils/GlossaryHelper.js
Expand Up @@ -36,6 +36,7 @@ var GlossaryHelper = {
entry.sourceReference = data.srcTerm.reference
entry.glossaryTerms = []
entry.qualifiedName = {name: qualifiedName}
entry.externalId = data.externalId

var srcTerm = this.generateTermDTO(data.srcTerm, false)
if (!isUndefined(srcTerm)) {
Expand Down Expand Up @@ -109,6 +110,7 @@ var GlossaryHelper = {
id: entry.id,
pos: defined(entry.pos, ''),
description: defined(entry.description, ''),
externalId: defined(entry.externalId, ''),
termsCount: entry.termsCount > 0 ? entry.termsCount - 1 : 0,
srcTerm: srcTerm,
transTerm: transTerm,
Expand All @@ -129,6 +131,7 @@ var GlossaryHelper = {
? this.toEmptyString(entry.transTerm.comment) : ''
const desc = this.toEmptyString(entry.description)
const pos = this.toEmptyString(entry.pos)
const extId = this.toEmptyString(entry.externalId)

const oriSource = this.toEmptyString(
originalEntry.srcTerm.content)
Expand All @@ -138,10 +141,12 @@ var GlossaryHelper = {
? this.toEmptyString(originalEntry.transTerm.comment) : ''
const oriDesc = this.toEmptyString(originalEntry.description)
const oriPos = this.toEmptyString(originalEntry.pos)
const oriExtId = this.toEmptyString(originalEntry.externalId)

let isSrcModified = (desc !== oriDesc) ||
(pos !== oriPos) ||
(source !== oriSource)
(source !== oriSource) ||
(extId !== oriExtId)
let isTransModified = (trans !== oriTrans) || (comment !== oriComment)

let isSrcValid = !isEmpty(trim(source))
Expand Down

0 comments on commit 1906bc2

Please sign in to comment.