mirror of
https://github.com/wekan/wekan.git
synced 2026-11-24 09:59:47 -05:00
Org mode files from Emacs, Orgzly, Beorg or organice import as boards: level-1 headings become lists and level-2 headings cards. TODO keywords, including those a #+TODO line declares, decide the done tag; [#A] priorities become priority:A labels and :tags: labels. SCHEDULED, DEADLINE and CLOSED become the start, due and end dates, and a :CREATED: property the creation date. Body text becomes the description, and its - [ ] checkboxes and childless level-3 headings the card's checklist; a level-3 heading with children becomes a checklist of its own. #+TITLE names the board. Timestamps carry no zone in Org and are read and written as UTC. Repeaters, warning delays and text outside cards are reported in the loss report. Export writes the same outline. tests/orgMode.test.cjs covers custom keywords, localized day names, the round trip and the negatives. A Playwright case imports a file through the page, and the export audit fetches the new format. New instruction text is in English, pending Transifex. Thanks to xet7 !
25 lines
1.8 KiB
JavaScript
25 lines
1.8 KiB
JavaScript
// Shape validation before creating a board. Unknown/empty objects must not
|
|
// report a successful import which silently contains no source records.
|
|
export function validateImportSourceShape(source, value) {
|
|
const arrayAt = (object, key) => object && Array.isArray(object[key]);
|
|
let valid = false;
|
|
switch (source) {
|
|
case 'wekan': case 'trello': valid = arrayAt(value, 'cards') && arrayAt(value, 'lists'); break;
|
|
case 'kanboard': valid = arrayAt(value, 'tasks'); break;
|
|
case 'jira': valid = arrayAt(value, 'issues'); break;
|
|
case 'github': case 'gitlab': case 'gitea': case 'forgejo':
|
|
valid = Array.isArray(value) || arrayAt(value, 'issues'); break;
|
|
case 'deck': valid = arrayAt(value, 'stacks') || arrayAt(value?.board, 'stacks'); break;
|
|
case 'openproject': valid = Array.isArray(value) || arrayAt(value, 'elements') || arrayAt(value?._embedded, 'elements'); break;
|
|
case 'asana': valid = Array.isArray(value) || arrayAt(value, 'data'); break;
|
|
case 'zenkit': valid = Array.isArray(value) || arrayAt(value, 'items')
|
|
|| (arrayAt(value, 'elements') && (arrayAt(value, 'entries') || arrayAt(value, 'listEntries'))); break;
|
|
case 'csv': valid = Array.isArray(value) && value.length > 0 && value.every(Array.isArray); break;
|
|
case 'excel': valid = typeof value?.excelBase64 === 'string' && value.excelBase64.length > 0; break;
|
|
case 'markdown': case 'todotxt': case 'taskwarrior': case 'focalboard': case 'todoist': case 'orgmode': valid = typeof value === 'string' && value.trim().length > 0; break;
|
|
case 'leo': valid = typeof value === 'string' && /<leo_file[\s>]/.test(value); break;
|
|
case 'opml': valid = typeof value === 'string' && /<opml[\s>]/.test(value); break;
|
|
}
|
|
if (!valid) throw new Error(`Invalid ${source} import document shape`);
|
|
}
|