Commit graph

8206 commits

Author SHA1 Message Date
Thiemo Kreuz 170ca9d58a Reuse generic button widget for elements in the new sidebar
This introduces another generic "button-like" class that can
be reused in multiple places in the new sidebar. The main
change in this patch is the "add more information" button
which is now an instance of this new class as well.

This patch also simplifies over-complicated setup code in
related widgets.

Bug: T274544
Change-Id: I0cfe7675d02fdd5c5dc8d9198bb3f4aec9abf397
2021-07-13 17:23:27 +00:00
Thiemo Kreuz 28049425ec Various design tweaks to the new template dialog sidebar
Still far from being finished, but much closer to the mocks
already.

Bug: T274544
Change-Id: I1feee06e43a4b9c10a2d9443b6d816595bead64d
2021-07-13 13:00:37 +00:00
Thiemo Kreuz 31904688df Update new sidebar when moving template parts up/down
The new sidebar now updates accordingly when elements are
moved around.

Bug: T274544
Change-Id: Ic6bc3484c54523aa4edc6b48a843c47059569061
2021-07-13 10:18:20 +02:00
Thiemo Kreuz 226e2657ef More robust debug container for new template editor sitebar
Before, the new sidebar was hacked in a place where it confused
the BookletLayout logic. This became visible when using the
up/down buttons to move elements in the sidebar.

This new container wraps the new and the old sidebar. It also
uses a temporary color to make it easier to see where one ends
and the other starts.

Bug: T274544
Change-Id: I4e5b40b1d1556886fc85cff9e926a02e4888f032
2021-07-13 09:11:57 +02:00
jenkins-bot 6395ef82d9 Merge "Fix HotCat interface not working after cancelling visual editing" 2021-07-12 14:36:48 +00:00
jenkins-bot 5bd9eff8ea Merge "Full add/delete support for all 3 types in template sidebar" 2021-07-12 14:04:32 +00:00
jenkins-bot f92d85604c Merge "Add template outline widgets for all content types" 2021-07-12 10:52:19 +00:00
Thiemo Kreuz 5edf7dac18 Full add/delete support for all 3 types in template sidebar
From now on you can remove and add all 3 types of content from
the new sidebar.

Bug: T274544
Change-Id: If1e04ff503d72cbe9ea07c8036c9e3a0547cc0d0
2021-07-12 10:15:14 +00:00
jenkins-bot af8c144091 Merge "Move template outline item header into the base class" 2021-07-12 09:24:38 +00:00
jenkins-bot 240a405dfa Merge "Remove unused parameters from MWTransclusionModel methods" 2021-07-12 09:05:51 +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
Bartosz Dziewoński 58b230a308 Fix HotCat interface not working after cancelling visual editing
Cloning the #catlinks node loses all native event handlers registered
on it. jQuery's `.clone( true )` method can only copy jQuery event
handlers, so it does not help. As a result, when the node is
reattached to the page after cancelling visual editing, HotCat's
interface is still visible, but not functional.

To fix this problem, keep a reference to the original node rather than
a clone.

https://developer.mozilla.org/en-US/docs/Web/API/Node/cloneNode#notes
https://api.jquery.com/clone/

Change-Id: I2c0b3d1a919b67053a17dd11fd2b7dc7556267ef
2021-07-09 13:51:09 +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 c2bc8c7e26 Merge "Move code that belongs to the template specification" 2021-07-08 08:46:40 +00:00
jenkins-bot e70ca5bd42 Merge "Add missing test case with template parameter placeholder" 2021-07-08 08:33:15 +00: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
jenkins-bot 06f63bdc10 Merge "Remove unnecessary code from template related classes" 2021-07-08 07:39:14 +00:00
jenkins-bot 275fb5a2d6 Merge "Remove duplicate code from ve.ui.MWParameterSearchWidget" 2021-07-08 07:39:05 +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 3cd91100a9 Move code that belongs to the template specification
Separation of concerns:
* The template model knows which parameters are currently used,
  but doesn't know what's documented.
* The spec knows what's documented, but doesn't know what's
  currently used.

Change-Id: I97cac00d6775a17a07059d0e8a7a116adc6080b3
2021-07-07 16:45:35 +02:00
Thiemo Kreuz 9624f61701 Add missing test case with template parameter placeholder
There are some methods that behave different when a parameter
placeholder (where the parameter name is "") is present. Some
skip placeholders, some don't. This is critical to cover
before we make further changes to this class.

What I also do in this patch:
* Use shorter variable names to make the code easier to read.
* Don't reuse the `transclusionData` variable but use a copy
  of the expected value. This makes the assertions much
  easier to understand.
* Bring every test in the same "setup" → "execute" → "assert"
  order.

Change-Id: I41a691c56bc509b132dc719ff820ae1ade4ccc3a
2021-07-07 15:53:40 +02:00
jenkins-bot 5160c4d520 Merge "Allow text selection on the "More"/"Less" button fade effect" 2021-07-07 09:47:45 +00:00
Thiemo Kreuz 1c98f4cce0 Remove unnecessary code from template related classes
For example, checking if a parameter is required works just fine
for unknown parameters. They are never required. Since I16708b0
we don't need to guard the spec related methods any more.

Change-Id: Id90e4cb810dc9faca3b26f122a534f276ee31709
2021-07-07 10:18:41 +02:00
Thiemo Kreuz f6e5866deb Allow text selection on the "More"/"Less" button fade effect
It's good practice to make transparent elements transparent
for mouse clicks as well, i.e. make it possible to select text
behind the fade effect.

Bug: T283943
Bug: T286235
Change-Id: Ib5022a74c70e4b7cb5e2a0faad20bd9abcc0da36
2021-07-07 07:48:28 +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
Thiemo Kreuz e3d3fd9eaf Remove unused parameters from MWTransclusionModel methods
Change-Id: Icdeddb92a498e0dd1182b19de1c4effdb1741fef
2021-07-06 15:47:32 +02:00
Thiemo Kreuz 137be4438f Remove unused .getWikitext() methods from transclusion classes
These methods are special in so far that they create *minimal*
wikitext where optional whitespace is not preserved. I tried
to rename the methods to reflect this, but could not find a
caller. What's used instead are the .serialize() methods.

Bug: T284895
Change-Id: Iedaa5b7efa9675151cc0553854d8aef3f9a46cbb
2021-07-06 10:58:11 +02:00
jenkins-bot 9e6387176b Merge "Add @private/@protected documentation to template dialog code" 2021-07-06 08:41:55 +00:00
jenkins-bot de71ebc9de Merge "Simplify ve.dm.MWTemplateModel.hasParameter() a lot" 2021-07-06 08:23:15 +00:00
jenkins-bot 4a5f811c82 Merge "Keep template parameter position when resolving aliases" 2021-07-05 11:44:19 +00:00
jenkins-bot 8504fd9545 Merge "Minor code cleanups to the MWTemplateSpecModel class" 2021-07-05 10:01:46 +00:00
Thiemo Kreuz fbb7d211d0 Simplify ve.dm.MWTemplateModel.hasParameter() a lot
A lot of the checks are redundant. The first check still is
redundant because the later two cover everything as well. But
I left it for performance reasons.

Additionally:
* There was no test for the method.
* This patch also updates a few pieces of documentation in the
  same class.

Change-Id: I10f2944a844cc070bdc08dec6719929b383e34fa
2021-07-05 11:58:42 +02:00
Thiemo Kreuz 16ca60009b Minor code cleanups to the MWTemplateSpecModel class
Bug: T285483
Change-Id: I22005907effe855ab5e830c94d2bc32c640b5aa5
2021-07-05 09:16:23 +00:00
jenkins-bot 6acdb3bc8e Merge "Add missing JSDoc documentation to template related classes" 2021-07-05 09:09:40 +00:00
jenkins-bot 7cd766becf Merge "Avoid calling own getters in template model class" 2021-07-05 09:09:38 +00: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