Petite modification dans le client Scrutari

This commit is contained in:
Vincent Calame 2023-07-24 20:00:43 +02:00 committed by root
parent 8debdd2696
commit 764ea3a040
2 changed files with 55 additions and 60 deletions

View File

@ -54,8 +54,8 @@ Scrutari.Lav.init = function (client) {
}));
}
client.initForms();
client.initButtons(Scrutari.Lav.actionHandler);
client.initChangeListeners(Scrutari.Lav.changeHandler);
client.initButtons();
client.initChangeListeners();
client.checkInitialQuery();
function _initLav() {
@ -134,7 +134,7 @@ Scrutari.Lav.newResultProcess = function (client, scrutariResult, searchOrigin)
};
/**
* Personnalisation des actions sur les boutons, passée à client.initButtons()
* Actions propres au client
*/
Scrutari.Lav.actionHandler = function (client, button, action, target) {
switch(action) {
@ -148,7 +148,7 @@ Scrutari.Lav.actionHandler = function (client, button, action, target) {
};
/**
* Personnalisation des écouteurs actions sur les boutons, passée à client.initButtons()
* Personnalisation des écouteurs actions sur les boutons
*/
Scrutari.Lav.changeHandler = function (client, element, name) {
switch(name) {
@ -182,47 +182,6 @@ Scrutari.Lav.changeHandler = function (client, element, name) {
}
};
/**
* Objet définissant les points d'entrée (hook) particuliers, transmis à la configuration
*/
Scrutari.Lav.HOOKS = {
completeFiche : function (scrutariResult, fiche, categoryName) { //Extrait le numéro du titre
let start = fiche.mtitre[0];
let numero = "";
if (start.startsWith("#")) {
let idx = start.indexOf("-");
if (idx > 0) {
numero = start.substring(0, idx).trim();
fiche.mtitre[0] = start.substring(idx + 1);
}
}
fiche._numero = numero;
}
};
/**
* Objet centralisant les fonctions surchargées du client
*/
Scrutari.Lav.FUNCTIONS = {
uiInit: function (client) {
Scrutari.Lav.init(client);
},
ignoreElement: null,
isFilterEnable: null,
mainsearchResultCallback: function (client, scrutariResult) {
$("#scrutari_lav_sequence").html(Scrutari.Lav.formatSearchSequence(client, scrutariResult));
},
mainsearchErrorCallback: null,
subsearchResultCallback: null,
subsearchErrorCallback: null,
initFilterByQuery: null,
newResultProcess: function (client, scrutariResult, searchOrigin) {
return Scrutari.Lav.newResultProcess(client, scrutariResult, searchOrigin);
},
startLoading: null,
endLoading: null
};
Scrutari.Lav.getConfigOptions = function () {
return {
paginationLength: Scrutari.Lav.PAGINATION_LENGTH,
@ -237,7 +196,36 @@ Scrutari.Lav.getInitOptions = function () {
ficheBodyList: "fiche_mtitre,fiche_msoustitre,libreavous_start_ul,fiche_primaryattributearray,fiche_mcomplementarray,fiche_secondaryattributearray,fiche_motclearray,fiche_bythesaurusarray,libreavous_end_ul", //Ajout de libreavous_start_ul et libreavous_end_ul, retrait de fiche_year,
historyAtLast: true,
ignoreList: "area-title,area-stats,modal-*", //Utilisé en mode développement
hooks: Scrutari.Lav.HOOKS,
functions: Scrutari.Lav.FUNCTIONS
hooks: {
completeFiche : function (scrutariResult, fiche, categoryName) { //Extrait le numéro du titre
let start = fiche.mtitre[0];
let numero = "";
if (start.startsWith("#")) {
let idx = start.indexOf("-");
if (idx > 0) {
numero = start.substring(0, idx).trim();
fiche.mtitre[0] = start.substring(idx + 1);
}
}
fiche._numero = numero;
}
},
functions: {
uiInit: Scrutari.Lav.init,
ignoreElement: null,
isFilterEnable: null,
mainsearchResultCallback: function (client, scrutariResult) {
$("#scrutari_lav_sequence").html(Scrutari.Lav.formatSearchSequence(client, scrutariResult));
},
mainsearchErrorCallback: null,
subsearchResultCallback: null,
subsearchErrorCallback: null,
initFilterByQuery: null,
newResultProcess: Scrutari.Lav.newResultProcess,
startLoading: null,
endLoading: null,
actionHandler: Scrutari.Lav.actionHandler,
changeHandler: Scrutari.Lav.changeHandler
}
};
};

View File

@ -1,4 +1,4 @@
/* version: 4209 */
/* version: r4220 */
var Scrutari = {};
Scrutari.log = function (msg) {
if ((console) && (console.log)) {
@ -2081,7 +2081,9 @@ Scrutari.Client = function (scrutariConfig, clientId) {
modalAction: Scrutari.DefaultUi.modalAction,
newResultProcess: Scrutari.DefaultUi.newResultProcess,
startLoading: Scrutari.DefaultUi.startLoading,
endLoading: Scrutari.DefaultUi.endLoading
endLoading: Scrutari.DefaultUi.endLoading,
actionHandler: Scrutari.DefaultUi.actionHandler,
changeHandler: Scrutari.DefaultUi.changeHandler
};
this.cssClasses = {
disabled: "scrutari-Disabled",
@ -2423,12 +2425,15 @@ Scrutari.Client.prototype.initForms = function () {
return false;
});
};
Scrutari.Client.prototype.initButtons = function (actionHandler) {
Scrutari.Client.prototype.initButtons = function () {
var client = this;
if (!actionHandler) {
actionHandler = _noneHandler;
}
$("#" + client.clientId).on("click", Scrutari.toCssQuery({scrutariButton: true}), function () {
let actionHandler;
if (client.functions.actionHandler) {
actionHandler = client.functions.actionHandler;
} else {
actionHandler = _noneHandler;
}
let button = this;
let action = this.dataset.scrutariButton;
let target = this.dataset.scrutariTarget;
@ -2490,12 +2495,15 @@ Scrutari.Client.prototype.initButtons = function (actionHandler) {
}
}
};
Scrutari.Client.prototype.initChangeListeners = function (changeHandler) {
Scrutari.Client.prototype.initChangeListeners = function () {
var client = this;
if (!changeHandler) {
changeHandler = _noneHandler;
}
$("#" + client.clientId).on("input", "input", function () {
let changeHandler;
if (client.functions.changeHandler) {
changeHandler = client.functions.changeHandler;
} else {
changeHandler = _noneHandler;
}
let element = this;
let name = this.name;
if (name) {
@ -3002,7 +3010,6 @@ Scrutari.Process.prototype.updateLinks = function () {
}
};
Scrutari.Process.prototype.addPaginations = function ($paginationBlock) {
Scrutari.log("original");
if (this.scrutariResult.getFicheGroupType() === 'category') {
this.addCategoryPaginations($paginationBlock);
} else {
@ -3061,8 +3068,8 @@ Scrutari.DefaultUi.init = function (client) {
var scrutariMeta = client.scrutariMeta;
$("#" + client.clientId).html(client.compileStructure("main"));
client.initForms();
client.initButtons(Scrutari.DefaultUi.actionHandler);
client.initChangeListeners(Scrutari.DefaultUi.changeHandler);
client.initButtons();
client.initChangeListeners();
Scrutari.DefaultUi.initMainTitle(client);
client.$count('stats-global', 'update', scrutariMeta.getGlobalFicheCount());
client.$hidden('init', 'show');