mirror of
https://github.com/wekan/wekan.git
synced 2026-11-07 11:02:33 -05:00
A CSV, TSV or Excel import now shows which column is which card field before importing, pre-filled from the header names - English names and WeKan's own export column names in every language - and asks for what is missing: a file with no list column gets one list, named on the page, instead of one list per row. Unused columns can be kept as text custom fields. The choice goes to the server as csvMapping, checked before anything is written, and the REST import and api.py take one too. The Owner column is applied, as are swimlane, received date, parent card, spent time, overtime and archived. A TSV value containing a comma stays one value. A dropdown custom field value that is not one of its items is skipped instead of failing the import. An Excel workbook is read sheet by sheet, its header found in row 1 or where WeKan's export puts it, in any language; formula cells are read as their results and rich text as text. WeKan's own Excel export imports, and a workbook with many boards - each on its own sheet, as Export all boards writes it - imports as many boards; the Activity sheet is skipped. Thanks to xet7 !
30 lines
1.1 KiB
JavaScript
30 lines
1.1 KiB
JavaScript
// Every language's names for the columns WeKan's CSV and Excel exports write
|
|
// (models/lib/csvImportMapping.js HEADER_I18N_KEYS). An export is written in
|
|
// the exporting user's language, so importing it back - possibly by somebody
|
|
// who uses another language - has to know all of them. Loaded once, on the
|
|
// first CSV or Excel import, and kept: the translation files do not change
|
|
// while the server runs.
|
|
import languages from '/imports/i18n/languages';
|
|
import { unwrapI18nModule } from '/imports/i18n/loadHelpers';
|
|
import { pickHeaderTranslations } from '/models/lib/csvImportMapping';
|
|
|
|
let loading = null;
|
|
|
|
export function importHeaderNames() {
|
|
if (!loading) {
|
|
loading = (async () => {
|
|
const out = {};
|
|
for (const [key, language] of Object.entries(languages)) {
|
|
if (!language || typeof language.load !== 'function') continue;
|
|
try {
|
|
out[key] = pickHeaderTranslations(unwrapI18nModule(await language.load()));
|
|
} catch (error) {
|
|
// One language that fails to load only loses its own names.
|
|
}
|
|
}
|
|
return out;
|
|
})();
|
|
}
|
|
return loading;
|
|
}
|