Commit graph

54 commits

Author SHA1 Message Date
jenkins-bot 442ba0bf6b Merge "Update JSDocs related to the reference re-use dialog" 2024-10-04 11:56:43 +00:00
jenkins-bot 3591e4f14d Merge "Allow the ref re-use sub-menu options to wrap" 2024-10-04 11:50:23 +00:00
WMDE-Fisch bcd76a24c4 Allow the ref re-use sub-menu options to wrap
We discovered that the label can be really long depending on the
language. On mobile, where the screen is quite narrow it seems
more useful to let it wrap.

In this context it's even more relevant, because the options you
can choose from might only differ in the last parts of the message.

Bug: T375053
Change-Id: I9ec111ab1b80843f993d605ff11a1702c3d7b37c
2024-10-04 11:11:22 +02:00
thiemowmde 9ceabba9fe Update JSDocs related to the reference re-use dialog
Bug: T375053
Change-Id: I69a5caa8de730328ce4b5e2f92d9e04dcc576b6d
2024-10-04 11:08:58 +02:00
thiemowmde 44aefe2a6e Remove misplaced tooltip on ellipsis in citation dialog
We want the tooltip on the entire search result item, but not on
the button. The button probably needs a dedicated tooltip. To be
discussed. Let's start with removing the wrong tooltip.

Bug: T375053
Change-Id: I69da1f3cf80cf94342498a30b47acac8412d08ca
2024-10-04 10:16:23 +02:00
WMDE-Fisch 14d87b1e04 Add a submenu to offer a re-use with different details
Adding a submenu to the results of the reference re-use search.
This allows the user to either create a direct reuse or a reuse with
different details.

Hide the menu when there's a sub-reference.

Known Issues:
- Ref name is hidden (conditionally when our feature is enabled) as a
  quick fix to not having a good layout choice yet.
- Submenu is clipped at the dialog bounds.
- Submenu highlight should vanish when the submenu is closed
- Instrument action with metrics.

Bug: T375053
Change-Id: I3eddd6bad328aaf9bb99eb2783ba66d4e08f862d
2024-10-01 13:26:52 +02:00
Adam Wight e2ea1bcf68 [refactor] reuse dialog handles its children's events
Hide some knowledge from the reference dialog, and prepare the way
for additional events such as "extends".

Bug: T375053
Change-Id: I6097eb85deadcb58d1f56844c65726f19dbf6dda
2024-09-30 11:22:07 +02:00
WMDE-Fisch 73917d493b [refactor] Move result items rendering to ReferenceResultWidget
The exact rendering of each item should be part of the widget.
This also allows a better application of the sub-ref indent.

Bug: T375841
Change-Id: Ic2c24f40d59f41b316c6d6f362726c1ee68f2102
2024-09-29 20:06:02 +02:00
Adam Wight 324e34fb12 Indent subrefs in the reuse search item list
TODO: This can be merged as-is, since it only affects pages with
subrefs, but it behaves surprisingly when the ref body is long.  In
this case, the text wraps around and flows onto the next lines
unindented.

A full implementation would require deeper changes to the item pane
layout, which is happening in a separate patch.  Recommend merging
this as a quick visual fix and then we come back to the subref+long
content edge case once the pane is easier to adjust layout in.

Bug: T375841
Change-Id: I65510f1550e033e57a3493676d8fc24f628c0600
2024-09-27 13:45:55 +02:00
WMDE-Fisch b5a41a62de [refactor] Renaming some fields in SearchWidget for clarity
Should be a no-op. I checked CodeSearch for other usages but seems
safe so far.

Bug: T370875
Change-Id: I4969e93308735f06be3e344616341c1284157c19
2024-09-09 09:03:11 +02:00
Adam Wight ab0f2ea000 [refactor] Finish decoupling search widget from InternalList
Bug: T370875
Change-Id: I6ed43ea3a5b25c2ef5afc373b5a2523a730fd11e
2024-09-03 12:12:01 +02:00
Adam Wight 633969300b [refactor] Update some usages to new refs interface
Change-Id: Idfffbe92ad1385e85b078bc4794a529c5f770eae
2024-08-29 13:21:48 +02:00
Adam Wight 6e03d2cafa Moving ref group knowledge into a dedicated data structure
Pushes per-group knowledge down into a structured object and give it
an interface, separated from the singleton cache across all groups.

Also changes the behavior of orphaned subrefs so that they're still
rendered as subrefs, with an error placeholder where the parent
should be.

Bug: T372871
Change-Id: I84e679a8365f3fbfabaf344d99f56f6d069c0776
2024-08-26 09:26:15 +00:00
Adam Wight baedd6c44c Rename function to getIndexLabel to clarify that it's presentation
Bug: T370874
Change-Id: I2e00aca86d2a97f8dff11b742e010ef117b5522a
2024-07-30 12:05:25 +00:00
Adam Wight 06e7dda6a3 Helper function getAllGroupNames
Bug: T370874
Change-Id: I8d61b1ab428ab30e250c8dad05d1b97e15905ed5
2024-07-30 00:00:50 +02:00
Adam Wight 257b3f3816 Switch reuse dialog to use shared numbering mechanism
This patch gives us the same number as will appear in the document,
even when subrefs are present.

Tests could be improved using sinon to check some call assertions
but should be fine for now.

Removed the test for placeholders, because these should be filtered
in MWDocumentReferences.getGroupRefsByParents()

Bug: T370874
Change-Id: I7543a6593308c529bcfbeb0835a7c0882cbf8621
2024-07-26 09:44:36 +02:00
thiemowmde 7f33002411 Fix reference search not working with uppercase groups/names
The internal search index is optimized and expects everything to be
lowercase. This was already done for the text, but not for the name
and group. As far as I can see in the Git history this problem always
existed ever since this code was written.

This fixes an 11 (!) year old bug.

Bug: T53838
Change-Id: I12b3b7c23d34d49b630e9151525409dbddfac24e
2024-07-19 09:59:35 +00:00
thiemowmde a62e855697 Disallow recursively extending already extended references
Note that the duplicated search panel is most probably a temporary
solution anyway. We probably want a single search panel that can do
both kinds of "reuse with/without different details".

This is also inconsequential for production. Nothing related to
extended references is currently visible on production.

Added to the otherwise unrelated T369005 for code review purposes.

Bug: T369005
Change-Id: Iedee38dacc01ae59fb1a681e49e655ca91b25b64
2024-07-18 08:59:50 +00:00
WMDE-Fisch e7443560f0 Introduce a clearSearch method for the ReferencesSearchWidget
Mainly to support the activity tracking use case where we want to
track an active use everytime the user starts anew in this UI.

Bug: T368533
Change-Id: Iecf7e697bbbd637c4a00a44debf615c2351eb390
2024-07-16 16:21:35 +02:00
WMDE-Fisch 20c3798055 Fix re-use search activity tracking name
C&P mistake in the original implementation. Otherwise we end up
with an undefined in the name.

Bug: T362347
Change-Id: I5c6957ca9fc81e6a5211aab050025eea5d0addbe
2024-06-25 17:02:04 +02:00
Ed Sanders 5a2154de38 ESLint: Enforce prefer-arrow-callback
Change-Id: I8d96b69e8c15bc8ad84cfb0c511396e5b3e7ac20
2024-06-03 12:31:33 +01:00
thiemowmde c921c76dd2 Consolidate duplicate "is reference list empty" code paths
Introduce a static method so we don't need to copy paste code.

Note that the static method still largely duplicates what the method
.buildIndex() will later do. Both loops iterate the reference groups
and the references in each group. The main difference is that the
"is empty" check stops extremely early the moment it finds any
non-empty group.

That's also why I'm convinced it's not worth caching the result.
I benchmarked it and it's nanoseconds. But there are more reasons:

The non-static .isIndexEmpty() method is currently only used when
Citoid is active the same time. Which means the cached result was
entirely unused on installations without Citoid.

Bug: T356871
Change-Id: Id5c4295086bc977ef52ad141be9962d2eecb1bcc
2024-05-07 15:51:12 +02:00
jenkins-bot 2349c3ceec Merge "Use OOUI's native "unselect all" feature" 2024-05-07 12:15:20 +00:00
WMDE-Fisch 52b9521dc9 Add tracking for VE Cite re-use interaction
Includes a minor drive by cleanup for an obsolete JSDoc block.

Bug: T362347
Change-Id: Ie4a6ebc5a468c0419001b0170c9cc7e13de616ba
2024-05-07 12:47:37 +02:00
jenkins-bot 29e8ba9ea0 Merge "Further delay search index build in ReferenceSearchWidget" 2024-04-30 10:49:17 +00:00
jenkins-bot 74b42ace80 Merge "Make ReferenceSearchWidget code a bit more functional" 2024-04-30 10:49:14 +00:00
thiemowmde e925fb4e16 Add safe-guard to ReferenceSearchWidget.buildIndex
Note this is only a bandaid patch that avoids the failure in this
place, but doesn't solve the fundamental problem. It appears like
the data coming from Parsoid (in internalList.….firstNodes and
internalList.….indexOrder) is somehow out of sync, and one of the
numbers in the .indexOrder array points to an element in .firstNodes
that doesn't exist (any more?). I don't know why.

Bug: T351550
Change-Id: Iaa4c748462d90d7783edb89713b61ffff6d70765
2024-04-09 09:23:32 +02:00
thiemowmde 203a1cde34 Further delay search index build in ReferenceSearchWidget
The search index is really only used in a single place, in the
buildSearchResults method at the very bottom of the class. I find it
more obvious to understand what's going on when the places where the
search index is populated and used are as close together as possible.

This again really only moves existing code around without actually
changing anything.

We can also drop the extra "built" property and use a special null
value instead. This is possible because we know the only consumer of
the this.index property and can guarantee it can't get confused by
the null.

Bug: T356871
Change-Id: Iaddb3b16b3aa776f89fca2bf0350cce9b6bb1a23
2024-04-04 15:13:50 +02:00
thiemowmde e9561ade15 Make ReferenceSearchWidget code a bit more functional
This turns two methods with side-effects into more pure functions
with more obvious input and output. buildSearchIndex rebuilds the
internal search index from the internalList. buildSearchResults
filters and creates the result widgets the user will see.

This patch really only moves existing code around but doesn't change
anything. Except that this.built is set before onQueryChange is
called, not after. This avoids potential endless loops in case
onQueryChange happens to trigger buildIndex again.

Bug: T356871
Change-Id: Ib80a2dcb85779d64bec53caf90c49879d0ea2258
2024-04-04 15:12:57 +02:00
jenkins-bot 7906b2147a Merge "Remove confusing, unnecessary .length check on a string" 2024-03-27 08:15:09 +00:00
thiemowmde 61a49f4337 Remove confusing, unnecessary .length check on a string
I find this particularly confusing because it makes it look like this is
an array. As a reminder, while empty arrays are false in PHP they are
not in JavaScript. An extra `if ( array && array.length )` is really
critical. But this is a string. Empty strings are false in JavaScript.
No problem.

This was originally written in 2013 via Ib244ff6 as a pure .length
check. The duplication was added a year later via Id401d97 for an
unknown reason.

Bug: T356871
Change-Id: Ied335f170a9a0a7bbc8c8fd12f95b6902f401bbf
2024-03-27 07:16:54 +00:00
jenkins-bot dbff601ebf Merge "Remove obsolete @method annotations" 2024-03-18 10:00:17 +00:00
Adam Wight 73c90a0e7d Clean up and fix some jsdoc annotations
Some of the annotations were used in a way that confused jsdoc.  This
cleans up redundant annotations and uses more canonical tags.

These changes cause all classes to now appear in the generated pages.

Includes linking to external docs.

Bug: T358641
Change-Id: Iaee1dadcc19a70c27839d0d27dfa6a07a70fb46b
2024-02-29 13:05:42 +01:00
thiemowmde 5d8e256fbc Remove obsolete @method annotations
These tags are 10 years old. Current documentation generators don't
need them.

Tagging something explicitely as being a @method can be useful in
an interface where the elements are initialized with e.g. `= null;`
instead of having an implementation. But we have implementations
here. Sure these are methods. No need to say that in the
documentation.

Also removing a comment that's obviously a copy-paste mistake from
what was the ve.ui.MWMediaSearchWidget back then. See Ib244ff6 and
before.

Change-Id: I7df6c789d10fd89e7fe97d56c942fd22c56d8458
2024-02-22 20:07:33 +01:00
thiemowmde 96da6cedfe Use OOUI's native "unselect all" feature
No need to manually scan for the currently selected item. And no
need to do it twice. The feature is a little hidden (calling the
method with no parameter) but always was supported.

Bug: T356871
Change-Id: I02401284eef5687eb0825d8d9ae0df294b3b4e03
2024-02-22 18:58:01 +01:00
DLynch 6bc1ae4146 Revert "Avoid creating a MWReferenceModel if not needed"
This reverts commit 74f66bc478.

Reason for revert: this broke reference reuse from Citoid

Change-Id: I86efea4945c1795dbfd61f4e020d78ca81a6f4d1
2024-02-16 03:54:34 +00:00
Adam Wight 74f66bc478 Avoid creating a MWReferenceModel if not needed
It's fine to copy attributes directly from the reference node rather
than go through the specialized model object.

Bug: T336417
Change-Id: Idaca192137dc762ddced2ee8446a7d838f97e317
2024-02-07 15:24:12 +01:00
mareikeheuer 1eb405eb54 Convert Cite extention to ES6
Bug: T343220
Change-Id: I769f0bfaa5af14d6ea4861ea738b44c98feb6193
2023-08-23 12:39:29 +00:00
thiemowmde 341847a410 Fix inconsistent usage of lastIndexOf in VE reference code
I assume the code was using lastIndexOf as some kind of performance
optimization. Certain StackOverflow threads suggest it without going
into detail. It's not correct here. You can actually name a group
"mwReference/", which will result in the (valid) internal name
"mwReference/mwReference/". This works as expected with indexOf but
not with lastIndexOf.

Change-Id: I8e85ae5c11a74016c7720fcdb6ac6478431aaa8e
2023-06-06 13:37:25 +02:00
thiemowmde 889c2ea011 Fix empty previews in reference reuse dialog
This fixes a minor inconsistency: A reference that comes from a
template and is already reused outside of the template is only
partially available to VE, and previewed with a warning message
because of this:

"This reference is defined in a template or other generated block,
and for now can only be previewed in source mode."

This was missing in the reuse dialog.

Note this patch is not meant to make any design decision, but to use
the existing design consistently.

You can test this with and without the Citoid extension. It works in
both cases.

Bug: T336372
Change-Id: I962cf111b1882bcd736f1090ca17d2b176495d2f
2023-05-10 13:03:24 +00:00
thiemowmde fd90304b23 Make auto-generated reference names like name=":0" visible in VE
This is a prerequisite before any work related to T52568 (being able
to manually name references in VisualEditor) can start.

Why these names should not be hidden:
* We don't know if the name is actually part of the auto-generated
  sequence in the current article or copy-pasted from somewhere else.
* Manually given names that start with a colon are currently hidden
  even if they are unrelated to the auto-generated sequence.
* The information is highly relevant for users switching between VE
  and wikitext. Especially when a reference is used multiple times
  the relevant wikitext can be as short as <ref name=":0" />. The
  literally only information in this case is the number.

Since these numbers are still more technical than anything we make
them very dim to emphasize the contrast to non-numeric names.

Bug: T52568
Bug: T92432
Change-Id: I65cb6998cb5f8659cd9043f3d4aaeac1c5f69da8
2023-02-23 12:28:02 +01:00
Ed Sanders cada626709 Use useView mode of PreviewElement for re-use search widget
Generating the preview from the model is much slower and not
required in this context.

Bug: T310318
Change-Id: I73ab222c268939eb542aaae8b529446eae45abc7
2022-06-15 16:28:39 +01:00
Thiemo Kreuz 7a2f271ce6 Use .test() instead of .match()
.match() returns the matches. But these are not needed here. The
boolean method is .test().

Change-Id: I9e6f13f25fb8ccc6d3e873288d1100f4a2a56b15
2021-12-29 18:24:22 +01:00
Ed Sanders c8b691b8d1 Follow-up cf95dbd: Fix incorrect scope in loop
Change-Id: Iae5ec0321e19bfa1c5f53326bf9d9a3082d96f77
2021-11-15 14:39:15 +00:00
Ed Sanders cf95dbd4be Move var declarations inline
Change-Id: I824a65e72a72e5acf65c54a63299469f7acb649d
2021-11-03 16:38:31 +00:00
Ed Sanders 8e3bc8cb2c Match line-breaking whitespace in reference names
Bug: T263698
Change-Id: I436b0fbf1756e08fe9ff9013aff7479d5ec653f6
2020-09-24 20:29:00 +02:00
Thiemo Mättig bbc1f2c91d Use standard form for @license tags
See https://spdx.org/licenses/

Change-Id: Ic091ebc3844abcd6de90b3241382fb4732200a6d
2018-03-20 03:18:37 +00:00
zoranzoki21 288226aba5 Replace "getSelectedItem" with "findSelectedItem" for consistency
Bug: T184037
Change-Id: Ie4b191ba55cf1cf1300182e056a5a4901c18d583
2018-01-10 11:51:25 +00:00
James D. Forrester 0999d771b6 doc: Bump copyright year
Also make the overly-terse statement clearer.

Change-Id: I752bb82444bf7cb41480076bace42331dc35a598
2018-01-02 17:05:50 -08:00
James D. Forrester 0d20873fa6 doc: Bump copyright year notice, 'team' name
Change-Id: Ia090c417a1aa716b255613199b5e49616bf0517a
2017-04-20 16:50:43 +00:00