Skip to content

Commit ce492dd

Browse files
committed
Merge branch 'develop'
2 parents 1fe4c8a + 9c11aba commit ce492dd

File tree

17 files changed

+454
-85
lines changed

17 files changed

+454
-85
lines changed

client/style/main.less

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
@import "/imports/ui/components/community/RecentActivityTeaser/recentActivityTeaser.import.less";
5757
@import "/imports/ui/components/discussionComments/DiscussionCommentsList/discussionCommentsList.import.less";
5858
@import "/imports/ui/components/editor/addComment/AddComment/addComment.import.less";
59+
@import "/imports/ui/components/editor/addRevision/AddRevision/addRevision.import.less";
5960
@import "/imports/ui/components/editor/addTranslation/AddTranslation/addTranslation.import.less";
6061
@import "/imports/ui/components/editor/addRevision/CommentActionButtons/commentActionButtons.import.less";
6162
@import "/imports/ui/components/editor/textNodes/TextNodesEditor/textNodesEditor.import.less";

imports/lib/router.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -292,12 +292,16 @@ FlowRouter.route('/sign-out', {
292292
triggersEnter: [
293293
() => {
294294
try {
295-
AccountsTemplates.logout();
295+
Meteor.logout(() => {
296+
const domain = Utils.getEnvDomain();
297+
Cookies.remove('userId', { domain });
298+
Cookies.remove('loginToken', { domain });
299+
FlowRouter.go('/');
300+
});
296301
} catch (err) {
297302
console.log(err);
298303
}
299-
Cookies.remove('userId');
300-
Cookies.remove('loginToken');
304+
301305
},
302306
],
303307
action: () => {

imports/lib/utils.js

+14
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import Config from './_config/_config.js';
55

66
// models
77
import Editions from '/imports/models/editions';
8+
import Commenters from '/imports/models/commenters';
89

910

1011
const Utils = {
@@ -265,6 +266,19 @@ const Utils = {
265266

266267
return editions;
267268
},
269+
getCommenters(commenterData) {
270+
271+
const commentersList = [];
272+
273+
commenterData.forEach(commenter => {
274+
const currentCommenter = Commenters.findOne({
275+
_id: commenter.value,
276+
}, {fields: {_id: 1, slug: 1, name: 1}});
277+
commentersList.push(currentCommenter);
278+
});
279+
280+
return commentersList;
281+
}
268282
};
269283

270284
export default Utils;

imports/ui/components/commentary/comments/CommentBodyText/CommentBodyText.js

+17-8
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,28 @@ class CommentBodyText extends React.Component {
2727

2828
highlightText(text) {
2929
const { searchTerm } = this.props;
30+
const termToHighlightRegEx = new RegExp(searchTerm, 'ig');
31+
const termToHighlight = text.match(termToHighlightRegEx)[0];
3032

31-
if (searchTerm) {
32-
const termToHighlightRegEx = new RegExp(searchTerm, 'ig');
33-
const termToHighlight = text.match(termToHighlightRegEx)[0];
33+
const highlightTag = `<mark class="highlighted">${termToHighlight}</mark>`;
34+
35+
return text.replace(termToHighlight, highlightTag);
36+
}
3437

35-
const highlightTag = `<mark class="highlighted">${termToHighlight}</mark>`;
38+
renderHTML(text) {
39+
const { searchTerm } = this.props;
40+
let html = text;
41+
42+
if (searchTerm) {
43+
html = this.highlightText(html);
44+
}
3645

37-
return text.replace(termToHighlight, highlightTag);
3846

47+
if (this.props.createRevisionMarkup) {
48+
return createRevisionMarkup(html);
3949
}
4050

41-
return text;
42-
51+
return { __html: html };
4352
}
4453

4554

@@ -49,7 +58,7 @@ class CommentBodyText extends React.Component {
4958
return (
5059
<div
5160
className="comment-body"
52-
dangerouslySetInnerHTML={{__html: this.highlightText(text)}}
61+
dangerouslySetInnerHTML={this.renderHTML(text)}
5362
onClick={onTextClick}
5463
/>
5564
);

imports/ui/components/editor/addComment/AddComment/AddComment.js

+50-11
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import RaisedButton from 'material-ui/RaisedButton';
77
import FontIcon from 'material-ui/FontIcon';
88
import IconButton from 'material-ui/IconButton';
99
import Snackbar from 'material-ui/Snackbar';
10+
import Cookies from 'js-cookie';
11+
import slugify from 'slugify';
1012

1113
import getMuiTheme from 'material-ui/styles/getMuiTheme';
1214
// https://github.com/JedWatson/react-select
@@ -179,6 +181,8 @@ class AddComment extends React.Component {
179181
this.moveTagBlock = this.moveTagBlock.bind(this);
180182
this.onTagValueChange = this.onTagValueChange.bind(this);
181183
this.onIsMentionedInLemmaChange = this.onIsMentionedInLemmaChange.bind(this);
184+
this.selectTagType = this.selectTagType.bind(this);
185+
this.addNewTag = this.addNewTag.bind(this);
182186
}
183187

184188
_enableButton() {
@@ -269,8 +273,8 @@ class AddComment extends React.Component {
269273
// TODO: form validation
270274
// TODO: Migrate to formsy components
271275
const error = this.validateStateForSubmit();
272-
this.showSnackBar(error);
273-
if (error.errors) {
276+
if (error) {
277+
this.showSnackBar(error);
274278
return false;
275279
}
276280

@@ -309,9 +313,10 @@ class AddComment extends React.Component {
309313
}
310314

311315
showSnackBar(error) {
316+
console.log("error LOG", error);
312317
this.setState({
313-
snackbarOpen: error.errors,
314-
snackbarMessage: error.errorMessage,
318+
snackbarOpen: true,
319+
snackbarMessage: error.message,
315320
});
316321
setTimeout(() => {
317322
this.setState({
@@ -322,7 +327,7 @@ class AddComment extends React.Component {
322327

323328
validateStateForSubmit() {
324329
let errors = false;
325-
let errorMessage = 'Missing comment data:';
330+
let errorMessage = '';
326331
if (!this.state.titleValue) {
327332
errors = true;
328333
errorMessage += ' title,';
@@ -341,12 +346,9 @@ class AddComment extends React.Component {
341346
}
342347
if (errors === true) {
343348
errorMessage = errorMessage.slice(0, -1);
344-
errorMessage += '.';
349+
errorMessage = new Meteor.Error('data-missing', 'Missing comment data:'.concat(errorMessage, '.'));
345350
}
346-
return {
347-
errors,
348-
errorMessage,
349-
};
351+
return errorMessage;
350352
}
351353

352354
addReferenceWorkBlock() {
@@ -440,6 +442,40 @@ class AddComment extends React.Component {
440442
});
441443
}
442444

445+
selectTagType(tagId, event, index) {
446+
const currentTags = this.state.tagsValue;
447+
currentTags[index].keyword.type = event.target.value;
448+
this.setState({
449+
tagsValue: currentTags
450+
});
451+
452+
Meteor.call('keywords.changeType', Cookies.get('loginToken'), tagId, event.target.value, (err) => {
453+
if (err) {
454+
this.showSnackBar(err);
455+
} else {
456+
this.showSnackBar({message: 'Keyword type changed'});
457+
}
458+
});
459+
}
460+
461+
addNewTag(tag) {
462+
463+
const keyword = [{
464+
title: tag.value,
465+
slug: slugify(tag.value.toLowerCase()),
466+
type: 'word',
467+
count: 1,
468+
tenantId: Session.get('tenantId'),
469+
}];
470+
471+
Meteor.call('keywords.insert', Cookies.get('loginToken'), keyword, (err) => {
472+
if (err) {
473+
this.showSnackBar(err);
474+
} else {
475+
this.showSnackBar({message: 'Tag added'});
476+
}
477+
});
478+
}
443479
// --- END SUBMIT / VALIDATION HANDLE --- //
444480

445481
render() {
@@ -468,7 +504,7 @@ class AddComment extends React.Component {
468504
value={this.state.commenterValue}
469505
onChange={this.onCommenterValueChange}
470506
placeholder="Commentator..."
471-
multi={true}
507+
multi
472508
/>
473509
:
474510
''
@@ -492,6 +528,8 @@ class AddComment extends React.Component {
492528
moveTagBlock={this.moveTagBlock}
493529
onTagValueChange={this.onTagValueChange}
494530
onIsMentionedInLemmaChange={this.onIsMentionedInLemmaChange}
531+
selectTagType={this.selectTagType}
532+
addNewTag={this.addNewTag}
495533
/>
496534

497535
</div>
@@ -542,6 +580,7 @@ class AddComment extends React.Component {
542580
value: rW.value,
543581
label: rW.label,
544582
slug: rW.slug,
583+
type: rW.type,
545584
i,
546585
});
547586
});

imports/ui/components/editor/addComment/TagsInput/TagsInput.js

+13-6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { createContainer } from 'meteor/react-meteor-data';
99
import {
1010
FormGroup,
1111
ControlLabel,
12+
FormControl,
1213
} from 'react-bootstrap';
1314
import Select from 'react-select';
1415
import update from 'immutability-helper';
@@ -23,7 +24,7 @@ const ListGroupItemDnD = createListGroupItemDnD('tagBlocks');
2324

2425
const TagsInput = ({
2526
tags, tagsValue, addTagBlock, removeTagBlock, moveTagBlock,
26-
onTagValueChange, onIsMentionedInLemmaChange
27+
onTagValueChange, onIsMentionedInLemmaChange, selectTagType, addNewTag
2728
}) => {
2829

2930
if (!tags) {
@@ -88,7 +89,7 @@ const TagsInput = ({
8889
}}
8990
/>
9091
</div>
91-
<Select
92+
<Select.Creatable
9293
name="tags"
9394
id="tags"
9495
required={false}
@@ -97,11 +98,17 @@ const TagsInput = ({
9798
value={tagsValue[i].tagId}
9899
onChange={onTagValueChange}
99100
placeholder="Tags . . ."
101+
onNewOptionClick={addNewTag}
100102
/>
101-
<FormGroup>
102-
<ControlLabel>Tag type: </ControlLabel>
103-
{tagsValue[i].keyword && tagsValue[i].keyword.type ? tagsValue[i].keyword.type : 'no tag selected'}
104-
</FormGroup>
103+
{tagsValue[i].keyword && tagsValue[i].keyword.type ?
104+
<FormGroup>
105+
<ControlLabel>Tag type</ControlLabel>
106+
<FormControl onChange={(event) => { selectTagType(tagsValue[i].tagId, event, i); }} value={tagsValue[i].keyword.type} componentClass="select" placeholder="select">
107+
<option value="word">word</option>
108+
<option value="idea">idea</option>
109+
</FormControl>
110+
</FormGroup> : ''
111+
}
105112
<FormGroup>
106113
<ControlLabel>Is Not Mentioned in Lemma: </ControlLabel>
107114
<Checkbox

0 commit comments

Comments
 (0)