Merge pull request #113 from ahammouda/main

Added ability to change placeholder text for comment/tag, and make comment replies optional
This commit is contained in:
Rainer Simon 2022-10-02 19:23:10 +02:00 committed by GitHub
commit 9c8810eb36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 32 additions and 26 deletions

View File

@ -87,6 +87,12 @@ const CommentWidget = props => {
const onChangeReplyPurpose = purpose => const onChangeReplyPurpose = purpose =>
props.onUpdateBody(draftReply, { ...draftReply, purpose: purpose.value }); props.onUpdateBody(draftReply, { ...draftReply, purpose: purpose.value });
// Pre-condition: will be true if the annotation exists, and Annotorious is not in read-only mode
const isReadable = (!props.readOnly && props.annotation);
// Extra condtion to: reply field exists if there is no comment yet, or disableReply is false.
const hasReply = comments.length === 0 || !props.disableReply;
return ( return (
<> <>
{ comments.map((body, idx) => { comments.map((body, idx) =>
@ -101,18 +107,18 @@ const CommentWidget = props => {
onSaveAndClose={props.onSaveAndClose} /> onSaveAndClose={props.onSaveAndClose} />
)} )}
{ !props.readOnly && props.annotation && { isReadable && hasReply &&
<div className="r6o-widget comment editable"> <div className="r6o-widget comment editable">
<TextEntryField <TextEntryField
focus={props.focus} focus={props.focus}
content={draftReply.value} content={draftReply.value}
editable={true} editable={true}
placeholder={comments.length > 0 ? i18n.t('Add a reply...') : i18n.t('Add a comment...')} placeholder={comments.length > 0 ? i18n.t('Add a reply...') : (props.textPlaceHolder || i18n.t('Add a comment...'))}
onChange={onEditReply} onChange={onEditReply}
onSaveAndClose={() => props.onSaveAndClose()} onSaveAndClose={() => props.onSaveAndClose()}
/> />
{ props.purposeSelector && draftReply.value.length > 0 && { props.purposeSelector && draftReply.value.length > 0 &&
<PurposeSelect <PurposeSelect
editable={true} editable={true}
content={draftReply.purpose} content={draftReply.purpose}
onChange={onChangeReplyPurpose} onChange={onChangeReplyPurpose}

View File

@ -98,7 +98,7 @@ const TagWidget = props => {
{!props.readOnly && {!props.readOnly &&
<Autocomplete <Autocomplete
focus={props.focus} focus={props.focus}
placeholder={i18n.t('Add tag...')} placeholder={props.textPlaceHolder || i18n.t('Add tag...')}
vocabulary={props.vocabulary || []} vocabulary={props.vocabulary || []}
onChange={onDraftChange} onChange={onDraftChange}
onSubmit={onSubmit}/> onSubmit={onSubmit}/>