Commit graph

200 commits

Author SHA1 Message Date
James D. Forrester 98fffb3d78 build: Upgrade various devDependencies to latest and make pass
* grunt-contrib-csslint: 0.4.0 -> 0.5.0
* grunt-banana-checker: 0.2.2 -> 0.4.0
* grunt-jscs: 1.8.0 -> 2.1.0

Change-Id: I3070938723648ef4e320d6abf88112b9c5a2b802
2015-10-06 17:24:40 -07:00
James D. Forrester 017fa53e65 Add a url type for URLs
Bug: T54880
Change-Id: I722fcbc957825c2aaea32d9350480d29a388bb68
2015-09-30 22:15:19 +00:00
James D. Forrester 62d3138216 Add a wiki-template-name type for template names
Bug: T88900
Change-Id: Ia1c87072f453df4b756de6725c4b3ab1dda84497
2015-09-17 12:28:11 -07:00
Ed Sanders 9f96761044 Dialog: Use a 'done' button on edit param page instead of 'back'
'Back' suggests that changes in the form won't be saved.

Change-Id: I0df0887caa6317393a3a891dd292aa4dc54cc32b
2015-09-14 12:25:22 +01:00
Ed Sanders fffb070355 Use ActionFieldLayout for 'Add parameter'
Change-Id: I0d69b689cabfa9bd3a503b39a08ec98028a7eca8
2015-09-13 19:50:58 +01:00
Ed Sanders 49165cc00a Fix language widget
Change-Id: I2fc6984d20863cbe54153fbd83530cbaca585cca
2015-09-13 19:50:57 +01:00
Ed Sanders 10775df785 Remove $ = this.$ from OOJSUI code
This feature was removed a while ago.

Change-Id: I2ae0147f9e605e0f86ea4d26e8c1eaba43db29e2
2015-09-13 16:51:19 +01:00
Ltrlg fdd0514024 Go back to using a configurable link for documentation
The message allows per-wiki configuration. The default target is better
for normal users of TemplateData than the previous hard-coded one and
has already been translated in some languages from when it was used
previously.

This also moves the messages dependencies from `ext.templateData` to
`ext.templateDataGenerator.ui`, which is the only module that uses
them: the correct strings were displayed only by inheritance.

Bug: T112011
Change-Id: I81ab684bb0ed9b0767df75635284c51129ac7000
2015-09-10 21:56:05 +00:00
James D. Forrester ac2c2f268e build: Switch from grunt-jscs-checker to grunt-jscs
Use the 'wikimedia' preset, and make pass.

Change-Id: I1923b391bf79cc0992eb02ebe64c969e08354b6f
2015-06-05 18:21:18 -07:00
Moriel Schottlender ec0467c65a Add an example property to parameters
The example is optional and can be translated.

Bug: T53049
Change-Id: I9e2d66a805e25409532a742521886233ce3de569
2015-04-09 19:23:42 +01:00
Moriel Schottlender ff77f32e38 [BREAKING CHANGE] Change "default" property to InterfaceText
Default should be InterfaceText and support languages.

Bug: T54966
Change-Id: I7be3a8be72df3e5d80300bd72fcd7197e43155aa
2015-04-02 08:53:51 +01:00
Purodha 4c8673bbdb TemplateData: add PLURAL to message Templatedata-modal-notice-import-numparams
See
https://translatewiki.net/wiki/Thread:Support/About_MediaWiki:Templatedata-modal-errormsg-import-paramsalreadyexist/en

Change-Id: Ife5e9d0afd9320271c8921162487f8c0338f24cd
2015-03-26 21:39:29 +00:00
Moriel Schottlender 3820295f23 Reorganize api calls and add sourceHandler and error message
Add a sourceHandler that deals with all source-related actions
like fetching template source and validating the existing
TemplateData string.

Also add a MessageDialog warning the user in case the TemplateData
is invalid. In this case, the user will be given the option either
to correct the JSON by hand or to start the editor to replace the
existing TemplateData with a new one.

Bug: T91730
Bug: T91325
Change-Id: I4e6d04f02565a02d8dcf5c70a575ab6433caa27f
2015-03-18 18:21:02 +00:00
Moriel Schottlender 4141bed38b Prevent a dependent property from updating on infinite loops
A dependent and dependee properties should only update one another
once in the model, and the UI should be responsible for resetting
the input when it is toggled.

Bug: T92558
Change-Id: I944aaf9c44d0f305a34458f0b8009a98c9570661
2015-03-12 14:01:38 -07:00
Moriel Schottlender ffbc8e1520 TDG: Support optional text of 'deprecated' property
The deprecated property allows for either a boolean or text, so we
should allow the user to insert guidance text in case that property
is true. To achieve that, the model also defines 'textValue' for
boolean properties with text representation so an internal property can
be set to hold that value and inputs can be automatically built from the
property structure.

Bug: T90734
Change-Id: Iadc6abdcc0cf2721a311cf43847b306cb269b5e8
2015-03-11 17:08:26 +00:00
Bartosz Dziewoński a3ddde4a8f Don't flicker "Manage TemplateData" button's disabledness state
The code would call .setDisabled( true ), fire off an API request, and
then always call .setDisabled( false ) when the request finished,
regardless of the response.

Bug: T91324
Change-Id: Iee440a1fca966e0c66669ee5e78b6f5ab8f7f8d6
2015-03-07 20:20:32 +01:00
Timo Tijhof 3ecbaefef1 Document code with JSDuck
Change-Id: Ieb812a2fb85135f6db18a9a02c94efd83695a19e
2015-03-06 17:56:30 -08:00
Moriel Schottlender 3cc6afaa75 Use wikitext instead of page prop when checking for existing TemplateData
On the edit page, we show the user a message if a related page
(parent of /doc page, or vice versa) already has templatedata.

This check was wrongly detecting that the parent page has templatedata
when editing '/doc'. The check shouldn't use the 'templatedata' API
since that also includes transcluded templatedata.

Look in the wikitext content instead.

Change-Id: I9788e2beb0809ac3e676a90cd0dfe519c005afc9
2015-03-02 22:52:48 +00:00
Moriel Schottlender 9b3cf2b971 Delete boolean values if they are false
For values like 'deprecated', 'suggested' and 'required' make sure
that if they are marked as 'false' they are deleted from the result
string. If the original TemplateData already had either one of
those parameters marked as false don't delete so to avoid dirty
diffs.

Bug: T90283
Change-Id: I34c81d45e3967ce5398691d97d1a15908b8a2e57
2015-02-25 16:26:32 -08:00
Timo Tijhof 796e7b1a76 Correct jsduck documentation tags casing
Change-Id: Ic438492ea4e7060c3c5626ae9b5493f70cfb578e
2015-02-21 17:05:40 +00:00
jenkins-bot ca94adc3a9 Merge "Allow adding a new parameter again" 2015-02-19 02:10:11 +00:00
Moriel Schottlender c525aef5b0 Allow adding a new parameter again
Due to a bug, new parameters could not be added unless they were
previously deleted. This commit fixes that bug.

Change-Id: I3784d1b3d650893f26abb63994d13c08b148075b
2015-02-19 02:02:15 +00:00
Moriel Schottlender d59d517339 Warn if a TemplateData block already exists in related page
Check if there already is a TemplateData block in a related
page and warn the user if that is the case. Related pages are
either the /doc page or, if we are already in a /doc page, its
immediate parent.

Bug: T74062
Change-Id: I83212f14ecd2dcc18970d21ad0d833b461405390
2015-02-18 17:56:13 -08:00
Moriel Schottlender e6e728b58e Change global class variables to mw.TemplateData
Nest all classes for the templatedata dialog in mw.TemplateData
namespace.

Change-Id: Ib514378c9fbc0fb993b3cbc2fa48ced920167226
2015-02-18 17:47:08 -08:00
jenkins-bot 39da09b516 Merge "Use ActionFieldLayout for language and auto-choose new lang on add" 2015-02-03 00:54:15 +00:00
jenkins-bot 492f933bb8 Merge "Reset paramOrder widget on dialog setup" 2015-01-30 17:50:17 +00:00
Moriel Schottlender 3ad7e0b1e3 Reset paramOrder widget on dialog setup
Make sure that every time the dialog is open, the paramOrder
widget is emptied so it can be refilled fresh from the model.

Bug: T88126
Change-Id: I628c66710cb1f2f77385b16c627585350f357c45
2015-01-30 17:41:41 +00:00
Moriel Schottlender d141e924f6 Use ActionFieldLayout for language and auto-choose new lang on add
Change the current hacky layout to the proper ActionFieldLayout,
and also make sure that when the user adds a language, the new
language is selected.

Change-Id: I737a1dcfc08bd47829661daf3c08e2e480670842
2015-01-29 11:58:56 -08:00
Moriel Schottlender b3877b327d Allow adding a deleted parameter in the templatedata dialog
If a user adds a parameter that was previously deleted, the
parameter properties will be completely emptied, and the parameter
will be added as if it is new.

Bug: T86916
Change-Id: Ib739ee09229750f94314636d4290dbe6662b4c0f
2015-01-28 18:50:43 -08:00
Moriel Schottlender d212901649 Add param order drag/drop widget to TemplateData dialog
Make sure the parameter order is editable with the drag/drop widget.

Change-Id: I35079907b2ed9f5ecdcd438dd69ed9892ce3e428
2015-01-23 19:02:56 +00:00
Moriel Schottlender edf70972e1 Adapt the type input to work with the new ooui getMenu()
The type in the templatedata editor didn't update because the events
were attached to the previous ooui SelectWidget, and should be
adjusted to use the new methods.

Bug: T86922
Change-Id: I619d1cc69f672d2d03d7dafa97ba3d950de9d89d
2015-01-20 17:19:40 +00:00
Moriel Schottlender ee56d518fb Add deprecated switch to the editor
The 'deprecated' boolean property was missing from the templatedata
edit dialog.

Change-Id: Ib05e832d8fc91896816b3f8b22f7678dacb245cd
2015-01-16 11:00:27 -08:00
Moriel Schottlender 16cca5b1a2 Trim aliases on save
Make sure that aliases get trimmed and are not getting extra spaces
when saving a parameter.
NOTE: To prevent dirty diffs, only parameters that are 'touched'
(viewed or edited directly in the editor) will be trimmed. The editor
will keep all other "wrong" values that have trailing or preceding
whitespaces as-is.

Bug: T85330
Change-Id: I64ecb88a7d736fa36b5e6debf2e94b0d37152020
2015-01-12 15:29:38 -08:00
Moriel Schottlender df59f0179a Eventify TemplateDataGenerator and use oojs-ui
Change the ui/data behavior to work with oojs and event emitters,
and replace the gui from jquery ui to oojs-ui.

Changes made:
* Recreate the templatedata editor with oojs and ooui.
* Create a standalone templatedata model with internal validation.
* Allow the user to insert language-specific strings:
  * Allow adding arbitrary languages and values
  * Normalize output between language object and 'simple' string
  * Add new language code by searching for its name or code
* Import parameters from template code
  * If the template is in subpage and there is no code in the
    current page, the code will request the contents of the parent
    page.

Change-Id: I985ea03dfee58984ec22ec9a157a00968bfca878
2014-12-22 12:58:37 -05:00
Moriel Schottlender 4c236dc961 Correct placement of <noinclude> tags
The noinclude tags should appear only if the page is not a subpage
and only around the <templatedata> tags.

Change-Id: I492bb35c8f2c70235f3ceefdddcc4df6548d7469
2014-11-25 17:02:48 +00:00
jenkins-bot 8210018147 Merge "Let help link target be locally over-ridden; default to the MW help page" 2014-10-21 17:53:50 +00:00
Moriel Schottlender 5de265eab4 Add <noinclude> tags to new <templatedata> strings
If the template is not in a subpage, all new <templatedata> strings
will be wrapped with <noinclude>.

This will not happen to existing <templatedata> strings, since there
is no way of knowing if existing strings are already inside a
<noinclude> chunk - especially if those tags also include a bit of
other text. This will be applied for all new templatedata tags that
are inserted in the main template page.

Bug: 69149
Change-Id: I083a76858513760910973cd788687822fda0e879
2014-10-09 18:15:55 -04:00
James D. Forrester f7706868f3 Let help link target be locally over-ridden; default to the MW help page
Bug: 67621
Change-Id: Ic205a8bd51516d3fa580955b310014e4fe30ec6d
2014-09-25 11:05:39 -07:00
Moriel Schottlender 4f3e647758 Implement new 'autovalue' parameter property
Add an 'autovalue' parameter property to the TemplateData spec. And
implement it in the validation for the API and in the editor.

Also added tests to make sure all parameter attributes preserve
their values before and after parsing, including the 'autovalue'
parameter.

Bug: 51428
Change-Id: Iffb376a804d39388d2b5b6ea3583ef2a292eea41
2014-09-19 16:36:29 -07:00
Moriel Schottlender b313bbe485 Refactor TemplateData Editor
Refactor and rewrite the templatedata editor to make it more flexible and
adaptable to new types. Separating the model from the gui, and adding new and
improved unit tests.

Also added features:
* Map depracated param types into current types.
* Retrieve template code from top template page if we are in a subpage.
* Mark parameters that do not appear in the template code.
* Add parameter types and a more flexible way to add and adjust the types.
* Add a link to TemplateData documentation from the main edit page.
* Add support for paramOrder; order the parameters according to the given array.
* Make the template parameter table sortable so users can change the paraOrder.

Bug: 59745
Bug: 65951
Bug: 66920
Bug: 67310
Bug: 67621
Change-Id: I65a76c2b772ef76c5dbbe71dd433c881c097b202
2014-08-30 15:18:05 -07:00
Moriel Schottlender 9a7f8de499 Block object descriptions from edit
Some descriptions allow for language objects. For the moment, these
should be blocked for editing so the original JSON string won't be
corrupted. The current fix blocks any input that is not a string
or an expected array in aliases as uneditable.

Bug: 60089
Change-Id: I9b13e2f3cfd805d382564e270484557567932a0f
2014-06-04 17:37:02 -07:00
James D. Forrester 64a39ae460 Add a grunt checker for jshint, jscs, csslint, and banana and pass them
There was a pre-existing jshint config (.jshintrc) file that this upgrades based
on the equivalent files for VisualEditor and OOjs UI.

Change-Id: I3ecb0e65cc7ff090b7457be895917fbd8b8afd18
2014-06-03 20:16:18 -07:00
James D. Forrester 3f05967d94 Add 'date' type support for ISO 8601 date-times
Change-Id: Ida5b09fb763bef12f92cf687b5170b5f5b5840a2
2014-05-23 18:50:00 -07:00
James D. Forrester b50d5d1a6b Fix name of file GUI message (…-modal-… not …-model-…)
Bug: 65545
Change-Id: I7084b1738ff5e880c104aace3425114258e87bca
2014-05-20 12:51:56 -07:00
James D. Forrester fb34a07c02 Add a wiki-file-name type for file names
Bug: 52652
Change-Id: Ibe8d143abbb607eb71549536aaac6555528813cc
2014-04-28 13:21:53 -07:00
Ltrlg 6a014700da Do not add 'required' if not set and false wanted
The 'required' property of a 'Param' is optional and defaults to false.
Thus there is no reason for adding it when it was not set and the user wants it to be false.

Bug: 61761
Change-Id: I2b2fae5d2d8b1dac2ad2e1a965d9ba5bd7372eef
2014-03-07 23:19:52 +00:00
Moriel Schottlender b22c73fc2d Prevent the dialog from applying changes on bad input
Make sure the dialog does not change the json string if the
editor form contains any errors.

Change-Id: Ib4d36f70e1f9d5b34605b4e54fd12b6e2405c37a
2014-01-20 06:22:42 -05:00
Moriel Schottlender f9bc87e2b8 Adjusting error message for invalid inputs
The invalid characters ('|', '=', and '}}') will be displayed through
individual parameters, for consistency, and to avoid parsing problems
in translatewiki.

Change-Id: Ic87541419aab5664f3530209e1ad8689deec33a5
2014-01-18 12:57:35 -05:00
Moriel Schottlender 3dfa316fad Make {{ a parameter in the error message in the editor dialog
Translatewiki warns of an unbalanced parenthesis problem in the
translation string. Turning the {{ into a parameter solves this issue.

Change-Id: I2fd69b3e901175dad22d285aa2373916acd4f208
2014-01-18 00:09:29 -05:00
Moriel Schottlender 8c27921232 Implement edit interface for TemplateData documentation
This adds a TemplateData manager to the edit page in the Template
namespace.

If a <templatedata> tag already exists, the tool will parse it and
display it in a visual interface that the user can then manipulate in
their own language. If there is no <templatedata> tag, the dialog will
appear empty and allow users to add and tweak their desired template
parameter data.

The tool also allows rudimentary parameter import, which picks up the
parameters from a current template into the GUI to make the user's life
easier when producing TemplateData.

The template documentation editor feature is off by default. To enable it
use $wgTemplateDataUseGUI = true in LocalSettings.

Bug: 50436
Change-Id: I863a8199c0b08cc52b320ed00dcba912dd2aeefc
2014-01-14 18:39:20 -08:00