Commit graph

13160 commits

Author SHA1 Message Date
WMDE-Fisch 1673f9f8bf Add notes and warning for missing parameter documentation
Bug: T276574
Change-Id: Iba0dd661ccdfd6cbb13aef7e8ace25995ecf0cf8
2021-09-01 17:29:25 +02:00
Thiemo Kreuz fc0b419540 Highlight first template parameter when using tab to navigate
I tried to memorize the cursor position in the list of
parameters. This way you could leave the list with tab, and
return to the original position with shift+tab. Unfortunately
this is not how the SelectWidget works. The moment the
highlight is gone it's gone. There is nothing that remembers
a position. We could introduce code to do this. But I feel
like this is a lot of effort for not much benefit. Also not
listed as a requirement anywhere, at the moment.

Bug: T285323
Change-Id: I8d44ba4539ec4b5535bc031accfeacd87e1886eb
2021-09-01 14:05:01 +00:00
Thiemo Kreuz 7a8ad64cbd Fix click/enter on template parameters not focusing the input
This got lost in patch I20dbd2b.

Both events come from the same sidebar class. The difference
between the two is:
* selectPart is when the button representing a top-level part
  is clicked.
* focusPart is when a parameter name is clicked while the
  parameter is already checked.

Yes, this is confusing at the moment. Following patches will
rename, merge and split a lot of these events to be much more
self-explaining.

Bug: T285323
Change-Id: I0c6b53c93c712ff5e47c1beb5199d590cba7ab1a
2021-09-01 16:01:17 +02:00
Thiemo Kreuz 9dbbc06273 Fix …TemplateSpecModel reporting missing pages as documented
The code in .cacheTemplateDataApiResponse() where the `specCache`
is filled skips missing pages. .setTemplateData() is never called.
While we could – in theory – check the `missing` flag (as done in
patchset 1), this flag never makes it to the spec.

Rather simple solution: Mark everything as undocumented, as long
as .setTemplateData() is not called.

This affects only missing pages. .setTemplateData() is called in
all other situations.

Bug: T272487
Bug: T276574
Bug: T290136
Change-Id: I7045e84f2f2ba5aa4591c94ea495b0249e6c40d6
2021-09-01 14:59:03 +02:00
Thiemo Kreuz b7efea5559 Remove unused event listener from …ParameterSelectWidget
We forgot to remove this in I319896a. The individual
…TransclusionOutlineParameterWidgets don't fire this event any
more. Instead this is done by the …SelectWidget.

Bug: T285323
Change-Id: I2c29e45127464785ffdc32d73b52188fcbefb7bf
2021-09-01 11:58:36 +00:00
Thiemo Kreuz b0ddcb0010 Highlight corresponding template parameter in new sidebar
Note there are currently two different code paths utilizing two
different events. The existing event handler actually changes
the selection of the top-level part in the sidebar (the
corresponding template name turns blue). The new event handler
highlights a parameter (it turns gray). This is currently
intentional (partly because of a bug in OOUI). I will try to
merge these code paths, if possible.

Please test, and if it works fine from the user's perspective,
please merge it as it is for now.

Bug: T285323
Bug: T289043
Change-Id: I8fafee68b8b7ff225c7b3c327f483f3426d8129c
2021-09-01 11:15:37 +02:00
jenkins-bot f7265428e8 Merge "Try to use margin/padding instead of flex for template dialog" 2021-09-01 08:53:01 +00:00
jenkins-bot 3b5064318c Merge "Connect focus event from BookletLayout to new sidebar" 2021-09-01 08:47:07 +00:00
Thiemo Kreuz a4dac831d9 Try to use margin/padding instead of flex for template dialog
Proof of concept: while flex is – well – flexible, it feels like
this should be possible with some good old block containers and
margins. It's pixel-perfect in my test.

Bug: T288465
Change-Id: I1458900fff197e08ce318398524a3cf2b6b9ee2a
2021-09-01 10:35:52 +02:00
jenkins-bot a86ef8db42 Merge "Add temporary compatibility to ve.dm.MWTransclusionModel" 2021-09-01 07:33:41 +00:00
jenkins-bot 37f78f9afa Merge "Harden title parsing in MWTransclusionModel a bit" 2021-08-31 17:09:37 +00:00
jenkins-bot fd4084efb9 Merge "Use ve.targetLinksToNewWindow in MWDismissibleMessageWidget" 2021-08-31 14:21:40 +00:00
jenkins-bot bc1af53609 Merge "Text improvements for unkown parameter input" 2021-08-31 14:10:46 +00:00
WMDE-Fisch 099d6bad87 Use ve.targetLinksToNewWindow in MWDismissibleMessageWidget
Change-Id: I71a2c933e4af0dac4a083ce34820fa2994fc388d
2021-08-31 15:06:20 +02:00
WMDE-Fisch 14d3e8144c Text improvements for unkown parameter input
- Change description text according to ticket
- Make sure link to template page opens in new tab
- Add missing placeholder text

Bug: T272487
Change-Id: Ie8189e9cb9db5908e8fc5fc8bf7ff20df5595094
2021-08-31 14:57:24 +02:00
jenkins-bot 9d0c480529 Merge "Narrow selector for links when adding _blank" 2021-08-31 12:42:36 +00:00
jenkins-bot 49eaab5139 Merge "Add tests for ve.ui.MWTransclusionOutlineParameterSelectWidget" 2021-08-31 12:04:02 +00:00
jenkins-bot a6c01e946a Merge "Rename …OutlineItem CSS class to match widget class name" 2021-08-31 11:35:18 +00:00
WMDE-Fisch 99cee2be11 Narrow selector for links when adding _blank
Change-Id: Ia05117759c81fff6f35256931d0894c0b8051fe6
2021-08-31 13:08:25 +02:00
jenkins-bot ef486588ce Merge "Add tests for new ve.ui.MWAddParameterPage" 2021-08-31 10:55:16 +00:00
Thiemo Kreuz c32a6d794a Fix inconsistent keyboard :focus styles in template outline
This fixes a few style issues:
* The buttons that represent top-level elements have a proper
  2px focus rectangle again. Back to the OOUI default.
* The list of parameters does have a 1px focus rectangle all
  around. Intentionally thin because there is a 2nd level of
  keyboard navigation (via cursor keys) in this element.
* All these focus rectangles look the same in Firefox. Before,
  it was a thin dotted line on the parameter list.
* Parameters with long names don't wrap on a 2nd line any more.
  I believe this was working before but got lost in I92e8fd2.

Bug: T285323
Change-Id: I0229b6395a64a9903335bf96349af70fb20ad047
2021-08-31 12:30:24 +02:00
Thiemo Kreuz b84251080a Rename …OutlineItem CSS class to match widget class name
Bug: T285323
Change-Id: Ib307a23adb4712f253610b5029483ea8c049b7ce
2021-08-31 12:16:10 +02:00
Thiemo Kreuz d8718fde95 Add temporary compatibility to ve.dm.MWTransclusionModel
Method names have been changed in I8fa47ed, assuming these are
private. It looks like some hacks exist out there. Let's make
these peoples life easier.

Change-Id: I63c80761fe06e2f3a4bb104fe3e8c17d1c7faa02
2021-08-31 07:00:32 +00:00
Thiemo Kreuz 5ffaa3e313 Add tests for ve.ui.MWTransclusionOutlineParameterSelectWidget
Note this covers both the outer SelectWidget as well as most of
the functionality of the item class. This is because the outer
widget manages everything. The items are mostly dumb containers
for a `.selected` bool flag.

Bug: T289560
Change-Id: I6bffda3b74a4bca26032e2602563d64f7bf9bf40
2021-08-30 19:48:42 +00:00
jenkins-bot 106011d713 Merge "Remove some stylelint rules not needed anymore" 2021-08-30 16:03:33 +00:00
jenkins-bot 7f8b6202ac Merge "Correct focus handling when adding undocumented parameters" 2021-08-30 15:43:35 +00:00
jenkins-bot 4297f44543 Merge "Add/simplify assertions in transclusion outline related code" 2021-08-30 15:34:22 +00:00
jenkins-bot fc8f99bd24 Merge "More complete top-level part selection support in new sidebar" 2021-08-30 15:20:57 +00:00
WMDE-Fisch 685bd0b303 Remove some stylelint rules not needed anymore
Got stylelint feedback from local npm test runs about that.

Change-Id: I4e2f1f8baeeac1608f104982c709aaec01e372b5
2021-08-30 17:07:43 +02:00
Thiemo Kreuz fcd555ba68 Correct focus handling when adding undocumented parameters
When I press the button to expand the input field for
undocumented parameters, it needs to be focused. Otherwise I
have to click it manually all the time.

We probably forgot to list this as an acceptance criteria when
working on Ic5dcd36.

This also replaced a bit of JavaScript with CSS. I do this
mainly because I found the mixture before (one piece was
hidden via JavaScript, another via CSS) a bit confusing.

Bug: T272487
Change-Id: I0cbee63c65a37f2f1860bde007c1e5c8408ba006
2021-08-30 17:03:30 +02:00
Thiemo Kreuz 99558f9076 Connect focus event from BookletLayout to new sidebar
This makes sure the corresponding top-leve part is selected in
the list on the left when navigating the main area on the
right.

Bug: T289043
Change-Id: Id1b398e1786c4099d5b14fe88dd21a106269096b
2021-08-30 17:00:52 +02:00
Thiemo Kreuz 926913cad6 Add/simplify assertions in transclusion outline related code
Bug: T289560
Change-Id: Ia76e13582a182c8184b3e8642c5c03bf3d674a24
2021-08-30 14:58:50 +00:00
jenkins-bot ddee2bdb72 Merge "Allow selecting top-level parts in the new sidebar" 2021-08-30 13:32:12 +00:00
Thiemo Kreuz e9bd350f68 Add tests for new ve.ui.MWAddParameterPage
The class was added via Ic5dcd36 just a few days ago.

Bug: T289560
Change-Id: I3f729fb6c5d7c28a221d88294d5547809f10a17d
2021-08-30 13:02:52 +00:00
jenkins-bot 62a390d39f Merge "Add rather complex QUnit tests for transclusion outline code" 2021-08-30 10:48:22 +00:00
jenkins-bot fdea0c5357 Merge "More test cases for more complex template dialog functionality" 2021-08-30 08:54:19 +00:00
jenkins-bot 155cefa073 Merge "Tests for some trivial but critical template model methods" 2021-08-30 08:48:31 +00:00
jenkins-bot 0d3f7941e6 Merge "ve.ce.MWHeadingNode: Fix Uncaught TypeError: this.root is null" 2021-08-28 15:58:11 +00:00
Thiemo Kreuz 115441b5d8 Add rather complex QUnit tests for transclusion outline code
These are more integration tests than actual "unit" tests. What
the tested code does depends a lot on e.g. how the model and
spec classes behave, and even on some events. Which is good. We
want to cover all of this with tests. The only question is: Is
there a good way to make these tests easier to read, while they
still cover the same code?

Bug: T289560
Change-Id: I8c681f161c272d143a07ca4d0080b4089b48bcb6
2021-08-28 12:34:36 +00:00
Thiemo Kreuz 1f19d85ea8 More test cases for more complex template dialog functionality
Contains:
* Full test coverage (I believe) for the filter functionality in
  …OutlineTemplateWidget.

Also some TODOs for missing tests I believe are critical.

Bug: T289560
Change-Id: I2ac5add8e189d501d3558bbd4854cb92155bcb96
2021-08-28 14:02:57 +02:00
Thiemo Kreuz 0ba7480901 More complete top-level part selection support in new sidebar
This comes with a few significant changes:
* A whole bunch of places in the code that focus and highlight
  an element in the old sidebar consider the new sidebar now.
* Same when e.g. the toolbar at the bottom needs to know which
  part is selected. This is read from the new sidebar now.
* To make this possible I had to merge the small helper class
  we introduced in I7bc73cc back into the dialog.

It's helpful to understand how the event flow works:
* You click a template name. This does nothing (does not select
  the element). It only triggers an event.
* The event is catched by the outer container that manages
  all parts. From there all elements are unselected, and one
  selected. This call is internal and should not trigger
  another event.

Bug: T285323
Bug: T288827
Bug: T289043
Change-Id: I4a2d2b83cf2691423d4b0e6f4487228fa3c7b56d
2021-08-27 19:16:00 +02:00
Thiemo Kreuz 544bd5688c Allow selecting top-level parts in the new sidebar
This is mostly, if not exclusively visual, at the moment. The
actual state is still managed by the old sidebar.

I made the element OptionWidgets for convenience. This gives us
all the functionality we need (primarily setSelected and
isSelected), without to much clutter. However, I didn't made
the container a SelectWidget. This comes with to much stuff we
don't need at this level, e.g. cursor key navigation.

Bug: T285323
Bug: T289043
Change-Id: I20dbd2ba23ceaa9125947b25e037c0bb3c91a471
2021-08-27 18:22:37 +02:00
Thiemo Kreuz 55beccbb79 Tests for some trivial but critical template model methods
Not only do we want to make sure getUniquePartId() always starts
at 0 and increments correctly, it should return a number (and
not e.g. "part_0").

I realize the getTitle() test is also testing functionality from
mw.libs.ve.… (can be found in the file ve.utils.parsoid.js).
This is intentional. What we care about at this point is not a
library but the very specific functionality of a very specific
method we use quite a lot in code we touch.

Bug: T289560
Change-Id: I43c1d00dacf27a68b16f62ecca4adda22f437391
2021-08-27 12:49:06 +00:00
jenkins-bot c1ce1e3d4b Merge "Move small code snippets into …OutlineParameterSelectWidget" 2021-08-27 11:36:53 +00:00
jenkins-bot e778057389 Merge "Remove not needed boilerplate from QUnit tests" 2021-08-27 10:56:08 +00:00
jenkins-bot c5ea00c03d Merge "Remove wikitext buttons from the content view" 2021-08-27 10:33:02 +00:00
jenkins-bot 86f9acf616 Merge "Cleanup feature flags in ve.ui.MWParameterPage" 2021-08-27 10:32:10 +00:00
jenkins-bot f2b94e10b6 Merge "More test cases for MWTransclusionOutlineContainerWidget" 2021-08-27 10:00:04 +00:00
jenkins-bot 4dd435f3af Merge "More meaningful assertions for all outline part widgets" 2021-08-27 09:59:21 +00:00
jenkins-bot bdb3a783c9 Merge "Add basic QUnit tests for all transclusion outline classes" 2021-08-27 09:59:16 +00:00
Bartosz Dziewoński 702d261bbd ve.ce.MWHeadingNode: Fix Uncaught TypeError: this.root is null
Similar code elsewhere checks whether this.root is set
(e.g. ve.ce.FocusableNode.prototype.onFocusableSetup).
And code here checks whether this.surface is set.

Bug: T289201
Change-Id: If07dc75ca76f2d171bc2eae83be10083d95096f8
2021-08-26 21:35:19 +02:00
Andrew Kostka d94fb21b1e Remove wikitext buttons from the content view
Bug: T285669
Change-Id: I875a41e54e7a33cb9f67383d887a732a31649bbb
2021-08-26 17:47:14 +02:00
Thiemo Kreuz 7aeff4bfd3 Move small code snippets into …OutlineParameterSelectWidget
Most notably:
* Move some code snippets from the outer …TemplateWidget to
  the inner …SelectWidget, without introducing new
  dependencies.
* Move all knowledge about the item class
  …OutlineParameterWidget class into …SelectWidget.
* Some more self-documenting method names for event handlers.
* Avoid the somewhat ambiguous variable name "checkbox" in
  favor of "item". That's how it's named in the upstream OOUI
  …SelectWidget.

This is extracted from the following patch Ibd94c39. The
difference is that the following patch adds a new dependency:
The …SelectWidget gets to know the template model. This patch
here contains all changes that are possible without this new
dependency.

Bug: T288827
Change-Id: I187f313c84424b28005d9276cb1356029f9ebb75
2021-08-26 17:30:03 +02:00
Andrew Kostka afe8e8f721 Cleanup feature flags in ve.ui.MWParameterPage
Change-Id: Id1be6512f763d9ddb98665005d378947fdd3e6bb
2021-08-26 17:25:09 +02:00
jenkins-bot a5718f01c5 Merge "Remove unnecessary title parsing from template related code" 2021-08-26 15:08:13 +00:00
jenkins-bot 765b1da5b1 Merge "Use spec label for template link generation" 2021-08-26 14:13:22 +00:00
Thiemo Kreuz c8536f1a71 Remove unnecessary title parsing from template related code
There are 2 situations:

1. Either the template name is used in a [[…]] link. In this case
we must provide the namespace. MWTemplateModel.getTitle() does
this. However, it's not a mw.Title object and therefor not really
guaranteed to be a valid title. This is fine. The worst thing
that can happen is that the link points to an error message.
But this should be entirely unreachable anyway.

2. Some messages want to display the name of the template.
Ideally without the namespace. That's what
MWTemplateSpecModel.getLabel() is for. Again this is not
guaranteed to be a valid mw.Title. But it doesn't need to. It's
only used as a label.

Change-Id: I03d0481201620a2f5c444ee32b656bcaade98aac
2021-08-26 15:58:15 +02:00
jenkins-bot 34992ba3ac Merge "Basic cursor key support in new template dialog sidebar" 2021-08-26 13:46:40 +00:00
WMDE-Fisch 3913f635d4 Use spec label for template link generation
We should only need that label for the link. The other mechanic
would fail when editing wikitext like this:

{{{{echo|<}}|param=foo}}

Bug: T272487
Change-Id: If8d228b40bf1589181e83e8f68f3c33b4c7759c7
2021-08-26 15:09:48 +02:00
Thiemo Kreuz 0bd9e587b3 Basic cursor key support in new template dialog sidebar
Bug: T285323
Depends-On: I47effe05427cfabfcf534920edee79521eaa033f
Change-Id: I319896a20a71b18655ebb93663d47e656a1a67a6
2021-08-26 12:48:49 +00:00
Thiemo Kreuz df713170e0 Harden title parsing in MWTransclusionModel a bit
It appears like it's currently not possible to reach this code
with an invalid template name like `{{foo}}`. But this is not
guaranteed.

The purpose of this code is to call the TemplateData API. This is
pointless when a title is invalid. We know a page with this name
can't exist. So we skip it.

But that's all this code cares about. It should not crash. Nor
does it need to report this situation.

This is related to the discussion in Ic364e75.

Change-Id: If9bacc91b1c7bb110b33bfd395e1cbdf538e6c22
2021-08-26 14:46:01 +02:00
jenkins-bot 6c33cc4a35 Merge "Add message on multipart content" 2021-08-26 07:34:15 +00:00
jenkins-bot 5be007ee9a Merge "Minor cleanups to new add parameter input widget" 2021-08-26 07:26:53 +00:00
jenkins-bot 4741abe803 Merge "Added new input page for undocumented parameters" 2021-08-26 07:26:41 +00:00
Thiemo Kreuz a0e613d8fc Remove not needed boilerplate from QUnit tests
These tests obviously don't need this extra environment.
They run just fine (and faster) without.

Bug: T289560
Change-Id: Ib186a07cd556f741e0440ffa54ae6aaaf626adcd
2021-08-25 12:01:14 +00:00
WMDE-Fisch 67988452ab Add message on multipart content
Bug: T276574
Change-Id: Iff5c2fd4071dd03ca62c395cce4041dacb1c7ea6
2021-08-25 10:47:16 +02:00
Thiemo Kreuz 9392282bf2 More test cases for MWTransclusionOutlineContainerWidget
This also fixes a mistake in the class where we forgot to
disconnect event handlers when an element is removed from
the list. This doesn't have much of a consequence, as the
event flow is only in one direction, from the destroyed
element up. This is not possible any more.

Bug: T289560
Change-Id: I0bcc1d68c50b8cbdb033ef6692b34e2fc94e8d85
2021-08-24 15:46:46 +00:00
Thiemo Kreuz e56b4e82f5 Add test for ve.ui.MWParameterCheckboxInputWidget
This is not a file we created recently, but one we care about.
This is also a nice start to get in the mood to write tests.

Bug: T289560
Change-Id: I6475b00508cfa9188ab0d78c2bfd31bab8aed6ed
2021-08-24 15:44:43 +00:00
Thiemo Kreuz 352e7795ca More meaningful assertions for all outline part widgets
Bug: T289560
Change-Id: I81f882d6e6793198371ff9ff3e1e5bbbec98e0d9
2021-08-24 13:17:16 +02:00
Thiemo Kreuz f6953d4096 Add basic QUnit tests for all transclusion outline classes
This is just the smallest possible boilerplate to get the first
trivial test running. More test cases will be added in the
following patches.

Bug: T289560
Change-Id: I3a4e49a7b9761db00b211e933386bad71d4f0942
2021-08-24 11:31:14 +02:00
Thiemo Kreuz 3bca0f30c9 Minor cleanups to new add parameter input widget
Most of what I did in patchset 1 is now squashed into the
original patch Ic5dcd36.

Bug: T272487
Change-Id: I5cfd500da4c496a31ec5a28fedee4a079acc6123
2021-08-24 10:22:55 +02:00
Svantje Lilienthal 5c9fbca085 Added new input page for undocumented parameters
Bug: T272487
Change-Id: Ic5dcd36c9f647f9b52b98e5a520a1df1960a5b48
2021-08-24 10:18:43 +02:00
jenkins-bot e803c20007 Merge "Rename …ParameterCheckboxLayout now that it's an actual Widget" 2021-08-23 14:46:09 +00:00
jenkins-bot f1c9012916 Merge "Remove dependency from new sidebar to the BookletLayout" 2021-08-23 14:40:02 +00:00
jenkins-bot 6cdd1f6ebf Merge "Clean up toggleSidebar by splitting out 'auto'" 2021-08-23 14:31:39 +00:00
Thiemo Kreuz 3b5bc1b0b2 Fix non-existing property name .isNewSidebar
This is obviously a rebase mistake. We renamed the property in
I78a5129.

Change-Id: I43247ebf6c8910d12c90aa2dd1f9111f4ed69a07
2021-08-23 15:44:28 +02:00
Adam Wight b1a376a6e1 Clean up toggleSidebar by splitting out 'auto'
This naturally fits into a new function.

Bug: T274554
Change-Id: Icda432dc1a13243efddc9949f41a00162053970d
2021-08-23 14:38:24 +02:00
WMDE-Fisch fc8ce9d7e3 Fix typos in doc
Change-Id: I5895207ca2d9de91bb92e6ab3566fbf2880bf393
2021-08-20 14:56:32 +02:00
jenkins-bot d6316145b5 Merge "Better method names in MWTransclusionModel class" 2021-08-20 11:29:49 +00:00
jenkins-bot 112bd2e5cb Merge "Call focusPart() only once in MWTemplateDialog.onReplacePart()" 2021-08-20 09:56:52 +00:00
jenkins-bot cdf7d907a9 Merge "Fix null error in ve.ui.MWTemplateDialog" 2021-08-20 09:48:27 +00:00
jenkins-bot 928b33ce69 Merge "Re-add adding undocumented paramters in some cases" 2021-08-20 09:33:18 +00:00
Thiemo Kreuz 8fbdd4258f Fix null error in ve.ui.MWTemplateDialog
Introduced via Ifd52369 just a few minutes ago.

Bug: T288827
Change-Id: I859f606c0608f9725bb64ff56a501a7a2c85c1df
2021-08-20 09:24:56 +00:00
jenkins-bot 6f052b928d Merge "Use page ID string instead of object reference" 2021-08-20 08:37:48 +00:00
jenkins-bot d3e8fe001c Merge "Streamline and harden template paramter search widget behavior" 2021-08-20 08:35:45 +00:00
WMDE-Fisch c3e5ea2fe1 Re-add adding undocumented paramters in some cases
Bug: T272487
Change-Id: I862c2802da1340d302a2a95e8e9d17bd6fd35877
2021-08-20 10:13:20 +02:00
Thiemo Kreuz 5fcc862eb1 Remove dependency from new sidebar to the BookletLayout
This replaces I8cf9ecd.

Significant changes:
* The …OutlineContainerWidget doesn't need to know the
  BookletLayout any more. The only remaining resason to have
  this dependency was some focus management. This is now done
  via an event.
* Renamed an existing event to match the new one. The two
  really mean and do the exact same, even if they are
  triggered from two different places.
* Simplified some existing code.
* Updated documentation.

Bug: T288827
Change-Id: Ifcf2cadabf7fa4b8ecb72e3937003fab3b00d9bb
2021-08-20 10:07:03 +02:00
Thiemo Kreuz 7045371a4d Better method names in MWTransclusionModel class
Names like "fetch" or "resolve" are heavily ambiguous and
continue to confuse me. I hope these new names reflect better
what's going on.

Bug: T288827
Depends-On: I587a203a9370e4742f87586b4f1867b37459c375
Change-Id: I8fa47ed313e7d7b2c114a5638a67c4f3c8b830f1
2021-08-20 10:00:10 +02:00
Thiemo Kreuz 4f9426d61a Rename …ParameterCheckboxLayout now that it's an actual Widget
This is a direct follow-up for Idc5e048.

Bug: T285323
Change-Id: Ia03d594386a9a59a4819bf78c7d2edcd465dfd52
2021-08-20 09:56:40 +02:00
Thiemo Kreuz 301c84bda4 Call focusPart() only once in MWTemplateDialog.onReplacePart()
This merges all code-paths that re-select a part (i.e. an input
widget on the right side of the template dialog).

Note there is an edge-case that actually changes with this
patch. When a page is removed, and creating a new page fails,
there is an `if ( page )` check. Before, the behavior was that
nothing gets selected in this case. After this change the
behavior is the same as if a page was removed: the closest one
gets selected. Not only does this make more sense. The `if` is
only a fail-safe anyway and should not result in different
behavior.

Bug: T288827
Change-Id: Ibb0260587588fb51a876658b16a81c5a73371dc4
2021-08-20 09:49:30 +02:00
Thiemo Kreuz 47bed4e1c8 Use page ID string instead of object reference
You will see where I'm going with this in the following patches.

Bug: T288827
Change-Id: Ifd52369d19c01499fb9cc801c3deec46c26810fd
2021-08-20 09:47:57 +02:00
Thiemo Kreuz 45096d1e2f Streamline and harden template paramter search widget behavior
What this changes:
* The moment the user selects anything in the parameter search
  widget, the input is cleared, no matter what happens next.
  Even in case of an error. We know the input was bad in this
  case. Let's get rid of it.
* The method makes sure it does not even try to add a
  duplicate parameter. This should be unreachable, but better
  be safe than sorry.

This is split from I5eeb973. I run into this while playing
around with different approaches related to hiding deprecated
parameters. Typically there should be no way the parameter
search widget offers a duplicate. Still I believe it's a good
idea to have this extra safety-net.

Bug: T272487
Bug: T288827
Change-Id: I04e76d73b4a3f6467d0ccf3ccff5d2f6b4114bd9
2021-08-20 07:46:26 +00:00
jenkins-bot eaeaf7240a Merge "Rename custom outline widget events to not conflict" 2021-08-19 13:49:29 +00:00
jenkins-bot 834d7fee77 Merge "Rename conflicting .setSelected() method in outline widget" 2021-08-19 13:46:24 +00:00
jenkins-bot 2326468533 Merge "Remove unused code from ve.ui.MWTransclusionOutlinePartWidget" 2021-08-19 13:43:26 +00:00
jenkins-bot b7f572bd06 Merge "Reduce deep nesting in ve.dm.MWTransclusionModel" 2021-08-19 13:40:55 +00:00
jenkins-bot fdde92f820 Merge "Refactor onReplacePart in TemplateDialog" 2021-08-19 13:40:52 +00:00
jenkins-bot 0bf5c8493b Merge "Remove parameter adding on new sidebar code" 2021-08-19 13:40:16 +00:00
Thiemo Kreuz 095c891040 Remove unused code from ve.ui.MWTransclusionOutlinePartWidget
* getPartId() is unused.
* Use this.data instead of a custom this.partId.
* No need to store this.header as a property.
* Rename the event to "headerClick". That's enough when the
  event comes from a widget that does have the word "part" in
  it's name.

Bug: T274544
Bug: T288827
Change-Id: I8c70425403c6cd6a19e3a1cacb2b085e5c8b2e46
2021-08-19 11:03:44 +00:00
Thiemo Kreuz 3365c0fd66 Rename custom outline widget events to not conflict
The base widgets we are going to use (notably OO.ui.OptionWidget
and OO.ui.SelectWidget) also have events, and some of them use
the same names. Such conflicts are really hard to track down.

This is meant to be temporary. The goal is to use the events
from the base classes and get rid of the custom ones, if
possible.

Bug: T285323
Change-Id: I0f103a5bbb8fb800e57009e3bf709f00a651fdda
2021-08-19 09:55:11 +00:00
Thiemo Kreuz 68712e979b Rename conflicting .setSelected() method in outline widget
The problem here is that the OO.ui.OptionWidget base class
(changed in the previous patch) also contains a .setSelected()
method, but with slightly different behavior. This results
in crazy behavior when I try to make the outer widget an
OO.ui.SelectWidget.

Renaming the method to be a custom, private helper method
avoids this problem.

The plan is to actually use the default setSelected()
behavior and get rid of the helper method. This will be done
in later patches.

Bug: T285323
Change-Id: I84e752f20a4d07007fd4e61989f9b34983410950
2021-08-19 09:54:55 +00:00
WMDE-Fisch eeda931f59 Refactor onReplacePart in TemplateDialog
As preparation to introduce then new UI to add unknown parameters.
This is a few things:
- Merge the code paths when adding a MWTemplateModel
- Put code adding parameters to the dialog next to each other so
  that preventing reselection happens around that block
- Reduce duplicated code when re-focusing after addition
- Move adding the placeholder page to the end
- Add and clean up inline documentation

Bug: T272487
Change-Id: Ic700edd42027a928a236ed11f2c257fffe994257
2021-08-19 08:19:01 +00:00
WMDE-Fisch d41714f3a1 Remove parameter adding on new sidebar code
This removes the paramter placeholder page from all places where it's
not usefull anymore under the new sidebar.

The new UI will be re-added in follow up patches.

Bug: T272487
Change-Id: Ifc6f6f64fed1a1b23c92282e2a1bb40a7d401d72
2021-08-19 08:18:55 +00:00
Thiemo Kreuz 0af0978db4 Use same .useNewSidebar property name everywhere
This makes it easier to find stuff.

Change-Id: I78a51290767db4fe06ba0d4d2d251e8df07368b4
2021-08-19 10:13:16 +02:00
jenkins-bot ef43ae2950 Merge "Add getters for un-/documented parameters" 2021-08-19 07:19:05 +00:00
WMDE-Fisch 9aaeac3318 Add getters for un-/documented parameters
Will be needed to figure out when the new UI to add parameters should
be visible.

Bug: T272487
Change-Id: I97d2429b7845905784ef18e9d41cd5e6f85bbd01
2021-08-19 07:00:30 +00:00
jenkins-bot 5102ed2ab5 Merge "ve.ui.MWMediaDialog: mediaUploadBooklet may be undefined" 2021-08-18 16:50:07 +00:00
jenkins-bot f2e0388dc1 Merge "ve.ui.MWBackTool: Avoid using global ve.init.target" 2021-08-18 16:50:04 +00:00
jenkins-bot 68cfd5da16 Merge "Remove addParameter button from new sidebar" 2021-08-18 09:34:26 +00:00
jenkins-bot b05b165981 Merge "Make template parameter checkbox widget an OptionWidget" 2021-08-18 09:31:52 +00:00
jenkins-bot 029a982625 Merge "Remove unwanted scrollbar in responsive template dialog" 2021-08-18 09:22:36 +00:00
Thiemo Kreuz 220c98ab44 Make template parameter checkbox widget an OptionWidget
The plan is to change the outer …TemplateWidget (which contains
a list of template parameter checkboxes) into a SelectWidget.
But this requires the elements in the list to be a subclass of
OptionWidget.

Note this change does not have any effect, as of this patch. But
this makes the following patches smaller and easier to follow.

Additionally:
* The OptionWidget class is already a LabelElement. No need to
  initialize this twice. This happens via the parent constructor
  now.
* Remove CSS that is not needed any more after Idc5e048. This is
  not a FieldLayout any more.
* Update some related code documentation.

Bug: T285323
Change-Id: I92e8fd2bbece9e6c55083cdfe6ed7ad16a64d688
2021-08-18 11:11:41 +02:00
WMDE-Fisch 891814d12c Remove addParameter button from new sidebar
Bug: T272487
Change-Id: Ie790a056f16727a89199f9737862281e0ac455a3
2021-08-18 09:22:43 +02:00
jenkins-bot d417d3709b Merge "Use the "wikitext" for content in transclusions" 2021-08-17 13:32:37 +00:00
jenkins-bot 52e24c650a Merge "Remove sidebar margin on single transclusion" 2021-08-17 13:29:16 +00:00
WMDE-Fisch 03af517d19 Adjust icon spacing in new sidebar menu
The icons have a padding of 6px around the icon image itself. To
get to the required 16px/8px space the margin was adjusted
accordingly. Note that there's also a 2px padding around the menu.

Bug: T272482
Change-Id: I3df9f355dfd5c4e6366432555b96bf788e784280
2021-08-17 14:26:06 +02:00
WMDE-Fisch 53186fc231 Remove sidebar margin on single transclusion
Bug: T272482
Change-Id: I5696dbd469161b1ab1ede2bb3f49e6dd24b98521
2021-08-17 13:54:36 +02:00
Thiemo Kreuz 7503b323b1 Stop re-creating template parameter pages over and over again
This is what actually happens:
* We call `addParameter()`.
* This triggers an `add` event.
* This calls an `MWTemplateDialog.onAddParameter` event handler.
* This code doesn't check if a parameter already exists (because
  it shouldn't). It detroys the page in the content pane on the
  right and recreates it from scratch.

The only reason we do this is to focus the input field on the
right. This patch introduces a dedicated event to do this.

Bug: T288827
Change-Id: I47effe05427cfabfcf534920edee79521eaa033f
2021-08-17 13:34:41 +02:00
WMDE-Fisch 199d9536d1 Use the "wikitext" for content in transclusions
Bug: T272482
Change-Id: Ibe68b49c25b4f0d88483c22e0e4b8462d935a45b
2021-08-17 13:06:49 +02:00
Thiemo Kreuz 88ebae9b0f Remove unused properties from template part widget classes
It doesn't look like we are going to need these.

Bug: T288827
Change-Id: I0bcc1aea85ce589db814a1bed12226d47728d7e9
2021-08-16 14:52:54 +02:00
jenkins-bot 5c9bfe6a33 Merge "Make checkbox element in the sidebar an actual widget" 2021-08-16 12:36:40 +00:00
jenkins-bot c3ff9df19e Merge "Basic keyboard navigation in the new template dialog sidebar" 2021-08-16 12:36:37 +00:00
jenkins-bot ddfde5f3b6 Merge "Remove duplicate class property from checkbox layout" 2021-08-16 11:56:16 +00:00
jenkins-bot 4d6d700e8f Merge "Add isDocumented() feature to ve.dm.MWTemplateSpecModel" 2021-08-16 11:29:26 +00:00
jenkins-bot eb0e2cd507 Merge "Change filterParameter(s) event to work with a list" 2021-08-16 11:10:09 +00:00
jenkins-bot 41c286c68c Merge "Rename ambiguous "add button" click handlers" 2021-08-16 11:01:36 +00:00
jenkins-bot 0e6c56160e Merge "Show sidebar controls only when multi-part content is present" 2021-08-16 10:54:41 +00:00
jwbth 6d7a062dbb Fix history.replaceState call on diff pages
The history.replaceState call in onReviewModeButtonSelectSelect() (1)
ignores any changes to the document URL made by external tools such as
RevisionSlider, (2) replaces with an empty string the history entry
state object if it was set by external tools such as, again,
RevisionSlider. Both 1 and 2 result in a wrong URL ending up in the
address bar at some point. This patch addresses these problems, (1)
creating a new mw.Uri() object every time
onReviewModeButtonSelectSelect() is called, (2) keeping the current
history.state object.

The original variable storing the URI object is renamed to avoid
shadowing (optionally can be replaced with its value as it's used only
once).

Bug: T288636
Change-Id: Ieb97b561a6c076aa28aae231fe286ac4d1051bbd
2021-08-14 10:51:24 +00:00
Thiemo Kreuz b264a9c381 Add isDocumented() feature to ve.dm.MWTemplateSpecModel
Bug: T272487
Change-Id: I39c612358cc0238c515c8eb28aa1b40418a10cef
2021-08-13 12:47:28 +02:00
jenkins-bot 3999f5bac3 Merge "Fixing minor jsdoc typo" 2021-08-12 09:30:17 +00:00
jenkins-bot ea0f1c2610 Merge "Minimize template dialog CSS a bit" 2021-08-11 13:19:20 +00:00
Andrew Kostka a2135d524d Show sidebar controls only when multi-part content is present
Bug: T272482
Change-Id: I092438bc9c7d5569f758786ca6952beffdf37507
2021-08-11 15:00:59 +02:00
jenkins-bot 1f91b2e185 Merge "Rename and document definition of "empty" in ve.ui.MWParameterPage" 2021-08-11 07:44:33 +00:00
Thiemo Kreuz 97486b2b3d Rename and document definition of "empty" in ve.ui.MWParameterPage
I found this while working on T274551, which is all about the
definition of "empty".

In the old sidebar a parameter's name is dimmed (gray) as long as
the parameter's value is empty. This stops working entirely when
there is a default value.

My first impulse was "this is a bug". When there is a default
value, both the empty string and the default value (when the user
enters it exactly) typically trigger the same behavior: The
template uses the default value, just as if the user entered it.

But this code is correct because of the way it is used. Only
parameters that are "truly" empty should be visually marked as
such. The moment there is a default value it is either impossible
to change this back to an empty string – meaning the parameter
can never be truly empty – or the empty string is meaningful user
input.

Bug: T274551
Change-Id: I90657bfe83e56afd3942428c0dd8a47b444e39c9
2021-08-11 07:24:41 +00:00
Thiemo Kreuz d1f87646df Make checkbox element in the sidebar an actual widget
This should not have any effect on how the thing looks and
behaves.
* All elements in the sidebar should be reachable with the tab
  key, including disabled elements.
* Enter jumps to the corresponding paremeter in the content
  area on the right. But enter doesn't change the checkbox
  state.
* Space canges the checkbox.

The class will be renamed in the next patch.

Bug: T285323
Change-Id: Idc5e04828ece0ba77a65e4c839cd3ffccc3b6733
2021-08-11 09:12:00 +02:00
Thiemo Kreuz 993c64f9a2 Minimize template dialog CSS a bit
Bug: T272481
Change-Id: I156c8f2ea4a70d2e86a7bc4282738c51bebc3f2a
2021-08-11 08:09:40 +02:00
Thiemo Kreuz 0bbcb436c1 Change filterParameter(s) event to work with a list
As discussed in Ia44da16. This change avoids possibly hundreds
of events (when a template does have hundreds of parameters),
and replaces them with a single one.

Bug: T288202
Change-Id: Ic819e8c93e872b653c238f396f1f327b6a8759d2
2021-08-11 08:06:22 +02:00
WMDE-Fisch 8f39c56ded Fixing minor jsdoc typo
Change-Id: Id543c939836d1c15f5cfdcfc7450efc574e85cb6
2021-08-10 16:15:30 +02:00
jenkins-bot 84799aa36c Merge "Don't show toolbar in MWLanguageVariantInspector text targets" 2021-08-10 01:17:08 +00:00
David Chan b8e2bfe051 Don't show toolbar in MWLanguageVariantInspector text targets
Bug: T284402
Depends-On: Idc8d2ffdae3f1168813fcb89ce5ca20bd835f9ab
Change-Id: I9316d77218b81ed47f99293ed70fe02c32edb96e
2021-08-09 23:34:48 +00:00
Thiemo Kreuz f32a062e3f Basic keyboard navigation in the new template dialog sidebar
There is still a lot to do, but this implements some basic
behavior that was missing before.

* You can now use the tab key to navigate all checkboxes,
  including disabled ones (required parameters).
* Enter key now works on both the checkbox as well as when
  the entire line is highlighted. Enter forces the checkbox
  to be checked and moves the focus to the content area.
* Mouse clicks now work on the entire line. Before, only the
  text label was clickable.

Open issues (not to be resolved in this patch):
* Clicking the text label and the empty space after the text
  label does different things. Probably shouldn't.
* Should a click on the label check the checkbox?
* Space key should probably not move the focus to the content
  area.
* Focus rectangle is different on disabled rows. Is this ok?
* Background color when a line is focussed is missing.

Change-Id: I22ccd1bea92e4f098d4b25a9e38cddde5c103423
2021-08-09 18:38:28 +02:00
Thiemo Kreuz 984a3a1ebf Remove duplicate class property from checkbox layout
The checkbox is the first parameter in the parent constructor.
The parent is the FieldLayout class. The checkbox becomes the
this.fieldWidget in the parent class. Just use this instead of
storing a duplicate reference.

Bug: T274543
Change-Id: I4ae7d467334f88f2be93a62660145a025089401f
2021-08-09 18:31:30 +02:00
Thiemo Kreuz 7d464fbf1f Remove unwanted scrollbar in responsive template dialog
I get a scrollbar at the bottom of the sidebar. The reason is
that the container's width is 100% + 1px. The extra pixel is
from the border, which is not needed in this mode.

Bug: T274554
Change-Id: I4f749be6b9a7f89f9a7a195dc66c5c18253b1327
2021-08-09 18:28:56 +02:00
jenkins-bot 622a85a2eb Merge "Split long ve.ui.MWTransclusionOutlineTemplateWidget methods" 2021-08-09 12:50:43 +00:00
Thiemo Kreuz 2ce7bb0213 Split long ve.ui.MWTransclusionOutlineTemplateWidget methods
This direct follow-up is meant to resolve the change request
from I1b0480a.

Bug: T274551
Change-Id: Iee4bab0b9807e6d36435d31bf8ec879d13d9ad3b
2021-08-09 10:40:53 +00:00
Thiemo Kreuz 9e74e2f352 Ignore default values as not being valuable as well
This check makes sure the user doesn't loose work when clicking
the back button. I would like to argue that neither of these
values is valuable enough to block the user with a confirmation
dialog:
* Literally nothing is lost when the input is empty.
* The auto-value is only temporarily lost, but will
  automatically be restored when the user decides to add the
  template back. The input field is pre-filled with this value.
* The default value doesn't need to be manually entered. It will
  show up anyway when the parameter is missing.

There is a rare edge-case, but it is not really relevant in this
situation. Some templates allow to override a default value with
the empty string. This will be considered irrelevant by this
code. However, this was already happening before and doesn't
change with this patch.

The only edge-case where this patch makes a difference is if a
parameter is marked as required or suggested, is documented to
have a default value, _and_ the template allows to override it
with an empty string. But this combination is rather crazy, if
not bogus, and not worth considering here, I believe.

Bug: T274551
Change-Id: Ib176a82844335c3d4dd5b720d335ec28245e1637
2021-08-09 10:28:09 +00:00
jenkins-bot aa868059ee Merge "Better name for ambiguous "empty" concept in the model" 2021-08-09 09:40:40 +00:00
jenkins-bot d5b40aaab7 Merge "Fix off-by-1 error when deprecated parameters are hidden" 2021-08-06 13:28:45 +00:00
Thiemo Kreuz 35080a8646 Better name for ambiguous "empty" concept in the model
This is really only about the methods name, but doesn't change
any behavior.

I realized we work with several different definitions of what
"empty" means. There are at least two significant definitions:

1. When a parameter's value is the empty string or identical
to the default value, the behavior of the template is the same.
It will use the default value just as if the user entered it.

The auto-value is a meaningful value in this scenario and can't
be considered equal to the empty string.

2. The context here is when the user presses the back button.
This will destroy all user input. But an auto-value is not user
input. It will appear again when the user realizes they made a
mistake. Nothing is lost.

Personally, I would not use the word "empty" to describe this
concept. Things like "containsUserProvidedValue",
"isCustomValue", "isMeaningfulValue", … come to mind. These are
all still a big vague. A "user provided" value can be identical
to the default or auto-value. "Custom" how? I went for
"containsValuableData" for now.

Bug: T274551
Change-Id: I2912a35556795c867a6b2396cbad291e947f0ed6
2021-08-06 15:11:44 +02:00
jenkins-bot 004d37dc1d Merge "Hide old sidebar when the new one is enabled" 2021-08-06 13:10:04 +00:00
Thiemo Kreuz 6446cf950f Fix off-by-1 error when deprecated parameters are hidden
This is a direct follow-up to I6ebd020.

Steps to reproduce the bug:
* Make sure you have a template with a deprecated parameter.
  The position doesn't matter.
* Add the template. The deprecated parameter is hidden.
* Add an undocumented parameter, e.g. "b". This is added to the
  end, as it should.
* Add an undocumented parameter "a". This should appear before
  "b", but doesn't. The reason is because the invisible
  deprecated parameter is in the list that is used to calculate
  the index, shifting it by 1 (or more when there are more
  hidden parameters).

This patch includes a few closely related changes:
* We can loop the list of checkboxes directly instead of
  indirectly via the list of parameter names.
* I made it so that an active filter only resets if it would
  hide the new parameter. The original problem we had to solve
  was that the new parameter would always be visible, even if
  it doesn't match the filter. This awkward mismatch is still
  guaranteed to not happen.

Bug: T274551
Change-Id: I1b0480ae836cc19b77b159d3fb30ff32e8c59df4
2021-08-06 12:24:49 +00:00
jenkins-bot 1cb4a5a471 Merge "Remove redundant ve.dm.MWTemplatePlaceholderModel.isEmpty" 2021-08-06 10:56:00 +00:00
jenkins-bot 4e2f3befe9 Merge "Make the sidebar in the transclusion dialog responsive" 2021-08-06 10:40:44 +00:00
jenkins-bot 5dabf57f94 Merge "Filter right content side of the template dialog as well" 2021-08-06 10:26:55 +00:00
Andrew Kostka 21e9f5f0c4 Make the sidebar in the transclusion dialog responsive
Bug: T274554
Change-Id: I51e988e6fb0e50c9d542400471152807626539ea
2021-08-05 17:23:22 +02:00
Andrew Kostka 2f1cfdd187 Cleanup feature flags in ve.ui.MWTransclusionDialog
Change-Id: I6f6326c981da998b547a2a1990e26185763093ca
2021-08-05 17:00:27 +02:00
Thiemo Kreuz 3e5a2d6c82 Filter right content side of the template dialog as well
I came up with a new event to do this. This event is triggered
individually for each parameter. An alternative is a single
event that gets a list of visible parameters. Is this better?
What do you think?

Bug: T288202
Change-Id: Ia44da16917c28171a01aef0f1c613dcd5d3266ba
2021-08-05 14:36:10 +02:00
jenkins-bot fce48b0958 Merge "Split MWTransclusionModel methods to do one thing only" 2021-08-05 10:32:18 +00:00
Thiemo Kreuz 87410aaa7d Reduce deep nesting in ve.dm.MWTransclusionModel
This is split from I8fa47ed. I believe these changes are
non-controversial.

Change-Id: I3c5d4e1867ee0f53736f55fb7c6f27ad8d304596
2021-08-05 10:59:22 +02:00
Thiemo Kreuz f37814ba61 Rename ambiguous "add button" click handlers
Change-Id: I25fd1430443feffcc3fb17115dc4129890063c48
2021-08-05 10:51:26 +02:00
Thiemo Kreuz 0351537ba2 Hide old sidebar when the new one is enabled
This is – for now – intentionally done in a way that can be
undone. This will still be helpful for debugging for a while.
But we need to get rid of the duplication to be able to make
this new functionality visible on the beta cluster.

Actual removal will hapen the moment we actually remove the
old toolbar. There are already tickets for this.

Bug: T286765
Change-Id: I842c3c39a55a273af20643fa8a602d2e57fb6b8c
2021-08-05 09:14:40 +02:00
Thiemo Kreuz 5e2a898459 Don't offer deprecated parameters when they aren't used
This affects only the new sidebar. Deprecated parameters don't
get a checkbox, except they are used already. "Used" includes
parameters that are present, but empty.

Bug: T274551
Change-Id: I6ebd020d02650c19060345d13495373acab363df
2021-08-04 16:34:54 +02:00
jenkins-bot 21d9f533c8 Merge "Avoid conflicts between 2017 wikitext editor and DiscussionTools new topic tool" 2021-08-03 16:14:18 +00:00
jenkins-bot cf17a1f191 Merge "Remove tooltip from template dialog title" 2021-08-03 15:29:10 +00:00
Thiemo Kreuz 920550560d Remove redundant ve.dm.MWTemplatePlaceholderModel.isEmpty
This method already exists in the ve.dm.MWTransclusionPartModel
base class where it does the exact same.

Bug: T274551
Change-Id: I19d5914ed9b4b435c83ea4d64019bc46ce1ce8fd
2021-08-03 14:40:50 +02:00
jenkins-bot 7ef4fdc0c2 Merge "Revert "Hide deprecated parameters if they don't have a value"" 2021-08-03 08:42:35 +00:00
Thiemo Kreuz (WMDE) 8d9b4526c6 Revert "Hide deprecated parameters if they don't have a value"
This reverts commit 0d4dee341b.

Reason for revert: This made it entirely impossible to add a
deprecated parameter, even if done intentionally. Needs more tests.

Bug: T274551
Change-Id: I7389bad0845cd1ce78f9d7ef71592cb1ce2a063e
2021-08-03 08:24:24 +00:00
jenkins-bot e57daaad98 Merge "Minor JSDoc documentation fixes in template dialog code" 2021-07-29 12:13:17 +00:00
jenkins-bot c7274acf80 Merge "Remove skinning modules when showing preview" 2021-07-28 19:35:42 +00:00
jenkins-bot 8102c3cc36 Merge "Move abort event tracking from the start to the end of the teardown process" 2021-07-28 16:59:03 +00:00
Arlo Breault 2fd09aaba3 Remove skinning modules when showing preview
Bug: T185284
Change-Id: Ifec8809cd75cb76c79936a69351be0c7779de39e
2021-07-28 10:55:16 -04:00
Bartosz Dziewoński ec3341c9a1 Avoid conflicts between 2017 wikitext editor and DiscussionTools new topic tool
They both want to handle the same URLs. If we detect that
DiscussionTools new topic tool will open, then do not open 2017
wikitext editor.

Bug: T282204
Change-Id: Ic7dd677ea219938969f60bab91387c2e03ebdbe6
2021-07-28 16:10:22 +02:00
jenkins-bot 98aeab538b Merge "MWInternalLinkAnnotationWidget: show disambiguation pages last" 2021-07-28 03:00:52 +00:00
MusikAnimal 4fbab29e22 MWInternalLinkAnnotationWidget: show disambiguation pages last
Disambiguation pages are rarely the page users intend to link to,
especially with newbies. By moving the disambig page(s) as the last
result, the user is more likely to pick the page they actually intended
to link to.

Bug: T285510
Depends-On: I2b8545f6dd4849629037f81f48a540748e60da83
Change-Id: Id55a19e7665d8f88559c471de36e5447fb2babb0
2021-07-27 18:36:50 -04:00
Bartosz Dziewoński 6dc9b55b21 Move abort event tracking from the start to the end of the teardown process
Bug: T237063
Change-Id: I66869f8a84692e6fbe00373460449714cc722084
2021-07-27 22:50:52 +02:00
jenkins-bot 632d83aa8d Merge "Fix rare exception when editor loading is aborted" 2021-07-27 17:27:30 +00:00
Bartosz Dziewoński 995644de88 Fix rare exception when editor loading is aborted
If editor loading was aborted while the surface was already being set up,
this code would cause the following exception:

    Uncaught TypeError: Cannot read property 'tools' of null

Introduced in c02c529537 (2017) because
our coding conventions at the time demanded that all `var` statements
must appear at the beginning of a function.

Bug: T287487
Change-Id: Id657d6f1e1189c17ede25362f145bb7b10f441db
2021-07-27 17:40:13 +02:00
jenkins-bot e36d67cf75 Merge "Hide deprecated parameters if they don't have a value" 2021-07-23 11:04:17 +00:00
Andrew Kostka 0d4dee341b Hide deprecated parameters if they don't have a value
Bug: T274551
Change-Id: I6bfceae2579a5bcedae9da7eb5326fe8f60ea7c0
2021-07-22 12:24:57 +02:00
Andrew Kostka ef33a908a0 Dynamically set the visibility of the sidebar search
With this users can also filter undocumented parameters
that they added to an empty starting template.

Bug: T272481
Change-Id: I99adb38b0ae4d4ade91fcb506f10c0222b9bb5e8
2021-07-20 13:11:08 +02:00
Andrew Kostka 6cec42f8dc Don't reset the sidebar search field if the search widget is undefined
Bug: T286987
Change-Id: I66116ea08d4682e179e9eb70d117454194e3517d
2021-07-20 12:08:00 +02:00
Andrew Kostka d44bc19d20 Adjust the styling for the template parameter search
Bug: T272481
Change-Id: Ie1c6b95cf32640401cb2a17bcda656a40a22e9b4
2021-07-16 18:03:48 +02:00
jenkins-bot d738698deb Merge "Fix incomplete back button implementation in template dialog" 2021-07-16 14:41:07 +00:00
jenkins-bot 317b78782e Merge "Make it possible to reuse existing transclusion outlines" 2021-07-16 14:25:24 +00:00
jenkins-bot 4cb9b05668 Merge "fix order of sidebar elements" 2021-07-16 14:15:16 +00:00
Svantje Lilienthal 2f4e73d6ed fix order of sidebar elements
Bug: T272481
Change-Id: Ifd925bd6e8b972fd5d4e851c3a39a91aeac97d43
2021-07-16 15:10:56 +02:00
jenkins-bot 18a18bc825 Merge "Fix incomplete template dialog event handling in new sidebar" 2021-07-16 13:07:03 +00:00
Thiemo Kreuz 014bc9369c Fix incomplete back button implementation in template dialog
Bug: T286783
Change-Id: Ie86e2c8c6a874fde11591286a83faba71a34430d
2021-07-16 14:54:09 +02:00
jenkins-bot 575d4a8376 Merge "Fix ellipsis on long strings in parameter search widget" 2021-07-16 12:48:53 +00:00
Thiemo Kreuz 5c6d2212da Make it possible to reuse existing transclusion outlines
Note that this patch alone probably does not make that much
sense. The code executed is pretty much the same. The only
difference is that the empty (!) …ContainerWidget is kept
and re-filled with what might be a completely different
template.

This is not much of a difference to before when the
container was recreated.

This change will make more sense when the container has to
manage more state, e.g. focus states. This state will
survive then.

Change-Id: Ic336d10a595e3e222741a3dc57c1d54639166b7a
2021-07-16 14:43:31 +02:00
Thiemo Kreuz 092276009a Minor JSDoc documentation fixes in template dialog code
Change-Id: I3697e48697ab0910b90b418abbc370736589b6e1
2021-07-16 14:25:11 +02:00
jenkins-bot 4ab5fd5c6b Merge "Add a message next to undocumented parameters" 2021-07-16 12:05:29 +00:00
Thiemo Kreuz 1bbf7c3394 Fix ellipsis on long strings in parameter search widget
This ellipsis was there before we started working on this code,
but was never working properly.

We understand that the CSS was intentionally done like this (as
the comment explains). However:
* We changed the width of the dialog. The old value doesn't
  match any more.
* The width is different when the sidebar is expanded vs. when
  it is collapsed. Even if we update the number, it won't
  always work.
* The 100% work fine in current browsers. I can only assume
  this was different back in 2014 when this CSS was written
  (see Ia8259e9).

Bug: T285044
Change-Id: I3de2b0ed0b6a05d2b9fa0b325a2b12277564b271
2021-07-16 13:33:51 +02:00
Thiemo Kreuz 434c11f6de Fix incomplete template dialog event handling in new sidebar
Notably:
* Don't require the model in the new sidebar via dependency
  injection, but connect the event handlers later. This is
  relevant because we currently create the new sidebar in the
  wrong spot. Removing the hard dependency allows us to split
  the code and utilize initialize() and getSetupProcess()
  correctly. This will be done in a following patch.
* The change event now includes the new position. This makes
  it very easy to add this missing feature to the new sidebar.

Also:
* Stop triggering change events when nothing changed. These
  events are expensive. They bubble all the way up to the
  TransclusionModel, and to all linked
  onTransclusionModelChange() handlers.
* Update event documentation to make this more visible.

Bug: T274544
Change-Id: Iafe29f18a6fed14d9c3124c9756aa840886afbbc
2021-07-16 11:29:26 +00:00
jenkins-bot cdf2497983 Merge "Tweaks and cleanups to template parameter search" 2021-07-16 10:47:37 +00:00
jenkins-bot 3858829c19 Merge "Fix template editor showing more than one new sidebar" 2021-07-16 10:18:06 +00:00
Thiemo Kreuz 1164f67f40 Tweaks and cleanups to template parameter search
Notably:
* Include parameter aliases, labels and descriptions in the
  search.
* Don't use a possibly outdated search index, but live data.
* Clear filter when a new checkbox is added.

Bug: T272481
Change-Id: Ie90a803af6178a8bb6de370a0f8e079800d9f8a2
2021-07-16 12:11:13 +02:00
jenkins-bot 6e86365b81 Merge "Add parameter search to sidebar of VE TemplateDialog" 2021-07-16 10:06:15 +00:00
Svantje Lilienthal 066c663864 Add parameter search to sidebar of VE TemplateDialog
Bug: T272481
Change-Id: If044e5d134f1b24f939c4786949e6ca34fb79e1e
2021-07-16 09:48:29 +00:00
jenkins-bot 974db3940f Merge "Show ellipsis when sidebar parameter names are too long" 2021-07-16 08:28:13 +00:00
Andrew Kostka 9ffdd51f04 Show ellipsis when sidebar parameter names are too long
Bug: T285044
Change-Id: I6bf53ec4d6d45888ed7e9ba1d67848e41224de63
2021-07-15 17:35:42 +02:00
jenkins-bot a8ff5f2b41 Merge "Remove trash icons from the content view" 2021-07-15 15:21:57 +00:00
Thiemo Kreuz 8ab2ec25ea Fix template editor showing more than one new sidebar
Bug: T274544
Bug: T286715
Change-Id: I9fe8b53a73b1862eca2d99afb02aa3d532d61918
2021-07-15 15:17:44 +00:00
Andrew Kostka f02c48ea52 Add a message next to undocumented parameters
Bug: T274550
Change-Id: I1af71150239ebc9966cc22e7d28883fbac99fdf1
2021-07-15 14:47:21 +02:00
Andrew Kostka 01d8a8c7a4 Remove trash icons from the content view
Bug: T275761
Change-Id: I8d2c1b8ebdc2e20779d0207b1a2ebe6ce36c54e7
2021-07-15 12:20:45 +02:00
Thiemo Kreuz 766b220f5a Finishing touches to new template editor sidebar
In detail:
* Allow clicks on all elements in the new sidebar. This should
  focus the corresponding element on the right.
* Make all elements in the new sidebar tabbable.
* Fix MWTransclusionOutlineTemplateWidget.createCheckbox() to
  not need a temporary param object any more.
* Rewrite more code in MWTransclusionOutlineTemplateWidget to
  be shorter and easier to read.
* Fix MWTemplateModel.addParameter() to not do way to much
  stuff when a parameter already exists.
* Update code documentation.
* Use more specific, less ambiguous variable and method names.

Bug: T274544
Change-Id: Iaf6f7d1b0f7bf0e9b03eb86d01f3eceadece6fe4
2021-07-15 08:40:35 +00:00
Thiemo Kreuz ff9f8a9e2d Focus template editor elements on click in the new sidebar
Clicks on the left side now focus elements on the right
side.

This patch also simplifies the …ContainerWidget constructor.
The config parameter should only be used for "OOUI things"
that are needed by subclasses and mixins. But the parameters
we have here are not "UI things".

Passing them as config passes them to classes where we don't
know what they do with it. What probably happens is that
some class keeps a reference to the entire config object,
which doesn't have a benefit and possibly blocks garbage
collection.

Bug: T274544
Change-Id: I0c0e4a1ba59dcb43141338ffe939c9c6783e000d
2021-07-15 08:40:28 +00:00
Thiemo Kreuz 198c5dba77 Make button to add undocumented template parameter work
Thanks to the widget now being an actual ButtonElement.

Bug: T274544
Change-Id: I1b0ef28b0aa115a027a07f3ae53c583598483e96
2021-07-15 08:40:20 +00:00
Thiemo Kreuz eb1f1e28a3 Make new template editor sidebar items actual ButtonElements
Actually reusing this OOUI mixin gives us a lot of well
developed functionality we need anyway. Most notably proper
event management, e.g. click events.

The number of CSS properties we need to override is managable,
I would argue. Let's see:
* Our buttons are not inline-elements, but should use the full
  width.
* No focus-border left and right for the same reason.
* We want much more inner padding.
* We want a stronger hover effect.
* We need to fine-tune the position of the icon. This is
  because of the inner padding.
* Need to get rid of a negative margin that's only relevant
  for inline-buttons.

I currently feel like the benefits are worth living with
slightly more brittle code. Note that we can undo this change
any time because all this is well encapsulated in this new
class.

Bug: T274544
Change-Id: I33f275a958964d49e803e56bf74a6fa961093da1
2021-07-14 13:31:40 +02:00
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 06bc660b35 Split MWTransclusionModel methods to do one thing only
Before the method fetchRequestAlways() was doing two entirely
different things. Note how the two function arguments are
split now. Each method uses only one of them.

Change-Id: I592a1f29fd9c677a0ff18115cccda36950172001
2021-07-06 15:50:09 +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