Skip to content

Commit

Permalink
fix(glossary info): include lastModifiedBy info in entry (zanata#1200)
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng authored Jun 20, 2016
1 parent c418b92 commit 78c1cc4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 11 deletions.
31 changes: 31 additions & 0 deletions frontend/src/main/web/src/containers/Glossary/EntryModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,30 @@ import {
*/
class EntryModal extends Component {

generateTermInfo(term) {
if (term) {
const person = term.lastModifiedBy
const date = term.lastModifiedDate

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

if (!isPersonEmpty || !isDateEmpty) {
let parts = ['Last updated'];
if (!isPersonEmpty) {
parts.push('by:');
parts.push(person);
}
if (!isDateEmpty) {
parts.push(date)
}
return parts.join(' ');
}
}
return undefined
}


render () {
const {
entry,
Expand All @@ -35,6 +59,10 @@ class EntryModal extends Component {
const enableComment = transSelected &&
entry.transTerm && !isEmpty(transContent)

const info = transSelected
? this.generateTermInfo(entry.transTerm)
: this.generateTermInfo(entry.srcTerm)

return (
<Modal show={show}
onHide={() => handleEntryModalDisplay(false)}>
Expand Down Expand Up @@ -118,6 +146,9 @@ class EntryModal extends Component {
</EditableText>
</div>
) : '' }
{!isEmpty(info) &&
<div className='C(muted) Pt(rq)'>{info}</div>
}
</Modal.Body>
<Modal.Footer>
<Row theme={{ base: {j: 'Jc(c)'} }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class NewEntryModal extends Component {
<Modal.Header>
<Modal.Title>New Term</Modal.Title>
</Modal.Header>
<Modal.Body atomic={{t: 'Ta(start)'}} scrollable={false}>
<Modal.Body atomic={{t: 'Ta(start)'}}>
<div className='Mb(rh)'>
<label className='Fw(b)'>Term</label>
<EditableText
Expand Down
11 changes: 7 additions & 4 deletions frontend/src/main/web/src/utils/DateHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,19 @@ var DateHelper = {

getDate: function (milliseconds) {
if (!isEmpty(milliseconds)) {
return new Date(milliseconds)
const intMiliseconds = parseInt(milliseconds);
return new Date(intMiliseconds)
} else {
return undefined
}
return
},

shortDate: function (date) {
if (date) {
return moment(date).format('MMM Do, YYYY')
return moment(date).format('DD/MM/YYYY')
} else {
return undefined
}
return
}
}

Expand Down
16 changes: 10 additions & 6 deletions frontend/src/main/web/src/utils/GlossaryHelper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { isUndefined, filter, forOwn } from 'lodash'
import { trim } from './StringUtils'
import { isEmpty } from 'lodash'
import { isEmpty, toString } from 'lodash'
import DateHelpers from './DateHelper'
import defined from 'defined'

Expand Down Expand Up @@ -82,18 +82,22 @@ var GlossaryHelper = {
let srcTerm =
this.getTermByLocale(entry.glossaryTerms, entry.srcLang)
srcTerm.reference = entry.sourceReference
if (!isEmpty(srcTerm.lastModifiedDate)) {
const srcDate = toString(srcTerm.lastModifiedDate)
if (!isEmpty(srcDate)) {
srcTerm.lastModifiedDate =
DateHelpers.shortDate(DateHelpers.getDate(srcTerm.lastModifiedDate))
DateHelpers.shortDate(DateHelpers.getDate(srcDate))
}

let transTerm
if (transLocaleId) {
transTerm = this.getTermByLocale(entry.glossaryTerms, transLocaleId)
if (transTerm) {
transTerm.lastModifiedDate =
DateHelpers.shortDate(DateHelpers.getDate(transTerm.lastModifiedDate))
if (isUndefined(transTerm.comment)) {
const transDate = toString(transTerm.lastModifiedDate)
if (!isEmpty(transDate)) {
transTerm.lastModifiedDate =
DateHelpers.shortDate(DateHelpers.getDate(transDate))
}
if (isEmpty(transTerm.comment)) {
transTerm.comment = ''
}
} else {
Expand Down

0 comments on commit 78c1cc4

Please sign in to comment.