Page MenuHomePhabricator

[Task] Widgets should delegate isInitialValue calls as far as possible
Closed, InvalidPublic

Description

In the terms view, the API requests to save changed values are done in the labelview, descriptionview and aliasesview widgets. These, but only these three widgets should have a full implementation of isInitialValue that possibly creates Wikibase-DataModel-JavaScript objects and compares them. All other, higher level widgets should delegate an isInitialValue call to their sub-widgets.

This not only avoids duplicate code. It also avoids creating Wikibase-DataModel-JavaScript objects.

Same for the statements and sitelinks views.

Event Timeline

Candidates in the terms section:

  • label-, description- and aliasesview are all fine. All three handle edits itself and propagate them to a changer. Both isInitialValue and value (the later is tracked in T124787) are required for that. The only issue is that the code of the three widgets looks different, but shouldn't.
  • entitytermsforlanguageview wraps a label-, description- and aliasesview. It's isInitialValue forwards nicely.
  • entitytermsforlanguagelistview contains a list of entitytermsforlanguageview widgets. It does not forward isInitialValue but instead does a complicated comparison. This is the main issue why I created this ticket.
  • entitytermsview wraps a single entitytermsforlanguagelistview and forwards nicely.

Statements section:

  • statementview forwards to RankSelector.isInitialValue as well as snakview.isInitialValue, but compares qualifiers and references manually.
  • snaklistview contains a list of snakview widgets, but does not forward.
  • snakview is complicated. Does this count as a "leaf object"? Why is the code so complicated?
  • RankSelector is trivial and fine.
  • referenceview is also complicated and needs more investigation.

Sitelinks section:

  • sitelinkgroupview wraps a single sitelinklistview and forwards nicely.
  • sitelinklistview contains a list of sitelinkview widgets and should forward.
  • sitelinkview is a "leaf object" and fine.

Change 266710 had a related patch set uploaded (by Thiemo Mättig (WMDE)):
Simplify entitytermsforlanguagelistview.isInitialValue

https://gerrit.wikimedia.org/r/266710

Change 266727 had a related patch set uploaded (by Thiemo Mättig (WMDE)):
Simplify sitelinklistview.isInitialValue

https://gerrit.wikimedia.org/r/266727

Change 266710 merged by jenkins-bot:
Simplify entitytermsforlanguagelistview.isInitialValue

https://gerrit.wikimedia.org/r/266710

Change 266727 merged by jenkins-bot:
Simplify sitelinklistview.isInitialValue

https://gerrit.wikimedia.org/r/266727

Change 286668 had a related patch set uploaded (by Thiemo Mättig (WMDE)):
Clean up usage of self and private properties in snaklistview

https://gerrit.wikimedia.org/r/286668

Change 286669 had a related patch set uploaded (by Thiemo Mättig (WMDE)):
Forward snaklistview.isInitialValue to snakview

https://gerrit.wikimedia.org/r/286669

Change 286668 merged by jenkins-bot:
Clean up usage of self and private properties in snaklistview

https://gerrit.wikimedia.org/r/286668

Change 286669 abandoned by Thiemo Mättig (WMDE):
Forward snaklistview.isInitialValue to snakview

Reason:
Obsolete now, thanks to Adrian. :-)

https://gerrit.wikimedia.org/r/286669

Is there still something to do here? If yes it'd be good to clarify what.

isInitialValue does not exist any more.