Organigramm Zeilenumbruch geht
Dieser Commit ist enthalten in:
@ -29,7 +29,7 @@ const upload = multer({
|
|||||||
function parseOrganizationFromText(text: string) {
|
function parseOrganizationFromText(text: string) {
|
||||||
const units: any[] = []
|
const units: any[] = []
|
||||||
const byCode = new Map<string, any>()
|
const byCode = new Map<string, any>()
|
||||||
const lines = text.split('\n').map(line => line.trim()).filter(line => line && line.length > 2)
|
const rawLines = text.split('\n').map(line => line.trim()).filter(line => line && line.length > 2)
|
||||||
|
|
||||||
const patterns = {
|
const patterns = {
|
||||||
direktor: /(Direktor|Director)\s*(LKA)?/i,
|
direktor: /(Direktor|Director)\s*(LKA)?/i,
|
||||||
@ -45,6 +45,49 @@ function parseOrganizationFromText(text: string) {
|
|||||||
'1': '#dc2626', '2': '#ea580c', '3': '#0891b2', '4': '#7c3aed', '5': '#0d9488', '6': '#be185d', 'ZA': '#6b7280'
|
'1': '#dc2626', '2': '#ea580c', '3': '#0891b2', '4': '#7c3aed', '5': '#0d9488', '6': '#be185d', 'ZA': '#6b7280'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Join wrapped description lines to their header lines to avoid losing info across line breaks
|
||||||
|
// Recognize headers that start a new unit and merge subsequent non-header lines into the previous one
|
||||||
|
const headerRegex = new RegExp(
|
||||||
|
'^(?:' +
|
||||||
|
'Abteilung\\s+(?:\\d+|Zentralabteilung)' +
|
||||||
|
'|Zentralabteilung\\b' +
|
||||||
|
'|ZA\\b' +
|
||||||
|
'|(?:Dezernat|Dez)\\s+' +
|
||||||
|
'|SG\\s+' +
|
||||||
|
'|TD\\s+' +
|
||||||
|
'|Direktor' +
|
||||||
|
'|Director' +
|
||||||
|
'|Leitungsstab' +
|
||||||
|
'|LStab' +
|
||||||
|
'|Führungsgruppe' +
|
||||||
|
'|Personalrat' +
|
||||||
|
'|Schwerbehindertenvertretung' +
|
||||||
|
'|Datenschutzbeauftrag' +
|
||||||
|
'|Gleichstellungsbeauftrag' +
|
||||||
|
'|Innenrevision' +
|
||||||
|
'|IUK-Lage' +
|
||||||
|
')',
|
||||||
|
'i'
|
||||||
|
)
|
||||||
|
const lines: string[] = []
|
||||||
|
for (const original of rawLines) {
|
||||||
|
const line = original.replace(/[–—]/g, '-')
|
||||||
|
if (lines.length === 0 || headerRegex.test(line)) {
|
||||||
|
lines.push(line)
|
||||||
|
} else {
|
||||||
|
// continuation line: append to previous with spacing; handle hyphenation
|
||||||
|
const lastIdx = lines.length - 1
|
||||||
|
const prev = lines[lastIdx]
|
||||||
|
if (/[-–—]$/.test(prev)) {
|
||||||
|
lines[lastIdx] = prev.replace(/[-–—]$/, '') + line
|
||||||
|
} else if (/[,:;]$/.test(prev)) {
|
||||||
|
lines[lastIdx] = prev + ' ' + line
|
||||||
|
} else {
|
||||||
|
lines[lastIdx] = prev + ' ' + line
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const ensure = (u: any) => {
|
const ensure = (u: any) => {
|
||||||
const existing = byCode.get(u.code)
|
const existing = byCode.get(u.code)
|
||||||
if (existing) {
|
if (existing) {
|
||||||
|
|||||||
In neuem Issue referenzieren
Einen Benutzer sperren