Widget Devoir Finition
This commit is contained in:
parent
cd298af142
commit
d0fe9faa62
@ -113,28 +113,69 @@ async function getDoneStatusValues(userId: number): Promise<Set<string>> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
if (!data.result || !Array.isArray(data.result)) {
|
if (!data.result || !Array.isArray(data.result)) {
|
||||||
|
console.log('[LEANTIME_TASKS] ⚠️ Invalid response format from getAllStatusLabelsByUserId, using fallback');
|
||||||
|
console.log('[LEANTIME_TASKS] Response structure:', JSON.stringify(data, null, 2));
|
||||||
logger.warn('[LEANTIME_TASKS] Invalid response format from getAllStatusLabelsByUserId, using fallback');
|
logger.warn('[LEANTIME_TASKS] Invalid response format from getAllStatusLabelsByUserId, using fallback');
|
||||||
// Fallback to default values if API fails
|
// Fallback to default values if API fails
|
||||||
return new Set(['0', '3', '5']);
|
return new Set(['0', '3', '5']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log('[LEANTIME_TASKS] 📋 getAllStatusLabelsByUserId response structure:', {
|
||||||
|
resultType: typeof data.result,
|
||||||
|
isArray: Array.isArray(data.result),
|
||||||
|
length: data.result.length,
|
||||||
|
firstItem: data.result[0] ? Object.keys(data.result[0]) : null,
|
||||||
|
});
|
||||||
|
|
||||||
// data.result is an array of projects, each with labels
|
// data.result is an array of projects, each with labels
|
||||||
// Each label has: id, name, statusType, class, etc.
|
// Each label has: id, name, statusType, class, etc.
|
||||||
data.result.forEach((project: any) => {
|
data.result.forEach((project: any, projectIndex: number) => {
|
||||||
|
console.log(`[LEANTIME_TASKS] 📁 Project ${projectIndex}:`, {
|
||||||
|
projectId: project.id,
|
||||||
|
projectName: project.name,
|
||||||
|
hasLabels: !!project.labels,
|
||||||
|
labelsType: typeof project.labels,
|
||||||
|
labelsIsArray: Array.isArray(project.labels),
|
||||||
|
labelsCount: project.labels ? (Array.isArray(project.labels) ? project.labels.length : 'not array') : 'no labels',
|
||||||
|
});
|
||||||
|
|
||||||
if (project.labels && Array.isArray(project.labels)) {
|
if (project.labels && Array.isArray(project.labels)) {
|
||||||
project.labels.forEach((label: any) => {
|
project.labels.forEach((label: any, labelIndex: number) => {
|
||||||
|
console.log(`[LEANTIME_TASKS] 🏷️ Label ${labelIndex} in project ${projectIndex}:`, {
|
||||||
|
labelId: label.id,
|
||||||
|
labelName: label.name,
|
||||||
|
labelStatusType: label.statusType,
|
||||||
|
labelClass: label.class,
|
||||||
|
allKeys: Object.keys(label),
|
||||||
|
});
|
||||||
|
|
||||||
// Check if the label name (case-insensitive) contains "done"
|
// Check if the label name (case-insensitive) contains "done"
|
||||||
const labelName = String(label.name || '').toLowerCase().trim();
|
const labelName = String(label.name || '').toLowerCase().trim();
|
||||||
if (labelName === 'done' || labelName.includes('done')) {
|
const statusType = String(label.statusType || '').toLowerCase().trim();
|
||||||
// The status value is typically in label.id or label.name
|
|
||||||
// We need to extract the numeric status value
|
if (labelName === 'done' || labelName.includes('done') || statusType === 'done') {
|
||||||
const statusValue = String(label.id || label.name || '');
|
// The status value might be in different places depending on Leantime version
|
||||||
doneStatusValues.add(statusValue);
|
// Try label.id, label.name, or extract from label structure
|
||||||
|
let statusValue = '';
|
||||||
|
|
||||||
// Also try to extract numeric value if it's in a format like "projectId-status"
|
// If label.id is a number, use it directly
|
||||||
const parts = statusValue.split('-');
|
if (typeof label.id === 'number') {
|
||||||
if (parts.length > 1) {
|
statusValue = String(label.id);
|
||||||
doneStatusValues.add(parts[parts.length - 1]); // Last part is usually the status
|
} else if (label.id) {
|
||||||
|
// If it's a string like "projectId-status", extract the status part
|
||||||
|
const idStr = String(label.id);
|
||||||
|
const parts = idStr.split('-');
|
||||||
|
statusValue = parts.length > 1 ? parts[parts.length - 1] : idStr;
|
||||||
|
} else if (label.name) {
|
||||||
|
// Try to extract numeric value from name
|
||||||
|
const nameStr = String(label.name);
|
||||||
|
const numMatch = nameStr.match(/\d+/);
|
||||||
|
statusValue = numMatch ? numMatch[0] : nameStr;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (statusValue) {
|
||||||
|
doneStatusValues.add(statusValue);
|
||||||
|
console.log(`[LEANTIME_TASKS] ✅ Found done status: ${statusValue} from label:`, label);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user