Diferencia entre revisiones de «Widget:AddToTable»
De WikiEducator
(added options for radio buttons, select fields, country, and flag columns) |
m (1 revisión: import from en.WE after update to MW 1.23+) |
||
(2 revisiones intermedias por el mismo usuario no mostrado) | |||
Línea 1: | Línea 1: | ||
<includeonly><div id="b<!--{$tableid|escape:'quotes'}-->" style="height:2em"></div><script type="text/javascript">/* <![CDATA[ */ | <includeonly><div id="b<!--{$tableid|escape:'quotes'}-->" style="height:2em"></div><script type="text/javascript">/* <![CDATA[ */ | ||
$(function() { | $(function() { | ||
− | $.getScript("/ | + | $.getScript("/extensions/WE/widgets/addToTable.js", function() { |
window.weAddToTable('<!--{$tableid|escape:'quotes'}-->', {login: '<!--{$login|escape:'quotes'}-->', button: '<!--{$button|escape:'quotes'}-->', formtitle: '<!--{$formtitle|escape:'quotes'}-->', columns: '<!--{$columns|escape:'quotes'}-->', auto: '<!--{$auto|escape:'quotes'}-->', bottom: '<!--{$bottom|escape:'quotes'}-->'}); | window.weAddToTable('<!--{$tableid|escape:'quotes'}-->', {login: '<!--{$login|escape:'quotes'}-->', button: '<!--{$button|escape:'quotes'}-->', formtitle: '<!--{$formtitle|escape:'quotes'}-->', columns: '<!--{$columns|escape:'quotes'}-->', auto: '<!--{$auto|escape:'quotes'}-->', bottom: '<!--{$bottom|escape:'quotes'}-->'}); | ||
}); | }); | ||
Línea 13: | Línea 13: | ||
;formtitle:title of the popup form dialog | ;formtitle:title of the popup form dialog | ||
;columns:a semicolon separated list of descriptions for each column; each description contains an ampersand separated list of '''opt'''='''arg'''; items not specified fallback to the the older ''auto'' functionality, form labels are column headings and the presence of an '''*''' signals a textarea | ;columns:a semicolon separated list of descriptions for each column; each description contains an ampersand separated list of '''opt'''='''arg'''; items not specified fallback to the the older ''auto'' functionality, form labels are column headings and the presence of an '''*''' signals a textarea | ||
− | :;label:label in the form | + | :;label:label in the form (default: ''column heading'') |
:;type:type of field | :;type:type of field | ||
− | ::;text:one line text field | + | ::;text:one line text field (''default'') |
::;textarea:multiline text area | ::;textarea:multiline text area | ||
::;select:select from multiple options | ::;select:select from multiple options | ||
::;country:country selection dropdown | ::;country:country selection dropdown | ||
− | ::;flagc:country selection dropdown which inserts flag and country name | + | ::;flagc:country selection dropdown which inserts flag and country name (see [[:Template:FlagC]]) |
− | ::;flagcl:country selection dropdown which inserts flag and country name (which links to country page) | + | ::;flagcl:country selection dropdown which inserts flag and country name (which links to country page) (see [[:Template:FlagCL]]) |
::;radio:radio buttons for selecting limited option set | ::;radio:radio buttons for selecting limited option set | ||
+ | ::;user:current WikiEducator user name | ||
+ | ::;name:real name of current user | ||
+ | ::;userpage:real name of current user with link to userpage | ||
+ | ::;date:UTC date in ISO-8601 format | ||
+ | ::;timestamp:UTC date and time (hours:minutes) | ||
:;options:specify exclamation point separated options for a '''select''' field | :;options:specify exclamation point separated options for a '''select''' field | ||
:;note:short explanatory text for form element (displayed in small font) | :;note:short explanatory text for form element (displayed in small font) | ||
Línea 28: | Línea 33: | ||
;bottom:add to bottom of table (default: ''false'') | ;bottom:add to bottom of table (default: ''false'') | ||
==Example== | ==Example== | ||
− | <nowiki> | + | <nowiki>{{#widget:AddToTable|tableid=OERu14-11|login=Login to add|button=Register| |
− | </nowiki> | + | formtitle=Online registration for 3rd OERu Partners Meeting| |
− | + | columns=type=name&summary=true;;;type=flagcl;type=radio&options=Yes!Maybe!No|bottom=true}}</nowiki> | |
− | + | ||
− | + | Would add a button labeled '''Register''' to a table with 5 columns: | |
− | + | #Name (form element pre-populated with wiki realname, used in the edit summary message) | |
− | + | #Position (plain text field) | |
− | + | #Organisation (plain text field) | |
+ | #Country (a '''select''' element with country names, row data is in [[:Template:FlagCL]] format with flag and country name linking to WikiEducator country page) | ||
+ | #Attend (a radio button selection of '''Yes Maybe No''' options, with that text inserted in data cell) | ||
+ | New data rows are added at the '''bottom''' of the existing table that has the DOM id='''OERu14-11''' | ||
</noinclude> | </noinclude> |
Última revisión de 14:48 3 sep 2014
- If logged in, display a button that pops up a form to add a row to the table specified by the id.
- If not logged in, shows a link to the login page (which returns you to this page after login).
Parameters
- tableid
- HTML id of the table
- login
- text for the login link displayed if user is not logged in
- button
- legend for the button that pops up the form
- formtitle
- title of the popup form dialog
- columns
- a semicolon separated list of descriptions for each column; each description contains an ampersand separated list of opt=arg; items not specified fallback to the the older auto functionality, form labels are column headings and the presence of an * signals a textarea
- label
- label in the form (default: column heading)
- type
- type of field
- text
- one line text field (default)
- textarea
- multiline text area
- select
- select from multiple options
- country
- country selection dropdown
- flagc
- country selection dropdown which inserts flag and country name (see Template:FlagC)
- flagcl
- country selection dropdown which inserts flag and country name (which links to country page) (see Template:FlagCL)
- radio
- radio buttons for selecting limited option set
- user
- current WikiEducator user name
- name
- real name of current user
- userpage
- real name of current user with link to userpage
- date
- UTC date in ISO-8601 format
- timestamp
- UTC date and time (hours:minutes)
- options
- specify exclamation point separated options for a select field
- note
- short explanatory text for form element (displayed in small font)
- summary=true
- use the value of this column in the edit summary
- auto
- get legends and form types from headings (default: false) if the heading contains a * the field is a textarea, otherwise it is a text input
- bottom
- add to bottom of table (default: false)
Example
{{#widget:AddToTable|tableid=OERu14-11|login=Login to add|button=Register| formtitle=Online registration for 3rd OERu Partners Meeting| columns=type=name&summary=true;;;type=flagcl;type=radio&options=Yes!Maybe!No|bottom=true}}
Would add a button labeled Register to a table with 5 columns:
- Name (form element pre-populated with wiki realname, used in the edit summary message)
- Position (plain text field)
- Organisation (plain text field)
- Country (a select element with country names, row data is in Template:FlagCL format with flag and country name linking to WikiEducator country page)
- Attend (a radio button selection of Yes Maybe No options, with that text inserted in data cell)
New data rows are added at the bottom of the existing table that has the DOM id=OERu14-11