Commit graph

997 commits

Author SHA1 Message Date
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 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
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
jenkins-bot 9e6387176b Merge "Add @private/@protected documentation to template dialog code" 2021-07-06 08:41:55 +00:00
jenkins-bot 7afb7981d1 Merge "Rewrite MWTemplateDialog.setApplicableStatus for readability" 2021-07-01 11:56:30 +00:00
jenkins-bot 5028f4eaf3 Merge "Remove unused "insert" action from MWTemplateDialog" 2021-07-01 11:52:21 +00:00
Thiemo Kreuz f1a66c17e4 Rewrite MWTemplateDialog.setApplicableStatus for readability
I rearranged this piece of code like a dozen times before I
finally understood what it actually does. This should be much
more obvious now.

The idea is:
* If no edit was made the button is always disabled.
* You can save pretty much everything, except when the
  transclusion still starts with a placeholder.
* You can also click the done button when the dialog is empty.
  This feels a bit odd, but was like this before. I think this
  codepath is unreachable. But it probably doesn't hurt to
  keep it.

Bug: T284895
Change-Id: Ic483201b64fd64f414c5b1ec4c44198b8eadb9f2
2021-07-01 11:20:50 +02:00
Thiemo Kreuz 55a49195ba Add @private/@protected documentation to template dialog code
These tags don't do much, if anything. But they provide a hint
in which scope a method might be used.

Bug: T284895
Change-Id: I0b4bdd416ee89d26961c4ded4d8bbace8c57da76
2021-07-01 09:36:00 +02:00
jenkins-bot 7426139a41 Merge "Fix possibly uninitialized variable in template dialog" 2021-06-29 13:47:06 +00:00
Thiemo Kreuz (WMDE) e6d3828429 Revert "Extract "show all" to placeholder class"
This reverts commit 950a5300dc.

Reason for revert: This broke several workflows. The reason is
that MWParameterPlaceholderPage & MWParameterSearchWidget both
hold references to the MWTemplateModel. This model is not
always the same. The dialog might be the same when a template
is edited multiple times. But the model might be a new one.
From this point on the MWParameterSearchWidget pulls data from
an outdated model.

Bug: T284636
Bug: T285571
Change-Id: I7b9ea8cab8f17705ec8020f07e3732da6ba0e73c
2021-06-28 14:04:12 +02:00
Thiemo Kreuz 6b346442ad Hotfix for broken "Extract show all to placeholder class"
This does not revert commit 950a5300 but applies the most
minimal hotfix I could come up with.

The reason for the breakage is that MWParameterPlaceholderPage
& MWParameterSearchWidget both hold references to the
MWTemplateModel. This model is not always the same. The dialog
might be the same when a template is edited multiple times.
But the model might be a new one. From this point on the
MWParameterSearchWidget pulls data from an outdated model.

This extra check compares this model reference and creates a
new widget when it changed.

Bug: T284636
Bug: T285571
Change-Id: Ib3eca52bbff90ffbf56a257e3984adcbe02b310b
2021-06-27 18:29:23 +02:00
Thiemo Kreuz 2966b69609 Fix possibly uninitialized variable in template dialog
There is a codepath where `modelPromise` is undefined and
calling `modelPromise.then()` fails. This codepath implies
that the dialog is empty and there is nothing to update. We
can just close the dialog then.

I found this while debugging the actions in this dialog.
This happens when the dialog is empty (except for a
placeholder) but you submit it anyway. This is typically
not possible as the button is supposed to be disabled.
Still I think it's a good idea to make this code less
fragile.

The relevant code was introduced in Ibc2fc66 (2016).

Change-Id: Ia6b723548456c211b944a2320949bfc23b0afa16
2021-06-25 16:49:30 +02:00
jenkins-bot 118ae98a2a Merge "Wire model changes into new template sidebar" 2021-06-24 09:31:46 +00: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
Thiemo Kreuz 4367235dcc Inline many var declarations in the code below
This makes the code more readable and easier to reason about.
The ESLint rule responsible for this code style was removed
just recently.

Notes:
* I focus on classes that are relevant for what the WMDE team
  does right now.
* I merge multiple `var` keywords only when the variables are
  strongly connected.
* Caching the length in a for loop makes the code hard to
  read, but not really faster when it's a trivial property
  access anyway.

Bug: T284895
Change-Id: I621fed61d894a83dc95f58129bbe679d82b0f5f5
2021-06-23 09:02:24 +00:00
jenkins-bot 06ea3f84f8 Merge "Rewrite MWTransclusionDialog methods for readability" 2021-06-21 10:41:39 +00: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
Thiemo Kreuz c6f2683dd8 Rewrite MWTransclusionDialog methods for readability
Most notably:
* Introduce variable names that explain much better what's
  going on.
* Reduce nesting.

Bug: T284895
Change-Id: I793677d8107abb6354f9e19d79c4879a41c4bd93
2021-06-18 16:09:52 +02:00
Thiemo Kreuz c135f10f72 Remove unused "insert" action from MWTemplateDialog
This action was removed via Ib744b89 in 2019, see
https://gerrit.wikimedia.org/r/c/mediawiki/extensions/VisualEditor/+/491537/4/modules/ve-mw/ui/dialogs/ve.ui.MWTemplateDialog.js
Note the messages that are removed in this patch:
* …-action-insert was used for the "insert" action.
* …-action-apply was used for an "apply" action.
* …-action-cancel doesn't mention an action. Internally,
  the cancel action is "".

Since Ibd740ad the actions are registered in the
FragmentDialog superclass, see
https://gerrit.wikimedia.org/r/c/VisualEditor/VisualEditor/+/491536/2/src/ui/dialogs/ve.ui.FragmentDialog.js
Note the messages. Cancel is unchanged. …-action-insert and
…-action-apply are still there, but both linked to the same
"done" action. The "apply" and "insert" actions are gone.
I.e. they are merged into a single "done" action, represented
by a single button that changes the label from "Insert" to
"Apply changes" when needed.

On top of that,
MWTransclusionDialog.updateActionSet() replaces "Apply
changes" with "Save".

Note: Other dialogs also mention an "insert" action. I didn't
look at these. These are not in the focus of our team's
current project.

Bug: T284895
Change-Id: I1d35ada3b5b2049ed20c2d940a1c065b704c978d
2021-06-18 13:44:35 +02:00
jenkins-bot 595b3a1caf Merge "Better variable names for the template dialog's "single" mode" 2021-06-18 08:34:54 +00:00
Thiemo Kreuz 2a1defc26f Remove unused .onAddParameterBeforeLoad() method
https://codesearch.wmcloud.org/search/?q=onAddParameterBeforeLoad&i=1

Bug: T284895
Change-Id: Ib521e05d8def8514ffe1b3c3822f0151ab10932e
2021-06-17 18:30:02 +02:00
Thiemo Kreuz bba592460d Better variable names for the template dialog's "single" mode
The "mode" button is the button that allows to expand and
collapse the dialog. It can't be collapsed when multiple
templates are edited. That's what these lines do,
disabling the button.

"Can expand" is not the correct question. It's always
possible to expand the dialog no matter what it contains.

Bug: T284895
Change-Id: I60f3060695c80bf5541ef2156be89b85a62bf91b
2021-06-17 18:24:17 +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
jenkins-bot 6d101fb9d7 Merge "Extract "show all" to placeholder class" 2021-06-16 12:25:55 +00:00
jenkins-bot 09933c4905 Merge "Method for getting the currently selected element" 2021-06-16 07:22:28 +00:00
jenkins-bot 4c7f5ff805 Merge "Introduce a new class to encapsulate booklet inter-pane wiring" 2021-06-15 14:55:16 +00: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 3f4cfb0fd8 Merge "Rename "value" to "wikitext" in TransclusionContent… classes" 2021-06-11 14:10:24 +00:00
WMDE-Fisch 09d98669df Rename expand and collapse button msg key names
These are currently more confusing than helpfull. Also applied
alphabetical order.

Change-Id: I4d48f7bc28b403142a5818d1c7a062872afc660d
2021-06-11 13:16:44 +02:00
Adam Wight a2daf5f6c6 Method for getting the currently selected element
Continue refactoring booklet pane access.

Bug: T284632
Change-Id: I866f8550d269d05b40eaddf8abb4ed5be03f902d
2021-06-10 15:32:07 +02:00
Adam Wight 44035a2384 Introduce a new class to encapsulate booklet inter-pane wiring
Begin to extract the wiring between a sidebar and the content pane of
the template dialog booklet layout.  Eventually, this helper class
will present a high-level interface like "addPart(id)" and will take
care of creating the outline item, content page, and connecting
events.

Start very simple, take over the "focus" method.

Bug: T284632
Change-Id: I7bc73cc4386b99d95941fc6ed88ab5bd998de014
2021-06-10 15:30:51 +02:00
Thiemo Kreuz df419335bb Rename MWTransclusionDialog.setMode() to toggleSidebar()
This reflects better what the method actually does. This patch
is a direct follow-up for the renames started in Ib029fd4.

Change-Id: Ie3e87139a5c2f5ac196e0fcc02fb897fadc99177
2021-06-10 14:05:40 +02:00
WMDE-Fisch ecf317e0bd Fix message keys to show options in template dialog
The names of the messages keys are very confusing. The order was set
wrong during refactoring in Ib029fd48b393d2ab7d7cff6c842789e22989e944.

We should rename the keys in a follow up in sync with translatewiki.

Bug: T284649
Change-Id: I43794d80b7df7d00441cb583ca53bcab03999e65
2021-06-10 10:50:40 +00:00
Thiemo Kreuz 190237ee28 Rename sidebar state to distinguish from multiple transclusion
This dramatically simplifies the "mode" flag in
MWTransclusionDialog. The main reason to touch this code is:
The flag appears like it will be "single" when the dialog
contains a single template, and "multiple" when there are
multiple templates. But this is not true.

What the flag really does is show/hide the sidebar. The sidebar
is needed to be able to create multi-part templates. But a
dialog that already contains multiple templates can be set to
"single" mode (i.e. the user can collapse the sidebar), and
vice versa.

This patch focuses on private details inside of this class, but
keeps the terminology of a "mode" in some places. E.g. the
messages are not renamed to not cause unnecessary trouble for
translators.

Change-Id: Ib029fd48b393d2ab7d7cff6c842789e22989e944
2021-06-09 09:44:08 +02:00
Ed Sanders 857014fae9 Support watchlist expiry
Bug: T251348
Change-Id: I017a54784c758c5e97fb640721bd456adc0fbab5
2021-06-08 20:14:45 +00:00
jenkins-bot 2b0da3e338 Merge "Update template dialog title when multiple transclusions present" 2021-06-08 08:14:11 +00:00
Thiemo Kreuz 8d7c55aa71 Rename "value" to "wikitext" in TransclusionContent… classes
This class represents a raw wikitext snippet. There is also no
base class that would require us to follow a generic
getValue/setValue naming scheme.

Change-Id: I0891a2f6c0ae0121429a47c39221e99b9653e8e3
2021-06-08 09:27:47 +02:00
Thiemo Kreuz 7fdc560fb8 Rename "sequence" to "ordered parameter names"
There are 2 methods with the same name, but they are very
different. This makes it much easier to understand the
difference, I hope.

Change-Id: Ie1f049b2b14e1fe23f078e281ee797da29dfe3db
2021-06-07 23:24:17 +00:00
Andrew Kostka 67e48a26ef Update template dialog title when multiple transclusions present
Bug: T276568
Change-Id: I530a6cd8aea4f9fcafe7a03fc5050883f1f4b37c
2021-06-04 16:48:05 +02:00
jenkins-bot 69676950b3 Merge "Much longer descriptions of template dialog related classes" 2021-06-04 12:00:46 +00:00
Thiemo Kreuz e13b0dae48 Much longer descriptions of template dialog related classes
The idea is to possibly rename some of these classes, based on
these descriptions. But this should be done in later, separate
patches.

Change-Id: I7f9e5b2382711b434d6dd618489fa3ed8b7a46b4
2021-06-04 13:17:59 +02:00
jenkins-bot bc0f405317 Merge "NWE: Always paste rich text as plain, and show context item to convert" 2021-06-03 18:15:59 +00:00
Adam Wight d4eee82701 Update template dialog titles: Insert/Edit
Toggle depending on whether the transclusion existed or is new.

Bug: T276568
Change-Id: Ib9b76cac7cd57245e8db2ef10879069a86a6269e
2021-06-02 12:36:38 +02:00
jenkins-bot 7fe5b6a433 Merge "Template dialog button title toggles between Insert/Edit" 2021-06-02 10:34:53 +00:00
Adam Wight c49478de60 Template dialog button title toggles between Insert/Edit
Depends on whether this is a new or existing template transclusion.

Split from Ib9b76cac7cd57245e8db2ef10879069a86a6269e

Bug: T276568
Change-Id: I4d22e32fef067b640e9a9389deffaace736c3405
2021-06-02 12:00:15 +02:00
jenkins-bot fa94c27a8d Merge "Change header titles in the template dialog" 2021-06-02 09:05:04 +00:00
WMDE-Fisch 58cf1b0344 Change header titles in the template dialog
Bug: T276568
Change-Id: I5da40032c5b83d04ae92e86372c445d7a28d0444
2021-06-02 08:48:07 +00:00
WMDE-Fisch 98b6cc8bc2 Don't update backButton visibility if not set
Bug: T283511
Change-Id: Idb9668e45c6820cbb631d7a8aac34e03cf788802
2021-05-26 08:47:52 +02:00
jenkins-bot a01b56bcf1 Merge "Invert template search result highlighting" 2021-05-17 12:30:49 +00:00