Basculer le menu
Changer de menu des préférences
Basculer le menu personnel
Non connecté(e)
Votre adresse IP sera visible au public si vous faites des modifications.

« Module:Infobox/Configs/Localite » : différence entre les versions

De Nefald
Aucun résumé des modifications
Aucun résumé des modifications
 
(5 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,
   
 
     -- Icône avec type et nom
     -- Icône de l’infobox
     icone = {
     icone = {
         type = 'fas', -- ou 'fab', 'far', 'fal', 'fad'
         type = 'fas',
         nom = 'map-location-dot'
         nom = 'map-location-dot'
     },
     },
      
 
     image = function(args)  
     -- Gestion de l’image
     image = function(args)
         if args.image then
         if args.image then
             return {
             return {
Ligne 21 : Ligne 22 :
     end,
     end,


     -- Configuration du champ "type" avec validation et catégorisation
     -- Configuration du champ "type"
     typeField = {
     typeField = {
         required = false, -- Optionnel pour les localités
         required = false,
         allowedValues = {
         allowedValues = {
             ['ville'] = {
             ['ville'] = { display = 'Ville', category = 'Ville' },
                display = 'Ville',
             ['village'] = { display = 'Village', category = 'Village' },
                category = 'Villes'
             ['cité'] = { display = 'Cité', category = 'Cité' },
            },
             ['capitale'] = { display = 'Capitale', category = 'Capitale' },
             ['village'] = {
             ['port'] = { display = 'Port', category = 'Port' },
                display = 'Village',  
             ['forteresse'] = { display = 'Forteresse', category = 'Forteresse' },
                category = 'Villages'
             ['château'] = { display = 'Château', category = 'Château' },
            },
             ['ruine'] = { display = 'Ruine', category = 'Ruine' },
             ['cité'] = {
             ['avant-poste'] = { display = 'Avant-poste', category = 'Avant-poste' },
                display = 'Cité',
             ['campement'] = { display = 'Campement', category = 'Campement' },
                category = 'Cités'
             ['métropole'] = { display = 'Métropole', category = 'Métropole' },
            },
             ['sanctuaire'] = { display = 'Sanctuaire', category = 'Sanctuaire' },
             ['capitale'] = {
             ['cité-état'] = { display = 'Cité-État', category = 'Cité-État' }
                display = 'Capitale',
                category = 'Capitales'
            },
             ['port'] = {
                display = 'Port',
                category = 'Ports'
            },
             ['forteresse'] = {
                display = 'Forteresse',
                category = 'Forteresses'
            },
             ['château'] = {
                display = 'Château',
                category = 'Châteaux'
            },
             ['ruine'] = {
                display = 'Ruine',
                category = 'Ruines'
            },
             ['avant-poste'] = {
                display = 'Avant-poste',
                category = 'Avant-postes'
            },
             ['campement'] = {
                display = 'Campement',
                category = 'Campements'
            },
             ['métropole'] = {
                display = 'Métropole',
                category = 'Métropoles'
            },
             ['sanctuaire'] = {
                display = 'Sanctuaire',
                category = 'Sanctuaires'
            },
             ['métropole'] = {
                display = 'Cité-État',
                category = 'Cité-État'
            }
         },
         },
         errorMessage = 'Type de localité non reconnu. Types autorisés : ville, village, cité, capitale, port, forteresse, château, ruine, avant-poste, campement, métropole, sanctuaire'
         errorMessage = 'Type de localité non reconnu. Types autorisés : ville, village, cité, capitale, port, forteresse, château, ruine, avant-poste, campement, métropole, sanctuaire'
     },
     },


    -- Sections de l’infobox
     sections = {
     sections = {
         {
         {
Ligne 130 : Ligne 93 :
             }
             }
         }
         }
     }
     },
 
    -- Catégorisation automatique selon le type
    categories = function(args, config, frame)
        local cats = {}
        local title = mw.title.getCurrentTitle()
 
        -- On ajoute les catégories uniquement dans le namespace principal (0)
        if title.namespace ~= 0 then
            return cats
        end
 
        -- Catégorie selon le type
        if args.type and config.typeField and config.typeField.allowedValues then
            local cleanType = mw.text.trim(mw.ustring.lower(args.type))
            local typeDef = config.typeField.allowedValues[cleanType]
            if typeDef and typeDef.category then
                table.insert(cats, typeDef.category)
            end
        end
 
        return cats
    end
}
}


return config
return config