Commit graph

17568 commits

Author SHA1 Message Date
jenkins-bot 297cb53e33 Merge "Remove spec documentation that literally repeats the code" 2021-06-29 09:46:49 +00:00
jenkins-bot d588a736c2 Merge "Fix all spec methods to not crash on unknown parameters" 2021-06-29 09:41:07 +00:00
jenkins-bot c84dd3d44f Merge "Use separate data structure to store aliases in spec" 2021-06-29 09:41:05 +00:00
jenkins-bot 73fe8f7a38 Merge "Add icons to the show/hide button in the ExpandableContentElement" 2021-06-29 08:55:46 +00:00
jenkins-bot b3d23f59b3 Merge "Fix the show/hide button for the ExpandableContentElement on mobile" 2021-06-29 08:49:41 +00:00
Andrew Kostka 2c0f44df83 Add icons to the show/hide button in the ExpandableContentElement
Bug: T282996
Change-Id: I2013c00696af2320d871e12c6d523f0da1dcb277
2021-06-29 08:33:22 +00:00
Translation updater bot 080de68972 Localisation updates from https://translatewiki.net.
Change-Id: If7d122051b2bcd459499863f9be1964dc51ac3aa
2021-06-29 08:14:01 +02:00
jenkins-bot 9fcba8bac8 Merge "Minor documentation updates in template related classes" 2021-06-28 14:46:11 +00:00
Andrew Kostka e5cbe69187 Fix the show/hide button for the ExpandableContentElement on mobile
Bug: T283943
Change-Id: I23ae2350dfb9100ed6604fc93628c616c41ab2e1
2021-06-28 15:18:38 +02:00
jenkins-bot 8da60b7864 Merge "Hotfix for broken "Extract show all to placeholder class"" 2021-06-28 11:24:50 +00:00
jenkins-bot 9371e993b0 Merge "Simplify spec code dealing with default values" 2021-06-28 10:58:39 +00:00
jenkins-bot a6a314b580 Merge "Fix getDescription/Sets possibly returning undefined" 2021-06-28 10:55:36 +00:00
jenkins-bot 73c79d74c0 Merge "Better name for spec.isParameterKnown() method" 2021-06-28 10:36:25 +00:00
jenkins-bot 426ca299a0 Merge "Better name for spec.getParameterName() method" 2021-06-28 09:15:07 +00:00
jenkins-bot b661992efe Merge "Add new QUnit test for ve.dm.MWTemplateSpecModel" 2021-06-28 09:11:48 +00:00
Translation updater bot 6204a97ba5 Localisation updates from https://translatewiki.net.
Change-Id: I05a6799b182da122e0cdad318d059afae27e3725
2021-06-28 09:23:44 +02:00
Thiemo Kreuz 6b346442ad Hotfix for broken "Extract show all to placeholder class"
This does not revert commit 950a5300 but applies the most
minimal hotfix I could come up with.

The reason for the breakage is that MWParameterPlaceholderPage
& MWParameterSearchWidget both hold references to the
MWTemplateModel. This model is not always the same. The dialog
might be the same when a template is edited multiple times.
But the model might be a new one. From this point on the
MWParameterSearchWidget pulls data from an outdated model.

This extra check compares this model reference and creates a
new widget when it changed.

Bug: T284636
Bug: T285571
Change-Id: Ib3eca52bbff90ffbf56a257e3984adcbe02b310b
2021-06-27 18:29:23 +02:00
Thiemo Kreuz 26b0322ff0 Minor documentation updates in template related classes
Bug: T285483
Change-Id: I1cf17d7bfb01326b93bc781b2501a492d50f0aab
2021-06-25 16:46:59 +02:00
Thiemo Kreuz fb14183f3c Remove spec documentation that literally repeats the code
These comments don't add any knowledge. The text is either
duplicated, or the method signatur says it already. Having
to read these comments just to realize that they don't give
any additional information is not helpful, even error-prone.

Change-Id: I014028b1e9311b831a22c37859b2130aed2e9539
2021-06-25 06:38:37 +00:00
Thiemo Kreuz b7d88c541b Fix all spec methods to not crash on unknown parameters
Change-Id: I16708b048a785f0712084bd2d087e4aab77fb72b
2021-06-25 08:36:23 +02:00
Thiemo Kreuz b8382513fc Use separate data structure to store aliases in spec
Wait, what's going on here? This patch looks like it changes the
behavior of this code. But it doesn't. Here is what happened
before:
* Let's say a template contains 2 parameters, A and B.
* We don't know yet if these names are aliases.
* getParameterNames() returns [ "A", "B" ].
* extend() is called. The TemplateData documentation contains
  the parameters "B" and "C". "C" does have an alias "A".
* extend() can't find "C" and adds it to the end, as if it's a
  new parameter.
* extend() also iterates the aliases. For each alias it creates
  a reference to the specification object. In this case a
  reference from "A" to "C" is created.
* But "A" already exists. The position of "A" doesn't change,
  but the specification now says it's an alias.
* getParameterNames() skips aliases. It skips "A" and instead
  returns the new "C" from the end of the list.

This was the behavior before. It's unchanged, proven by the tests.

Change-Id: I04b8a14fbec7be5a1c4defabf92e94f694c1e638
2021-06-25 08:29:48 +02:00
Thiemo Kreuz 8f6098c03b Simplify spec code dealing with default values
The idea is to not actually store all these default values, but
fall back to the default only when needed.

Some more details:
* The only remaining property is ….name. The only reason to
  have this property is to distinguish between aliases and
  primary parameter names. This will be reworked in a later
  patch.
* The description falls back to null because this is the
  documented fallback, not undefined.
* The default value falls back to "", same as the auto-value.
  Why not null you might ask. This is intentional. Both the
  auto- and default value are effectively wikitext snippets,
  while the example is a label in the VE UI.

Bug: T285483
Change-Id: I1be3cca18f9ad6fc1c16362b24633f7613f02539
2021-06-24 18:13:41 +02:00
Thiemo Kreuz bab08440ea Fix getDescription/Sets possibly returning undefined
This is done for two reasons:

1. It fixes the behavior of two methods in rare edge-case
situations. They aren't documented to return undefined.

2. It reduces the amount of stuff this class stores when it's
nothing but a default value anyway. Note this patch does this
for the template-level properties only. Another patch will do
the same for the parameter-level properties.

Bug: T285483
Change-Id: If2e4d56da1fa52e32dc94191f36d7dc6a1487829
2021-06-24 18:07:46 +02:00
Thiemo Kreuz 2529d33f51 Better name for spec.isParameterKnown() method
This reflects much better how this method is meant to behave.

Note I will continue to remove documentation that doesn't
explain anything in addition to what the code already says.

Bug: T285483
Change-Id: I81fa8a5d9d0752f3aeac4015c9a27b50e054d4df
2021-06-24 18:05:14 +02:00
Thiemo Kreuz 30dc85f53b Better name for spec.getParameterName() method
This reflects much better what the method is for.

Bug: T285483
Change-Id: I7c90643421e32946fce4de813c7614b806b261f0
2021-06-24 18:02:52 +02:00
Thiemo Kreuz 3d02c1f364 Add new QUnit test for ve.dm.MWTemplateSpecModel
This patch also marks 2 methods as @private that are not and
should not be used outside of this class.

Bug: T285483
Change-Id: I8a8ffc4868a369b5c47068beb0e83f023872543d
2021-06-24 17:59:38 +02:00
jenkins-bot ec2c42932d Merge "Label for each template in sidebar" 2021-06-24 12:34:52 +00:00
jenkins-bot acc41f5ed6 Merge "Wiring for adding and removing parameters" 2021-06-24 10:55:46 +00:00
Adam Wight cc95ed8ef3 Label for each template in sidebar
Bug: T274545
Change-Id: I1731373a63f96eda0e43fe042746eaed40bfe6fb
2021-06-24 12:50:05 +02:00
jenkins-bot f1534d9e51 Merge ""Add more information" should be a button instead of a checkbox" 2021-06-24 10:39:05 +00:00
Andrew Kostka 5e2cd392c7 Wiring for adding and removing parameters
Bug: T274545
Change-Id: I0514a93f4313914a654e5f24cf78950cb4893409
2021-06-24 12:31:43 +02:00
Andrew Kostka 47c7d4939f "Add more information" should be a button instead of a checkbox
Bug: T274545
Bug: T272487
Change-Id: Icc4d461d763290b0bc07ec8dbaa98c625fc9e068
2021-06-24 09:55:17 +00:00
jenkins-bot f06856b2d9 Merge "Remove extraneous ve.ui.MWTemplateOutlineCheckboxListWidget.js" 2021-06-24 09:37:34 +00:00
jenkins-bot 118ae98a2a Merge "Wire model changes into new template sidebar" 2021-06-24 09:31:46 +00:00
jenkins-bot 58d06c2636 Merge "Revert "Revert "Fall back from explicit parameter order to TemplateData sort""" 2021-06-24 09:15:31 +00:00
Andrew Kostka 6a890c31bd Remove extraneous ve.ui.MWTemplateOutlineCheckboxListWidget.js
Bug: T274545
Change-Id: I327ee06aff19fd2d3841e4e4a2d09a24c47e4d89
2021-06-24 11:12:12 +02:00
Adam Wight 64c5b093cc Wire model changes into new template sidebar
Only partially wired.

Bug: T274545
Change-Id: I961ffbdd82829b18c08a7c33759a05427103fa8b
2021-06-24 11:09:39 +02:00
jenkins-bot f2fcb75d72 Merge "Tests for parameter serialization order" 2021-06-24 07:56:37 +00:00
Translation updater bot 1348b34693 Localisation updates from https://translatewiki.net.
Change-Id: Ib398fedb4a1fc9b9d7dba936826c78aaf46fef10
2021-06-24 08:27:27 +02:00
Adam Wight 1909fdff92 Revert "Revert "Fall back from explicit parameter order to TemplateData sort""
This reverts the revert commit d47b95eb4a.

When no `paramOrder` is given, known parameters should appear in the
order returned from the TemplateData API.

Previously, when TemplateData was present but no paramOrder
specified, then the parameters would appear in alphabetical order as
"unknown" parameters.  Now they will appear in the order listed in
TemplateData.  This is similar to the fully-specified behavior when
paramOrder is present.

This will only affect the Visual Editor template dialog, and has no
effect on serialization.

Bug: T274545
Change-Id: If8315781572af688ea1c1b14b3694b828f076b4a
2021-06-23 16:39:13 +02:00
Adam Wight 05bcb89f3f Tests for parameter serialization order
The results show that parameter order always follows the appearance
in the template invocation, regardless of `paramOrder`, whether the
parameters are aliased, or whether there are unknown params.

Bug: T285382
Change-Id: I76c6fe8f0a2482cf0856bbafd9f21ba9fc4919a4
2021-06-23 16:38:30 +02:00
jenkins-bot 2cbb32302f Merge "Inline many var declarations in the code below" 2021-06-23 09:24:05 +00:00
Thiemo Kreuz 4367235dcc Inline many var declarations in the code below
This makes the code more readable and easier to reason about.
The ESLint rule responsible for this code style was removed
just recently.

Notes:
* I focus on classes that are relevant for what the WMDE team
  does right now.
* I merge multiple `var` keywords only when the variables are
  strongly connected.
* Caching the length in a for loop makes the code hard to
  read, but not really faster when it's a trivial property
  access anyway.

Bug: T284895
Change-Id: I621fed61d894a83dc95f58129bbe679d82b0f5f5
2021-06-23 09:02:24 +00:00
Translation updater bot 69a3ff2c04 Localisation updates from https://translatewiki.net.
Change-Id: Ifceab025b106fcf05a2e70414ea89ff989e705c9
2021-06-23 08:12:08 +02:00
jenkins-bot d1c07aced8 Merge "Revert "Fall back from explicit parameter order to TemplateData sort"" 2021-06-22 18:16:33 +00:00
Awight d47b95eb4a Revert "Fall back from explicit parameter order to TemplateData sort"
This reverts commit 12f3ce5ed3.

Reason for revert: Considered undesirable, per T138200

Change-Id: I089a47b41a0bb0405841690ca577035cf95a8016
2021-06-22 17:50:16 +00:00
Adam Wight 1100db9665 Revert "Make template dialog header tooltip match title"
This reverts commit 7d05257059.

Change-Id: I16395c1118a5a1afe6c0f9022e478f38a2ac3755
2021-06-22 15:37:09 +02:00
jenkins-bot aeea9f1781 Merge "Fall back from explicit parameter order to TemplateData sort" 2021-06-22 12:43:30 +00:00
jenkins-bot 7089fb3c15 Merge "Tests for getAllParametersOrdered" 2021-06-22 12:37:18 +00:00
Adam Wight 12f3ce5ed3 Fall back from explicit parameter order to TemplateData sort
When no `paramOrder` is given, known parameters should appear in the
order returned from the TemplateData API.

Previously, when TemplateData was present but no paramOrder
specified, then the parameters would appear in alphabetical order as
"unknown" parameters.  Now they will appear in the order listed in
TemplateData.  This is similar to the fully-specified behavior when
paramOrder is present.

This will only affect the Visual Editor template dialog.

Bug: T274545
Change-Id: I32538de07641c288081042a41fe39eedfed7d939
2021-06-22 13:24:44 +02:00