mirror of
				https://github.com/zadam/trilium.git
				synced 2025-11-03 20:06:08 +01:00 
			
		
		
		
	fix inverse relation detection in relation maps
This commit is contained in:
		
							
								
								
									
										35
									
								
								src/services/promoted_attribute_definition_parser.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										35
									
								
								src/services/promoted_attribute_definition_parser.js
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,35 @@
 | 
			
		||||
function parse(value) {
 | 
			
		||||
    const tokens = value.split(',').map(t => t.trim());
 | 
			
		||||
    const defObj = {};
 | 
			
		||||
 | 
			
		||||
    for (const token of tokens) {
 | 
			
		||||
        if (token === 'promoted') {
 | 
			
		||||
            defObj.isPromoted = true;
 | 
			
		||||
        }
 | 
			
		||||
        else if (['text', 'number', 'boolean', 'date', 'url'].includes(token)) {
 | 
			
		||||
            defObj.labelType = token;
 | 
			
		||||
        }
 | 
			
		||||
        else if (['single', 'multi'].includes(token)) {
 | 
			
		||||
            defObj.multiplicity = token;
 | 
			
		||||
        }
 | 
			
		||||
        else if (token.startsWith('precision')) {
 | 
			
		||||
            const chunks = token.split('=');
 | 
			
		||||
 | 
			
		||||
            defObj.numberPrecision = parseInt(chunks[1]);
 | 
			
		||||
        }
 | 
			
		||||
        else if (token.startsWith('inverse')) {
 | 
			
		||||
            const chunks = token.split('=');
 | 
			
		||||
 | 
			
		||||
            defObj.inverseRelation = chunks[1];
 | 
			
		||||
        }
 | 
			
		||||
        else {
 | 
			
		||||
            console.log("Unrecognized attribute definition token:", token);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    return defObj;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
module.exports = {
 | 
			
		||||
    parse
 | 
			
		||||
};
 | 
			
		||||
		Reference in New Issue
	
	Block a user