Skip to content

Commit a07f894

Browse files
remove console info logs, optimize a loop
1 parent cf0604e commit a07f894

File tree

5 files changed

+28
-45
lines changed

5 files changed

+28
-45
lines changed

lib/AppContext.js

-14
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,6 @@ export default class AppContext {
377377
...enumResource,
378378
};
379379

380-
console.info(
381-
'Computed translation resources for:',
382-
currentLang,
383-
enumResource
384-
);
385380
});
386381

387382
// Generate translation maps between all possible language combinations
@@ -411,15 +406,6 @@ export default class AppContext {
411406
reverseNamespace,
412407
removeNumericKeys(reverseTranslationMap)
413408
);
414-
415-
console.info(
416-
`Added translation resources from ${sourceLang} to ${targetLang}:`,
417-
translationNamespace
418-
);
419-
console.info(
420-
`Added reverse translation resources from ${targetLang} to ${sourceLang}:`,
421-
reverseNamespace
422-
);
423409
});
424410
});
425411
}

lib/Toolbar.js

+13-18
Original file line numberDiff line numberDiff line change
@@ -113,18 +113,18 @@ class Toolbar {
113113
) => {
114114
// Helper function to translate a single value based on the current language and namespace
115115
const translateValue = (value) => {
116-
console.log(
117-
'executing translateValue for',
118-
value,
119-
i18next.options.resources
120-
);
121-
console.log(
122-
value,
123-
previousLocale,
124-
targetLocale,
125-
i18next.t(value, { lng: i18next.language, ns: 'reverse' }),
126-
i18next.t(value, { lng: i18next.language, ns: 'translation' })
127-
);
116+
// console.log(
117+
// 'executing translateValue for',
118+
// value,
119+
// i18next.options.resources
120+
// );
121+
// console.log(
122+
// value,
123+
// previousLocale,
124+
// targetLocale,
125+
// i18next.t(value, { lng: i18next.language, ns: 'reverse' }),
126+
// i18next.t(value, { lng: i18next.language, ns: 'translation' })
127+
// );
128128
// const namespace = i18next.language === 'default' ? 'reverse' : 'translation';
129129
return i18next.t(value, { lng: previousLocale, ns: namespace });
130130
};
@@ -140,7 +140,7 @@ class Toolbar {
140140
return dataHarmonizerData.map((row, row_index) => {
141141
return row.map((value, index) => {
142142
if (value != null && value != '' && isTranslatable[index]) {
143-
console.log(
143+
console.warn(
144144
`translating ${value} at ${index} (${this.context
145145
.getCurrentDataHarmonizer()
146146
.hot.getDataAtCell(row_index, index)})`
@@ -366,7 +366,6 @@ class Toolbar {
366366
context.addTranslationResources(context.template);
367367

368368
const dh = context.getCurrentDataHarmonizer();
369-
console.log("restartInterface", dh, context.getCurrentDataHarmonizer());
370369
this.updateGUI(dh, template_name, exportFormats);
371370
}
372371

@@ -386,7 +385,6 @@ class Toolbar {
386385
let jsonData;
387386
try {
388387
jsonData = JSON.parse(contentBuffer.text);
389-
console.log("jsonData", jsonData);
390388
} catch (error) {
391389
throw new Error('Invalid JSON data', error);
392390
}
@@ -436,7 +434,6 @@ class Toolbar {
436434
jsonData.Container[container_class],
437435
locale
438436
);
439-
console.log("list_data", list_data);
440437
if (list_data) context.dhs[dh].hot.loadData(list_data);
441438
else
442439
alert(
@@ -481,7 +478,6 @@ class Toolbar {
481478
// default schema is guaranteed to feature the Container
482479
schema_container.attributes
483480
).reduce((acc, [cls_key, { name, range }]) => {
484-
console.log(cls_key, { name, range });
485481

486482
// TODO: check if container attributes always have ranges?
487483
if (typeof range !== 'undefined') {
@@ -932,7 +928,6 @@ class Toolbar {
932928
)) {
933929
translationSelect.append(new Option(nativeName, langcode));
934930
}
935-
console.log('currentTranslationVal', currentTranslationVal);
936931
if (currentTranslationVal) {
937932
translationSelect.val(currentTranslationVal);
938933
translationSelect.trigger('input');

lib/utils/1m.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -711,7 +711,7 @@ export class OneToManyEventTracker extends EventTracker {
711711
712712
Later we can add an efficiency function that the filtering of records isn’t performed on a subordinate table until the user actually highlights the subordinate table’s tab such that they can see the data. But initially we don’t need that fancy just-in-time thing.
713713
*/
714-
console.log(
714+
console.warn(
715715
`Multi-row selection detected from row ${row} to ${row2}. Emitting empty Read event.`
716716
);
717717

lib/utils/fields.js

+14-10
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,10 @@ export function dataArrayToObject(dataArray, fields, options = {}) {
136136
* @param {Object} fields A flat version of data.js.
137137
* @return {Map<String, Integer>} Dictionary of all fields.
138138
*/
139-
export function fieldNameMapToIndex(fields) {
139+
export function fieldNameMapFromIndex(fields) {
140140
const map = {};
141141
for (const [fieldIndex, field] of fields.entries()) {
142-
map[field.name] = fieldIndex;
142+
map[fieldIndex] = field.name;
143143
}
144144
return map;
145145
}
@@ -149,10 +149,10 @@ export function fieldNameMapToIndex(fields) {
149149
* @param {Object} fields A flat version of data.js.
150150
* @return {Map<String, Integer>} Dictionary of all fields.
151151
*/
152-
export function fieldTitleMapToIndex(fields) {
152+
export function fieldTitleMapFromIndex(fields) {
153153
const map = {};
154154
for (const [fieldIndex, field] of fields.entries()) {
155-
map[field.title] = fieldIndex;
155+
map[fieldIndex] = field.title;
156156
}
157157
return map;
158158
}
@@ -163,8 +163,8 @@ export function fieldTitleMapToIndex(fields) {
163163
* @return {Map<Integer, Map<String, String>>}
164164
*/
165165
export function fieldSymbolsAtIndexMap(fields) {
166-
const invertedFieldTitleIndex = invert(fieldTitleMapToIndex(fields));
167-
const invertedFieldNameMapToIndex = invert(fieldNameMapToIndex(fields));
166+
const invertedFieldTitleIndex = fieldTitleMapFromIndex(fields);
167+
const invertedFieldNameMapToIndex = fieldNameMapFromIndex(fields);
168168
if (Object.keys(invertedFieldTitleIndex).length != Object.keys(invertedFieldNameMapToIndex).length) {
169169
console.error("Field Title and Field Index maps are different sizes!");
170170
} else {
@@ -190,8 +190,12 @@ export function slotNamesForTitlesMap(fields) {
190190
}
191191

192192
export function slotTitleForNameMap(fields) {
193-
return invert(slotNamesForTitlesMap(fields));
194-
}
193+
const fieldSymbolsAtIndex = fieldSymbolsAtIndexMap(fields);
194+
let tempObject = {};
195+
for (let index in fieldSymbolsAtIndex) {
196+
tempObject[fieldSymbolsAtIndex[index].slotName] = fieldSymbolsAtIndex[index].slotTitle;
197+
}
198+
return tempObject;}
195199

196200
export function findFieldIndex(fields, key, translationMap = {}) {
197201
// First try to find a direct match.
@@ -253,9 +257,9 @@ export function dataObjectToArray(dataObject, fields, options = {}) {
253257
return datatypes.stringify(originalValue, datatype);
254258
};
255259

260+
const slotNamesForTitles = slotNamesForTitlesMap(fields)
256261
for (const [slotTitle, value] of Object.entries(dataObject)) {
257-
console.log(slotTitle, slotNamesForTitlesMap(fields))
258-
const slotName = slotNamesForTitlesMap(fields)[slotTitle];
262+
const slotName = slotNamesForTitles[slotTitle];
259263
const fieldIdx = findFieldIndex(fields, slotName, translationMap);
260264

261265
if (fieldIdx < 0) {

lib/utils/templates.js

-2
Original file line numberDiff line numberDiff line change
@@ -412,13 +412,11 @@ class TemplateProxy {
412412
* @throws {LocaleNotSupportedError} If the provided locale is not supported by the template.
413413
*/
414414
updateLocale(newLocale = null) {
415-
console.log("updateLocale", newLocale, this._name);
416415
// HACK. rewrite code to allow 'default' to be a locale when accessed to produce this._defaultData
417416
if (newLocale == null || newLocale == 'en') {
418417
this._locale = null;
419418
} else {
420419
const bestLocale = findBestLocaleMatch(this._locales, [newLocale]);
421-
console.log("bestLocale", bestLocale);
422420
if (bestLocale !== null) {
423421
this._locale = bestLocale;
424422
} else {

0 commit comments

Comments
 (0)