Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
Update glossary term lastModifiedBy
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Eng committed Oct 15, 2015
1 parent 72d3361 commit 9cb00d6
Show file tree
Hide file tree
Showing 19 changed files with 103 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var CalendarMonthMatrix = React.createClass({
days = [], result = [],
dayColumns, firstDay, heading;

if (matrixData.length == 0) {
if (matrixData.length === 0) {
return <table><tr><td>Loading</td></tr></table>
}

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/main/web/lib/components/DayMatrix.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var DayMatrix = React.createClass({

handleDayClick: function(event) {
var dayChosen = this.props.date;
if (this.props.selectedDay == dayChosen) {
if (this.props.selectedDay === dayChosen) {
// click the same day again will cancel selection
Actions.clearSelectedDay();
} else {
Expand Down
6 changes: 3 additions & 3 deletions frontend/src/main/web/lib/components/SystemGlossary.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import _ from 'lodash';
import StringUtils from '../utils/StringUtils'

/**
* System glossary root component.
* Main view for glossary page
*/
var SystemGlossary = React.createClass({
mixins: [PureRenderMixin],
Expand Down Expand Up @@ -59,8 +59,8 @@ var SystemGlossary = React.createClass({
},

render: function() {
var srcLocale = this.state.srcLocale,
count = 0,
const srcLocale = this.state.srcLocale;
var count = 0,
selectedTransLocale = this.state.selectedTransLocale,
uploadSection = null,
newEntrySection = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ var ActionCell = React.createClass({
} else {
var isTransModified = self.state.entry.status.isTransModified;
var canUpdateComment = self.state.entry.status.canUpdateTransComment;
var isSaving = self.state.entry.status.isSaving === true;
var isSaving = self.state.entry.status.isSaving;

var infoTooltip = <Tooltip id="info">{self.props.info}</Tooltip>;
var info = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var ColumnHeader = React.createClass({
if(this.props.allowSort) {
if(this.state.sort !== null) {
var iconName = this.state.sort === 'descending' ? 'chevron-up' : 'chevron-down';
sortIcon = (<Icon name={iconName}/>);
sortIcon = <Icon name={iconName}/>;
}
return <button className='csec fwsb ph1/2' onClick={this._handleOnClick}>{this.props.value} {sortIcon}</button>;
} else {
Expand Down
37 changes: 19 additions & 18 deletions frontend/src/main/web/lib/components/glossary/DataTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var DataTable = React.createClass({

NO_ROW: -1,

contentHashIndex: 0,
CONTENT_HASH_INDEX: 0,

ENTRY: {
SRC: {
Expand Down Expand Up @@ -88,7 +88,7 @@ var DataTable = React.createClass({

/**
*
* @param fixedTop - top height for banner if can't get height from dom
* @param fixedTop - gets the height from the DOM if this is not specified
*/
_getHeight: function(fixedTop) {
var footer = window.document.getElementById("footer");
Expand Down Expand Up @@ -202,23 +202,23 @@ var DataTable = React.createClass({
Actions.updateSortOrder(field, ascending);
},

_renderCell: function (cellData) {
var key = this._generateKey(cellData.field.col, cellData.rowIndex, cellData.contentHash);
if (cellData.contentHash === null) {
_renderCell: function ({ contentHash, rowIndex, field, readOnly, placeholder }) {
var key = this._generateKey(field.col, rowIndex, contentHash);
if (contentHash === null) {
return (<LoadingCell key={key}/>)
} else {
var entry = this._getGlossaryEntry(cellData.contentHash);
var value = _.get(entry, cellData.field.field);
if (cellData.readOnly) {
var entry = this._getGlossaryEntry(contentHash);
var value = _.get(entry, field.field);
if (readOnly) {
return (<span className="mh1/2" key={key}>{value}</span>)
} else {
return (<InputCell
value={value}
contentHash={cellData.contentHash}
contentHash={contentHash}
key={key}
placeholder={cellData.placeholder}
rowIndex={cellData.rowIndex}
field={cellData.field.field}
placeholder={placeholder}
rowIndex={rowIndex}
field={field.field}
onFocusCallback={this._onRowClick}/>);
}
}
Expand Down Expand Up @@ -411,7 +411,7 @@ var DataTable = React.createClass({
},

_onRowClick: function (event, rowIndex) {
var contentHash = this._rowGetter(rowIndex)[this.contentHashIndex];
var contentHash = this._rowGetter(rowIndex)[this.CONTENT_HASH_INDEX];
if(this.props.focusedRow.rowIndex !== rowIndex) {
Actions.updateFocusedRow(contentHash, rowIndex);
}
Expand All @@ -436,15 +436,16 @@ var DataTable = React.createClass({
* @returns [contentHash] - contentHash in list
*/
_rowGetter: function(rowIndex) {
var self = this,
row = this.props.glossaryHash[rowIndex];
var row = this.props.glossaryHash[rowIndex];
if(_.isUndefined(row) || row === null) {
if(this.state.timeout !== null) {
clearTimeout(self.state.timeout);
clearTimeout(this.state.timeout);
}
this.state.timeout = setTimeout(function() {

this.state.timeout = setTimeout(() => {
Actions.loadGlossary(rowIndex);
}, self.TIMEOUT);
}, this.TIMEOUT);

return [null];
} else {
return row;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import React from 'react';
import {PureRenderMixin} from 'react/addons';
import React, { PureRenderMixin } from 'react/addons';
import Actions from '../../actions/GlossaryActions';
import { Button, Icon, Tooltip, Overlay } from 'zanata-ui';

Expand Down Expand Up @@ -39,12 +38,13 @@ var DeleteEntryModal = React.createClass({

if(this.props.entry.termsCount > 0) {
let translationPlural = this.props.entry.termsCount > 1
? 'translations' : 'translation'
info =
? 'translations' : 'translation';
info = (
<p>
Are you sure you want to delete this term and&nbsp;
<strong>{this.props.entry.termsCount}</strong> {translationPlural} ?
</p>
);
} else {
info = <p>Are you sure you want to delete this term ?</p>
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ var ImportModal = React.createClass({
var file = e.target.files[0],
reader = new FileReader();

reader.onload = (upload) => {
reader.onload = () => {
this.setState({file: file});
};
reader.readAsDataURL(file);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/main/web/lib/components/glossary/InputCell.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ var InputCell = React.createClass({
if(this.state.timeout !== null) {
clearTimeout(this.state.timeout);
}
this.state.timeout = setTimeout(function() {
Actions.updateEntryField(self.props.contentHash, self.props.field, value);
this.state.timeout = setTimeout(() => {
Actions.updateEntryField(this.props.contentHash, this.props.field, value);
}, this.TIMEOUT);
},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ var SourceActionCell = React.createClass({
rootClose
overlay={<Tooltip id='src-info'>{this.props.info}</Tooltip>}>
<Icon className="cpri" name="info"/>
</OverlayTrigger>);
</OverlayTrigger>
);

if(this.state.entry.status.isSaving) {
return (<div>{info} <Button kind='primary' className="ml1/4" loading>Update</Button></div>);
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/main/web/lib/constants/ActionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,4 @@ var GlossaryActionTypes = keymirror({
RESET_ENTRY: null
});

exports.UserMatrixActionTypes = UserMatrixActionTypes;
exports.GlossaryActionTypes = GlossaryActionTypes;
export { UserMatrixActionTypes, GlossaryActionTypes }
10 changes: 5 additions & 5 deletions frontend/src/main/web/lib/stores/GlossaryAPIStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ var GlossaryAPIStore = ({
.set("Pragma", "no-cache")
.set("Expires", 0)
.end(function (err, res) {
if (err != null && err.error) {
if (err && err.error) {
console.error(url, err);
}
if (res != null) {
Expand Down Expand Up @@ -42,7 +42,7 @@ var GlossaryAPIStore = ({
.set("Pragma", "no-cache")
.set("Expires", 0)
.end(function (err, res) {
if (err != null && err.error) {
if (err && err.error) {
console.error(url, err);
}
if (res != null) {
Expand Down Expand Up @@ -91,7 +91,7 @@ var GlossaryAPIStore = ({
.set('Accept', 'application/json')
.send(glossary)
.end(function (err, res) {
if(err != null && err.error) {
if(err && err.error) {
console.error(url, err);
}
if(res != null) {
Expand Down Expand Up @@ -120,7 +120,7 @@ var GlossaryAPIStore = ({
.set('Content-Type', 'application/json')
.set('Accept', 'application/json')
.end(function (err, res) {
if(err != null && err.error) {
if(err && err.error) {
console.error(url, err);
}
if(res != null) {
Expand Down Expand Up @@ -148,7 +148,7 @@ var GlossaryAPIStore = ({
.field('transLocale', data.uploadFile.transLocale)
.set('Accept', 'application/json')
.end(function (err, res) {
if(err != null && err.error) {
if(err && err.error) {
console.error(url, err);
}
if(res != null) {
Expand Down
22 changes: 19 additions & 3 deletions frontend/src/main/web/lib/stores/GlossaryStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import GlossaryAPIStore from './GlossaryAPIStore'

var PAGE_SIZE = 20,
CHANGE_EVENT = "change",
MAX_LISTENERS = 100; //number of listener for GlossaryStore (default is 11)
MAX_LISTENERS = 100; //overriding number of listener for GlossaryStore. (default is 11)

EventEmitter.prototype.setMaxListeners(MAX_LISTENERS);

Expand Down Expand Up @@ -110,7 +110,7 @@ function processGlossaryList(serverResponse) {
var transTerm =
GlossaryHelper.getTermByLocale(entry.glossaryTerms, transLocaleId);

if(transTerm != null) {
if(transTerm) {
transTerm.lastModifiedDate = DateHelpers.shortDate(DateHelpers.getDate(transTerm.lastModifiedDate));
if(_.isUndefined(transTerm.comment)) {
transTerm.comment = ''
Expand All @@ -130,7 +130,7 @@ function processGlossaryList(serverResponse) {
_state.glossary[entry.contentHash].status['isSrcValid'] = GlossaryHelper.isSourceValid( _state.glossary[entry.contentHash]);
_state.glossary[entry.contentHash].status['canUpdateTransComment'] = GlossaryHelper.canUpdateTransComment( _state.glossary[entry.contentHash]);
_state.glossaryHash[startIndex] = [entry.contentHash];
startIndex+=1;
startIndex++;
});
_state.original_glossary = _.cloneDeep(_state.glossary);
_state.loadingEntries = false;
Expand All @@ -157,17 +157,29 @@ function onUploadFile(percentCompleted) {
_state.uploadFile.status = percentCompleted;
}

/**
* Need notification feature to output message
* @param serverResponse
*/
function processUploadFile() {
_state.uploadFile.status = -1;
_state.uploadFile.show = false;
_state.uploadFile.transLocale = null;
_state.uploadFile.file = null;
}

/**
* Need notification feature to output message
* @param serverResponse
*/
function processDelete(serverResponse) {
console.debug('Glossary entry deleted');
}

/**
* Need notification feature to output message
* @param serverResponse
*/
function processSaveOrUpdate(serverResponse) {
_.assign(_state.newEntry, {
isSaving: false,
Expand All @@ -180,6 +192,10 @@ function processSaveOrUpdate(serverResponse) {
console.debug('Glossary entry saved');
}

/**
* Need notification feature to output message
* @param serverResponse
*/
function processUpdate(serverResponse) {
console.debug('Glossary entry updated');
}
Expand Down
20 changes: 10 additions & 10 deletions frontend/src/main/web/lib/utils/GlossaryHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,24 @@ var GlossaryHelper = {
var glossary = {}, entry = {};
glossary['glossaryEntries'] = [];

entry['contentHash'] = data.contentHash;
entry['pos'] = StringUtils.trim(data.pos);
entry['description'] = StringUtils.trim(data.description);
entry['srcLang'] = data.srcTerm.locale;
entry['sourceReference'] = data.srcTerm.reference;
entry['glossaryTerms'] = [];
entry.contentHash = data.contentHash;
entry.pos = StringUtils.trim(data.pos);
entry.description = StringUtils.trim(data.description);
entry.srcLang = data.srcTerm.locale;
entry.sourceReference = data.srcTerm.reference;
entry.glossaryTerms = [];

var srcTerm = this.generateGlossaryTermDTO(data.srcTerm, false);
if(!_.isNull(srcTerm) && !_.isUndefined(srcTerm)) {
entry['glossaryTerms'].push(srcTerm);
entry.glossaryTerms.push(srcTerm);
}

var transTerm = this.generateGlossaryTermDTO(data.transTerm, true);
if(!_.isNull(transTerm) && !_.isUndefined(transTerm)) {
entry['glossaryTerms'].push(transTerm);
entry.glossaryTerms.push(transTerm);
}

glossary['glossaryEntries'].push(entry);
glossary.glossaryEntries.push(entry);
return glossary;
},

Expand All @@ -74,7 +74,7 @@ var GlossaryHelper = {

getTermByLocale: function (terms, localeId) {
var term = _.filter(terms, 'locale', localeId);
return _.size(term) <= 0 ? null : term[0];
return term.length ? term[0] : null;
},

getEntryStatus: function (entry, originalEntry) {
Expand Down

0 comments on commit 9cb00d6

Please sign in to comment.