Commit graph

228 commits

Author SHA1 Message Date
Ed Sanders ef6294074e build: Update devDependencies
Change-Id: I80bd6849b1616b9c94e75eddfbf5f476b799e07b
2022-03-13 17:17:03 +00:00
Thiemo Kreuz d3f00177ba Don't extract template parameters from <pre>
<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
2022-03-03 21:20:40 +00:00
Thiemo Kreuz da8969812c Move getRawParams helper method to ApiTemplateData class
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
2022-02-09 12:37:33 +00:00
jenkins-bot c8537793c1 Merge "Fix and update type hints in JSDoc comments" 2022-01-17 17:11:19 +00:00
Thiemo Kreuz 5f749c6418 Allow aliases to be integers in addition to strings
Parameter names in a template can be numeric. While it makes a lot of
sense to force a specific format in the TemplateData JSON (i.e. only
strings), it's inconvenient and confusing if numbers are rejected for
being "invalid".

Effects of this patch:
* The incoming JSON is allowed to contain numbers in the aliases
  array.
* However, the API normalizes these and forces all aliases to be
  strings, as it was always documented.
* The editor component accepts anything in the aliases array, but
  forces all aliases to be strings. Again, as documented.
* Note that it was never possible to use numeric keys in the `params`
  list. This patch is only about aliases.

At the moment this is a somewhat "hidden" feature. We might or might
not update the documentation to officially allow numeric aliases.

Bug: T298795
Change-Id: I32ea296b4520e7f21b03a1f6390db4f43b613bdd
2022-01-10 13:33:27 +01:00
Thiemo Kreuz e79f19f09c Fix and update type hints in JSDoc comments
Change-Id: Ib38d3c4eff7630bd3aed04beee33adc5ae2101f3
2022-01-10 11:48:42 +01:00
Adam Wight 709c89909f Remove comma-delimiting code
No longer needed as of I9450f70e705d9596c7e0d7545f9b5505fc4aae04

Change-Id: I342db496a1e3e0b6c4466dbdd62ee0d8d21258c0
2021-12-17 12:08:10 +01:00
Thiemo Kreuz f7771a22a6 Edit aliases via a proper widget instead of comma-separated
Bug: T285284
Change-Id: I9450f70e705d9596c7e0d7545f9b5505fc4aae04
2021-12-17 11:50:27 +01:00
Thiemo Kreuz 2b2033c6ec Fix serialization adding empty autovalue when not needed
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
2021-11-29 10:53:35 +01:00
jenkins-bot da2077d5bc Merge "Fix parameter auto-detection picking up syntax elements" 2021-10-06 23:27:08 +00:00
jenkins-bot f16838ebc0 Merge "Remove small pieces of unused code" 2021-10-06 23:05:34 +00:00
Ed Sanders da93a0fffa Move var declarations inline
Change-Id: I177f91e67ea2ea2ab07d64002ae80365fabdedd3
2021-10-05 17:37:33 +01:00
Thiemo Kreuz 3060559d1d Fix parameter auto-detection picking up syntax elements
See T290322 for a detailed description.

Bug: T290322
Change-Id: Id9935482fb466e7a1f6e55f042b13fe5851412d0
2021-09-03 13:18:42 +02:00
Thiemo Kreuz 4766216948 Remove small pieces of unused code
Mostly unused variable initializations. Note I'm inlining some
`var` keywords in this patch. This is in line with the current
style guides. See for example the discussion in I4f198e2 (search
for "hoisted" in the comments). However, I'm not changing the
entire codebase, as this is not the goal of this patch and also
just not necessary at this point.

Change-Id: Ibd80566c44584851ee2530d6b16dd28eb3db6bfe
2021-08-28 12:10:22 +02:00
Thiemo Kreuz 2cb03827cc Fix several type hints in JavaScript code
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
2021-08-28 12:08:28 +02:00
jenkins-bot 73d5a6504d Merge "Change param duplicate numbering to start with 2" 2021-07-30 14:17:47 +00:00
jenkins-bot ffeaea6921 Merge "Fix handling of duplicate parameter names" 2021-07-30 14:11:09 +00:00
Thiemo Kreuz f6e1004720 Various minor JSDoc/PHPDoc documentation fixes
Change-Id: I537bf4086058a7e18c9118f7433090c4bfaf98e7
2021-07-12 11:47:55 +02:00
Ed Sanders f567bb1b51 Avoid fit-content, not supported by all browsers
Bug: T282285
Change-Id: I59e4f5aaa3f4bdd1d97d90fcb671454b00777922
2021-06-03 21:53:40 +01:00
WMDE-Fisch 75ca02c746 Inline fix for suggested values on unkown paramter types
Follow up to I33625eb38047fdbd2ca9d026c056f263e228e7df implementing
Thiemo's suggestion.

Bug: T280688
Change-Id: I63e804e2b122d7471a2f1c603b9734f820820e72
2021-04-23 10:14:01 +02:00
Andrew Kostka 6fd0857012 Fix suggested values not being shown when the param's type isn't specified
Bug: T280688
Change-Id: I33625eb38047fdbd2ca9d026c056f263e228e7df
2021-04-22 10:18:44 +02:00
Adam Wight 7b32bcefb4 Add suggested values parameter
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
2021-04-09 12:05:37 +02:00
Adam Wight e9e1b8ff48 Send title without namespace
These are a mess and hard to de-localize.  Also, the schema is
already documented as not including the namespace in this field.

A proper migration would be very difficult, so we'll have to remember
that our data includes this glitch and manually strip namespace
prefixes before the deployment date, as needed.

Change-Id: If2a4dd865b95458dc63162460f252500fd52436e
2021-02-18 18:27:53 +01:00
WMDE-Fisch 43e3043bab Allow input fields for parameter values to expand
Adding a new widget that inherits from MultilineTextInputWidget but
is initialized with only one row and prevents using the return key
to add new lines.

Bug: T263533
Change-Id: I5423f5f04075d21abd7acf09b622fd6444feeeb2
2021-02-17 17:27:54 +01:00
jenkins-bot e474d1632d Merge "Update a few confusing variable names in editor code" 2021-02-13 17:24:02 +00:00
Andrew Kostka d81226fdf7 Bucket the user's edit count before logging an event
Bug: T272569
Change-Id: I5313a3808b266bb60644b40bdb192db77208774a
2021-01-21 13:52:28 +01:00
Thiemo Kreuz 563a44ca72 Change param duplicate numbering to start with 2
… instead of 0. Conditionally add a dash in front as well to
avoid confusing results like '1' + sequence number = '12'.

Change-Id: I345704b00ba3812c4905f85e35cf21a6dfd05437
2021-01-08 14:50:04 +00:00
Thiemo Kreuz 954211d8ba Fix handling of duplicate parameter names
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
2021-01-08 15:48:55 +01:00
Andrew Kostka dfa86a7c71 The parameter-type-change event should also fire if type was initially undefined
Bug: T260343
Change-Id: I26f50dfd6b4b747b1ef88d619df6aff5278d412a
2021-01-08 14:09:34 +00:00
jenkins-bot fe3ee9ab6b Merge "Track parameter property changes" 2020-12-09 10:41:03 +00:00
jenkins-bot 248d4dfd9e Merge "Drop unnecessary top-level closures" 2020-12-07 15:34:32 +00:00
Thiemo Kreuz d08a6448e9 Track when (relevant) changes are made to <templatedata> tags
Bug: T267926
Change-Id: I55f72500b7bad7e648238560b516e870bc9130c8
2020-12-07 15:34:13 +01:00
Adam Wight 93b7bc0756 Drop unnecessary top-level closures
Change-Id: Ie8fbde864cd08f0657e4239f525ef9dd087aee41
2020-12-07 15:24:31 +01:00
Adam Wight 80021704d4 Track parameter property changes
This is temporary interaction tracking to better understand how the
dialog is used.

Bug: T260343
Change-Id: I14afa89e18676818f88c142059128a9f62dcadcb
2020-12-07 14:39:05 +01:00
Adam Wight eb6b61b3a7 Rename "property" variable for clarity
"props" sounds plural, but it is the name of a single property.

Change-Id: I62184d00d03e297568e1c335f31c961aa6983406
2020-12-04 18:44:48 +00:00
Adam Wight 5206188129 Assign reused dependentField value to a variable
Change-Id: Ie77fd61d5bb7d886ab069472d0294daf4039d4e2
2020-12-04 18:44:40 +00:00
Adam Wight 8e65e4d8fb Assign reused propertyInput value to a variable
Change-Id: Ic8ea8ae283112801266303eb1d2520931e47a418
2020-12-04 18:44:32 +00:00
Adam Wight 415286e377 Send metrics for template property interactions
Bug: T260343
Change-Id: I050eb4b87ccb9c8910847b929b86c3b3cb269b8a
2020-12-04 18:44:01 +00:00
Adam Wight 1d108b5104 Send metrics when applying changes
Bug: T260343
Change-Id: I6fea4195107baf301dd8f66967c86e9c7a762bd1
2020-12-04 18:43:30 +00:00
Adam Wight d8e418671d Send metrics when opening the dialog
Distinguish between create and edit.

Bug: T260343
Change-Id: I5cd29dff0c4db7e024395a9090c465a01527f079
2020-12-04 18:43:23 +00:00
Adam Wight a9a4485b22 Higher-level distinction when creating new TemplateData
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
2020-12-04 18:43:09 +00:00
Adam Wight b7fee749ab Migrate to package files: ext.templateDataGenerator.editTemplatePage
Change-Id: Ie03284701c1870b06116b7ce6a8ca1759c28d03b
2020-12-04 19:41:50 +01:00
Adam Wight bda6215309 Migrate to package files: ext.templateDataGenerator.data
Bug: T260343
Change-Id: Ifd171b40de704bff8c063da46b711a384238a0f5
2020-12-04 19:41:30 +01:00
Adam Wight 1010e6fb78 Migrate from jsduck to jsdoc
Bug: T138401
Change-Id: Iae74fdcae5e8c2541416d8cec8de8221cfc282ef
2020-11-30 21:56:30 +01:00
jenkins-bot 2a477094b9 Merge "Add progressive flags to various buttons" 2020-10-09 14:38:33 +00:00
jenkins-bot bb8e099e4a Merge "Remove unused "changesBooleanValue" property" 2020-10-07 17:04:52 +00:00
jenkins-bot 27e9916941 Merge "Use OutlineSelectWidget/OutlineOptionWidget for maps editing" 2020-10-07 10:06:55 +00:00
jenkins-bot 86a6865512 Merge "Fix parameter extraction from wikitext source" 2020-10-06 23:07:23 +00:00
jenkins-bot a0f98a1ea4 Merge "Also add padding to add parameter panel" 2020-10-06 23:02:38 +00:00
Marielle Volz 8a4e0ec984 Also add padding to add parameter panel
Follow up to Ica6bed595d8

Change-Id: I43d76ac256f18b69b556eadf5a53c20698cd860d
2020-10-06 09:37:09 +01:00