Skip to content

fix for job description #5011

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ workflows:
branches:
only:
- develop
- listing-develop-sync
- fix_for_job_descriptionn
# Production builds are exectuted
# when PR is merged to the master
# Don't change anything in this configuration
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@
"tc-accounts": "git+https://github.com/appirio-tech/accounts-app.git#dev",
"tc-core-library-js": "github:appirio-tech/tc-core-library-js#v2.6.3",
"tc-ui": "^1.0.12",
"topcoder-react-lib": "1.0.8",
"topcoder-react-lib": "1000.22.14",
"topcoder-react-ui-kit": "2.0.1",
"topcoder-react-utils": "0.7.8",
"turndown": "^4.0.2",
Expand Down
77 changes: 59 additions & 18 deletions src/shared/components/Editor/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,37 +46,69 @@ export default class EditorWrapper extends React.Component {
this.customPlugin = createCustomPlugin({
editor: this,
});

this.onBeforeInput = this.onBeforeInput.bind(this);
this.onPasteText = this.onPasteText.bind(this);
}

componentDidMount() {
const { connector, initialContent } = this.props;
connector.addEditor(this);
if (initialContent) {
let editorState = convertFromHTML(initialContent);
editorState = ContentState.createFromBlockArray(
editorState.contentBlocks,
editorState.entityMap,
);
editorState = EditorState.createWithContent(editorState);
this.initialContent = editorState.getCurrentContent();
setImmediate(() => this.setState({ editor: editorState }));
}
this.setInitialContent(initialContent);
}

componentWillReceiveProps({ connector, id }) {
const { connector: prevConnector } = this.props;
componentWillReceiveProps({ connector, id, initialContent }) {
const { connector: prevConnector, initialContent: prevInitialContent } = this.props;
this.id = id;
if (connector !== prevConnector) {
if (prevConnector) prevConnector.removeEditor(this);
if (connector) connector.addEditor(this);
}
if (initialContent !== prevInitialContent) {
this.setInitialContent(initialContent);
}
}

componentWillUnmount() {
const { connector } = this.props;
connector.removeEditor(this);
}

onBeforeInput() { // eslint-disable-line consistent-return
const { maxLength } = this.props;
const { editor: editorState } = this.state;
if (maxLength !== -1 && maxLength <= editorState.getCurrentContent().getPlainText('').length) {
return 'handled';
}
}

onPasteText(text) { // eslint-disable-line consistent-return
const { maxLength } = this.props;
const { editor: editorState } = this.state;
if (maxLength !== -1 && maxLength <= text.length + editorState.getCurrentContent().getPlainText('').length) {
return 'handled';
}
}

setInitialContent(content) {
if (content) {
let editorState = convertFromHTML(content);
if (editorState.contentBlocks) {
editorState = ContentState.createFromBlockArray(
editorState.contentBlocks,
editorState.entityMap,
);
editorState = EditorState.createWithContent(editorState);
this.initialContent = editorState.getCurrentContent();
setImmediate(() => this.setState({ editor: editorState }));
}
} else {
let { editor: editorState } = this.state;
editorState = EditorState.push(editorState, ContentState.createFromText(''));
this.setState({ editor: editorState });
}
}

getHtml() {
const { editor } = this.state;
return editorStateToHTML(editor.getCurrentContent());
Expand All @@ -98,10 +130,9 @@ export default class EditorWrapper extends React.Component {
* @param {String} type The new block style
*/
applyBlockStyle(type) {
const { editor } = this.state;
let editorState = editor;
let { editor: editorState } = this.state;
editorState = RichUtils.toggleBlockType(editorState, type);
this.setState({ editorState }); // eslint-disable-line
this.setState({ editor: editorState }); // eslint-disable-line
}

/**
Expand Down Expand Up @@ -231,13 +262,16 @@ export default class EditorWrapper extends React.Component {
}

render() {
const { connector, theme } = this.props;
const { connector, theme, placeholder } = this.props;

const st = this.state;

let containerStyles = style.container;
if (st.editor.getSelection().getHasFocus()) {
containerStyles += ` ${style.focused}`;
containerStyles += ` ${style.focused} is-focused`;
}
if (st.editor.getCurrentContent().hasText() || /<ol>|<ul>/.test(this.getHtml())) {
containerStyles += ' has-user-input';
}
if (theme.container) {
containerStyles += ` ${theme.container}`;
Expand All @@ -253,6 +287,7 @@ export default class EditorWrapper extends React.Component {
tabIndex={0}
>
<Editor
placeholder={placeholder}
editorState={st.editor}
handleKeyCommand={(command, state) => {
const editorState = RichUtils.handleKeyCommand(state, command);
Expand Down Expand Up @@ -283,6 +318,8 @@ export default class EditorWrapper extends React.Component {
]}
ref={(node) => { this.node = node; }}
spellCheck
handleBeforeInput={this.onBeforeInput}
handlePastedText={this.onPasteText}
/>
</div>
);
Expand All @@ -292,13 +329,17 @@ export default class EditorWrapper extends React.Component {
EditorWrapper.defaultProps = {
connector: new Connector(),
id: null,
initialContent: null,
initialContent: '',
theme: {},
placeholder: '',
maxLength: -1,
};

EditorWrapper.propTypes = {
connector: PT.instanceOf(Connector),
id: PT.string,
initialContent: PT.string,
theme: PT.shape(),
placeholder: PT.string,
maxLength: PT.number,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
@import "~styles/mixins";

@mixin html-content-style() {
@include roboto-regular;

font-size: 15px;
color: #262628;

em {
font-style: italic;
}

p {
margin: 7px 0;
line-height: 25px;
}

ul {
list-style-type: disc;
}

ol {
list-style-type: decimal;
}

ul,
ol {
margin: 0 0 0 25px;

li {
min-height: auto;
line-height: 20px;
padding: 0 0 0 12px;

&:last-child {
border: 0;
}
}
}

@content;
}
37 changes: 34 additions & 3 deletions src/shared/components/Settings/Profile/Work/List/Item/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PT from 'prop-types';
import ReactSVG from 'react-svg';
import moment from 'moment';
import { isomorphy } from 'topcoder-react-utils';
import { isEmpty as isDateEmpty } from 'utils/settings';

import './styles.scss';

Expand All @@ -23,8 +24,14 @@ export default function Item(props) {
onEditItem,
} = props;

const {
jobDescription,
technologies,
achievements,
} = work;

const hasSecondLine = () => {
if (_.isEmpty(work.timePeriodFrom) && _.isEmpty(work.timePeriodTo)
if (isDateEmpty(work.timePeriodFrom) && isDateEmpty(work.timePeriodTo)
&& _.isEmpty(work.position) && !work.working) {
return false;
}
Expand All @@ -45,11 +52,11 @@ export default function Item(props) {
{ `${work.company}${_.isEmpty(work.industry) ? '' : ` | ${work.industry}`}${_.isEmpty(work.cityTown) ? '' : ` | ${work.cityTown}`}` }
</div>
<div styleName="parameter-second-line">
{ `${!_.isEmpty(work.timePeriodFrom) ? moment(work.timePeriodFrom).format('YYYY') : ''}${!_.isEmpty(work.timePeriodTo) ? ` - ${moment(work.timePeriodTo).format('YYYY')}` : ` ${current}`} ${!_.isEmpty(work.position) && (!_.isEmpty(work.timePeriodTo) || !_.isEmpty(work.timePeriodFrom)) ? ' | ' : ''}${!_.isEmpty(work.position) ? `${work.position}` : ''}` }
{ `${!isDateEmpty(work.timePeriodFrom) ? moment(work.timePeriodFrom).format('YYYY') : ''}${!isDateEmpty(work.timePeriodTo) ? ` - ${moment(work.timePeriodTo).format('YYYY')}` : ` ${current}`} ${!_.isEmpty(work.position) && (!isDateEmpty(work.timePeriodTo) || !isDateEmpty(work.timePeriodFrom)) ? ' | ' : ''}${!_.isEmpty(work.position) ? `${work.position}` : ''}` }
</div>
<div styleName="parameter-second-line-mobile">
<p>
{`${!_.isEmpty(work.timePeriodFrom) ? moment(work.timePeriodFrom).format('YYYY') : ''}${!_.isEmpty(work.timePeriodTo) ? ` - ${moment(work.timePeriodTo).format('YYYY')}` : ` ${current}`}`}
{`${!isDateEmpty(work.timePeriodFrom) ? moment(work.timePeriodFrom).format('YYYY') : ''}${!isDateEmpty(work.timePeriodTo) ? ` - ${moment(work.timePeriodTo).format('YYYY')}` : ` ${current}`}`}
</p>
<p>
{`${!_.isEmpty(work.position) ? `${work.position}` : ''}`}
Expand Down Expand Up @@ -83,6 +90,30 @@ export default function Item(props) {
</p>
</a>
</div>
{ !_.isEmpty(jobDescription)
&& (
<div styleName="job-description">
<h4 styleName="title">Job Description</h4>
<div styleName="html-content" dangerouslySetInnerHTML={{ __html: jobDescription /* eslint-disable-line react/no-danger */ }} />
</div>
)
}
{ !_.isEmpty(technologies)
&& (
<div styleName="technologies">
<h4 styleName="title">Technologies</h4>
<div>{technologies.map(item => item.name).join(', ')}</div>
</div>
)
}
{ !_.isEmpty(achievements)
&& (
<div styleName="achievements">
<h4 styleName="title">Outputs and Achievements Within the Role</h4>
<div styleName="html-content" dangerouslySetInnerHTML={{ __html: achievements /* eslint-disable-line react/no-danger */ }} />
</div>
)
}
</div>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
@import "../../../../style";
@import './mixin';

.container {
display: flex;
flex-direction: row;
flex-wrap: wrap;
justify-items: center;
justify-content: space-between;
height: 100%;
Expand Down Expand Up @@ -151,3 +153,50 @@
}
}
}

.operation-container + div {
margin-top: 15px;
padding-top: 20px;
border-top: 1px solid #ededf2;
}

.job-description,
.technologies,
.achievements {
@include roboto-regular;

width: 100%;
margin: 0 0 20px;
margin-left: 66px;
font-size: 15px;
color: #262628;

.title {
@include roboto-medium;

line-height: 25px;
margin-bottom: 4px;
}
}

.technologies {
.title {
margin: 0;
line-height: 1;
}

div {
line-height: 25px;
}
}

.achievements {
margin-bottom: 5px;
}

.job-description,
.achievements {
.html-content {
@include html-content-style;
}
}
Loading