Commit graph

493 commits

Author SHA1 Message Date
Andrew Kostka 5e2cd392c7 Wiring for adding and removing parameters
Bug: T274545
Change-Id: I0514a93f4313914a654e5f24cf78950cb4893409
2021-06-24 12:31:43 +02:00
Andrew Kostka 47c7d4939f "Add more information" should be a button instead of a checkbox
Bug: T274545
Bug: T272487
Change-Id: Icc4d461d763290b0bc07ec8dbaa98c625fc9e068
2021-06-24 09:55:17 +00:00
Andrew Kostka 6a890c31bd Remove extraneous ve.ui.MWTemplateOutlineCheckboxListWidget.js
Bug: T274545
Change-Id: I327ee06aff19fd2d3841e4e4a2d09a24c47e4d89
2021-06-24 11:12:12 +02:00
Adam Wight 64c5b093cc Wire model changes into new template sidebar
Only partially wired.

Bug: T274545
Change-Id: I961ffbdd82829b18c08a7c33759a05427103fa8b
2021-06-24 11:09:39 +02:00
WMDE-Fisch c4f59132ae Only add asterisk after word characters in improved template search
This will avoid that the search breaks in edge cases where symbols
are used.

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

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

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

See also comment in Ie81b84be288553343017c4aaf8691c4e266995f5

Change-Id: Iff1746a8e5e94b56eb6c27465405aaf6b74c2310
2021-06-21 09:08:54 +02:00
WMDE-Fisch 0e04315c66 Add missing newline in JSDoc
Change-Id: I88f5814e3691f4787a04ac8c882a4c836d786bd7
2021-06-18 14:13:31 +02:00
Adam Wight 988cda65dd Template dialog checkbox list
Introduces new widgets forming the backbone of the experimental
template dialog sidebar.

FIXME: `text-overflow: ellipsis` is not working yet, the container
styles need adjustment.

Bug: T274543
Change-Id: Ie81b84be288553343017c4aaf8691c4e266995f5
2021-06-17 08:47:47 +00:00
Thiemo Kreuz d9596c7f20 Add tooltip to "dismissible message" close button
Bug: T284742
Change-Id: Ibf0cb23c44d440e7a986bc85120f4ea0f844d999
2021-06-17 07:57:10 +02:00
jenkins-bot 6d101fb9d7 Merge "Extract "show all" to placeholder class" 2021-06-16 12:25:55 +00:00
jenkins-bot ab47e5ff9a Merge "Small code cleanups for the MWDismissibleMessageWidget" 2021-06-16 11:11:47 +00:00
jenkins-bot 2a74f10909 Merge "Dismissible feedback message for the template search" 2021-06-16 11:02:50 +00:00
Thiemo Kreuz feb902aba0 Small code cleanups for the MWDismissibleMessageWidget
* Re-focus the input field after closing the message.
* Store only the message key. That's all that's needed.
* Avoid a class property that's not needed.
* Use the config object instead of calling .setLabel() manually.

Bug: T284742
Change-Id: If8e8bb6460fa5aea8ddd46c2e27b5f08b7772896
2021-06-16 10:32:08 +02:00
Andrew Kostka 13d1c4d2ac Dismissible feedback message for the template search
Bug: T284742
Change-Id: I5dc32521b899c3c9d35d1bf77d346384e4cc87e6
2021-06-16 10:03:04 +02:00
Adam Wight 950a5300dc Extract "show all" to placeholder class
We can skip all the up and down message passing by persisting the
parameter placeholders for each template dialog.  If the parameter
list is expanded then the placeholder is deleted, on being created
again it will still have state.

To test: create a transclusion with two templates, each having many
parameters.  "Add more information" to add parameters, expand the
list by clicking "Show <num> more fields", then delete the parameter
placeholder using the trash cans.  Try different permutations to fool
the cache or collide with another template.

This is preparation for other template sidebar dialog work.

Bug: T284636
Change-Id: I23bdd38b173114c2a9afafc7465c4beb92d25869
2021-06-14 18:09:26 +02:00
Thiemo Kreuz c2017f74b2 Remove @param/@return docs that literally repeat the code
These don't add any knowledge but make the code harder to read
and maintain, and are an additional source of errors.

Change-Id: Ied57741a3f985e355adfddb4e75378d5c497faa9
2021-06-14 15:44:51 +02:00
jenkins-bot c29dc420e0 Merge "Fix object vs. array initialization in template search" 2021-06-14 13:25:30 +00:00
Thiemo Kreuz b81c18a017 Fix and update documentation in template dialog related code
Some of this was copy-pasted but forgotten.

Change-Id: I08c48e8e0a4cf17ec0888e4ce85427f4da825776
2021-06-07 23:47:23 +00:00
jenkins-bot df5238cd11 Merge "Fix duplication bug in MWTemplateTitleInputWidget" 2021-06-04 10:50:39 +00:00
Thiemo Kreuz e97e325ac6 Guarantee exact match when searching for a template
When the existing search results don't contain an exact match
(see previous patch), perform an additional search for the
title. This uses OpenSearch. This is recommended in multiple
places and also used in the quick search field at the top of
MediaWiki.

Again, I came to the conclusion that an isolated unit test
would be complicated and not test much anyway. Better test
on-wiki.

Bug: T274903
Change-Id: Ib575248e089ff66814400202d224deff6369c772
2021-05-31 08:31:49 +00:00
Thiemo Kreuz 1a37edc53f Move exact matches to the top in template search
This code detects a few edge-cases:

1. When some search results are exact matches, make sure they
are always at the very top.

2. When the prefixsearch API is used, e.g. as a fallback,
redirects show up as a separate metadata structure outside of
the pages array. Consider these and stop if there is already
an exact match.

3. CirrusSearch returns redirects as part of the pages array.
When there is an exact match, make these redirects separate
options and add them to the top.

All of this is case-insensitive, on purpose. In case two
templates with different capitalization exist, we rely on
the backend to return both. The code introduced here is fine
with this.

Notes:
* This doesn't guarantee an exact match is always there. This
  requires an additional HTTP request and is done in the next
  patch.
* I tried to write unit tests for this, but gave up. The setup
  is complicated. An isolated unit test would not test much
  anyway. Better test this on-wiki.

Bug: T274903
Change-Id: I64e1b5633e7b878a4d0d23d66229ca87e69d0045
2021-05-31 09:54:39 +02:00
Thiemo Kreuz 621bca1df4 Show redirects as part of description in template search
These are the most minimal (and therefor most stable,
hopefully) hacks I could come up with so far.

Bug: T274903
Change-Id: I28ba414dd34aad756e29400eb656f0942291a923
2021-05-27 12:40:51 +02:00
jenkins-bot d06554c81e Merge "Ensure correct classes are added to surfaces" 2021-05-25 19:33:17 +00:00
jenkins-bot 539dc5ddba Merge "Remove unused 'inTargetWidget' config" 2021-05-24 21:11:53 +00:00
jenkins-bot 028658a4e1 Merge "Remove/fix a few small pieces of unused code" 2021-05-24 13:23:53 +00:00
Ed Sanders a71dd4f797 Ensure correct classes are added to surfaces
* Create getSurfaceClasses method.
* Pass surfaceClasses to target widgets.

This ensures that the 'content' class is passed to mobile
target widgets, and the 'mw-body-content' class is added
in a less hacky way.

Change-Id: Ibce6d1a1d0fda63cca354761f1b91f808858e95b
2021-05-23 20:04:28 +01:00
Thiemo Kreuz 8f045a7155 Remove/fix a few small pieces of unused code
I found these thanks to PHPStorm.

Change-Id: Ieb30a95debb58d3a454ac3c6f0546e5dbbe77ed4
2021-05-21 11:43:45 +00:00
Thiemo Kreuz b15455ec3d Fix duplication bug in MWTemplateTitleInputWidget
Template names sometimes show up twice when searching for a
template in the "Add a template" dialog.

This is a bit hard to test. The code responsible for this
is not in a single place. The feature is in the upstream
TitleWidget class. It's not broken. It makes sense to
provide e.g. "foo" and "Foo" as two separate options when
the user typed "foo", but the page is named "Foo". Both are
valid, and the feature allows the user to pick either.

But the VE widget does it's own normalization. Both entries
are normalized to "Foo". Both do the same. The additional
one is pointless.

You can try this on the actual enwiki: Open VE, insert a
template, search for "Template:nHLE".

Change-Id: I65e706c4d131a2f8c605d7979a02ea56f831bf03
2021-05-21 11:43:31 +00:00
Thiemo Kreuz b7043d6f24 Fix object vs. array initialization in template search
The "redirects" part in a prefixsearch query is always an
array, no matter if formatversion 1 or 2 is used.

The "pages" part is an object with formatversion 1, and an
array with formatversion 2.

As of now this always uses formatversion 1. This is
hard-coded in the upstream TitleWidget class.

Change-Id: I8cde8e104f8a288015da745db41016f6639b453b
2021-05-21 11:24:48 +02:00
Thiemo Kreuz 333cadd5d4 Add star to template search term only when it's possible
Discussed in T274903#7077957. Note this might not be the
"perfect" solution. We are still experimenting, and this is
all hidden behind a feature flag. This is the change with the
most minimal impact. Actively trimming the input is another
solution, but with a bigger impact we might want to discuss
first.

Bug: T274903
Change-Id: I2ed06c04bb96c7b61bd7e87ad001e639ea6d06a2
2021-05-11 16:31:42 +00:00
Thiemo Kreuz 6e08a27fc7 Use standard search API when searching for templates
Bug: T274903
Change-Id: I7de8f6cc55ab678ed741ae5ebbaad608b9a9b0db
2021-04-30 12:52:45 +00:00
Ed Sanders bc846108d1 Remove unused 'inTargetWidget' config
Change-Id: I7708acbe1592460973e4017b594299b6d31dc328
2021-04-29 15:48:17 +01:00
Lucas Werkmeister b6a4e76d42 MWEditSummaryWidget: Don’t query for title
As far as I can tell, the code only uses the comment, nothing else.
Omitting the title probably won’t make the underlying database query any
cheaper, but it should at least save some network traffic.

Change-Id: Ideb66ce3a24fb4f42fe8fc22ba0e93d05724d8b6
2021-03-13 13:48:21 +01:00
Lucas Werkmeister 9d7ddcf066 MWEditSummaryWidget: Handle suppressed comments
Bug: T277368
Change-Id: I76887672a0e8b3a2047d1b1b47724f1ee513db23
2021-03-13 13:48:20 +01:00
Thiemo Kreuz d43f13f4f8 Reduce deep indention in MWTemplateTitleInputWidget
Change-Id: Ie1bd279753dba3b96b694660977b9f44f6f0834e
2021-03-02 14:34:41 +00:00
Ed Sanders 443eaded40 Move newline-stripping filter into MWEditSummaryWidget
Edit summaries should always strip newlines, wherever
this widget is used.

Change-Id: I37177771fef831037067d6244fb27cba5e06528b
2021-01-16 16:16:49 +00:00
Ed Sanders 3cde92d60e AceEditorWidget: Fix toggleLineNumbers
Change-Id: I1a48e4351b2249b1ccf0af5c9b2fadd9a97d5f04
2021-01-03 00:23:08 +00:00
Arlo Breault 2402f430b4 Preserve inline media tag name in galleries across edits
Follow up to I37799076852fa6f062c9d85bcebb15998fb44a80

Hat tip to Bartosz for pointing this out.

Change-Id: Ic2968240a015bac2f831203e586535d2f9574963
2020-12-16 17:28:51 -05:00
WMDE-Fisch 094a9aa044 Replace deprecated doNotIgnoreMissingTitles
This parameter name was deprecated and replaced in 1.31. See also
Ie5fe2097cda45968bb080643d3afcac0b2868a6c

Change-Id: Ie9d6c70d3dfe3954504d3d698c122dceede7603d
2020-12-15 12:52:55 +01:00
Ed Sanders 5c84f0cd88 Rewrite EducationPopup so it isn't a mixin
Reference images are moved to Cite and used by Citoid.

Bug: T170919
Bug: T171292
Depends-On: I02041246dda1b3d3ad1bcc0b014fa022e8259b62
Change-Id: Id97659ed1fa64a1223a8957fefaf2a149edd0e9c
2020-09-24 21:33:50 +01:00
Thiemo Kreuz 5e2b7506b6 Reduce duplication/clutter in MWParameterResultWidget
The MWParameterSearchWidget that shows a list of all available
template parameters displays the (human-readable) label and
description of each parameter (both given via <templatedata>), as
well as the parameter's internal name and aliases, if there are
any.

This turns out to be non-helpful in the majority of situations:
* When there is no <templatedata> yet, there are no labels.
  Instead, the names are used as labels, which means they are
  *all* identical and everything is shown twice.
* The same happens when manually adding an "unknown field". Simply
  start typing, and you can add parameters with any name. What you
  type is shown twice (actually 3 times, 1 time in the input
  field, 2 times in the result widget).
* Many template parameters are already nice, human-readable. Even
  if <templatedata> exists and specifies labels, these labels are
  often identical to the names. There is no need to come up with
  something else if the name is already good enough. (Exception:
  Localizations, but these are rare.)

Furthermore, this is a *search* result widget. The pretty much
only reason the names and aliases are shown is because the user
can search for them, and needs to understand why a parameter was
found. This still works fine.

For comparison, when a parameter is required you will *never* see
it's name, because the parameter is always there, and never shows
up as a search result.

Change-Id: I6b1dca1c94b2c496930b5bfdfe1c6f76898faa2a
2020-08-20 12:32:02 +02:00
Ed Sanders 4545f53245 build: Update eslint-config-wikimedia to 0.17.0
Fix instances of variable shadowing.

Change-Id: I6e2befb020d7d4b506c7b46131eafacd951aa6d1
2020-08-18 13:16:49 +01:00
jenkins-bot c17c7047ef Merge "Fix: provide proper focus order to Category popup" 2020-07-13 19:58:56 +00:00
Akinwale Alagbe 2f7765d1e8 Fix: provide proper focus order to Category popup
Bug: T257173
Change-Id: I99e9332adb83bf1197da827583b9f22f68b2f395
2020-07-13 21:30:38 +02:00
Akinwale Alagbe 2a581819ec Fix: Adding accessibility labels to Visual Editor template elements
Bug: T245669
Change-Id: I3b792ffde571047d9900920188e92634b8f50298
2020-07-06 18:46:59 +00:00
Ed Sanders 6076708ff3 build: Update eslint-config-wikimedia to 0.16.0
Change-Id: I638e0f82949597e2a2e4ea18fc2f0258f225358c
2020-06-02 21:30:00 +01:00
Ed Sanders 651756c4fc eslint: Enable the mediawiki/class-doc rule and make pass
Also minor other adjustments

Change-Id: I9ee48359e3e53799f2f6240e44b53972283ce328
2020-04-17 22:59:11 +01:00
jenkins-bot faa6d75de8 Merge "Adding accessibility label to template and field name edit textbox" 2020-04-16 17:04:54 +00:00
Akinwale Alagbe 229a249cca Adding accessibility label to template and field name edit textbox
Change-Id: Ieeb29de8534300751956eb76477b38578478b4a2
2020-04-02 21:02:55 -07:00
Ed Sanders de47496b19 Move MWutils to preinit and rename to parsoid utils
Bring in ve.dm.MWInternalLinkAnnotation.static.getTargetDataFromHref
and ve.resolveUrl, so that the file has no dependencies on VE.

Change-Id: I03bc455d5484a6c51f3fa2397c64936b829fe7e3
2020-03-24 23:13:16 +01:00