Page MenuHomePhabricator

Extract and log data bridge parameters from edit links
Closed, ResolvedPublic5 Estimated Story Points

Description

As a developer I want to extract information from the template's edit link in order to create the client editing modal with the correct statements and edit flows.

Problem:
We need to get information about which statements to edit on which Item and with which edit flow. This ticket is for getting the basics of this: encoding the information in a dummy template and getting the information logged to console.

Example:

<span data-bridge-edit-flow="overwrite"><a href="https://www.wikidata.org/wiki/Q1234#P123"> edit icon goes here </a></span>

The output would be:

  • flow: overwrite
  • ItemID: Q1234
  • PropertyID: P123

BDD
GIVEN a template on the client
AND an edit link icon linking to the repository
AND a span with the edit flow parameter
THEN the edit flow and Item ID and Property ID for the statement group is logged to console

Acceptance criteria:

  • edit flow, Item ID and Property ID are logged to console

Event Timeline

We agreed during story time that the logging should happen in the app module, not in the init module, but didn’t yet know what exactly should be transmitted between the two modules.

As far as I can tell, the app will need the DOM elements corresponding to the edit links (which will probably be the surrounding <span data-bridge-flow="…">s, not the <a>s directly) so it can attach event handlers to them. The app could extract all the information from those elements itself, but I’m not sure if that won’t result in duplication between init and app – after all, init doesn’t send all the DOM elements to the app, only the ones that correspond to edit links. Or the ones that looks like they might correspond to edit links even if they don’t contain complete information?

I think either init extracts the full information for each edit link, and then passes to the app a list of init links along with their information; or init’s selection of DOM elements is fairly simple (CSS selector [data-bridge-flow], i. e. has that attribute), and what init sends to app is a list of candidate elements, and it’s app’s responsibility to extract the information from them (and, if some information is missing, discard them since they’re not valid edit links at all).


Side note: in the doc draft I used the name data-bridge-edit-flow rather than data-bridge-flow – either is fine, but I think the more verbose variant is also clearer. Any other opinions? Edit: We’ve decided to use data-bridge-edit-flow for now.