Skip to content

Commit 45a2608

Browse files
authored
Merge pull request #127 from LuCEresearchlab/highlighting-fixes
Highlighting fixes
2 parents 8760dac + f7e1fa1 commit 45a2608

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

frontend/src/components/v2/tagger_component/ClusterView.tsx

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,9 +120,12 @@ function ClusterItem({answer, taggingClusterSession, dispatchTaggingClusterSessi
120120
const misconception = getCurrentMisconception(taggingClusterSession)
121121
if (misconception == null) return
122122

123+
const start: number = answer.data[e.start] == ' ' ? e.start + 1 : e.start
124+
const end: number = answer.data[e.end] == ' ' ? e.end - 1 : e.end
125+
123126
const newRange: HighlightRangeColor = {
124-
start: e.start,
125-
end: e.end,
127+
start: start,
128+
end: end,
126129
misconception: misconception,
127130
color: taggingClusterSession.currentColor
128131
}
@@ -200,18 +203,20 @@ function ClusterItem({answer, taggingClusterSession, dispatchTaggingClusterSessi
200203
// hack to support indexes for words
201204
if (command.startsWith('' + displayKey + 'h')) {
202205
let counter: number = 0
203-
letters.forEach(letter => {
206+
letters.forEach((letter: any) => {
204207
const content = letter.textContent
205208
if (content == ' ') {
206209
counter++
207210
letter.textContent = `[${counter}] `
211+
letter.style.color = HIGHLIGHT_COLOR_ELEMENT
208212
}
209213
})
210214
} else {
211-
letters.forEach(letter => {
215+
letters.forEach((letter: any) => {
212216
const content = letter.textContent
213217
if (content?.indexOf(' ') != -1) {
214218
letter.textContent = ' '
219+
letter.style.color = ""
215220
}
216221
})
217222
}
@@ -229,7 +234,7 @@ function ClusterItem({answer, taggingClusterSession, dispatchTaggingClusterSessi
229234
}}>
230235
<KeyIndication
231236
displayKey={"" + displayKey}
232-
highlighted={stringEquals('' + displayKey + 'h', localCommand)}
237+
highlighted={localCommand.startsWith('' + displayKey + 'h')}
233238
/>
234239
<TruthCircle value={answer.picked}/>
235240
<div id={"Highlightable|" + displayKey} style={{padding: 'inherit'}}>

frontend/src/helpers/PostHelper.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ const post_answer_url = TAGGING_SERVICE_URL + '/datasets/tagged-answer'
88

99

1010
function post(url: string, data: any) {
11-
console.log('posting to ' + url)
12-
console.log(data)
1311
fetch(url, {
1412
method: 'POST',
1513
headers: {
1614
'Content-Type': 'application/json;charset=utf-8'
1715
},
1816
body: JSON.stringify(data)
19-
}).then((response: Response) => console.log(response.status));
17+
}).then((response: Response) => {
18+
if (response.status != 200) console.log(response.status)
19+
});
2020
}
2121

2222
export function postHelper(dataset_id: string,
@@ -45,9 +45,6 @@ export function postClusters(dataset_id: string,
4545
question_id: string,
4646
user_id: string,
4747
clusters: Cluster[]) {
48-
console.log(`posting to ${TAGGING_SERVICE_URL}/clusters/dataset/${dataset_id}/question/${question_id}/user/${
49-
user_id}`)
50-
console.log(clusters)
5148
post(`${TAGGING_SERVICE_URL}/clusters/dataset/${dataset_id}/question/${question_id}/user/${user_id}`,
5249
clusters)
5350
}

frontend/src/model/TaggingClusterSession.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,6 @@ function init(state: TaggingClusterSession,
106106
currentColor: string,
107107
history: string[]
108108
}) {
109-
console.log("init")
110109
return {
111110
...state,
112111
dataset_id: payload.dataset_id,
@@ -138,7 +137,6 @@ function setTags(state: TaggingClusterSession, tags: (string | null)[]): Tagging
138137
const new_tags = loadedTagsFormatAndSet(state, tags)
139138

140139
if (arrayFilteredNotNullEquals(new_tags, state.tags)) return state // no change
141-
console.log("setTags")
142140
return {
143141
...state,
144142
tags: new_tags,
@@ -147,7 +145,6 @@ function setTags(state: TaggingClusterSession, tags: (string | null)[]): Tagging
147145

148146
function setRangesList(state: TaggingClusterSession, rangesList: HighlightRange[][]): TaggingClusterSession {
149147
if (arrayFilteredNotNullEquals(rangesList, state.tags)) return state
150-
console.log("setRangesList")
151148
return {
152149
...state,
153150
rangesList
@@ -159,7 +156,6 @@ function setRanges(state: TaggingClusterSession, payload: { answer: Answer, rang
159156
const ranges: HighlightRange[] = payload.ranges
160157
const idx = getCurrentCluster(state).answers.findIndex(ans => stringEquals(ans.answer_id, answer.answer_id))
161158
if (idx === -1) return state
162-
console.log("setRanges")
163159
const new_ranges = [...state.rangesList]
164160
new_ranges[idx] = ranges
165161
return {
@@ -176,7 +172,6 @@ function setTagsAndRanges(state: TaggingClusterSession,
176172
ranges: HighlightRange[]
177173
}): TaggingClusterSession {
178174

179-
console.log("setTagsAndRanges")
180175

181176
const answer: Answer = payload.answer
182177
const tags: (string | null)[] = payload.tags

0 commit comments

Comments
 (0)