MCPcopy Create free account
hub / github.com/TechJeeper/Printventory / buildParentModelDisplayRecords

Function buildParentModelDisplayRecords

renderer.js:19147–19183  ·  view source on GitHub ↗
(models)

Source from the content-addressed store, hash-verified

19145 // Always create tags item and load asynchronously if needed
19146 const tagsItem = document.createElement('div');
19147 tagsItem.className = 'metadata-item tags-item';
19148 tagsItem.style.gridColumn = '1 / -1'; // Span both columns like other metadata
19149
19150 if (tagsDisplay) {
19151 // Tags already available, display them immediately
19152 const tagNamesForDisplay = model.tags
19153 .map(t => (typeof t === 'string' ? t : (t && (t.name || t)) || ''))
19154 .filter(Boolean);
19155 tagNamesForDisplay.sort((a, b) => a.localeCompare(b));
19156 tagsItem.innerHTML = `
19157 <span class="metadata-icon">🏷️</span>
19158 <span class="metadata-value tags-info" style="color: #ccc" title=""></span>
19159 `;
19160 metadataContainer.appendChild(tagsItem);
19161 const tagsValueSpanSync = tagsItem.querySelector('.tags-info');
19162 if (tagsValueSpanSync) {
19163 fillTagsWithFilterLinks(tagsValueSpanSync, tagNamesForDisplay);
19164 tagsValueSpanSync.setAttribute('title', tagsDisplay);
19165 }
19166 } else {
19167 // Create item and load tags asynchronously
19168 tagsItem.innerHTML = `
19169 <span class="metadata-icon">🏷️</span>
19170 <span class="metadata-value tags-info" style="color: #666"></span>
19171 `;
19172 metadataContainer.appendChild(tagsItem);
19173
19174 // Load tags asynchronously - get model ID first if needed
19175 const loadTags = async () => {
19176 try {
19177 let modelId = model.id;
19178
19179 // If model.id doesn't exist, get the model from database using filePath
19180 if (!modelId && model.filePath) {
19181 const fullModel = await window.electron.getModel(model.filePath);
19182 if (fullModel && fullModel.id) {
19183 modelId = fullModel.id;
19184 // Also check if tags are already in the full model
19185 if (fullModel.tags && Array.isArray(fullModel.tags) && fullModel.tags.length > 0) {
19186 const tagNames = fullModel.tags.map(t => (typeof t === 'string' ? t : (t.name || t))).filter(Boolean);

Callers 2

renderVirtualGridFunction · 0.85
renderVisibleItemsFunction · 0.85

Calls 5

getGridModelDedupeKeyFunction · 0.85
getModelRenderKeyFunction · 0.85
getParentModelGroupKeyFunction · 0.85
getParentModelGroupLabelFunction · 0.85

Tested by

no test coverage detected