Commit graph

537 commits

Author SHA1 Message Date
jenkins-bot f92d85604c Merge "Add template outline widgets for all content types" 2021-07-12 10:52:19 +00:00
jenkins-bot af8c144091 Merge "Move template outline item header into the base class" 2021-07-12 09:24:38 +00:00
Thiemo Kreuz a1384f34f3 Add template outline widgets for all content types
The two new widgets are pretty trivial now, thanks to the base
class.

Note there is still no code to delete the widgets. That's also
why you will always see a placeholder widget at the top. This
will be fixed with the next patches.

This patch also renames most of the "…TemplateOutline…" classes
to "…TransclusionOutline…" The reason is that these widgets are
not for a single template, but part of the container widget for
a more complex transclusion (i.e. a sequence of multiple
templates and wikitext snippets).

Bug: T274544
Change-Id: If4219b0b8ad4d1969ab1ec5ec4db0728811bab35
2021-07-12 09:19:06 +02:00
Thiemo Kreuz 2854be165e Move template outline item header into the base class
The icon and the name of the template are now created by the
base class. This is meant to be reused for other elements
that are not templates.

Bug: T274544
Change-Id: I76bbc0e8c0420e9c6357d093d5f5e1651a0c2719
2021-07-12 09:17:30 +02:00
Thiemo Kreuz fae6118071 Document and use mw.Api parameter defaults
Reasoning:
* format=json must be the default. Nothing else makes sense in
  the context of this code. This should not be a surprise.
* formatversion=2 is only a default when the custom
  getContentApi() is used, but not when mw.Api is used. One
  might argue that it's safer to always specify formatversion=2.
  However, this is not done in other places in this codebase.
  It should never be done or always.
* I find it confusing when the action=… is missing. Let's not
  rely on this default.

Change-Id: I6ca29f76bffc0849103c5bcff4aaf28fcaaa4c52
2021-07-12 09:13:59 +02:00
jenkins-bot 1569ab0a28 Merge "Remove empty container widgets that don't do anything" 2021-07-09 16:14:25 +00:00
jenkins-bot 0f1bef39b4 Merge "Abstract base class for top-level items in template editor" 2021-07-09 16:09:42 +00:00
jenkins-bot 48f711cd5c Merge "Rename CSS classes in new template dialog sidebar code" 2021-07-09 16:09:40 +00:00
Thiemo Kreuz 4018439348 Remove empty container widgets that don't do anything
This code doesn't do anything but adding an empty <div> to
something that is already a <div>. It doesn't even have a
class name, i.e. it's not referenced from anywhere. We can
add such containers back any time when it turns out we
actually need them.

Bug: T274544
Change-Id: I62546cc7939364db31f37b9de0c035974554544b
2021-07-09 15:57:11 +02:00
Thiemo Kreuz cfe2dadc93 Abstract base class for top-level items in template editor
This base class will be used to style the 3 types of top-level
items in the sidebar the same way, without the need to
duplicate code or styles.

Bug: T274544
Change-Id: I1a62ff610728d7150dea1717316ef20f6882783a
2021-07-09 15:48:08 +02:00
Thiemo Kreuz 1849924eff Rename CSS classes in new template dialog sidebar code
This matches the existing naming scheme better. I also plan to
re-use this class for other types that are not templates.
That's why the name is the more generic "transclusion" now.

This patch also removes a `padding: 2px` that's not that
helpful. We will need paddings later, but need to choose them
much more carfully.

Bug: T274544
Change-Id: I6f0f630da2230b023b3fb065e5ad86d8211bb7b3
2021-07-09 15:29:29 +02:00
Thiemo Kreuz 12dca65912 Delete last template search result, not a random one
Because the API uses a generator, the search results are ordered
alphabetically. The actual search result ranking is in a .index
field. This code accidentially deleted the alphabetically lowest
template instead of the least relevant one.

Change-Id: I79de024feb569e9f06bedab908a6509a4d4fa99b
2021-07-08 15:33:42 +02:00
Thiemo Kreuz ba1718ea11 Always add 1 prefixsearch match when searching for templates
We do this additional prefixsearch anyway. What we did before
was ignoring the result when it was not a 100% exact match.
Instead we can always add this 1 prefixsearch result when it
was not already part of the CirrusSearch result set.

This won't happen often. Usually the 1st prefixsearch result
was already part of the CirrusSearch result set anyway. But
if it wasn't, that's a serious issue for expert users that
expect the search to behave similar to the suggester at the
top of the MediaWiki interface (which is also a prefixsearch).

Change-Id: I959d2b058a3d64596a8cfbe5476ab351e40f8760
2021-07-08 11:15:34 +02:00
jenkins-bot 5c738aa74f Merge "Fixes and updates to template related JSDoc tags" 2021-07-08 08:24:44 +00:00
jenkins-bot c0b7783fc3 Merge "Change style for adding an "Unknown field" in the parameter search" 2021-07-08 08:20:59 +00:00
Svantje Lilienthal ee98622076 Change style for adding an "Unknown field" in the parameter search
Bug: T286236
Change-Id: Ibb3df034c9b423dd4130d8242bd7bf0dc742ee2f
2021-07-08 09:20:25 +02:00
Thiemo Kreuz d68e110e67 Fixes and updates to template related JSDoc tags
Some details:
* The config is not optional in these cases.
* This patch continues to remove some comments that don't add
  any information but just repeat what the code already says.

Change-Id: I5c27cd01ad80709bb583256821d65c6b65b74b05
2021-07-08 06:36:56 +00:00
Thiemo Kreuz f04feb043f Remove duplicate code from ve.ui.MWParameterSearchWidget
Introduced in 2 separate patches by the same author. This
patch removes the line that was introduced last.

Change-Id: I77575f7afe0f9276c7b54ee44d828e7ccb87c978
2021-07-07 09:34:50 +02:00
jenkins-bot a19bc2960f Merge "Keep undocumented parameters in the sidebar when unchecked" 2021-07-05 09:06:32 +00:00
jenkins-bot 8718ac8ece Merge "Fix parameter ordering when using aliases" 2021-07-05 08:33:01 +00:00
Andrew Kostka a867469b7b Keep undocumented parameters in the sidebar when unchecked
Bug: T274550
Change-Id: I010006cdbe5ce5cb79cc4248840d74cb992ff834
2021-07-05 10:17:55 +02:00
Andrew Kostka 6af13f0d42 Fix parameter ordering when using aliases
If a known parameter is present using one of it's aliases, then
only the aliased name should be shown to the user. This patch,
therefore, resolves the issue of the same parameter being added
to the sidebar twice.

When adding a parameter that is aliased, it will receive the same
position as the non-aliased parameter it is replacing.

Bug: T274545
Change-Id: If4e58c941fd0f0e690d3603935f5a5d3f9938163
2021-07-05 08:14:42 +00:00
Thiemo Kreuz 6757a1bfa9 Character = is not allowed in template parameter names
It's allowed in values, but not in parameter names. The moment
a parameter name contains an `=` the parameter name will be cut
off at this point, and what's behind the `=` will become part
of the value.

You can test this on any live wiki. Open VisualEditor. Edit any
template. Add a parameter with a name like `a=` and some value.
Switch to wikitext mode and back. Edit the template. The `=` is
now part of the value.

Bug: T98065
Change-Id: I5e00e8fac987471243605816b041d3638927ac3b
2021-07-04 14:03:21 +02:00
Thiemo Kreuz fecded9f70 Fix parameter search being to relaxed on unknown params
When what you type is a partial match, you can't add it as an
unknown parameter, even if that would be the correct action. The
reason for this unexpected edge-case is a mistake in the code
where a variable called "exactMatch" is set when a *partial*
"nameMatch" was found.

Bug: T285940
Change-Id: I6d12e2d7251a19d7d5f8be544c3c32a3ac14fcf0
2021-07-01 20:09:51 +02:00
Thiemo Kreuz 99523b855c Use and document the term "known parameter" in template code
The so called "spec" class keeps track of parameters that have
been used before, no matter if documented via TemplateData or
not. Removed parameters are still "known" (i.e. have been seen
before).

This feature allows to easily find previously used parameters
names when an undocumented parameter was removed and the user
tries to add it again.

Bug: T285483
Change-Id: Ia1555eea87cd99e7a3f386f4279ec5a80fb98a79
2021-07-01 12:03:38 +00:00
Thiemo Kreuz db531ddba5 Add missing search result limitation to template search
Bug: T274903
Change-Id: If57d28f7796d69825a25fa9b67bcd5c127c9e3b7
2021-07-01 09:33:52 +02:00
jenkins-bot f9cb2e3519 Merge "Don't create a checkbox for ve.ui.MWParameterPlaceholderPage" 2021-06-30 14:31:59 +00:00
jenkins-bot 0e3bf54e3f Merge "Add documentation to ve.ui.MWTemplateOutlineTemplateWidget" 2021-06-30 14:31:57 +00:00
jenkins-bot 217793ebd1 Merge "Use the parameter's label in the sidebar" 2021-06-30 14:31:55 +00:00
Thiemo Kreuz bc4aeed86e Avoid the term "canonical order" in template related docs
While the term "canonical" is not wrong, I find it still
somewhat ambiguous.

1. "Canonical" could mean different things. E.g. is the order
of parameters as they appear in the article's wikitext the
"canonical" one? It's possible to argue like this, esp. if a
template doesn't have TemplateData documentation. In this case
the only order known is the one from the wikitext.

2. "Canonical" sounds like the parameters must be reordered.
But this should never happen. Not having dirty diffs is more
important than having the parameters in a specific order.

Bug: T285483
Change-Id: I23658d37fea50b727667677ac6a49066673b2135
2021-06-30 09:38:28 +02:00
Andrew Kostka 0c141e2581 Add documentation to ve.ui.MWTemplateOutlineTemplateWidget
Change-Id: Ibc0b39fd417fa7eef5cf1cd52b9769c6514ce85d
2021-06-29 21:50:41 +02:00
Andrew Kostka 30917c8ba3 Don't create a checkbox for ve.ui.MWParameterPlaceholderPage
Change-Id: Ia02e86e026e618a4ace31306fe50f003c49080ae
2021-06-29 21:21:19 +02:00
Andrew Kostka 526a49672e Use the parameter's label in the sidebar
Change-Id: Ic2c00f51088d67453bb50ff0fa15f22c9fbd8e56
2021-06-29 20:44:17 +02:00
jenkins-bot 802be178e3 Merge "Extract MWTemplateTitleInputWidget.addExactMatch into a method" 2021-06-29 13:47:03 +00:00
Thiemo Kreuz (WMDE) e6d3828429 Revert "Extract "show all" to placeholder class"
This reverts commit 950a5300dc.

Reason for revert: This broke several workflows. The reason 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.

Bug: T284636
Bug: T285571
Change-Id: I7b9ea8cab8f17705ec8020f07e3732da6ba0e73c
2021-06-28 14:04:12 +02:00
Thiemo Kreuz b3bede3ba0 Extract MWTemplateTitleInputWidget.addExactMatch into a method
Same as in TemplateWizard, see I128bc00.

Bug: T274903
Change-Id: I8693b85625a8640e44c213300d7c6862430bec47
2021-06-25 17:07:32 +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
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 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
WMDE-Fisch c4f59132ae Only add asterisk after word characters in improved template search
This will avoid that the search breaks in edge cases where symbols
are used.

Including a fallback for ES5 browsers. The fallback should cover
almost all cases. Worst case would be not adding the asterisk even
though it might be valid.

Bug: T284554
Change-Id: Ie4aee0b77492b7a73bc251a8723a206dbd641600
2021-06-21 21:07:28 +02:00
WMDE-Fisch 407ff95597 Rename OutlineParameterCheckboxWidget to OutlineParameterCheckboxLayout
This not really just a checkbox widget anymore it inherits from
FieldLayout and became something more in that direction.

Let's use a mixture of these things to make it a bit clearer.

See also comment in Ie81b84be288553343017c4aaf8691c4e266995f5

Change-Id: Iff1746a8e5e94b56eb6c27465405aaf6b74c2310
2021-06-21 09:08:54 +02:00