Implement global batch completion UI, enhance JavaScript handling, and increment version code to 4.72.784
This commit introduces a new user interface for displaying the completion status of global batch assignments, including success, warning, and error states. The CSS is updated to style the completion messages appropriately. Additionally, JavaScript functions are added to manage the display of these messages based on assignment results. Localization keys are also added for improved user feedback. The version code is incremented to 4.72.784 to reflect these changes.
This commit is contained in:
@ -386,6 +386,82 @@
|
||||
}
|
||||
}
|
||||
|
||||
function bibEscHtml(str) {
|
||||
return String(str == null ? '' : str)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"');
|
||||
}
|
||||
|
||||
function bibFinishGlobalBatchGo(runResults) {
|
||||
var totalAssigned = 0;
|
||||
var totalExpected = 0;
|
||||
var nbEpreuves = runResults ? runResults.length : 0;
|
||||
|
||||
(runResults || []).forEach(function (result) {
|
||||
totalAssigned += result.assigned || 0;
|
||||
totalExpected += result.total || 0;
|
||||
});
|
||||
|
||||
var remaining = Math.max(0, totalExpected - totalAssigned);
|
||||
var state = 'ok';
|
||||
var icon = '\u2713';
|
||||
var title = bibJs('jsGlobalBatchCompleteTitle') || 'Assignation terminée';
|
||||
var message = '';
|
||||
var summary = bibJsFmt(
|
||||
'jsGlobalBatchCompleteSummary',
|
||||
totalAssigned,
|
||||
totalExpected,
|
||||
nbEpreuves
|
||||
);
|
||||
|
||||
if (totalAssigned === 0 && totalExpected > 0) {
|
||||
state = 'error';
|
||||
icon = '!';
|
||||
message = bibJs('jsAssignNone') || bibJs('jsErrGeneric');
|
||||
} else if (remaining > 0) {
|
||||
state = 'warning';
|
||||
icon = '!';
|
||||
message = bibJsFmt('jsAssignPartial', totalAssigned, remaining);
|
||||
} else if (totalAssigned > 0) {
|
||||
message = bibJsFmt('jsAssignFull', totalAssigned);
|
||||
} else {
|
||||
state = 'error';
|
||||
icon = '!';
|
||||
message = bibJs('jsErrGeneric');
|
||||
}
|
||||
|
||||
bibBatchProgressForceHide();
|
||||
bibRemoveGlobalSimViews();
|
||||
|
||||
var reloadLabel = bibJs('jsGlobalBatchCompleteReload') || 'OK';
|
||||
var html = '<div class="bib-global-batch-complete bib-global-batch-complete--'
|
||||
+ bibEscHtml(state)
|
||||
+ '" role="status" aria-live="polite">'
|
||||
+ '<div class="bib-global-batch-complete__icon" aria-hidden="true">' + icon + '</div>'
|
||||
+ '<h3 class="bib-global-batch-complete__title">' + bibEscHtml(title) + '</h3>'
|
||||
+ '<p class="bib-global-batch-complete__message">' + bibEscHtml(message) + '</p>'
|
||||
+ '<p class="bib-global-batch-complete__summary">' + bibEscHtml(summary) + '</p>'
|
||||
+ '<button type="button" class="btn btn-primary bib-global-batch-complete__reload btn-global-batch-complete-reload">'
|
||||
+ bibEscHtml(reloadLabel)
|
||||
+ '</button>'
|
||||
+ '</div>';
|
||||
|
||||
var detailBody = document.getElementById('bib-tool-detail-body');
|
||||
if (detailBody) {
|
||||
detailBody.innerHTML = html;
|
||||
var detail = document.getElementById('bib-tool-detail');
|
||||
if (detail) {
|
||||
detail.classList.remove('bib-ui-hidden');
|
||||
detail.scrollIntoView({ behavior: 'smooth', block: 'start' });
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
location.reload();
|
||||
}
|
||||
|
||||
function bibRemoveGlobalSimViews() {
|
||||
document.querySelectorAll('.bib-global-sim-view').forEach(function (el) {
|
||||
el.remove();
|
||||
@ -1054,7 +1130,11 @@
|
||||
});
|
||||
|
||||
return chain.then(function () {
|
||||
bibBatchProgressShow(globalTotal, globalTotal);
|
||||
bibBatchProgressShow(
|
||||
globalTotal,
|
||||
globalTotal,
|
||||
bibJs('jsGlobalBatchFinalizing') || bibJs('jsLoaderWait')
|
||||
);
|
||||
|
||||
var refreshChain = Promise.resolve();
|
||||
runResults.forEach(function (result) {
|
||||
@ -1072,56 +1152,10 @@
|
||||
|
||||
return refreshChain.then(function () {
|
||||
if (typeof refreshBibAnomaliesPanel === 'function') {
|
||||
refreshBibAnomaliesPanel();
|
||||
return refreshBibAnomaliesPanel();
|
||||
}
|
||||
|
||||
var totalAssigned = 0;
|
||||
var totalExpected = 0;
|
||||
|
||||
runResults.forEach(function (result) {
|
||||
totalAssigned += result.assigned;
|
||||
totalExpected += result.total;
|
||||
});
|
||||
|
||||
var remaining = Math.max(0, totalExpected - totalAssigned);
|
||||
|
||||
bibInvalidateGlobalBatchPanel();
|
||||
return bibEnsureGlobalBatchPanelLoaded().then(function () {
|
||||
if (bibActiveTool === 'global_batch') {
|
||||
bibInvalidateToolSlot('global_batch');
|
||||
bibMountToolContent('global_batch');
|
||||
initModuleBibTippy(document.getElementById('bib-tool-detail'));
|
||||
}
|
||||
|
||||
return Promise.all([
|
||||
updateGlobalBatchAnalysis(),
|
||||
updateGlobalBatchGeneratedAnalysis()
|
||||
]).then(function () {
|
||||
var genSection = bibGetGlobalBatchGeneratedSection();
|
||||
var infoEl = genSection
|
||||
? genSection.querySelector('.bib-global-gen-batch__info')
|
||||
: null;
|
||||
|
||||
if (totalAssigned === 0 && totalExpected > 0) {
|
||||
var msgNone = bibJs('jsAssignNone') || bibJs('jsErrGeneric');
|
||||
if (infoEl) {
|
||||
bibSetGlobalBatchInfo(infoEl, msgNone, 'error');
|
||||
}
|
||||
alert(msgNone);
|
||||
} else if (remaining > 0) {
|
||||
var msgPartial = bibJsFmt('jsAssignPartial', totalAssigned, remaining);
|
||||
if (infoEl) {
|
||||
bibSetGlobalBatchInfo(infoEl, msgPartial, 'warning');
|
||||
}
|
||||
alert(msgPartial);
|
||||
} else if (totalAssigned > 0) {
|
||||
var msgFull = bibJsFmt('jsAssignFull', totalAssigned);
|
||||
if (infoEl) {
|
||||
bibSetGlobalBatchInfo(infoEl, msgFull, 'ok');
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
}).then(function () {
|
||||
bibFinishGlobalBatchGo(runResults);
|
||||
});
|
||||
});
|
||||
})
|
||||
@ -1213,7 +1247,11 @@
|
||||
});
|
||||
|
||||
return chain.then(function () {
|
||||
bibBatchProgressShow(globalTotal, globalTotal);
|
||||
bibBatchProgressShow(
|
||||
globalTotal,
|
||||
globalTotal,
|
||||
bibJs('jsGlobalBatchFinalizing') || bibJs('jsLoaderWait')
|
||||
);
|
||||
|
||||
var refreshChain = Promise.resolve();
|
||||
runResults.forEach(function (result) {
|
||||
@ -1231,38 +1269,10 @@
|
||||
|
||||
return refreshChain.then(function () {
|
||||
if (typeof refreshBibAnomaliesPanel === 'function') {
|
||||
refreshBibAnomaliesPanel();
|
||||
return refreshBibAnomaliesPanel();
|
||||
}
|
||||
|
||||
var panelRef = bibGetGlobalBatchExistingSection();
|
||||
var infoEl = panelRef ? panelRef.querySelector('.bib-global-batch__info') : null;
|
||||
var totalAssigned = 0;
|
||||
var totalExpected = 0;
|
||||
|
||||
runResults.forEach(function (result) {
|
||||
totalAssigned += result.assigned;
|
||||
totalExpected += result.total;
|
||||
});
|
||||
|
||||
var remaining = Math.max(0, totalExpected - totalAssigned);
|
||||
|
||||
return updateGlobalBatchAnalysis().then(function () {
|
||||
if (totalAssigned === 0 && totalExpected > 0) {
|
||||
var msgNone = bibJs('jsAssignNone') || bibJs('jsErrGeneric');
|
||||
bibSetGlobalBatchInfo(infoEl, msgNone, 'error');
|
||||
alert(msgNone);
|
||||
} else if (remaining > 0) {
|
||||
var msgPartial = bibJsFmt('jsAssignPartial', totalAssigned, remaining);
|
||||
bibSetGlobalBatchInfo(infoEl, msgPartial, 'warning');
|
||||
alert(msgPartial);
|
||||
} else if (totalAssigned > 0) {
|
||||
bibSetGlobalBatchInfo(
|
||||
infoEl,
|
||||
bibJsFmt('jsAssignFull', totalAssigned),
|
||||
'ok'
|
||||
);
|
||||
}
|
||||
});
|
||||
}).then(function () {
|
||||
bibFinishGlobalBatchGo(runResults);
|
||||
});
|
||||
});
|
||||
})
|
||||
@ -1287,6 +1297,12 @@
|
||||
});
|
||||
|
||||
moduleBib.addEventListener('click', function (e) {
|
||||
if (e.target.closest('.btn-global-batch-complete-reload')) {
|
||||
e.preventDefault();
|
||||
location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.target.closest('.bib-tool-detail__close')) {
|
||||
e.preventDefault();
|
||||
bibCloseTool();
|
||||
|
||||
Reference in New Issue
Block a user