Modify

Opened 3 months ago

Last modified 4 weeks ago

#18949 new enhancement

[TaggingPreset] Make templates available for formatting key values, like for item names

Reported by: KorneySan Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: preset, template_for_key_value, name_template Cc:

Description (last modified by Don-vip)

Proposal is to make formatting by template available for key values like it done for item names.

This is especially usable for public transport routes naming.

In TaggingPresets there is an example for item naming:

<?xml version="1.0" encoding="UTF-8"?>
<presets>
        <item name="Public transportation" type="relation"
                name_template="Bus({operator} {ref} ?{'{from} - {via} - {to}' | '{from} - {to}' | '{from}' | '{to}'})"
                name_template_filter="type=route route=bus">
        </item>
</presets>

which set JOSM to DISPLAY a route relation name by that template. But the same is suitable for the route name by default:

    <text
        key="name"
        text="Name"
        default_template="Bus {ref}?{: '{from} → {to}'}"
        default_template_filter="type=route route=bus">
        />

The value set event should happen for example on route creation dialogue OK button press.

Attachments (0)

Change History (7)

comment:1 Changed 3 months ago by Don-vip

Description: modified (diff)

comment:2 Changed 3 months ago by simon04

Component: CoreInternal preset

comment:3 Changed 2 months ago by skyper

Component: Internal presetCore
Keywords: name_template added

name_template is only defined for <item>, atm. E.g., this is a an enhancement for core.

comment:4 Changed 2 months ago by simon04

I'm confused: the title says "formatting key values", the description says "formatting by template" (meaning for display purposes?), the description says "value set event" (change something?). Please provide the following details.

Having default_template="Bus {ref}?{: '{from} → {to}'}" in place, when creating a new relation (using the preset dialog only) without providing a name, the template should be evaluated based on the other values (which in turn might trigger a default_template as well??) and the result be set as name?

comment:5 Changed 2 months ago by Don-vip

Owner: changed from team to KorneySan
Status: newneedinfo

comment:6 in reply to:  5 Changed 4 weeks ago by KorneySan

Replying to Don-vip:

Having default_template="Bus {ref}?{: '{from} → {to}'}" in place, when creating a new relation (using the preset dialog only) without providing a name, the template should be evaluated based on the other values (which in turn might trigger a default_template as well??) and the result be set as name?

Exactly!
On preset dialog closing by OK button the engine should check the name value and if it is empty AND default_template is set, it should evaluate default_template and set the result to the name.

comment:7 Changed 4 weeks ago by simon04

Owner: changed from KorneySan to team
Status: needinfonew

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set.
to The owner will be changed from team to the specified user.
The owner will change to KorneySan
as duplicate The resolution will be set to duplicate.The specified ticket will be cross-referenced with this ticket
The owner will be changed from team to anonymous.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.