Commit graph

15 commits

Author SHA1 Message Date
Timo Tijhof 0560084393 ve.ui.MWTemplateDialog: Implement inferring of template data
Clean up of logic implemented during the template-sprint:

* Store spec inside the content model, directly associated
  with the content-part. This allowed fixing the bug where
  two spec-less template invocations overwrote each other's
  made-up template data due to it using "target.wt" as key.
  The opener now provides the fetcher with a "specId" which
  is set to "part/<id>" for wt-generated template targets.

* Batching is now implemented inside the fetcher instead
  of outside. This allows calling "getTemplateSpecs" inside
  the loop with a dedicated callback for each spec to store
  it in the content.parts[i] object passed by reference.

  It also makes it easier to use by different code paths.
  You call it as much as you like and it will queue up
  naturally through javascript yielding and then make a batch
  request. This is based on the pattern I used in MediaWiki core
  for mw.loader#addEmbeddedCSS.

Follows-up e7af635, da679b7.

Change-Id: I4d7121229d060a96d927585c987a1a81a474b922
2013-05-30 18:37:51 +01:00
Trevor Parscal da679b7a9c Template dialog cleanup
Objectives:

* Break template page creation into it's own method
* Get rid of styling being applied in JavaScript
* Fix styling issues

Changes:

ve.ui.MWTemplateDialog.js
* Add method for adding a template page
* Replace css calls with addition of classes for styling
* Cleanup of append calls

ve.ui.Dialog.css
* Make inputs in the template dialog full width and a reasonable height

ve.ui.Widget.css
* Swap margins with padding in labels to prevent layout issues
* Prevent textareas from being resized in safari/chrome

Change-Id: I4030d8605aad865251ecd0aeb8cc72d333bed6a4
2013-05-29 11:03:52 +01:00
Trevor Parscal b0f464ef0e Add support for editing multi-template nodes
Objectives:

* Refactor template dialog to support loading template data for, and
  editing multiple templates and interleaved content in a template node
* Update template node model to generate multi-template wikitext

Changes:

ve.dm.MWTemplateNode.js
* Rewrite getWikitext method to work with multi-template formats

ve.dm.MWTemplateDialog.js
* Retain information about the node and template calls
* Break AJAX handler into its own method
* Attach event handlers to inputs directly so template values are
  edited directly on the fly
* Refactor page building to support multiple templates
* Add multi-template support for template data API call
* Add support for editing plain text content

Change-Id: I92ff8a9e186701a3f8da88def92a5b7dcb607897
2013-05-29 01:10:57 +01:00
Trevor Parscal 6d8de30853 Use config object for ve.ui.PagedDialog.addPage optional args
Objectives;

* Cleanup the addPage API
* Add optional index param to addPage method

Changes:

ve.ui.MWMetaDialog.js, ve.ui.MWTemplateDialog.js
* Update uses of addPage

ve.ui.PagedDialog.js
* Bundle existing optional arguments into object
* Add index option for inserting a specific index

Change-Id: Idcef4d0a52fb817c7d888990920b2c12224a3392
2013-05-28 20:33:32 +01:00
Catrope b70d6e1b45 Remove duplicated code breaking the template dialog
Change-Id: Ied5dc71106601ab354441c2d81507b616553c0d9
2013-05-25 14:23:29 +02:00
Trevor Parscal 2e76271b4e The Great ve.ui.Surface refactor of 2013
Prologue:

Farewell ve.Editor my good chap… Oh, hey there HTML frames - I didn't
see you there! In a world where iframes are outlaws, and symbols like
document and window are global, there were more than a few assumptions
about which document or window was being used. But fear not - for this
commit (probably) tracks them all down, leaving a trail of
iframe-compatible awesomeness in its wake. With the great ve.ui.Surface
now able to be used inside of iframes, let the reference editing
commence. But there, lurking in the darkness is a DM issue so fierce it
may take Roan and/or Ed up to 3 whole hours to sort it out.

Note to Roan and/or Ed:

Editing references seems to work fine, but when saving the page there
are "no changes" which is a reasonable indication to the contrary.

Objectives:

* Make it possible to have multiple surfaces be instantiated, get along
  nicely, and be embedded inside of iframes if needed.
* Make reference content editable within a dialog

Approach:

* Move what's left of ve.Editor to ve.ui.Surface and essentially
  obliterate all use of it
* Make even more stuff inherit from ve.Element (long live this.$$)
* Use the correct document or window anywhere it was being assumed to be
  the top level one
* Resolve stacking order issues by removing the excessive use of z-index
  and introducing global and local overlay elements for each editor
* Add a surface to the reference dialog, load up the reference contents
  and save them back on apply
* Actually destroy what we create in ce and ui surfaces
* Add recursive frame offset calculation method to ve.Element
* Moved ve.ce.Surface's getSelectionRect method to the prototype

Bonus:

* Move ve.ce.DocumentNode.css contents to ve.ce.Node.css (not sure why it
  was separate in the first place, but I'm likely the one to blame)
* Fix blatant lies in documentation
* Whitespace cleanup here and there
* Get rid of ve.ui.Window overlays - not used or needed

Change-Id: Iede83e7d24f7cb249b6ba3dc45d770445b862e08
2013-05-24 14:01:02 +02:00
Timo Tijhof e7af635e88 ve.ui.MWTemplateDialog: Implement templatedata API fetch
Fetch
* Added basic name expansion logic since bug 48663 is not yet
  resolved in Parsoid.
* Fetch info from template data API.

Clean up (follows-up 97157a1c, de203cb8, 718db58)
* Remove redundant initialize method.
* Pass the entire target object to #getTemplateData
  because `target.wt` is *not* the template name.
* Reorganise #createPage to be more logical and rename
  to #createParamPage.
* Add todo comments for things currently missing.
* Implement error handling of promise to prevent UI from
  going stale if the promise is not resolved.
* Fix documentation in ve.ui.MWCategoryInputWidget.

Change-Id: Ie0114a81eead86d7a3b3e3a7a5b10d25c457b524
2013-05-20 23:50:19 -07:00
Inez Korczyński 97157a1c1c Use promise pattern inside MWTemplateDialog in order to download TemplateData (currently just mocked) asynchronously.
Change-Id: Ib23521cf40a80cc82872de82d3935414ef385d21
2013-05-16 20:37:15 -07:00
Inez Korczyński a191073d72 Create and commit transaction after attributes of the template are changed and applied.
Change-Id: I4a1acdadcd1486ddd5dafcfc794c9b3b93e92592
2013-05-15 17:49:27 -07:00
Inez Korczyński 1b4b6663c3 Introduce createPage method in ve.ui.MWTemplateDialog and even use it!
Change-Id: I7b063a9380742e157a4c7128c1654abcf3ad8c6f
2013-05-15 16:22:12 -07:00
Inez Korczyński ba5c4f104d Build TemplateDialog based on parameters that are passed to template
(instead of TemplateData as before).

Change-Id: I50b0e6ef1936c4b56f40fa73bd42b03587bdf979
2013-05-15 22:47:59 +00:00
Christian Williams f238683341 Content for Template Dialog
Initial commit of page content.

Change-Id: Iffdf4f4179c6f3b04611d4bd9548e7cf23188856
2013-05-15 15:13:38 -07:00
Inez Korczyński de203cb871 Process example template data and add pages to PagedDialog based on it.
Change-Id: I34ee42e66df26000842f9b1540a577b2621f8839
2013-05-15 14:36:44 -07:00
Christian Williams 3f6e127423 Pages in template dialog
Just a starting point for Inez to loop.

Change-Id: I6d418ba955f0904d34b474c984eef7f97be257e9
2013-05-15 13:39:34 -07:00
Trevor Parscal 231a50f2b6 Implement ve.ui.MWTemplateDialog
Objective:

* Add button to launch template dialog
* Add template dialog

Changes;

*.php
* Add messages and links to files

ve.ce.Node.css
* Make inline templates display as inline-block to contain their
  contents (allowing shields to work properly)

ve.ui.MWTemplateDialog.js
* New empty dialog for templates

ve.ui.MWTemplateButtonTool.js
* New template button, appears in context and launches dialog

Change-Id: I9174ed7c9012522246a6defc859276bf36763f5b
2013-05-15 19:36:18 +00:00