Commit graph

814 commits

Author SHA1 Message Date
Thiemo Kreuz 66f56f6c88 Defer creating template parameter search when it's not needed
From the user's perspective this is the same as before: When a
template doesn't have any parameters, there is no search field. The
moment the first (undocumented) parameter is added the search field
appears.

This is just delayed now. The widgets are only created the moment
they are actually needed.

This saves loading time and memory, especially in a multi-part
transclusion with many zero-parameter templates.

This also makes it a lot easier to change the minimal number of
parameters from 1 to e.g. 4.

Includes reverting the flexible header composition done in
Ib050e30a50ef965c1524e977d3a600c3ff836774

Bug: T298259
Change-Id: Ied7541d8d5c0b478a439dd31ce072e634287f181
2022-01-19 11:23:34 +01:00
Adam Wight a244f510c4 Make sidebar header and search field sticky during scroll
The search field will stay at the top of the window while scrolling a
single template.  In multi-part transclusions, the header will also
be sticky.

Hides the template header in single-part transclusions.

Bug: T298618
Change-Id: Ib050e30a50ef965c1524e977d3a600c3ff836774
2022-01-17 16:09:54 +01:00
WMDE-Fisch 20435b319c Add button to sidebar to hide/show unused fields
Bug: T298259
Change-Id: I8e5091b97dfb19eba981b2a919b82b6f14823990
2022-01-14 11:09:04 +00:00
Thiemo Kreuz 579cdaa145 Enforce formatversion=2 in template search
This is guaranteed via ve.init.mw.Target.getContentApi(). But the
ContentTranslation extension replaces this, and does not set a
formatversion. See e.g. SectionTranslationTarget.getContentApi().

Bug: T298599
Change-Id: I8768cae3153e9cbc29a8796ec21ef249f80471ed
2022-01-05 12:49:44 +01:00
jenkins-bot 717b5cf534 Merge "Use no-jquery/no-html to warn against writing HTML strings to the DOM" 2021-12-17 16:42:53 +00:00
jenkins-bot c92ea76af8 Merge "eslint: Enable no-jquery/no-append-html" 2021-12-17 16:42:42 +00:00
jenkins-bot 53ad459b27 Merge "ve.ui.MWMediaDialog: Clean up image metadata display" 2021-12-17 16:42:39 +00:00
jenkins-bot 6dc75d8283 Merge "Remove obsolete performance bottleneck from TransclusionModel" 2021-12-17 13:24:19 +00:00
Ed Sanders 2098292318 Use no-jquery/no-html to warn against writing HTML strings to the DOM
This forces us to comment when we are doing this deliberately.

Change-Id: Ide1bcb64f6c6076b48e88f1f27045bd93392f8a0
2021-12-16 01:28:42 +00:00
Ed Sanders 4d13a4f4ed eslint: Enable no-jquery/no-append-html
Prevents accidentally treating plain text or user input
as HTML, which could be an XSS vulnerability.

Change-Id: Id4af48447a0907962a57340cb60aca08df9cc505
2021-12-16 02:04:11 +01:00
Bartosz Dziewoński 97be4e21ad ve.ui.MWMediaDialog: Clean up image metadata display
* Fix incorrect use of .append() instead of .text() (which was causing
  some l10n messages to be treated as raw HTML)
* Avoid escaping and parsing HTML several times when plain text was
  intended
* Remove some unused options and variables

Follow-up to 839b64d882.

Change-Id: I124257c73fe09713afefccdec8e90200e6ae433d
2021-12-16 01:52:54 +01:00
Thiemo Kreuz 66636e1dd8 Skip bad suggestedvalues and aliases in the template dialog
Bug: T297386
Change-Id: I6456d720c923e8cff9b4500b6cfe52bc6fbc9dad
2021-12-09 16:58:13 +00:00
Thiemo Kreuz fd669a4d16 Remove obsolete performance bottleneck from TransclusionModel
This sorting algorithm was introduced via Ic6bc348 (T274544). Note
there is no index parameter in the .onReplacePart() handler at this
point. When a part was moved, it was removed and simply appended
to the end. The additional sorting was needed to move it back to the
correct position.

This changed a few days later via Iafe29f1. There is now an index
parameter. The .onReplacePart() handler does the same as before, but
puts the part at the correct position right away. The additional
sorting is pointless since then.

The removed code alone is responsible for 1/3 of the total blocking
time when the template dialog opens.

Bug: T296335
Change-Id: I6c3fa70b532d34cd29d59c3b48ab81ebf608d548
2021-12-06 17:36:53 +00:00
WMDE-Fisch f65eac3d66 Add placeholder for finding a template
Bug: T296465
Change-Id: I07c6e601111073b1269a3ab6c552f83e12196156
2021-11-26 16:30:19 +01:00
WMDE-Fisch bc89f1d8fd Set search icon on template placeholder search
Bug: T296465
Change-Id: I02932821b26c21eb559fdb391054b83d1da41d2a
2021-11-26 14:34:44 +00:00
jenkins-bot 1a4fb339eb Merge "Make better use of the ARIA mixin" 2021-11-22 17:18:51 +00:00
jenkins-bot 90643ef6d0 Merge "Prefere ve.extendObject over $.extend" 2021-11-18 21:22:16 +00:00
WMDE-Fisch c1c167a17f Make better use of the ARIA mixin
Bug: T295353
Change-Id: I7ccb1e771516df8198c6e07cbf37e9739bc0ed71
2021-11-18 15:21:47 +00:00
Ed Sanders 86c405a2e1 Prefere ve.extendObject over $.extend
Change-Id: I37fef45701653cef08de9ec699865aa4fdf477bc
2021-11-15 21:30:19 +00:00
WMDE-Fisch 26cab3125d Only use aria description on multipart transclusions
Moving responsibility to the part widget to check if we're in a
single transclusion.

Bug: T295353
Change-Id: I61b7891c04eb729647e2600318a97987fd88cb90
2021-11-15 12:22:12 +01:00
Ed Sanders 33840e88ee build: Update eslint-config-wikimedia to 0.21.0
Change-Id: I19465a5ab3bf71cd97967fd1fac41c645f05a419
2021-11-10 14:52:56 -05:00
WMDE-Fisch 3e28977087 Remove local aria-multiselectable
Added to OOUI v0.42.1 see I717ff53e18e95c72ace1c46b6236cfecb5cd8217

Bug: T291284
Change-Id: I45965181f22f9c5845f6dd44ab75e95305a43dce
2021-11-05 09:10:21 +01:00
jenkins-bot 3d3369298a Merge "Move id creation into AriaDescribe mixin" 2021-11-02 22:24:09 +00:00
Thiemo Kreuz 56fb18243c Move id creation into AriaDescribe mixin
Change-Id: Ifef4f3c0fee13a241488f473b561ced7b327fd73
2021-11-02 09:44:02 +00:00
jenkins-bot f223046fc8 Merge "Introducing a mixin for ARIA descriptions on parameter selection" 2021-11-01 15:56:51 +00:00
WMDE-Fisch f9fda0594f Introducing a mixin for ARIA descriptions on parameter selection
Allows setting aria labels and descriptions on elements in a
convinient way. I did not use the the .mixin. convention here for
because there's already another mixin in that folder that's also
not having .mixin. as part of its name. And then there's also no
no need to open up that extra namespace here.

If we move this upstream at some point this can be changed though.

Bug: T291284
Change-Id: I1b3d40400d539f851f13719e16ced200968a7f92
2021-11-01 13:20:00 +01:00
jenkins-bot b5a6e2e32b Merge "Support both DELETE and DEL when using template shortcuts on MacOS" 2021-10-29 16:10:37 +00:00
jenkins-bot c27c094cff Merge "Exclusively use CMD instead of CTRL for shortcuts on MacOS" 2021-10-29 16:10:34 +00:00
WMDE-Fisch dab5b5daae Add ARIA descriptions to sidebar widgets
When changing the source in the described-by attributes the screen
reader will read the text of the new source when the status changes.

Just changing the text within the elements holding the descriptions
does not work.

Bug: T291284
Change-Id: I31cc3061cf6c1f699babe41e99e0711f0eb03646
2021-10-29 12:07:53 +02:00
WMDE-Fisch ef57268b2e Set selected status to sidebar elements
ARIA-selected only works on specific elements/roles. I tried several
combinations here, the most fitting seemed to be the option role, but
that role did not work very well in FF with NVDA. It also should only
be used as direct child to a listbox e.g. with several children.

The next role that's working with ARIA-selected that seemed fitting
is the gridcell. It's still a bit hacky but works well in IE and FF
with NVDA. I suspect that that's pretty good coverage already then.

Bug: T291284
Change-Id: I85c865b0ab12d3923e472e5f36b5c07b7c722180
2021-10-28 12:40:50 +02:00
Andrew Kostka 0475812a20 Support both DELETE and DEL when using template shortcuts on MacOS
The following keyboard combinations are now supported on MacOS:

1) CMD + DELETE
2) CMD + DEL
3) CMD + FN + DELETE

(1) for keyboards without a DEL key use DELETE/BACKSPACE
(2) for keyboards with a DEL key
(3) FN + DELETE is a built-in an alias for DEL

Bug: T294519
Change-Id: I896837954b2f0b36a25484080e57d929a5abf774
2021-10-28 12:18:47 +02:00
Andrew Kostka 80fff73688 Exclusively use CMD instead of CTRL for shortcuts on MacOS
Bug: T294519
Change-Id: I8bd803b4a81ed5195ff0bb1b99b14f764d588eca
2021-10-28 11:53:38 +02:00
jenkins-bot 3e74dd7b9a Merge "Use <span> for the outline part headers" 2021-10-25 12:06:27 +00:00
WMDE-Fisch 37e7f930c4 Use <span> for the outline part headers
We're mainly interested in the layout of a button here. From a
semantic perspective this is just a header to an editable area
and not a button.

Bug: T291284
Change-Id: I683cca2e7d6549e652bd03ae1e46f4eff8c07d0a
2021-10-25 12:11:10 +02:00
jenkins-bot a932e5b6b3 Merge "Fix/cleanup template dialog methods dealing with parts vs. items" 2021-10-25 10:02:04 +00:00
jenkins-bot 6484f8dad3 Merge "Rework all code using template type related conditions" 2021-10-25 08:55:32 +00:00
jenkins-bot 4de710ca71 Merge "Add a11y label to sidebar parameter selection" 2021-10-22 11:51:44 +00:00
jenkins-bot 9a0d34aeae Merge "Add title to sidebar search" 2021-10-22 11:34:04 +00:00
jenkins-bot 8a295512d3 Merge "Don't try to focus a removed template parameter" 2021-10-22 11:09:46 +00:00
Thiemo Kreuz 29ef00fa29 Rework all code using template type related conditions
This is a more radical change, compared to the previous patch.
I will post more detailled explanations as comments on Gerrit.

Change-Id: I6909b3f0b2c153b7ee9995441e995ffa793eab40
2021-10-22 10:42:16 +00:00
WMDE-Fisch 6e7332193b Add title to sidebar search
Also to improve screen reader a11y.

Bug: T291284
Change-Id: Ib56d3ee542cb880edd7788ff524a72436e102627
2021-10-22 12:34:57 +02:00
WMDE-Fisch 79f1270593 Add a11y label to sidebar parameter selection
Bug: T291284
Change-Id: I581800d2c92c06c3585ac48be0242860f476022b
2021-10-22 12:31:24 +02:00
WMDE-Fisch b84d5f99d6 Set aria-multiselect on OutlineParameterSelectWidget
Bug: T291284
Change-Id: Iedb731d528b7f73c188aaa40eba74ba18dc8781e
2021-10-21 15:54:01 +02:00
Thiemo Kreuz 937352a138 Don't try to focus a removed template parameter
The event "focusTemplateParameterById" targets the right side of the
dialog. The input field for the parameter should be focussed. This
doesn't make any sense when the parameter was just removed (i.e.
unselected).

Change-Id: Ie75b1edaebe9d0444b98e66cb56a5c7774393bea
2021-10-21 08:46:37 +00:00
Bartosz Dziewoński 9f9f27eb08 Fix unintentional raw HTML message
Change-Id: Ib5d37d4bdc8a36f7b077995d35cea70fb84e4476
2021-10-18 22:37:25 +02:00
jenkins-bot c5e6c9f9e1 Merge "Minor documentation fixes" 2021-10-14 19:07:09 +00:00
Svantje Lilienthal 9b9c6ff492 Remove focus from first input field when clicking on template name in sidebar
Bug: T293250
Change-Id: I017bd9fa5e566762b78e354f9ff94902b2c8968a
2021-10-14 10:25:34 +00:00
Ed Sanders 295d139ef1 Minor documentation fixes
Change-Id: I6822c04c8d160431510e62752783e6829950dc36
2021-10-13 14:02:57 +01:00
Thiemo Kreuz dc85603c0e Remove redundant variable from TransclusionOutlineWidget
Change-Id: I27a890069748d9e689c96fa7c515568fb38e9973
2021-10-08 13:38:44 +02:00
jenkins-bot 990d5372e9 Merge "Fix first click on parameter page causing bad scroll" 2021-10-08 10:50:15 +00:00
Thiemo Kreuz f77ef7d7f4 Fix/cleanup template dialog methods dealing with parts vs. items
Some cleanup to improve readability and reduce the amount of code.
Relevant bits:
* One method name was wrong. It can actually return parameter ids,
  not only top-level part ids.
* I got rid of some fail-safe checks that are never needed or moved
  them to a more central place.

Change-Id: I08f2ad7bc7d3f985d6189dff170dda554f3d37c2
2021-10-08 07:43:23 +00:00
jenkins-bot 02e3aff969 Merge "Refactor how namespaces with subpages are exposed to JavaScript" 2021-10-07 17:57:11 +00:00
Thiemo Kreuz be789e6387 Fix first click on parameter page causing bad scroll
The idea of this piece of code is to make sure both sides of the
dialog show the same element. But it doesn't make sense to force the
*header* of a template into view when I clicked on a *parameter*.

Bug: T292718
Change-Id: I9945f8e54c856152f05bf717e43468ab5ab24d2f
2021-10-07 15:04:20 +02:00
jenkins-bot 0ba300554f Merge "Move some logic into the TransclusionModel class" 2021-10-07 07:51:54 +00:00
Thiemo Kreuz 866547d081 Harden …TemplateTitleInputWidget to avoid JS console spam
I run into this in some local test. There are two reasons this code
can be reached:
* When a wiki doesn't have the TemplateData extension, the
  additional API call from line #154 will fail. But the original
  search query succeeded. We have the `originalResponse` and can
  return it. This makes the code behave as if the additional
  TemplateData API call was never done.
* But what if the original search query failed? We still end in
  line #183 – as we should. But this time it can't return anything
  but undefined. This will be considered a valid, successful API
  response. But it isn't.

There might be a better way to clean up this chain of promises.
This is the smallest fix I found.

Change-Id: I02d3d053156da222ee424382007621f314777015
2021-10-06 20:14:55 +00:00
DannyS712 2984539f42 Refactor how namespaces with subpages are exposed to JavaScript
Instead of using an object mapping namespace ids to if they have
subpages enabled or not, pass an array of the namespaces where
subpages are enabled, reducing the size of the configuration that
gets loaded on all requests. Only requires a minor update to the
JavaScript that uses the value (check for array index instead of
object value).

Bug: T291729
Change-Id: Ia0ecac71721eceed52cc90f39ecc560bdf1b7f9b
2021-10-06 20:11:37 +00:00
Thiemo Kreuz 1904698105 Move some logic into the TransclusionModel class
I moved some code around and found that quite a lot of code wants to
know:
* Is the length of this transclusion exactly 1?
* I need that 1st part.

There is more that can potentially moved from the dialog to the model.
But I don't want to make this patch to big.

Bug: T292371
Change-Id: Ia94ed0450d04dd97c4c41f5bf7c266f9a534e821
2021-10-06 16:00:18 +00:00
Thiemo Kreuz 1731f3cc14 Better name for .selectPartByPageName() method
This method does not only select a "part", i.e. a top-level item like
a template. It also selects sub-items like template parameters. The
new name reflects this better.

Change-Id: I51a8ddbd05b283248afba5a623cc52da7b2434f5
2021-10-01 07:00:40 +00:00
Thiemo Kreuz a625669380 Add missing @fires documentation tags
Change-Id: I0c9b2aa827a6806004480b642c23f320b190b6ab
2021-09-30 15:50:33 +00:00
Thiemo Kreuz 152f5edae2 Add/remove some TODO comments
Change-Id: I99bf367025ba4830fb683add93087d42dce4566d
2021-09-28 09:55:47 +02:00
jenkins-bot 33e4f6da0b Merge "Add @private tags to template dialog related methods" 2021-09-27 11:10:37 +00:00
jenkins-bot c5ee1889b1 Merge "Rename misleading updateOutlineControlButtons event and handler" 2021-09-27 09:19:09 +00:00
Thiemo Kreuz 58f5882957 Implement basic Ctrl+Shift+Up/Down/Del support in new sidebar
Note this patch is somewhat incomplete. The feature fully works and
I would like to see this patch merged as it is. But whenever you
press one of the keys the focus is stolen by some element on the
right side of the dialog. This makes it impossible to e.g. press
Ctrl+Shift+Down multiple times. The idea is to work on this in the
next patch.

Bug: T290262
Change-Id: Ic67f2a696c94f1e5c71134d681161221aecbfdf6
2021-09-27 08:29:12 +00:00
Thiemo Kreuz f68c1e3794 Add @private tags to template dialog related methods
… obviously only to methods that are meant to be private, i.e.
only called from within the class (and possibly tests).

Change-Id: I581558078dc7210abac5f5724f71316ac45745e6
2021-09-26 11:51:36 +02:00
Thiemo Kreuz 19bb1810c4 Rename misleading updateOutlineControlButtons event and handler
The .onUpdateOutlineControlButtons() method doesn't describe what it
actually does. This issue was introduced in I9c5478a. (Intentionally,
to not make the patch to complicated.) Let's continue to rename
things to be a) unique and b) honest about what they do.

This is an alternative to I8d98e61.

Bug: T289043
Change-Id: I4d52ffa6e9e5df2025a0c33031c1517bcb421279
2021-09-26 11:50:38 +02:00
jenkins-bot 72681d45d2 Merge "Rename outline "container" widget" 2021-09-24 11:14:30 +00:00
Thiemo Kreuz 63d9969861 Rename outline "container" widget
I can't really tell what insight we get from the word "container".
Every widget is a "container" in some sense, isn't it?

This widget is just _the_ outline, I would argue.

Other suggestions?

Change-Id: I1fb27ee58c1a3dd790022504e978198dadf7ea02
2021-09-24 12:32:29 +02:00
Adam Wight bd7a1b0997 Unhighlight all items when highlighting
This prevents multiple highlighting, which was possible to achieve by clicking
sequentially in the input fields of two parameters from different templates.

Change-Id: I404936f1569ab544b693a9bc6921381636ea8f40
2021-09-24 09:26:56 +00:00
Adam Wight 64c7859c9f Prevent scrolling sidebar to heading of subitem
Scroll was landing in the wrong place.  Subitem should be kept
on-screen after click.

Change-Id: I3c1901b7b53ac523bcc0d33172b674b97421c06d
2021-09-24 07:53:01 +00:00
Thiemo Kreuz d6aece09cd Disable unwanted auto-scroll feature in template dialog
The weird auto-scroll feature is described in T289043#7297679.

This also fixes T291381 different than I393a2b1. Only one of the
patches should be merged.

Bug: T289043
Bug: T291381
Change-Id: I70d87f12fd68001e880510fb6c38d7c419d64b15
2021-09-22 13:30:37 +02:00
jenkins-bot acacece321 Merge "Document optional parameter" 2021-09-22 07:40:58 +00:00
Adam Wight 7d9a61ded7 Document optional parameter
This function can also be used to unhighlight.

Change-Id: Ic95d75dfa862951613d7c3bc21a19ec967cf9805
2021-09-21 16:36:49 +02:00
Thiemo Kreuz e037f99930 Merge custom "focusin" with "set" event handler
This code was introduced in I8fafee6. I can't tell any more what
the "bug" mentioned in the commit message was. Let's get rid of the
duplicate code path, see if we run into regressions and deal with
them one by one. That's much easier to handle than keeping this
confusing code path around.

Note this "focusin" event handler was actually re-implementing
parts of the upstream BookletLayout, namely
OO.ui.BookletLayout.onStackLayoutFocus().

Bug: T289043
Bug: T291381
Change-Id: Ib386ae6efec08465122f0e8ee81cd6dc9a2d337a
2021-09-21 10:14:57 +00:00
jenkins-bot b5388fec52 Merge "Regression: Fix broken click on top-level template elements" 2021-09-17 11:49:08 +00:00
jenkins-bot 4478eb15d8 Merge "Update and fix all @param config and @cfg documentation" 2021-09-16 20:09:15 +00:00
Thiemo Kreuz 482f4152cc Regression: Fix broken click on top-level template elements
The previous patch Id314ee8 was incomplete. The event changed.
The id in the event is not guaranteed to be a top-level partId any
more, but can be a template parameter's id.

Note: "Parameter id" and "pageName" is the same. The fact that
these ids match is how the left and the right side of the dialog
communicate.

Bug: T289043
Bug: T291151
Change-Id: I391f0f8edb96398fd33a2e0b01003013c52776da
2021-09-16 10:48:09 +02:00
jenkins-bot fe6c46bbdc Merge "Merge "templateParameterClick" and "choose" events" 2021-09-15 10:11:12 +00:00
jenkins-bot 3b78f40e7a Merge "Optimize .selectPartById() to fire less events" 2021-09-15 09:07:18 +00:00
Thiemo Kreuz cb685d1216 Fix enter sometimes focusing the wrong template part
The behavior of the enter key in the new template dialog sidebar
is somewhat inconsistent. When pressing enter on the name of a
template it sometimes just doesn't work, but focuses something
else.

I realized this is because the message "The … template doesn't
yet exist." does not have a link. There is nothing to focus in
this element. The code just gives up and the selection returns
to whatever was selected before.

It works when there is a link in the template header. But this
is not even that useful.

Let's try to always focus the first parameter instead. The user
can still press Shift + Tab to focus the link to the template
page.

Bug: T289043
Change-Id: Id314ee8ebf47d387df08c7fb432094b6d8f7a3d2
2021-09-14 18:14:05 +02:00
Thiemo Kreuz c33536112d Avoid referencing methods via strings, take 2
The first approach in patch I024ac1e doesn't work.

Change-Id: I4c9f8ef65c9e423a3e34f48483142a97ec6cef1e
2021-09-14 12:40:59 +00:00
jenkins-bot 787bc0db17 Merge "Revert "Avoid referencing methods via strings"" 2021-09-13 18:55:22 +00:00
Bartosz Dziewoński a667045383 Revert "Avoid referencing methods via strings"
This reverts commit 48283d5f19.

Change-Id: Ifc2b7fb9e9fb7deaecb6c0475db0f9253e81869f
2021-09-13 18:36:07 +00:00
Andrew Kostka a38338259d Improve input validation for the add parameter page
This patch improves the error handling for when a user tries to add
a parameter which is either an alias of a existing parameter, the
primary name of a existing aliased parameter, or a name/alias of an
existing parameter which is shown with an override label.

The error message was modified to always refer to the conflicting
parameter using the same name that is has in the sidebar.

Example: A parameter named "Parameter B" is already present in the
sidebar under its alias "B". When a user tries to add "Parameter B",
the new error message will inform the user that the parameter they
are trying to add already exists as "B".

Bug: T285869
Change-Id: I762b72b6cf14eb8ff5fcef63b4dcb70e297050de
2021-09-13 16:58:11 +02:00
jenkins-bot a52cb05804 Merge "Avoid referencing methods via strings" 2021-09-13 13:28:19 +00:00
jenkins-bot 401319cb67 Merge "Split focus handling from add/remove parameter events" 2021-09-13 13:28:16 +00:00
jenkins-bot b4ac8c45ce Merge "Make "templateParameterClick" event similar to "choose"" 2021-09-13 13:24:37 +00:00
Thiemo Kreuz 48283d5f19 Avoid referencing methods via strings
Should be a bit more obvious, I hope.

Change-Id: I024ac1e2d68bfe4c5af733c48967af4c51f336c1
2021-09-13 14:26:16 +02:00
jenkins-bot 0cfd298d18 Merge "Fix and test page name splitting code in template dialog" 2021-09-13 12:23:17 +00:00
jenkins-bot 1e4ef48393 Merge "Use OOUI 'classes' property instead of .addClass()" 2021-09-13 11:46:19 +00:00
Thiemo Kreuz e62b3fecbb Optimize .selectPartById() to fire less events
There is no point in firing this event when noting changed.
This should reduce flickering and some of the issues described
in I97d77f4.

Change-Id: I7c387889a4a33dac5053cec11a0641d358020b56
2021-09-13 13:42:20 +02:00
jenkins-bot 844606d573 Merge "Fix space bar on top-level template parts loosing focus" 2021-09-13 11:03:20 +00:00
Thiemo Kreuz 6cb287c225 Fix space bar on top-level template parts loosing focus
As a reminder (not part of this patch): Pressing enter on the name of
a template should select it, and jump to the content area on the right.
Pressing space (that's what this patch is about) should select as well,
but not move the focus.

The best way to test the behavior is with a multi-part template.

Bug: T285323
Bug: T289043
Change-Id: I97d77f43b231696f92ba6758a6b8feac34e02e6d
2021-09-13 10:34:28 +02:00
Thiemo Kreuz aa556e3ef8 Update and fix all @param config and @cfg documentation
I tried to review all of them. Some of the changes I did:
* Make sure the `config` parameter is not marked as optional
  when it is not.
* Make sure default values are mentioned.
* List individual `@cfg` options when it makes sense.

Note I don't list all options a class could accept (e.g. via all
its parent classes and mixins). That's too much. Instead I checked
how a class is actually used and list only these options.

Even then I don't list everything, e.g. unspecific options
like "classes" that can be used pretty much everywhere.

Change-Id: Idf4fbe1dc3608ace277df9e385f2f140df3a2f50
2021-09-12 12:35:27 +00:00
Thiemo Kreuz 338a800837 Merge "templateParameterClick" and "choose" events
We don't need to distinguish between these any more. Both are
"active", i.e. both focus the widget on the right side of the
dialog. Sometimes the "choose" event is fired to actually add
or remove a parameter. Sometimes it's fired, but the state of
the parameter doesn't change (for whatever reason, i.e.
because the parameter name was clicked instead of the
checkbox). There is nothing to do in this case, except for the
focus change.

Change-Id: I3c7c0c81a075ccff76eda0a4fb2aa1ac7be3cec5
2021-09-11 17:47:08 +00:00
Thiemo Kreuz 1493aa7a35 Split focus handling from add/remove parameter events
* The template model fires an "add" event. Listeners don't
  automatically steal the focus any more.
* Instead there is a separate "focusTemplateParameterById" event
  fired from all relevant places that add a parameter.
* The "remove" doesn't steal the focus any more.

Bug: T285323
Change-Id: I93f17727524bfbcf6f11647a6c2441781337c4cc
2021-09-11 17:47:02 +00:00
Thiemo Kreuz cdc168d32a Use OOUI 'classes' property instead of .addClass()
The 'classes' property is a OOUI interface. Personally, I like
this code style better.

However. It appears like the code style in this codebase is
somewhat mixed. It looks like the top-level .$element always
uses .addClass(), while other code uses the 'classes' property.
Should we unify this?

Change-Id: I9ecd75e22d00f06ffd707f766dc9e8d748ff9a37
2021-09-11 17:41:45 +00:00
Thiemo Kreuz 22757fa901 Fix and test page name splitting code in template dialog
In JavaScript .split() behaves different, compared to PHP. In
PHP the last element contains the rest of the string. In
JavaScript the rest of the string is discarded. The limit acts
as if the array is truncated. That's why we can reduce the
number in

  'foo/bar'.split( '/', 1 )[ 0 ]

to 1, as we are only interested in the element "foo".

The same code in the other class is currently not covered by a
test. But changing it accordingly should be obviously fine now.

Change-Id: I20c27d480ddb1799df9eb1e5bc119b724e80653d
2021-09-11 17:40:39 +00:00
Thiemo Kreuz ec526ea64f Make "templateParameterClick" event similar to "choose"
The original idea was to make the interface as narrow as
possible. However, it turns out it's better to model the
"templateParameterClick" event more closely after the "choose"
event.

This is split off to make reviewing the following patches
easier.

Change-Id: I271f576c6cd756cecfc6cb1fd64810f8da5c3575
2021-09-10 17:19:19 +02:00
Thiemo Kreuz 30d4096aeb Remove invisible tab target from template dialog sidebar
The list of parameters should remove itself from the list of
possible tab navigation targets when it's empty.

Note there is no way to remove elements from the parameter
list. That's why we don't care about "remove" or "clear"
actions.

Change-Id: I8b1215117e0ddc94f787d173e9bea6f7567d9671
2021-09-10 06:42:22 +00:00
Thiemo Kreuz 3ee7a1f1ed Do not pass Message object to …DismissibleMessageWidget
I wanted to change this for quite a while now. It was discussed
again in Iff1d2c0.

Change-Id: Iaaac9bf91d9b11557ab068d2c719084c46b3ecb2
2021-09-03 15:21:36 +00:00
jenkins-bot 836ab09a79 Merge "Rename and document select/focus events in template dialog" 2021-09-03 09:38:21 +00:00
jenkins-bot 7eb5b5a1ef Merge "Cleanups and optimizations related to .parseDom()" 2021-09-02 20:03:09 +00:00
Thiemo Kreuz 36bd65dda7 Cleanups and optimizations related to .parseDom()
E.g. avoid calling the rather expensive method multiple times
in a row, if only 1 of the results is needed.

Change-Id: Iff1d2c0892367e927303f6f45d3231e04c045cab
2021-09-02 18:29:09 +00:00
jenkins-bot 7848b1a071 Merge "Fix inconsistent keyboard :focus styles in template outline" 2021-09-02 13:04:17 +00:00
jenkins-bot 7c304dc444 Merge "Highlight first template parameter when using tab to navigate" 2021-09-02 10:18:22 +00:00
jenkins-bot abdbf57f84 Merge "Fix click/enter on template parameters not focusing the input" 2021-09-02 10:11:49 +00:00
jenkins-bot c8e00fb98a Merge "Highlight corresponding template parameter in new sidebar" 2021-09-02 10:10:13 +00:00
Thiemo Kreuz 06cf00f4c6 Rename and document select/focus events in template dialog
I tried hard to come up with the best possible names. Some of the
criteria I used:
* Longer and more unique is better. This makes it much easier to
  e.g. search for the event name.
* The term "part" should only be used for top-level parts. While
  template parameters have a unique id, they are not a subclass
  of …TransclusionPartModel and therefor not "parts".
* BookletLayout manages "pages" via "page names".
  * The page names of top-level parts are identical with the part
    id, see ve.ui.MWTemplateDialog.getPageFromPart.
  * The page names of parameters are identical with the parameter
    model id, see ve.ui.MWTemplateDialog.onAddParameter.

Some code knows parameter ids, but not what pages are. Other code
knows page names, but not what parameters are. The transition
currently happens in the …OutlineContainerWidget. We might want
to move this point up to the …TemplateDialog. But I would argue
this is good enough for now and can be changed later, if needed.

Bug: T285323
Change-Id: Iab2805b3203988db400b67c8d00e48905fdc53dc
2021-09-01 16:23:59 +00: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 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 3b5064318c Merge "Connect focus event from BookletLayout to new sidebar" 2021-09-01 08:47:07 +00:00
WMDE-Fisch 099d6bad87 Use ve.targetLinksToNewWindow in MWDismissibleMessageWidget
Change-Id: I71a2c933e4af0dac4a083ce34820fa2994fc388d
2021-08-31 15:06:20 +02:00
jenkins-bot 9d0c480529 Merge "Narrow selector for links when adding _blank" 2021-08-31 12:42:36 +00:00
WMDE-Fisch 99cee2be11 Narrow selector for links when adding _blank
Change-Id: Ia05117759c81fff6f35256931d0894c0b8051fe6
2021-08-31 13:08:25 +02: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 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 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
jenkins-bot c1ce1e3d4b Merge "Move small code snippets into …OutlineParameterSelectWidget" 2021-08-27 11:36:53 +00:00
jenkins-bot f2b94e10b6 Merge "More test cases for MWTransclusionOutlineContainerWidget" 2021-08-27 10:00:04 +00: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
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 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
jenkins-bot e803c20007 Merge "Rename …ParameterCheckboxLayout now that it's an actual Widget" 2021-08-23 14:46:09 +00: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 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
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
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
jenkins-bot 68cfd5da16 Merge "Remove addParameter button from new sidebar" 2021-08-18 09:34:26 +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
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 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
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 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
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