From 5d4201fec53d7a3245187d12f5005baf27645e99 Mon Sep 17 00:00:00 2001 From: "pierluigi.dicianni" Date: Mon, 14 Oct 2024 11:27:20 +0200 Subject: [PATCH 1/8] Fix ticket MATECAT-3ZN --- .../es6/components/createProject/TmGlossarySelect.js | 11 ++++++++--- public/js/cat_source/es6/pages/NewProject.js | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/public/js/cat_source/es6/components/createProject/TmGlossarySelect.js b/public/js/cat_source/es6/components/createProject/TmGlossarySelect.js index e3a9b9f933..7dd47b140f 100644 --- a/public/js/cat_source/es6/components/createProject/TmGlossarySelect.js +++ b/public/js/cat_source/es6/components/createProject/TmGlossarySelect.js @@ -5,8 +5,13 @@ import {CreateProjectContext} from './CreateProjectContext' import {orderTmKeys} from '../settingsPanel/Contents/TranslationMemoryGlossaryTab' export const TmGlossarySelect = () => { - const {SELECT_HEIGHT, tmKeys, setOpenSettings, modifyingCurrentTemplate} = - useContext(CreateProjectContext) + const { + SELECT_HEIGHT, + tmKeys, + setOpenSettings, + modifyingCurrentTemplate, + projectTemplates, + } = useContext(CreateProjectContext) const tmKeyActive = Array.isArray(tmKeys) ? tmKeys.filter(({isActive}) => isActive) @@ -34,7 +39,7 @@ export const TmGlossarySelect = () => { className={`${hasNoPrivateKeys ? 'select-without-private-keys' : ''}`} maxHeightDroplist={SELECT_HEIGHT} showSearchBar={true} - isDisabled={!tmKeys} + isDisabled={!tmKeys || !projectTemplates?.length} options={tmKeys} multipleSelect={'dropdown'} activeOptions={tmKeyActive} diff --git a/public/js/cat_source/es6/pages/NewProject.js b/public/js/cat_source/es6/pages/NewProject.js index 12731f0833..d23dda2ef9 100644 --- a/public/js/cat_source/es6/pages/NewProject.js +++ b/public/js/cat_source/es6/pages/NewProject.js @@ -732,6 +732,7 @@ const NewProject = ({ setOpenSettings, isImportTMXInProgress, setIsImportTMXInProgress, + projectTemplates, modifyingCurrentTemplate, }} > From 019fdaa9fb6d248a273a099ee85c3e851cc080db Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 14 Oct 2024 11:30:23 +0200 Subject: [PATCH 2/8] MATECAT-43H: target languages modal --- .../es6/components/createProject/TargetLanguagesSelect.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/cat_source/es6/components/createProject/TargetLanguagesSelect.js b/public/js/cat_source/es6/components/createProject/TargetLanguagesSelect.js index a58ba4fbfd..b82b0299a8 100644 --- a/public/js/cat_source/es6/components/createProject/TargetLanguagesSelect.js +++ b/public/js/cat_source/es6/components/createProject/TargetLanguagesSelect.js @@ -11,7 +11,7 @@ export const TargetLanguagesSelect = () => { const getActiveLabel = () => targetLangs.map(({name}) => name).join(',') const openModal = () => - languages.length > 0 && setIsOpenMultiselectLanguages(true) + languages?.length > 0 && setIsOpenMultiselectLanguages(true) return (
Date: Mon, 14 Oct 2024 12:46:14 +0200 Subject: [PATCH 3/8] MATECAT-42Z: go to next translated segment --- .../header/cattol/segment_filter/segment_filter.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/js/cat_source/es6/components/header/cattol/segment_filter/segment_filter.js b/public/js/cat_source/es6/components/header/cattol/segment_filter/segment_filter.js index f6ffd5c297..331e5f15c9 100644 --- a/public/js/cat_source/es6/components/header/cattol/segment_filter/segment_filter.js +++ b/public/js/cat_source/es6/components/header/cattol/segment_filter/segment_filter.js @@ -284,9 +284,11 @@ let SegmentFilterUtils = { gotoNextTranslatedSegment: (sid) => { const filteredData = SegmentFilterUtils.getLastFilterData()['segment_ids'] if (filteredData) { - const list = filteredData['segment_ids'] - const index = list.indexOf('' + sid) - const nextFiltered = index !== list.length - 1 ? list[index + 1] : list[0] + const index = filteredData.indexOf('' + sid) + const nextFiltered = + index !== filteredData.length - 1 + ? filteredData[index + 1] + : filteredData[0] let segment = SegmentStore.getSegmentByIdToJS(nextFiltered) if (segment && segment.status !== 'DRAFT' && segment.status !== 'NEW') { SegmentActions.openSegment(nextFiltered) From 0879eacc76dddf33c89cbd0b9300c14c7a6214b3 Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 14 Oct 2024 12:49:26 +0200 Subject: [PATCH 4/8] MATECAT-304: action menu revise link --- public/js/cat_source/es6/components/header/ActionMenu.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/public/js/cat_source/es6/components/header/ActionMenu.js b/public/js/cat_source/es6/components/header/ActionMenu.js index f7077e627c..2a7da83ba3 100644 --- a/public/js/cat_source/es6/components/header/ActionMenu.js +++ b/public/js/cat_source/es6/components/header/ActionMenu.js @@ -51,9 +51,11 @@ export const ActionMenu = ({ const getQualityReportMenu = () => { return (
    -
  • - Revise -
  • + {jobUrls.revise_urls ? ( +
  • + Revise +
  • + ) : null}
  • Translate
  • From 5e7bbedf838fff9ba8a268016cd8aff4d4e07bbc Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 14 Oct 2024 13:03:55 +0200 Subject: [PATCH 5/8] MATECAT-2SC: fix transformToHtml exception --- .../utils/DraftMatecatUtils/tagUtils.js | 90 ++++++++++--------- 1 file changed, 46 insertions(+), 44 deletions(-) diff --git a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/tagUtils.js b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/tagUtils.js index cd336243e8..f5823825c3 100644 --- a/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/tagUtils.js +++ b/public/js/cat_source/es6/components/segments/utils/DraftMatecatUtils/tagUtils.js @@ -11,53 +11,55 @@ import matchTagStructure from '../../../segments/utils/DraftMatecatUtils/matchTa export const transformTagsToHtml = (text, isRtl = 0) => { isRtl = !!isRtl - try { - for (let key in tagSignatures) { - const { - placeholderRegex, - decodeNeeded, - style, - placeholder, - regex, - styleRTL, - selfClosing, - } = tagSignatures[key] - if (placeholderRegex) { - let globalRegex = new RegExp( - placeholderRegex.source, - placeholderRegex.flags + 'g', - ) - text = text.replace(globalRegex, (match, text) => { - let tagText = decodeNeeded - ? Base64.decode(text).replace(//g, '>') // Forza conversione angolari in < o > [XLIFF 2.0] Tag senza dataref - : selfClosing - ? text - : match - return ( - '' + - tagText + - '' + if (text) { + try { + for (let key in tagSignatures) { + const { + placeholderRegex, + decodeNeeded, + style, + placeholder, + regex, + styleRTL, + selfClosing, + } = tagSignatures[key] + if (placeholderRegex) { + let globalRegex = new RegExp( + placeholderRegex.source, + placeholderRegex.flags + 'g', ) - }) - } else if (regex) { - let globalRegex = new RegExp(regex) - text = text.replace(globalRegex, (match) => { - let tagText = placeholder ? placeholder : match - return ( - '' + - tagText + - '' - ) - }) + text = text.replace(globalRegex, (match, text) => { + let tagText = decodeNeeded + ? Base64.decode(text).replace(//g, '>') // Forza conversione angolari in < o > [XLIFF 2.0] Tag senza dataref + : selfClosing + ? text + : match + return ( + '' + + tagText + + '' + ) + }) + } else if (regex) { + let globalRegex = new RegExp(regex) + text = text.replace(globalRegex, (match) => { + let tagText = placeholder ? placeholder : match + return ( + '' + + tagText + + '' + ) + }) + } } + text = matchTag(text) + } catch (e) { + console.error('Error parsing tag in transformTagsToHtml function', e) } - text = matchTag(text) - } catch (e) { - console.error('Error parsing tag in transformTagsToHtml function', e) } return text } From 68024f7f37ffe0faac43ce8eeea97ec7ba10b196 Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 14 Oct 2024 15:11:02 +0200 Subject: [PATCH 6/8] MATECAT-43D: speech to text --- public/js/cat_source/es6/utils/speech2text.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/cat_source/es6/utils/speech2text.js b/public/js/cat_source/es6/utils/speech2text.js index 6f304c0d04..65ccd1c139 100644 --- a/public/js/cat_source/es6/utils/speech2text.js +++ b/public/js/cat_source/es6/utils/speech2text.js @@ -88,7 +88,7 @@ const Speech2Text = { }, startSpeechRecognition: function (microphone) { const segment = SegmentStore.getCurrentSegment() - + if (!segment) return if (!microphone.hasClass('micSpeechActive')) { microphone.addClass('micSpeechActive') Speech2Text.animateSpeechActive() From 4522688a08e49e42f62fe31fd0d97bba852d4f21 Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 14 Oct 2024 15:24:33 +0200 Subject: [PATCH 7/8] MATECAT-3Z4: segment filter --- public/js/cat_source/es6/actions/SegmentActions.js | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/public/js/cat_source/es6/actions/SegmentActions.js b/public/js/cat_source/es6/actions/SegmentActions.js index b3127eb09f..384fd36bf6 100644 --- a/public/js/cat_source/es6/actions/SegmentActions.js +++ b/public/js/cat_source/es6/actions/SegmentActions.js @@ -39,6 +39,7 @@ import {getSegmentsIssues} from '../api/getSegmentsIssues' import {sendSegmentVersionIssue} from '../api/sendSegmentVersionIssue' import {getSegmentVersionsIssues} from '../api/getSegmentVersionsIssues' import {sendSegmentVersionIssueComment} from '../api/sendSegmentVersionIssueComment' +import SegmentFilter from '../components/header/cattol/segment_filter/segment_filter' const SegmentActions = { localStorageCommentsClosed: @@ -1401,7 +1402,11 @@ const SegmentActions = { localStorage.setItem(this.localStorageCommentsClosed, true) }, gotoNextSegment() { - if (SegmentsFilterUtil.enabled() && SegmentsFilterUtil.filtering()) { + if ( + SegmentsFilterUtil.enabled() && + SegmentsFilterUtil.filtering() && + SegmentsFilterUtil.open + ) { SegmentsFilterUtil.gotoNextSegment(SegmentStore.getCurrentSegmentId()) } else { let next = SegmentStore.getNextSegment() @@ -1424,7 +1429,11 @@ const SegmentActions = { // this is expected behaviour in review // change this if we are filtering, go to the next // segment, assuming the sample is what we want to revise. - if (SegmentsFilterUtil.enabled() && SegmentsFilterUtil.filtering()) { + if ( + SegmentsFilterUtil.enabled() && + SegmentsFilterUtil.filtering() && + SegmentsFilterUtil.open + ) { SegmentsFilterUtil.gotoNextTranslatedSegment(sid) } else { const nextTranslatedSegment = SegmentStore.getNextSegment({ From ae5ac6935abdc2525d63981f2c270973bf3704d8 Mon Sep 17 00:00:00 2001 From: riccio82 Date: Mon, 14 Oct 2024 15:31:00 +0200 Subject: [PATCH 8/8] MATECAT-2NN: select prev segment --- .../js/cat_source/es6/stores/SegmentStore.js | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/public/js/cat_source/es6/stores/SegmentStore.js b/public/js/cat_source/es6/stores/SegmentStore.js index e86bf88412..8d7aa12b7d 100644 --- a/public/js/cat_source/es6/stores/SegmentStore.js +++ b/public/js/cat_source/es6/stores/SegmentStore.js @@ -279,21 +279,19 @@ const SegmentStore = assign({}, EventEmitter.prototype, { let selectedSegment = this._segments.find((segment) => { return segment.get('selected') === true }) - if (!selectedSegment) { - selectedSegment = this.getCurrentSegment() - } else if (selectedSegment) { - selectedSegment = selectedSegment.toJS() - } else { - return - } - let prev = this.getPrevSegment(selectedSegment.sid) - if (prev) { - var index = this.getSegmentIndex(prev.sid) - this._segments = this._segments.map((segment) => - segment.set('selected', false), - ) - this._segments = this._segments.setIn([index, 'selected'], true) - return prev.sid + selectedSegment = !selectedSegment + ? this.getCurrentSegment() + : selectedSegment.toJS() + if (selectedSegment) { + let prev = this.getPrevSegment(selectedSegment.sid) + if (prev) { + var index = this.getSegmentIndex(prev.sid) + this._segments = this._segments.map((segment) => + segment.set('selected', false), + ) + this._segments = this._segments.setIn([index, 'selected'], true) + return prev.sid + } } }, getSelectedSegmentId() {