diff --git a/js/components/record/RecordRow.js b/js/components/record/RecordRow.js index 7d29093a..9c40e256 100644 --- a/js/components/record/RecordRow.js +++ b/js/components/record/RecordRow.js @@ -4,7 +4,6 @@ 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"; @@ -12,21 +11,42 @@ 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 : , - recordPhase = props.record.phase; + }; 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 {isAdmin && @@ -52,7 +72,7 @@ let RecordRow = (props) => { { isAdmin && - + } @@ -63,9 +83,6 @@ let RecordRow = (props) => { }; -const isAdvancedView = {} - - const getFormTemplateOptionName = (formTemplate, formTemplatesOptions) => { if (!formTemplate) { return ""; diff --git a/js/constants/DefaultConstants.js b/js/constants/DefaultConstants.js index 8b3dcb6a..96a7dc1d 100644 --- a/js/constants/DefaultConstants.js +++ b/js/constants/DefaultConstants.js @@ -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', diff --git a/js/i18n/cs.js b/js/i18n/cs.js index 1905fdbd..1d6f0485 100644 --- a/js/i18n/cs.js +++ b/js/i18n/cs.js @@ -148,6 +148,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', diff --git a/js/i18n/en.js b/js/i18n/en.js index 9d1a0629..217ec59a 100644 --- a/js/i18n/en.js +++ b/js/i18n/en.js @@ -148,6 +148,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',