* deprecated means "please do not use this".
* required means "you must use this".
* suggested means "it's a good idea to use this".
* optional means "you typically don't need this".
There is no combination that makes any sense. They are really
exclusive to each other.
Still we have to keep the three checkboxes for backwards
compatibility reasons. It was always possible (and will probably
continue to be possible) to have more than one of the three fields
enabled. While users like VisualEditor will make a good guess (e.g.
ignore the rest when "deprecated" is checked) I really think we
should not attempt to hide (and auto-fix) it in this dialog. That's
why the proposed code continues to show the old checkboxes when
more than one is checked.
Bug: T202851
Change-Id: I994268d658602761b180f489bedb50b91fe0c419
It's always true and doesn't make any difference because of this.
I think the idea was to do some validation in the method. This
never happened and is done outside of the method instead (better
separation of concerns).
This is split from I1655174 to make it easier to review.
Change-Id: I48b7da75659365e5a2f72b680d40ee4b5b2904a2
Reasons:
* It's not the job of this code to validate the incoming types. This
happens server-side.
* The new code reflects better what actually happened: we stopped
using the prefix "string/".
* This was not (probably never) in sync with the server-side
validation. Some types got replaced, some didn't.
Change-Id: I0a35ca334c9e243dee548b271ddb3e1ca4498611
The data structure at the top of Model.js uses types like "string",
"array" and so on. Fields that share a type behave identical. I find
it odd to repeat parts of this data structure in the code. That's
what the types are for.
Change-Id: Iae55c18ececb809a56e40d3179d2cde357309d0a
The short `|| defaultValue` pattern is very common in JavaScript.
Note that in JavaScript – in contrast to PHP – empty arrays and
objects are not considered "falsy".
Change-Id: I97935c4dc2276d48d53ade3f7b4fdc28b62d89ba
It's required via the spec. We should act as if it's always there,
even when the actual "original data object" doesn't contain it.
Bug: T307331
Change-Id: I129b0c77e701df6ebbdc39432360cea8f10575e8
<pre> behaves very similar to <nowiki> in so far that whatever it
contains doesn't get parsed as wikitext. It might contain {{{…}}}
tripple brackets, but these aren't going to be activated as template
parameters.
Bug: T91326
Change-Id: I05c24e369d97c48161c565e2ef30969ec28c6a23
This method is not used anywhere else:
https://codesearch.wmcloud.org/search/?q=getRawParams
I tried to make the code a bit more readable. Notable:
* Make use of the return value we get from the preg_… function.
* {{3,} means "the character '{' 3 or more times". {{{+ does the
same. Note the { doesn't need to be escaped when it's not
followed by a number.
* At the end, it doesn't make any difference when we scan for
optional closing brackets. The moment we find at least 3 we are
done.
The test is intentionally not moved. This is something for a later
patch.
Bug: T301337
Change-Id: I55e31ceecea2ae7c35bcfbc2d641b35f751820db
The autovalue field appears to be the only one with this edge-case.
This is because all other fields are either multi-lingual and
processed by the `….allowLanguages` code path above, or because
of other special-case handling somewhere else.
The idea is:
* Non-empty values are always added.
* When the property (in this case `"autovalue": "…"` existed
before, it's kept, even if it's now empty.
Bug: T295074
Change-Id: Ie4d9825b89edb4bbbbc4283dc48e9113e537869a
Two main mistakes:
* The {...foo} syntax is for a variable number of parameters.
But this is not the case here.
* Optional parameters should be marked as such via [foo].
Change-Id: I0c26ea44fab6094616443ce8fae4fd47c61fd7c4
Parameters may include a `suggestedvalues` property, which is rendered
in the UI for some parameter types.
TemplateData editor UI elements are implemented behind the
TemplateDataSuggestedValuesEditor feature flag.
Bug: T271897
Change-Id: I14012c79b3fa0d48c58fd8999584cc03ec03575e
… instead of 0. Conditionally add a dash in front as well to
avoid confusing results like '1' + sequence number = '12'.
Change-Id: I345704b00ba3812c4905f85e35cf21a6dfd05437
I looks like the Model.params data structure is build in a way
that it allows mismatching parameter "keys" and "names". E.g.
{
"a": { "name": "a" },
"a0": { "name": "a" },
}
There are comments in the code that suggest this is
intentional.
I found code that confused these two values and tries to use
the name as a key, for example. This fails, messes up the
paramOrder, and such.
This should not have much, if any effect for users because
users are blocked from doing this anyway, e.g. buttons get
disabled.
Change-Id: I2067024ad8d5b8e985a4f162cf6875f523777a6c
This is needed for metrics collection.
The patch shifts responsibility for filling out an empty record when
there is no existing TemplateData, or it's corrupt.
We could clean up further by making logic robust to missing `params`
in the original templatedata, so that an empty structure is simply
`{}`.
Bug: T260343
Change-Id: I6ddc2660257890290cd40c54f9c8507ab5206d6c
This fixes a series of issues:
* The JS implementation had a trim() in one place that was
missing in PHP.
* The actual parameter name in the paramNames/$params array was
trimmed, but the "normalized" name (this is only for duplicate
detection) was not trimmed.
* It was possible for an empty parameter to show up.
This resulted in very strange behavior, e.g. {{{ 1}}}{{{1 }}}
was detected as "1" and "10" (?), i.e. it would try to renumber
the duplicate in a strange way (string "1" plus a counter that
starts with 0).
Change-Id: I0a6371f3633b03b5b21809ecd06ea4c72d7d914d
This does not have any effect on how this code behaves. It's
only relevant when a human reads the code. I tried to bring the
properties in an order that makes the most sense, grouping stuff
that clearly belongs together, as well as following how stuff is
ordered on
https://www.mediawiki.org/wiki/Extension:TemplateData
Change-Id: Ibbe1027023f8d87bbd0a70411882a25671918670
Seperate different maps of maps-object into different panels that
contains text-area to edit the map, delete button to delete the map, and
can be navigated through using a side-bar, that also have "Add new map"
button at the top to add a new map.
Bug: T258820
Change-Id: Ib53a73203f6010b3fd8a5cd78c74c904be2340f2
"Unknown" is the special, default value when nothing else is
specified. It feels wrong to find this in alphabetical order
between all the other values, as if "Unknown" is something I'm
expected to pick. While this is possible, it's almost never
necessary. "Unknown" is the default anyway. If I'm fine with
that, I never change it. But if I want to pick something else,
I typically expect the list to show the "nothing selected yet"
default first so I can easily avoid it.
Change-Id: I283a1b0545efba208af777a0b2056740263dfc32
This is used by the includeMissingTitles option of API action=templatedata.
Parameter syntax existing within nowiki tags or comments will not be valid
for the template.
Bug: T237195
Change-Id: Ibbfa3e21488f2a37fc494862e929baf50607d4c9
- Enable multiline.
- Enable updating the model with user changes if user clicks "Done".
- Disable "Done" button if the user inserts invalid JSON to handle JSON errors the
user might cause, and "Done" is enabled again if the JSON is valid.
- Create "cancel" button/action which will be for maps panel only, to
discard all changes made by the user.
Bug: T257503
Change-Id: Icd495290bae0b1684f8cd53864904a35e60fffe7
Adding maps object to TemplateData GUI. By adding mapPanelButton to the
main panel and creating the map panel which contains multiline input
widget to show and insert the map info.
Bug: T254478
Change-Id: Iacff86812cbc448fcdbae24e7eeffb0384781dd5
* I've moved the one remaining file in resources/ to modules/.
The repo had both resources/ and modules/.
* Class files are named after their class.
* Files with init logic on a page are named init.js.
* Files that only export re-usable classes for another module,
are named index.js.
Bug: T193826
Depends-On: If661c68bea069e99cfff35711efdde7805a12851
Change-Id: Ic8975d7ba349ba50f9039545d2eb8d912ccdce26