Commit graph

784 commits

Author SHA1 Message Date
Thiemo Kreuz 6d41da0de7 Use short syntax for transforming one event into another
Change-Id: Id794f2b620edebd6eab71e3380ce1eeffcdc95ef
2022-07-12 11:54:04 +02:00
jenkins-bot 479732f516 Merge "Take parameter list out of tab navigation when empty" 2022-07-08 13:13:26 +00:00
Adam Wight fb81938c74 Take parameter list out of tab navigation when empty
This prevents an invisible and unactionable focus target when the
parameter search field doesn't match anything.

Bug: T312547
Change-Id: Ib29913a547cd68649d29e28d921c4c1358bad7b8
2022-07-08 13:59:37 +02:00
WMDE-Fisch 0850a205df Lessy-fying OutlineTemplateWidget rules
Also renaming one class for convenience.

Change-Id: I0ef079ca40d061f5f2cde0eafdd04737d63c370f
2022-07-08 13:33:23 +02:00
jenkins-bot 768e8517f8 Merge "Revert "Restore selection after keyboard parameter navigation"" 2022-07-07 15:14:31 +00:00
Andrew Kostka 079a1ce6ff Remove highlighting when typing in a search field
Bug: T311204
Change-Id: I583c02df3def6cfeb347e9b63045b62e1d735e24
2022-07-07 13:40:42 +00:00
Adam Wight a83d37d864 Revert "Restore selection after keyboard parameter navigation"
We don't want to restore selection.  Instead, we'll remove all
parameter selections onFocus, in a later patch.

This reverts commit 787d44af66.

Bug: T312017
Change-Id: Ia1dc8061dfd1813a58befff5adc5c3882b54d8e2
2022-07-07 15:24:11 +02:00
Adam Wight f93527e00f Scroll even if sidebar selection hasn't changed
This should be safe because selection is only set from use cases
in which we do want the sidebar scrolled to the matching item.

Bug: T290975
Change-Id: Ib0c66bb048768d633d0f638c775eba24cd652db8
2022-07-06 14:58:55 +02:00
jenkins-bot 4730987f2c Merge "Remove selection when selected parameter is unchecked" 2022-07-06 08:11:01 +00:00
WMDE-Fisch bc4fcfa04a Remove selection when selected parameter is unchecked
Adjusting some methods to support the usecase.

Bug: T312085
Change-Id: I4b97ab912f9ac0046f72167c3b573ee8e14e58d9
2022-07-05 19:22:36 +02:00
Adam Wight 787d44af66 Restore selection after keyboard parameter navigation
When blurring out of keyboard parameter navigation, the
last-selected parameter will be highlighted again.

Bug: T312017
Change-Id: I8b0fb667b44b324529d4c45c39bf21573517f989
2022-07-05 13:37:38 +02:00
Adam Wight 6c16f93504 Prevent highlighting the first parameter when clicking to remove
Tabbing into the parameter select list should highlight the first
parameter, but focusing a checkbox by clicking it to uncheck should
not trigger this highlighting.

Copied from the superclass method.

Bug: T312014
Change-Id: Ia1fd450bad4861eb2815ca21eae69ee31e40ac08
2022-07-04 15:50:56 +02:00
Adam Wight c2e111239b Reuse hard and soft action handlers
New sidebar events take a `soft` parameter allowing reuse between
"hard" and "soft" selection and parameter add.  The "hard" variant
causes a content-pane focus.

Bug: T311987
Change-Id: Ic49718840ae56eb4cfab01ce964a2fbc2d8db63b
2022-07-04 13:42:34 +02:00
WMDE-Fisch 4371c4fde2 Adding lines in doc comments
Change-Id: Ie9a8ae32b4fdf476ad607f805c91357d824474a4
2022-07-01 16:25:40 +02:00
Adam Wight 1653815e8c Rename event to be descriptive, not prescriptive
Events should be named based on what happened, not what the
side-effect will be.

Change-Id: I563db48181e1db79ca22ef2ba1e25d5186976110
2022-07-01 12:42:23 +02:00
Adam Wight d93e35a0d1 Reconnect "soft select" event
Bug: T311296
Bug: T311711
Change-Id: Ic4ee673d339ec0b4b5f54f3d7a878e3ab03f7113
2022-07-01 12:30:01 +02:00
Adam Wight d592c75623 Use short style to wire event reemission
Change-Id: Id39ecc8e96627a228c8da91628f769cab42f71bd
2022-06-30 15:55:17 +02:00
Adam Wight aa7501a8e3 Select parameters like templates
Bug: T311204
Change-Id: I61294087963f4659f065f011a2cac350cfd35dda
2022-06-30 14:23:41 +02:00
jenkins-bot df26e6f9c3 Merge "Template dialog controls default to disabled" 2022-06-30 07:28:48 +00:00
Adam Wight d32303587e Template dialog controls default to disabled
If nothing has been selected, the action buttons should be
initialized in a disabled state.

Bug: T311608
Change-Id: I32fee0d73f6e13e09dc421c944df73b79e0260bb
2022-06-30 07:55:25 +02:00
Adam Wight d6ebbf0ea3 Remove outlineSelectWidget (old sidebar)
It seems that the controls widget was the only side-effect we still
needed for maintaining existing behavior.

Bug: T310866
Change-Id: I507dacef4e56946b836b0fca31effce611260aec
2022-06-29 17:08:51 +02:00
Thiemo Kreuz 767a928a23 Move remove button toggle code to more appropriate place
This patch does a few closely related things:
* Replace a direct dialog → sidebar access with dialog → layout →
  sidebar.
* Move the misplaced removeButton.toggle() to a more appropriate
  place.

Bug: T311069
Change-Id: I5a2802aab587a6f7de4681bce4e9961a064ef8ee
2022-06-29 16:31:25 +02:00
Thiemo Kreuz 269770fe76 Remove unused code and properties from forked ControlsWidget
Bug: T311296
Change-Id: I8eb279f05901ace48cf9cc70ac8ce0ee6e9b40e1
2022-06-29 10:26:26 +00:00
Adam Wight 2ff0f6d5f2 Move custom buttons into outline controls
Bug: T311296
Change-Id: I5cc45f6a05ca029e319e04e76f6e35bfd5b506a6
2022-06-29 10:08:35 +00:00
Svantje Lilienthal ead1e258d5 Create new refreshControls function in TwoPane
Bug: T311296
Change-Id: I5a06238a7cf58189616f1b812bec74e99ef7922f
2022-06-29 11:44:07 +02:00
Adam Wight 6de61ccf77 Fork OutlineControlsWidget
Bug: T311223
Change-Id: Id2f9fc89c607c8001e8b150add1ffbcaa318993a
2022-06-27 16:46:11 +02:00
WMDE-Fisch 5dd32ea95d Bold parameters that contain some value
Value changes are triggerd and tracked from the parameter page and
change events will be forwared to the outline, if they are relevant.

Initial value is read from the model.

Bug: T308730
Change-Id: I0a3b0faf40aee44889404dcce31d850714360580
2022-06-20 10:27:59 +02:00
Thiemo Kreuz 218ac78960 Remove obsolete "search for a parameter" page and widgets
… as well as messages, CSS, and icons that are now unused.

Bug: T310859
Change-Id: I1a2797728788cf1a86299414c1430ded0b362d4e
2022-06-17 10:23:00 +02:00
Thiemo Kreuz 1a2bb91310 Stop using deprecated "ParameterPlaceholderPage" class name
Removing a class name that's going to be deleted from places where
it's not strictly needed, e.g. comments.

Bug: T307188
Change-Id: Ifb14695d05510d2c0e25623afa99c4e84af3aaf9
2022-06-16 18:09:26 +02:00
jenkins-bot b99ed46e1b Merge "Improve test coverage of template dialog outline" 2022-06-13 12:24:01 +00:00
Ed Sanders 5d060c34cc GalleryImageNode: Handle broken images
Most of this logic copied from MWBlockImageNode.

Change-Id: I92c860c53741c5ee48c8bce216987d97a92bc05f
2022-05-23 15:29:42 +01:00
Ed Sanders fb1ed9e700 MWGalleryImageNode: Avoid converting altText from null to ''
Bug: T308747
Change-Id: Icd811a6baaa2213d8615bdcb3690d26aa35ab302
2022-05-21 04:09:41 +02:00
Thiemo Kreuz 9297428eca Improve test coverage of template dialog outline
This focuses on some scenarios that are
a) complex enough to be worth a test,
b) but simple enough so I don't need to spend hours on comming up
   with a test setup. ;-)

This patch also simplifies the ARIA related code in
MWTransclusionOutlinePartWidget a bit.
* Check 1 of the 3 ARIA configs only. Only having one is already
  helpful and should not be skipped.
* No need for the large conditional. setAriaDescribedBy() works fine
  with undefined.

Bug: T291157
Change-Id: I142782ec9b96147de64497f4f6a373eae05b9c8e
2022-05-04 12:01:58 +02:00
WMDE-Fisch d996288169 Move message about missing parameters to sidebar
Will be removed when parameters are added. Needs different margins
depending on beeing shown in the single transclusion mode without
header or on multiple transclusions.

Bug: T300710
Change-Id: Ieb95d7276aa4d4b0fcbb74f87ab734e4a393dc21
2022-04-29 10:03:23 +02:00
Thiemo Kreuz 8831887e3c Update template search fallback to max out at 10
Before, the fallback algorithm was somewhat adaptive, trying harder and
harder the fewer CirrusSearch results have been found. This updated
algorithm guarantees that 10 results are shown.

Warning: You might see only 9 results. The reason is a bogus, unrelated
behavior in the mw.widgets.TitleWidget in core that's used as a base
class here. There is a "showMissing" option that's apparently enabled
by default, and prepends a non-existing title from the main namespace,
ignoring the "namespace" option. This extra result from the wrong
namespace is later dropped by the very same widget.

This code here sees 10 results before the bogus one is dropped.
Disabling "showMissing" causes other issues. We would need a series (?)
of custom hacks to work around all this, but this seems inappropriate.
Let's live with 9 for the moment.

Bug: T303524
Change-Id: I2c577c9ef2752b6c6cd360f4023e151e9272fcd5
2022-04-21 09:25:00 +00:00
Thiemo Kreuz 50497ee7f3 Drop assumption that all template search index start at 1
The main advantage of this change is that it drops the assumption
that the index starts with 1. This is not necessarily the case when
we prepend extra search results. Dropping this assumption here allows
to simplify such code.

* The incoming list of pages is guaranteed to be an array.
* There is no point (any more) that could cause the array to become
  sparse.
* Note we still make a copy of the `origPages` array at some point,
  e.g. on `.filter()`.

Bug: T303524
Change-Id: Ifbd92bb052155c613d2ca21ab6d54a0b3ef28c0c
2022-04-21 11:23:48 +02:00
Thiemo Kreuz 89e5c2fb92 Disable useless "showMissing" option in TemplateTitleInputWidget
This option is not only buggy (it just doesn't work when the namespace
option is set the same time), it is not useful in this context even
if it would work. It doesn't make much sense to suggest non-existing
templates in the context of the template dialog. If adding a
non-existing template really is what the user wants, they can still do
this by simply typing the name of the template and submitting the form.
We never need this to show up in the suggester below the input field.

The main advantage of this change is that is saves 1 useless API
request that's potentially done every time a key is pressed.

Bug: T303524
Change-Id: I903340a06d6e6490bb58f628f41903aa044ccb21
2022-04-20 14:43:29 +00:00
Thiemo Kreuz d3d3e1cf75 Move "index from redirect" logic up in template search widget
This separates the two steps:
1. See if items in the list of `origPages` miss their `.index`
   property, and add it if possible.
2. Later code doesn't need to care about redirects any more.

Note that `origPages` is not used for anything else. And even if,
it's not wrong to have the index for each search result on both the
redirect and the redirect target.

Change-Id: I12135f0430c944b4e33c49ece7779d7c3bb6c211
2022-04-20 14:50:36 +02:00
Thiemo Kreuz e24c8ecd2d Fix misleading variable name in TemplateTitleInputWidget
This is not a pageid, but a simple numeric index in an array. Luckily
it doesn't make a practical difference for this particluar way of
iterating something.

Change-Id: I7ec9ace00d4fba7adde17670058a0365b30f5617
2022-04-19 14:40:00 +00:00
Thiemo Kreuz af2779fc06 Fix API response default in TemplateTitleInputWidget
The result is guaranteed to be in formatversion=2, where the list of
pages is an array, not an object.

Change-Id: Ic73a68c3e249a70108a6a19a89f4ff6c475794ed
2022-04-19 13:35:27 +02:00
jenkins-bot 616fa37de4 Merge "Fill template search results with prefix matches when Cirrus fails" 2022-04-08 11:57:23 +00:00
jenkins-bot 5fef22001d Merge "Full fallback to prefixsearch when Cirrus returns nothing" 2022-04-01 13:24:51 +00:00
Thiemo Kreuz 912bc34f62 Fill template search results with prefix matches when Cirrus fails
This code is optimized for the 2 most relevant use cases:

1. When Cirrus finds 10 results, we still want to search for the top 1
prefix match. This is critical for templates like !!. This will appear
at the top. unshiftPages() makes sure the limit of 10 is enforced.

2. When Cirrus fails to find anything, we search for 10 prefix matches
and use these instead.

The code can also handle everything in between. For example, when
Cirrus finds 5 results, we search for 5 more prefix matches and add
them when Cirrus missed them. The total number in the end might be 5 to
10 depending on the number of duplicates. This is intentional. Why?
Let's say we always search for 10 prefix matches and add them to the
top when Cirrus missed them. This might remove _all_ Cirrus results.
This shouldn't happen. This extra code is only to fill in glaring gaps,
not to replace Cirrus. 5 results are fine.

Bug: T303524
Change-Id: Ib0471795124c0c7001b6901edaf8e7b380e426b1
2022-03-29 13:18:12 +02:00
Thiemo Kreuz 6bbf7d1907 Full fallback to prefixsearch when Cirrus returns nothing
There is already some kind of "fallback" to prefixsearch. We always
check if the top-1 prefixsearch result is part of the result set.
Because of this the current worst-case scenario is that only this
1 result is shown.

This patch implements a full fallback to prefixsearch. But only when
there are 0 CirrusSearch results. Further tuning might be done in
later patches.

Bug: T304925
Change-Id: I1927eedad60c9b9ac2021481a85376c08ccf6fdb
2022-03-29 13:17:05 +02:00
Thiemo Kreuz c8af207681 Use boolean RegExp.test() instead of .match() where possible
.test() is the dedicated syntax for a boolean "does match? yes/no?"
check. .match() returns an array of matches, or null. This is just not
needed in these situations.

Change-Id: Ibb996ab843d1a6c7d7af98d6a112990665d543b2
2022-03-24 11:04:43 +01:00
Thiemo Kreuz a6f784c095 Fix hiding unused template parameters sometimes not working
We ended mixing two concepts in a single method:

* We need a method that allows us to create the parameter list widget
when it's needed, even if it's empty. This is relevant when a template
is entirely empty, and the first parameter is added. This wasn't
working. Instead the parameter list was created with all parameters.

* On initialization we either want all parameters to be shown, or only
used ones. But this code is only needed once, on initialization. I
ended inlining this code in this patch.

Bug: T300640
Bug: T304046
Change-Id: I6620a870e4420dcb8fecf522b3274458eeec891d
2022-03-22 15:41:55 +01:00
Ed Sanders f6ea2e3457 Fix resize of MWAceEditorWidget when setting up
Bug: T303964
Change-Id: Ic8efbd7df74213fddaec987aff60e733f9550db2
2022-03-18 22:30:54 +00:00
jenkins-bot 401da7ee13 Merge "Remove MWDismissibleMessageWidget and use MessageWidget's showClose option instead" 2022-03-17 11:43:33 +00:00
jenkins-bot cada5a3ab8 Merge "Extract template scrollToTop method" 2022-03-15 12:17:50 +00:00
WMDE-Fisch 96dc96da8d Extract template scrollToTop method
Also putting the findFirstSelected to where it belongs.

Bug: T302965
Change-Id: Ibc56abfdf84a0b5eade5b6a44903d769f424206d
2022-03-11 12:30:51 +01:00