Skip to content
Snippets Groups Projects
Commit d7a9e2ad authored by Peter Rotich's avatar Peter Rotich
Browse files

Merge pull request #547 from greezybacon/issue/search-no-priority


forms: Allow searching any priority

Reviewed-By: default avatarPeter Rotich <peter@osticket.com>
parents 87f46df2 27921f29
No related branches found
No related tags found
No related merge requests found
...@@ -926,7 +926,13 @@ class SelectionField extends FormField { ...@@ -926,7 +926,13 @@ class SelectionField extends FormField {
'id'=>1, 'label'=>'Widget', 'required'=>false, 'id'=>1, 'label'=>'Widget', 'required'=>false,
'default'=>false, 'default'=>false,
'choices'=>array(false=>'Drop Down', true=>'Typeahead'), 'choices'=>array(false=>'Drop Down', true=>'Typeahead'),
'hint'=>'Typeahead will work better for large lists')), 'hint'=>'Typeahead will work better for large lists'
)),
'prompt' => new TextboxField(array(
'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'',
'hint'=>'Leading text shown before a value is selected',
'configuration'=>array('size'=>40, 'length'=>40),
)),
); );
} }
...@@ -941,7 +947,7 @@ class SelectionField extends FormField { ...@@ -941,7 +947,7 @@ class SelectionField extends FormField {
} }
class SelectionWidget extends ChoicesWidget { class SelectionWidget extends ChoicesWidget {
function render() { function render($mode=false) {
$config = $this->field->getConfiguration(); $config = $this->field->getConfiguration();
$value = false; $value = false;
if ($this->value instanceof DynamicListItem) { if ($this->value instanceof DynamicListItem) {
...@@ -953,9 +959,9 @@ class SelectionWidget extends ChoicesWidget { ...@@ -953,9 +959,9 @@ class SelectionWidget extends ChoicesWidget {
$value = $this->value; $value = $this->value;
$name = $this->getEnteredValue(); $name = $this->getEnteredValue();
} }
if (!$config['typeahead']) { if (!$config['typeahead'] || $mode=='search') {
$this->value = $value; $this->value = $value;
return parent::render(); return parent::render($mode);
} }
$source = array(); $source = array();
...@@ -968,7 +974,8 @@ class SelectionWidget extends ChoicesWidget { ...@@ -968,7 +974,8 @@ class SelectionWidget extends ChoicesWidget {
<span style="display:inline-block"> <span style="display:inline-block">
<input type="text" size="30" name="<?php echo $this->name; ?>" <input type="text" size="30" name="<?php echo $this->name; ?>"
id="<?php echo $this->name; ?>" value="<?php echo $name; ?>" id="<?php echo $this->name; ?>" value="<?php echo $name; ?>"
autocomplete="off" /> placeholder="<?php echo $config['prompt'];
?>" autocomplete="off" />
<input type="hidden" name="<?php echo $this->name; <input type="hidden" name="<?php echo $this->name;
?>_id" id="<?php echo $this->name; ?>_id" value="<?php echo $value; ?>"/> ?>_id" id="<?php echo $this->name; ?>_id" value="<?php echo $value; ?>"/>
<script type="text/javascript"> <script type="text/javascript">
......
...@@ -493,6 +493,11 @@ class TextboxField extends FormField { ...@@ -493,6 +493,11 @@ class TextboxField extends FormField {
'id'=>4, 'label'=>'Validation Error', 'default'=>'', 'id'=>4, 'label'=>'Validation Error', 'default'=>'',
'configuration'=>array('size'=>40, 'length'=>60), 'configuration'=>array('size'=>40, 'length'=>60),
'hint'=>'Message shown to user if the input does not match the validator')), 'hint'=>'Message shown to user if the input does not match the validator')),
'placeholder' => new TextboxField(array(
'id'=>5, 'label'=>'Placeholder', 'required'=>false, 'default'=>'',
'hint'=>'Text shown in before any input from the user',
'configuration'=>array('size'=>40, 'length'=>40),
)),
); );
} }
...@@ -540,6 +545,11 @@ class TextareaField extends FormField { ...@@ -540,6 +545,11 @@ class TextareaField extends FormField {
'html' => new BooleanField(array( 'html' => new BooleanField(array(
'id'=>4, 'label'=>'HTML', 'required'=>false, 'default'=>true, 'id'=>4, 'label'=>'HTML', 'required'=>false, 'default'=>true,
'configuration'=>array('desc'=>'Allow HTML input in this box'))), 'configuration'=>array('desc'=>'Allow HTML input in this box'))),
'placeholder' => new TextboxField(array(
'id'=>5, 'label'=>'Placeholder', 'required'=>false, 'default'=>'',
'hint'=>'Text shown in before any input from the user',
'configuration'=>array('size'=>40, 'length'=>40),
)),
); );
} }
...@@ -660,7 +670,7 @@ class ChoiceField extends FormField { ...@@ -660,7 +670,7 @@ class ChoiceField extends FormField {
)), )),
'prompt' => new TextboxField(array( 'prompt' => new TextboxField(array(
'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'', 'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'',
'hint'=>'Text shown in the drop-down select before a value is selected', 'hint'=>'Leading text shown before a value is selected',
'configuration'=>array('size'=>40, 'length'=>40), 'configuration'=>array('size'=>40, 'length'=>40),
)), )),
); );
...@@ -858,7 +868,13 @@ class PriorityField extends ChoiceField { ...@@ -858,7 +868,13 @@ class PriorityField extends ChoiceField {
} }
function getConfigurationOptions() { function getConfigurationOptions() {
return array(); return array(
'prompt' => new TextboxField(array(
'id'=>2, 'label'=>'Prompt', 'required'=>false, 'default'=>'',
'hint'=>'Leading text shown before a value is selected',
'configuration'=>array('size'=>40, 'length'=>40),
)),
);
} }
} }
FormField::addFieldTypes('Built-in Lists', function() { FormField::addFieldTypes('Built-in Lists', function() {
...@@ -907,8 +923,9 @@ class TextboxWidget extends Widget { ...@@ -907,8 +923,9 @@ class TextboxWidget extends Widget {
?> ?>
<span style="display:inline-block"> <span style="display:inline-block">
<input type="text" id="<?php echo $this->name; ?>" <input type="text" id="<?php echo $this->name; ?>"
<?php echo $size . " " . $maxlength; ?> <?php echo $size . " " . $maxlength
<?php echo $classes.' '.$autocomplete; ?> .' '.$classes.' '.$autocomplete
.' placeholder="'.$config['placeholder'].'"'; ?>
name="<?php echo $this->name; ?>" name="<?php echo $this->name; ?>"
value="<?php echo Format::htmlchars($this->value); ?>"/> value="<?php echo Format::htmlchars($this->value); ?>"/>
</span> </span>
...@@ -930,7 +947,8 @@ class TextareaWidget extends Widget { ...@@ -930,7 +947,8 @@ class TextareaWidget extends Widget {
$class = 'class="richtext no-bar small"'; $class = 'class="richtext no-bar small"';
?> ?>
<span style="display:inline-block;width:100%"> <span style="display:inline-block;width:100%">
<textarea <?php echo $rows." ".$cols." ".$maxlength." ".$class; ?> <textarea <?php echo $rows." ".$cols." ".$maxlength." ".$class
.' placeholder="'.$config['placeholder'].'"'; ?>
name="<?php echo $this->name; ?>"><?php name="<?php echo $this->name; ?>"><?php
echo Format::htmlchars($this->value); echo Format::htmlchars($this->value);
?></textarea> ?></textarea>
...@@ -967,20 +985,27 @@ class PhoneNumberWidget extends Widget { ...@@ -967,20 +985,27 @@ class PhoneNumberWidget extends Widget {
} }
class ChoicesWidget extends Widget { class ChoicesWidget extends Widget {
function render() { function render($mode=false) {
$config = $this->field->getConfiguration(); $config = $this->field->getConfiguration();
// Determine the value for the default (the one listed if nothing is // Determine the value for the default (the one listed if nothing is
// selected) // selected)
$choices = $this->field->getChoices(); $choices = $this->field->getChoices();
$def_key = $this->field->get('default'); // We don't consider the 'default' when rendering in 'search' mode
if (!$def_key && $config['default']) $have_def = false;
$def_key = $config['default']; if ($mode != 'search') {
$have_def = isset($choices[$def_key]); $def_key = $this->field->get('default');
if (!$have_def) if (!$def_key && $config['default'])
$def_key = $config['default'];
$have_def = isset($choices[$def_key]);
if (!$have_def)
$def_val = ($config['prompt'])
? $config['prompt'] : 'Select';
else
$def_val = $choices[$def_key];
} else {
$def_val = ($config['prompt']) $def_val = ($config['prompt'])
? $config['prompt'] : 'Select'; ? $config['prompt'] : 'Select';
else }
$def_val = $choices[$def_key];
$value = $this->value; $value = $this->value;
if ($value === null && $have_def) if ($value === null && $have_def)
$value = $def_key; $value = $def_key;
......
...@@ -617,7 +617,8 @@ if ($results) { ...@@ -617,7 +617,8 @@ if ($results) {
elseif (!$f->hasData()) elseif (!$f->hasData())
continue; continue;
?><label><?php echo $f->getLabel(); ?>:</label> ?><label><?php echo $f->getLabel(); ?>:</label>
<div style="display:inline-block;width: 12.5em;"><?php $f->render(); ?></div> <div style="display:inline-block;width: 12.5em;"><?php
$f->render('search'); ?></div>
<?php } ?> <?php } ?>
</fieldset> </fieldset>
<p> <p>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment