Page MenuHomePhabricator

Change SVGTranslate's initialization into a view model
Closed, ResolvedPublic5 Estimated Story Points

Description

We are initializing in a few steps, some load on jquery load and some on document 'ready'; but the system is about to become slightly more advanced, and will need to take into account local storage in certain situations alongside the "disalbe/enable" inputs based on the initial language that started.

For example, if we store values on tab close, then when the tab reopens (and we initialize) we want to reapply the stored values and not disable inputs. We need to make sure the behavior is consistent and predictable.

As @Samwilson pointed out, it might be time to create a view model, where the behavior is centralized, synchronous, controlled, and can be tested.

The view model can do the initialization and then control all behavior of the input values, especially the saving/fetching of the local storage in a global way (rather than per-input) and listening, in aggregate, to all input change event.

Note: This ticket includes doing tests and putting them in CI, if it's easy to do.

Event Timeline

Mooeypoo renamed this task from Examine the architecture of initialization in SVGTranslate to Change SVGTranslate's initialization into a view model.Feb 22 2019, 12:17 AM
Mooeypoo updated the task description. (Show Details)

Just a note, the ViewModel could use the mixin OO.ui.mixin.GroupWidget; the individual input widgets could then be infused and then immediately added through addItems and then we can do this.aggregate( 'change', this.whateverListensToAnyInputChange.bind( this ) to listen to any change event.

Niharika updated the task description. (Show Details)
Niharika set the point value for this task to 5.

The first part of this is ready to look at https://github.com/wikimedia/svgtranslate/pull/76 — it's not at all the complete model, it mostly sets up QUnit and starts the transition to a more testable architecture.

The first part of the model is done, and the actual meaningful bits will follow soon in tasks relating to their behaviour. No QA required for this I think, unless we want to double-check that nothing's broken.

@Samwilson I don't see anything broken in staging. Is this up on production? If not, let's get it out.

Samwilson moved this task from Product sign-off to Q3 2018-19 on the Community-Tech-Sprint board.

This has been included in version 0.4.0 and is now in production.