r88718 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r88717‎ | r88718 | r88719 >
Date:13:55, 24 May 2011
Author:yaron
Status:deferred
Tags:
Comment:
Added toggling of "Allowed values" field, so only certain property types would display that field
Modified paths:
  • /trunk/extensions/SemanticForms/specials/SF_CreateProperty.php (modified) (history)

Diff [purge]

Index: trunk/extensions/SemanticForms/specials/SF_CreateProperty.php
@@ -106,6 +106,20 @@
107107 }
108108 }
109109
 110+function toggleAllowedValues(property_type) {
 111+ var allowed_values_div = document.getElementById("allowed_values");
 112+ // Page, String, Number, Email - is that a reasonable set of types
 113+ // for which enumerations should be allowed?
 114+ if (property_type == '{$datatype_labels['_wpg']}' ||
 115+ property_type == '{$datatype_labels['_str']}' ||
 116+ property_type == '{$datatype_labels['_num']}' ||
 117+ property_type == '{$datatype_labels['_ema']}') {
 118+ allowed_values_div.style.display = "";
 119+ } else {
 120+ allowed_values_div.style.display = "none";
 121+ }
 122+}
 123+
110124 END;
111125
112126 // set 'title' as hidden field, in case there's no URL niceness
@@ -125,7 +139,7 @@
126140 foreach ( $datatype_labels as $label ) {
127141 $select_body .= " " . Xml::element( 'option', null, $label ) . "\n";
128142 }
129 - $text .= Xml::tags( 'select', array( 'id' => 'property_dropdown', 'name' => 'property_type', 'onChange' => 'toggleDefaultForm(this.value);' ), $select_body ) . "\n";
 143+ $text .= Xml::tags( 'select', array( 'id' => 'property_dropdown', 'name' => 'property_type', 'onChange' => 'toggleDefaultForm(this.value); toggleAllowedValues(this.value);' ), $select_body ) . "\n";
130144
131145 $default_form_input = wfMsg( 'sf_createproperty_linktoform' );
132146 $values_input = wfMsg( 'sf_createproperty_allowedvalsinput' );