Page MenuHomePhabricator

[Story] Introduce factory for JS views
Closed, ResolvedPublic

Description

Currently, all views (jquery.wikibase widgets) are immediately constructed wherever needed. This has several implications:

  • They are harder to test because they construct subviews
  • Dependencies have to be passed through all parent views
  • Knowledge about our views being jQuery-based is scattered throughout our code-base

I propose to introduce a ViewFactory along the following rough spec:

ViewFactory = function( valueViewBuilder, entityStore, dataTypeStore, entityChangersFactory, … )
ViewFactory.prototype = {
  getEntityview: function( node, wb.datamodel.Entity value ){
    return $( node ).entityview( {
      value: value,
      viewFactory: this,
      …
    } );
  },
  getStatementview: function( node, wb.datamodel.Statement value ),
  …
}

That could be constructed in wb.ui.entityViewInit.

  • Task: Implement Factory

Introduce factory to the following widgets:

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 3:55 AM
bzimport set Reference to bz73380.
bzimport added a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).
Lydia_Pintscher removed a subscriber: Unknown Object (MLST).Dec 1 2014, 2:34 PM
Jonas renamed this task from Introduce factory for JS views to [Task] Introduce factory for JS views.Sep 30 2015, 9:43 AM
Jonas updated the task description. (Show Details)
Jonas moved this task from Review to Done on the Wikidata-Sprint-2015-09-29 board.

There's much more to be done here.

Change 243496 had a related patch set uploaded (by Jonas Kress (WMDE)):
Use ViewFactory for building statementviews in statementlistview

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

Jonas removed a project: Patch-For-Review.
Jonas removed a subscriber: gerritbot.

Change 243494 had a related patch set uploaded (by Jonas Kress (WMDE)):
Use ViewFactory for constructing statementlistviews in statementgroupview

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

Change 243496 had a related patch set uploaded (by Jonas Kress (WMDE)):
Use ViewFactory for building statementviews in statementlistview

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

This should be implemented at least down to the snakview. Sitelinks and terms are probably not important, since there's not so much passing through going on.

Jonas renamed this task from [Task] Introduce factory for JS views to [Story] Introduce factory for JS views.Oct 7 2015, 12:32 PM
Jonas updated the task description. (Show Details)
Jonas subscribed.

Could you please update the list of widgets in the description, so the focus of this story is clear.

Change 243494 merged by jenkins-bot:
Use ViewFactory for constructing statementlistviews in statementgroupview

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

Change 243496 merged by jenkins-bot:
Use ViewFactory for building statementviews in statementlistview

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

I don't like these task lists in descriptions, but I added them anyway. I think creating subtasks would have been a better way, though.

I also think that in most cases a separate ticket is the best, but didn't want you to force to do so. Feel free to create them if you like...

With https://gerrit.wikimedia.org/r/#/c/246769/, I consider this done. There are still more views that could be constructed in the view factory, but there are few if any options passed through these.

Change 247241 had a related patch set uploaded (by Jonas Kress (WMDE)):
Clean up statementview

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

Change 247241 merged by jenkins-bot:
Clean up statementview

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

Jonas moved this task from Review to Done on the Wikidata-Sprint-2015-10-13 board.