« Module:Infobox/Configs/Personnage » : différence entre les versions
De Nefald
Autres actions
Aucun résumé des modifications |
Aucun résumé des modifications |
||
| (2 versions intermédiaires par le même utilisateur non affichées) | |||
| Ligne 1 : | Ligne 1 : | ||
local config = { | local config = { | ||
titre = function(args) | titre = function(args) | ||
return args.nom or '{{PAGENAME}}' | return args.nom or '{{PAGENAME}}' | ||
end, | end, | ||
icone = { | icone = { | ||
type = 'fas', | type = 'fas', | ||
nom = 'person' | nom = 'person' | ||
}, | }, | ||
image = function(args) | image = function(args) | ||
if args.image then | if args.image then | ||
| Ligne 17 : | Ligne 17 : | ||
end, | end, | ||
-- | -- STATUT DU PERSONNAGE | ||
statutField = { | |||
required = false, | |||
allowedValues = { | |||
['vivant'] = { display = 'Vivant', category = 'Personnage vivant' }, | |||
['décédé'] = { display = 'Décédé', category = 'Personnage décédé' }, | |||
['disparu'] = { display = 'Disparu', category = 'Personnage disparu' }, | |||
['immortel'] = { display = 'Immortel', category = 'Personnage immortel' } | |||
} | |||
}, | |||
-- CATÉGORIES AUTOMATIQUES (STATUT UNIQUEMENT) | |||
categories = function(args, config, frame) | categories = function(args, config, frame) | ||
local cats = {} | local cats = {} | ||
local title = mw.title.getCurrentTitle() | local title = mw.title.getCurrentTitle() | ||
-- | -- catégories uniquement namespace principal | ||
if title.namespace ~= 0 then | if title.namespace ~= 0 then | ||
return cats | return cats | ||
end | end | ||
-- | -- catégorie selon statut | ||
if args. | if args.statut and config.statutField and config.statutField.allowedValues then | ||
local | local cleanStatut = mw.text.trim(mw.ustring.lower(args.statut)) | ||
local | local statutDef = config.statutField.allowedValues[cleanStatut] | ||
if | |||
table.insert(cats, | if statutDef and statutDef.category then | ||
table.insert(cats, statutDef.category) | |||
end | end | ||
end | end | ||
| Ligne 49 : | Ligne 62 : | ||
{ cle = 'lieu_naissance', label = 'Lieu de naissance' }, | { cle = 'lieu_naissance', label = 'Lieu de naissance' }, | ||
{ cle = 'lieu_residence', label = 'Lieu de résidence' }, | { cle = 'lieu_residence', label = 'Lieu de résidence' }, | ||
{ cle = 'statut', label = 'Statut' } | { cle = 'statut', label = 'Statut' } | ||
} | } | ||
}, | }, | ||
| Ligne 58 : | Ligne 71 : | ||
{ cle = 'organisation', label = 'Organisation' }, | { cle = 'organisation', label = 'Organisation' }, | ||
{ cle = 'role', label = 'Rôle' }, | { cle = 'role', label = 'Rôle' }, | ||
{ cle = 'croyances', label = 'Croyances' } | { cle = 'croyances', label = 'Croyances' } | ||
} | } | ||
}, | }, | ||
| Ligne 67 : | Ligne 80 : | ||
{ cle = 'conjoint', label = 'Conjoint' }, | { cle = 'conjoint', label = 'Conjoint' }, | ||
{ cle = 'parents', label = 'Parents' }, | { cle = 'parents', label = 'Parents' }, | ||
{ cle = 'enfants', label = 'Enfants' } | { cle = 'enfants', label = 'Enfants' } | ||
} | } | ||
}, | }, | ||
| Ligne 76 : | Ligne 89 : | ||
{ cle = 'taille', label = 'Taille' }, | { cle = 'taille', label = 'Taille' }, | ||
{ cle = 'poids', label = 'Poids' }, | { cle = 'poids', label = 'Poids' }, | ||
{ cle = 'traits', label = 'Traits' } | { cle = 'traits', label = 'Traits' } | ||
} | } | ||
} | } | ||