Skip to content

Commit

Permalink
[New #18] Added record status tooltip for rejected and published phases
Browse files Browse the repository at this point in the history
  • Loading branch information
LaChope committed Dec 13, 2023
1 parent a7b6f9d commit 6aafaef
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 15 deletions.
45 changes: 31 additions & 14 deletions js/components/record/RecordRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,49 @@ import HelpIcon from "../HelpIcon";
import {Button} from "react-bootstrap";
import {injectIntl} from "react-intl";
import withI18n from "../../i18n/withI18n";
import RecordValidator from "../../validation/RecordValidator";
import {LoaderSmall} from "../Loader";
import PropTypes from "prop-types";
import {RECORD_PHASE, ROLE} from "../../constants/DefaultConstants";

let RecordRow = (props) => {
const record = props.record,
formTemplateOptions = props.formTemplateOptions,
isComplete = RecordValidator.isComplete(record),
completionTooltip = props.i18n(isComplete ? 'records.completion-status-tooltip.complete' : 'records.completion-status-tooltip.incomplete'),
recordPhase = props.record.phase,
isAdmin = props.currentUser.role === ROLE.ADMIN,
deleteButton = props.disableDelete ? null :
<Button variant='warning' size='sm' title={props.i18n('records.delete-tooltip')}
onClick={() => props.onDelete(record)}>{props.i18n('delete')}{props.deletionLoading &&
<LoaderSmall/>}</Button>,
recordPhase = props.record.phase;
<LoaderSmall/>}</Button>;

const getGlyph = () => {
if (recordPhase === RECORD_PHASE.OPEN) return "to-do";
if (recordPhase === RECORD_PHASE.COMPLETED) return "ok";
if (recordPhase === RECORD_PHASE.PUBLISHED) return "envelope";
if (recordPhase === RECORD_PHASE.REJECTED) return "remove";
}
switch (recordPhase) {
case RECORD_PHASE.OPEN:
return 'to-do';
case RECORD_PHASE.COMPLETED:
return 'ok';
case RECORD_PHASE.PUBLISHED:
return 'envelope';
case RECORD_PHASE.REJECTED:
return 'remove';
default:
return '';
}
};

const getCompletionStatusTooltip = () => {
switch (recordPhase) {
case RECORD_PHASE.COMPLETED:
return props.i18n('records.completion-status-tooltip.complete');
case RECORD_PHASE.OPEN:
return props.i18n('records.completion-status-tooltip.incomplete');
case RECORD_PHASE.REJECTED:
return props.i18n('records.completion-status-tooltip.rejected');
case RECORD_PHASE.PUBLISHED:
return props.i18n('records.completion-status-tooltip.published');
default:
return "";
}
};

return <tr>
{isAdmin &&
Expand All @@ -49,7 +69,7 @@ let RecordRow = (props) => {
</td>
{ isAdmin &&
<td className='report-row content-center'>
<HelpIcon text={completionTooltip} glyph={getGlyph()}/>
<HelpIcon text={getCompletionStatusTooltip()} glyph={getGlyph()}/>
</td>
}
<td className='report-row actions'>
Expand All @@ -60,9 +80,6 @@ let RecordRow = (props) => {
</tr>
};

const isAdvancedView = {}


const getFormTemplateOptionName = (formTemplate, formTemplatesOptions) => {
if (!formTemplate) {
return "";
Expand Down
2 changes: 1 addition & 1 deletion js/constants/DefaultConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export const INPUT_LENGTH_THRESHOLD = 70;

export const PASSWORD_LENGTH = 4;

export const RECORD_REQUIRED_FIELDS = ['localName', 'completed'];
export const RECORD_REQUIRED_FIELDS = ['localName'];

export const ALERT_TYPES = {
INFO: 'info',
Expand Down
2 changes: 2 additions & 0 deletions js/i18n/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export default {
'records.completion-status': 'Stav vyplnění',
'records.completion-status-tooltip.complete': 'Všechny povinné informace ze záznamu byly vyplněny.',
'records.completion-status-tooltip.incomplete': 'Některé povinné informace ze záznamu ještě nebyly vyplněny.',
'records.completion-status-tooltip.rejected': 'Formulář byl odmítnut',
'records.completion-status-tooltip.published': 'Formulář byl zveřejněn',
'records.last-modified': 'Naposledy upraveno',
'records.open-tooltip': 'Zobrazit či upravit tento záznam',
'records.delete-tooltip': 'Smazat tento záznam',
Expand Down
2 changes: 2 additions & 0 deletions js/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,8 @@ export default {
'records.completion-status': 'Completion status',
'records.completion-status-tooltip.complete': 'All required fields of the record have been filled out.',
'records.completion-status-tooltip.incomplete': 'Some of the required fields of the record have not yet been filled out.',
'records.completion-status-tooltip.rejected': 'The form was rejected',
'records.completion-status-tooltip.published': 'The form has been published',
'records.last-modified': 'Last modified',
'records.open-tooltip': 'View and edit the record',
'records.delete-tooltip': 'Delete this record',
Expand Down

0 comments on commit 6aafaef

Please sign in to comment.