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.
[x] Task: Implement Factory
Introduce factory to the following widgets:
[x] Task: Children of entityviews https://gerrit.wikimedia.org/r/242337
[x] Task: Statementgroupviews in statementgrouplistview https://gerrit.wikimedia.org/r/242823
[x] Task: Statement list view
[x] Task: Statementview in statementlistview
[x] Task: Referenceview and snaklistview in statementview https://gerrit.wikimedia.org/r/246767
[x] Task: Snaklistview in referenceview https://gerrit.wikimedia.org/r/246768
[x] Task: Snakview in snaklistview https://gerrit.wikimedia.org/r/246769