Jump to content

ICT:FinalConfig - PLACE: Difference between revisions

From Costa Sano MediaWiki
No edit summary
No edit summary
 
(14 intermediate revisions by the same user not shown)
Line 4: Line 4:


The aim is to create an interface without MediaWiki clutter and well protected to avoid confusing users with unnecessary elements on the page.  
The aim is to create an interface without MediaWiki clutter and well protected to avoid confusing users with unnecessary elements on the page.  
The Cargo template follows what has been decided in the DBML. It is the second implementation of an entity in order to finetune a final dashboard layout.
The Cargo template follows what has been decided in the DBML. It is the implementation of one entity "Place".
This entity have a special feature: filling in the address will give the coordinnates and in dashboard you then have a link to openstreetmap. In order to realise this a javascript is an extra.
 
This entity has a special feature: filling in the address will automatically fill in the coordinates and, in the dashboard, provide a link to OpenStreetMap. In order to realize this, JavaScript is used.
 
As the system uses de facto Dark mode, special care is taken to avoid default MediaWiki or Page Forms error messages that render as white boxes. Using the Vector-2022 skin, modifying Common.css proved unreliable; therefore, JavaScript-based solutions were preferred.
 
This configuration deliberately favors explicit behavior and robustness over visual polish or implicit framework behavior, in order to ensure long-term maintainability.


= Cargo Table: =
= Cargo Table: =
Template:Place
Template:Place
<pre>
<pre>
<<noinclude>
<noinclude>
Place data template
Place data template
</noinclude>


{{#cargo_declare:
{{#cargo_declare:
  _table=Places
  |_table=Places
  |title=String
  |Code=Page
  |code=String
  |Parent=Page
  |parent=Page
  |Label=String
  |type=String
  |Type=String
  |address=String
  |Address=String
  |latitude=Float
  |Latitude=Float
  |longitude=Float
  |Longitude=Float
  |notes=Text
  |Notes=Text
}}
}}
{{#forminput:form=Place}}
</noinclude>


{{#cargo_store:
{{#cargo_store:
  title={{{title|}}}
  |Code={{FULLPAGENAME}}
  |code={{PAGENAME}}
  |Parent={{{Parent|}}}
  |parent={{{parent|}}}
  |Label={{{Label|}}}
  |type={{{type|}}}
  |Type={{{Type|}}}
  |address={{{address|}}}
  |Address={{{Address|}}}
  |latitude={{{latitude|}}}
  |Latitude={{{Latitude|}}}
  |longitude={{{longitude|}}}
  |Longitude={{{Longitude|}}}
  |notes={{{notes|}}}
  |Notes={{{Notes|}}}
}}
}}


== {{{title|}}} ==
== {{{Label|}}} ==
{{DISPLAYTITLE:{{{Label}}}}}


{{DISPLAYTITLE:{{{title}}}}}
{{#if:{{{Parent|}}}|
'''Parent place:''' [[{{{Parent}}}]]
}}


{{#if:{{{parent|}}}|Parent place: [[{{{parent}}}]]}}
'''Notes:'''
{{{Notes|}}}


{{#if:{{{Latitude}}}{{{Longitude}}}|
'''Map:''' 
[https://www.openstreetmap.org/?mlat={{{Latitude}}}&mlon={{{Longitude}}} View on OpenStreetMap]
}}
</pre>
</pre>


Once the template is created don't forget to manually force the creation of the Cargo table.
Once the template is created, the Cargo table must be created manually.
If modifications are done to the table, one needs to manually update the table and then go to the Cargo interface to swap the temporary table to become the official one. Take care what is inside and outside
If modifications are made to the table structure, the table must be recreated and the temporary table swapped via the Cargo administration interface.
 
The field Code stores the full page name (including namespace) to ensure unambiguous identification and safe use as a foreign key across entities.
 
Important conventions:
- Field names start with a capital letter
- Code is the page name and acts as the technical identifier
- Label is the human-readable name and is mandatory for all entities
- Dashboards generate and manage pages in a dedicated namespace (Place)
- The field name Label must not be renamed, as it is relied upon by shared JavaScript validation logic
 
Special lines at the bottom of the template:
<pre>
<pre>
<noinclude>
== {{{Label|}}} ==
{{DISPLAYTITLE:{{{Label}}}}}
 
{{#if:{{{Parent|}}}|
'''Parent place:''' [[{{{Parent}}}]]
}}
 
'''Notes:'''
{{{Notes|}}}
 
{{#if:{{{Latitude}}}{{{Longitude}}}|
'''Map:''' 
[https://www.openstreetmap.org/?mlat={{{Latitude}}}&mlon={{{Longitude}}} View on OpenStreetMap]
}}
</pre>
</pre>
These lines ensure that the human-readable name (Label) is consistently used as the visible page title, while the actual page name remains the stable technical identifier (Code).
This decoupling allows renaming the label without breaking Cargo relations, dashboards, or foreign keys.
The last block conditionally displays a link to OpenStreetMap only when valid geographic coordinates are present, avoiding broken or misleading links.
Coordinates are normally filled automatically via JavaScript based on the Address field.


= Page Form: =
= Page Form: =
Line 67: Line 110:
|no footer
|no footer
}}}
}}}
''Fields marked with (*) are required.''


{{{for template|Place}}}
{{{for template|Place}}}
Line 72: Line 116:
{| class="formtable"
{| class="formtable"


! Title
! Code
| {{{field|title|mandatory}}}
| {{PAGENAME}}
|-
|-


! Code
! Name (*)
| {{PAGENAME}}
| {{{field|Label}}}
|-
|-


! Parent Place
! Parent place
| {{{field|parent
| {{{field|Parent
  |label=Parent place
|input type=combobox
  |input type=combobox
|values from namespace=Place
  |values from namespace=Place
|placeholder=Top level (no parent)
  |existing values only
  |placeholder=Top level (no parent)
}}}
}}}
|-
|-


! Type
! Type
| {{{field|type}}}
| {{{field|Type
|input type=dropdown
|values=Continent,Country,Region,Province,City,Neighborhood,Street
}}}
|-
|-


! Address
! Address
| {{{field|address|id=pf-address}}}
| {{{field|Address}}}
|-


! Latitude
| {{{field|Latitude}}}
|-
|-
! Latitude
| {{{field|latitude|id=pf-latitude}}}


|-
! Longitude
! Longitude
| {{{field|longitude|id=pf-longitude}}}
| {{{field|Longitude}}}
 
|-
|-


! Notes
! Notes
| {{{field|notes|input type=textarea}}}
| {{{field|Notes|input type=textarea}}}


|}
|}
Line 115: Line 159:


{{{end template}}}
{{{end template}}}
</pre>
</pre>


The first section is important to avoid clutter.
The first section avoids MediaWiki edit clutter.
<pre>
<pre>
{{{info
{{{info
Line 128: Line 171:
}}}
}}}
</pre>
</pre>
In the display of the Form;Place page one might see
 
<pre>
The field Label (displayed to the user as “Name”) is mandatory for all entities.
{{{end template}}}
This requirement is not implemented using the Page Forms |mandatory option, as this produces unusable white error boxes in the dark Vector-2022 environment.
</pre>
 
at the bottom. This is not a bug but a side effect too long to explain here.
Instead:
- the requirement is communicated via text and (*)
- enforcement is handled via JavaScript at save time


= Dashboard page =
= Dashboard page =
Line 145: Line 190:
{{#cargo_query:
{{#cargo_query:
  tables=Places
  tables=Places
  |fields=_pageName,code,title,type,parent,latitude,longitude
  |fields=_pageName,_pageTitle,Label,Type,Parent,Latitude,Longitude
  |where=_pageNamespace=3006
  |where=_pageNamespace=3006
  |order by=code
  |order by=_pageTitle
  |format=template
  |format=template
  |template=PlaceRow
  |template=PlaceRow
Line 155: Line 200:
|}
|}


Choose your place code corresponding to above table and respecting the naming conventions.
Choose your place code corresponding to above table and respecting the naming conventions.
Take maximum 4 capital letters for the code.
Take maximum 6 capital letters for the code.


{{#forminput:
{{#forminput:
Line 164: Line 209:
  |returnto=Dashboard:Place
  |returnto=Dashboard:Place
}}
}}


<div style="text-align:right; font-size:90%;">
<div style="text-align:right; font-size:90%;">
Line 174: Line 215:
</pre>
</pre>


Different measures are taken to deal with caching data in MediaWiki, Cargo and what happens in a browser.
IMPORTANT:
<pre>
Dashboard tables are positional.
|cache=no
The number and order of:
</pre>
- table headers
This is needed on the Cargo side to avoid caching and the following puts a new datetime on the page making it different from the previous version with the result that the page is renewed and the cached version is dropped.
- Cargo query fields
<pre>
- row template cells
<div style="text-align:right; font-size:90%;">
MUST match exactly.
Last updated: {{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}} – {{CURRENTTIME}} UTC
</div>
</pre>
This last block should be low enough on the page otherwise the effect might be missing and manual purge cache needed instead.


The layout of the dashboard makes use of a Template:PlaceRow as described below.
Only the first column (Code) is clickable and leads to the edit form.
It makes the first column of the table clickable to go back to the Form and edit the record.
All other columns are displayed as plain text to prevent navigation to record pages.


= Row transclusion Template =
= Row transclusion Template =
Line 194: Line 231:
<includeonly>
<includeonly>
|-
|-
| {{#formlink:form=Place|target={{{_pageName}}}|link text={{{code}}}|returnto=Dashboard:Place}}
| {{#formlink:
| {{{title}}}
  form=Place
| {{#switch:{{{type}}}
  |target={{{_pageName}}}
    |city=🏙️ City
  |link text={{{_pageTitle}}}
    |region=🗺️ Region
  |returnto=Dashboard:Place
    |building=🏛️ Building
}}
    |site=📍 Site
| {{{Label}}}
    |#default=📌 {{{type}}}
| {{{Type}}}
  }}
| {{#if:{{{Parent|}}}|{{#titleparts:{{{Parent}}}|1}}|}}
| {{{parent}}}
| {{#if:{{{Latitude}}}{{{Longitude}}}|
| {{#if:{{{latitude}}}{{{longitude}}}|[https://www.openstreetmap.org/?mlat={{{latitude}}}&mlon={{{longitude}}} 🗺️]}}
  [https://www.openstreetmap.org/?mlat={{{Latitude}}}&mlon={{{Longitude}}} 🗺️]
| — }}
</includeonly>
</includeonly>
</pre>
</pre>


=Javascript=
Parent values are displayed as plain text (not links) to prevent users from navigating directly to record pages. All record editing is performed via forms accessed from the dashboard.
A javascript is used to fill the coordinnates from the content of the address field.
MediaWiki:Common.js
<Pre>
// The form is already present in the DOM, so we can run immediately
$(function() {
    const addr = $('input[name="Place[address]"]');
    const lat  = $('input[name="Place[latitude]"]');
    const lon  = $('input[name="Place[longitude]"]');


    console.log("Address fields found:", addr.length);
= Javascript =
Multiple JavaScript functions are used to:
- auto-purge dashboards
- fill coordinates based on address input
- provide OpenStreetMap links
- enforce mandatory fields at save time


    if (addr.length === 0) {
MediaWiki:Common.js
        console.log("Address field not found");
<pre>
        return;
[unchanged JavaScript content]
    }
 
    addr.on('change', function() {
        console.log("Address changed:", addr.val());  // <— ADD THIS LINE
 
        const q = encodeURIComponent(addr.val());
        if (!q) return;
 
        const url = 'https://nominatim.openstreetmap.org/search?format=json&q=' + q;
 
        $.getJSON(url, function(data) {
            if (data && data.length > 0) {
                lat.val(data[0].lat);
                lon.val(data[0].lon);
            }
        });
    });
});
</pre>
</pre>


All entity templates must define a Label field, which is treated as mandatory by the shared JavaScript logic.


All Place pages are stored in the Place namespace with the page name acting as the Code.


All this creates pages in the namespace Place with the name being the code. The page is a configuration to serve in Page Forms extension. Below is an example of such a page.
Example:
<pre>
<pre>
{{Place
{{Place
|title=Berck-sur-Mer
|Label=Brussels
|type=city
|Parent=EURO
|latitude=50.406
|Type=City
|longitude=1.563
|Address=Brussel
|notes=Important location for early Costa Sano history.
|Latitude=50.8467372
|Longitude=4.3524930
|Notes=Nihil
}}
}}
</pre>
</pre>


 
Such pages are configuration pages and must be accessed via the dashboard, not directly.
 
As you can see the page as is cannot be used as such and should be read via the dashboard page.


== References: ==
== References: ==

Latest revision as of 11:09, 17 February 2026

Final Configuration for the Place Entity

Document revision: 2026-02-17 by Mngr

The aim is to create an interface without MediaWiki clutter and well protected to avoid confusing users with unnecessary elements on the page. The Cargo template follows what has been decided in the DBML. It is the implementation of one entity "Place".

This entity has a special feature: filling in the address will automatically fill in the coordinates and, in the dashboard, provide a link to OpenStreetMap. In order to realize this, JavaScript is used.

As the system uses de facto Dark mode, special care is taken to avoid default MediaWiki or Page Forms error messages that render as white boxes. Using the Vector-2022 skin, modifying Common.css proved unreliable; therefore, JavaScript-based solutions were preferred.

This configuration deliberately favors explicit behavior and robustness over visual polish or implicit framework behavior, in order to ensure long-term maintainability.

Cargo Table:

Template:Place

<noinclude>
Place data template
</noinclude>

{{#cargo_declare:
 |_table=Places
 |Code=Page
 |Parent=Page
 |Label=String
 |Type=String
 |Address=String
 |Latitude=Float
 |Longitude=Float
 |Notes=Text
}}

{{#cargo_store:
 |Code={{FULLPAGENAME}}
 |Parent={{{Parent|}}}
 |Label={{{Label|}}}
 |Type={{{Type|}}}
 |Address={{{Address|}}}
 |Latitude={{{Latitude|}}}
 |Longitude={{{Longitude|}}}
 |Notes={{{Notes|}}}
}}

== {{{Label|}}} ==
{{DISPLAYTITLE:{{{Label}}}}}

{{#if:{{{Parent|}}}|
'''Parent place:''' [[{{{Parent}}}]]
}}

'''Notes:'''
{{{Notes|}}}

{{#if:{{{Latitude}}}{{{Longitude}}}| 
'''Map:'''  
[https://www.openstreetmap.org/?mlat={{{Latitude}}}&mlon={{{Longitude}}} View on OpenStreetMap]
}}

Once the template is created, the Cargo table must be created manually. If modifications are made to the table structure, the table must be recreated and the temporary table swapped via the Cargo administration interface.

The field Code stores the full page name (including namespace) to ensure unambiguous identification and safe use as a foreign key across entities.

Important conventions: - Field names start with a capital letter - Code is the page name and acts as the technical identifier - Label is the human-readable name and is mandatory for all entities - Dashboards generate and manage pages in a dedicated namespace (Place) - The field name Label must not be renamed, as it is relied upon by shared JavaScript validation logic

Special lines at the bottom of the template:

== {{{Label|}}} ==
{{DISPLAYTITLE:{{{Label}}}}}

{{#if:{{{Parent|}}}|
'''Parent place:''' [[{{{Parent}}}]]
}}

'''Notes:'''
{{{Notes|}}}

{{#if:{{{Latitude}}}{{{Longitude}}}| 
'''Map:'''  
[https://www.openstreetmap.org/?mlat={{{Latitude}}}&mlon={{{Longitude}}} View on OpenStreetMap]
}}

These lines ensure that the human-readable name (Label) is consistently used as the visible page title, while the actual page name remains the stable technical identifier (Code).

This decoupling allows renaming the label without breaking Cargo relations, dashboards, or foreign keys.

The last block conditionally displays a link to OpenStreetMap only when valid geographic coordinates are present, avoiding broken or misleading links.

Coordinates are normally filled automatically via JavaScript based on the Address field.

Page Form:

Form:Place

<noinclude>
Form for creating and editing Place pages.
</noinclude>

{{{info
|no summary
|no preview
|no minor edit
|no watch
|no footer
}}}
''Fields marked with (*) are required.''

{{{for template|Place}}}

{| class="formtable"

! Code
| {{PAGENAME}}
|-

! Name (*)
| {{{field|Label}}}
|-

! Parent place
| {{{field|Parent
 |input type=combobox
 |values from namespace=Place
 |placeholder=Top level (no parent)
}}}
|-

! Type
| {{{field|Type
 |input type=dropdown
 |values=Continent,Country,Region,Province,City,Neighborhood,Street
}}}
|-

! Address
| {{{field|Address}}}
|-

! Latitude
| {{{field|Latitude}}}
|-

! Longitude
| {{{field|Longitude}}}
|-

! Notes
| {{{field|Notes|input type=textarea}}}

|}

{{{standard input|save}}}

{{{end template}}}

The first section avoids MediaWiki edit clutter.

{{{info
|no summary
|no preview
|no minor edit
|no watch
|no footer
}}}

The field Label (displayed to the user as “Name”) is mandatory for all entities. This requirement is not implemented using the Page Forms |mandatory option, as this produces unusable white error boxes in the dark Vector-2022 environment.

Instead: - the requirement is communicated via text and (*) - enforcement is handled via JavaScript at save time

Dashboard page

Dashboard:Place

= 🗺️ Costa Sano Research PLACE Dashboard =

📖 [[Dashboard:Place/Help|Need Help?]]

{| class="wikitable sortable"
! Code !! Title !! Type !! Parent !! Map
{{#cargo_query:
 tables=Places
 |fields=_pageName,_pageTitle,Label,Type,Parent,Latitude,Longitude
 |where=_pageNamespace=3006
 |order by=_pageTitle
 |format=template
 |template=PlaceRow
 |named args=yes
 |cache=no
}}
|}

Choose your place code corresponding to above table and respecting the naming conventions.  
Take maximum 6 capital letters for the code.

{{#forminput:
 form=Place
 |namespace=Place
 |button text=➕ New place
 |returnto=Dashboard:Place
}}

<div style="text-align:right; font-size:90%;">
Last updated: {{CURRENTDAY}} {{CURRENTMONTHNAME}} {{CURRENTYEAR}} – {{CURRENTTIME}} UTC
</div>

IMPORTANT: Dashboard tables are positional. The number and order of: - table headers - Cargo query fields - row template cells MUST match exactly.

Only the first column (Code) is clickable and leads to the edit form. All other columns are displayed as plain text to prevent navigation to record pages.

Row transclusion Template

Template:PlaceRow

<includeonly>
|-
| {{#formlink:
   form=Place
   |target={{{_pageName}}}
   |link text={{{_pageTitle}}}
   |returnto=Dashboard:Place
 }}
| {{{Label}}}
| {{{Type}}}
| {{#if:{{{Parent|}}}|{{#titleparts:{{{Parent}}}|1}}|—}}
| {{#if:{{{Latitude}}}{{{Longitude}}}|
   [https://www.openstreetmap.org/?mlat={{{Latitude}}}&mlon={{{Longitude}}} 🗺️]
 | — }}
</includeonly>

Parent values are displayed as plain text (not links) to prevent users from navigating directly to record pages. All record editing is performed via forms accessed from the dashboard.

Javascript

Multiple JavaScript functions are used to: - auto-purge dashboards - fill coordinates based on address input - provide OpenStreetMap links - enforce mandatory fields at save time

MediaWiki:Common.js

[unchanged JavaScript content]

All entity templates must define a Label field, which is treated as mandatory by the shared JavaScript logic.

All Place pages are stored in the Place namespace with the page name acting as the Code.

Example:

{{Place
|Label=Brussels
|Parent=EURO
|Type=City
|Address=Brussel
|Latitude=50.8467372
|Longitude=4.3524930
|Notes=Nihil
}}

Such pages are configuration pages and must be accessed via the dashboard, not directly.

References: