Skip to content
Snippets Groups Projects
Commit 13db47f6 authored by Jared Hancock's avatar Jared Hancock Committed by Peter Rotich
Browse files

queue: Fix addition of properties to conditions

parent 13eb6dc6
Branches
Tags
No related merge requests found
...@@ -450,6 +450,8 @@ class QueueColumnCondition { ...@@ -450,6 +450,8 @@ class QueueColumnCondition {
var $queue; var $queue;
var $properties = array(); var $properties = array();
static $uid = 1;
function __construct($config, $queue=null) { function __construct($config, $queue=null) {
$this->config = $config; $this->config = $config;
$this->queue = $queue; $this->queue = $queue;
...@@ -482,8 +484,7 @@ class QueueColumnCondition { ...@@ -482,8 +484,7 @@ class QueueColumnCondition {
// Lookup the field to search this condition // Lookup the field to search this condition
if (isset($searchable[$name])) { if (isset($searchable[$name])) {
list(,$field) = $searchable[$name]; return $searchable[$name];
return $field;
} }
} }
...@@ -512,7 +513,7 @@ class QueueColumnCondition { ...@@ -512,7 +513,7 @@ class QueueColumnCondition {
} }
// Fetch a criteria Q for the query // Fetch a criteria Q for the query
if ($field = $this->getField($name)) if (list(,$field) = $this->getField($name))
return $field->getSearchQ($method, $value, $name2 ?: $name); return $field->getSearchQ($method, $value, $name2 ?: $name);
} }
...@@ -583,7 +584,11 @@ class QueueColumnCondition { ...@@ -583,7 +584,11 @@ class QueueColumnCondition {
} }
function getShortHash() { function getShortHash() {
return substr($this->getHash(), -10); return substr(base64_encode($this->getHash(true)), -10);
}
static function getUid() {
return static::$uid++;
} }
static function fromJson($config, $queue=null) { static function fromJson($config, $queue=null) {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
<input name="condition_field[]" value="<?php echo $field_name; ?>" type="hidden" /> <input name="condition_field[]" value="<?php echo $field_name; ?>" type="hidden" />
<div class="pull-right"> <div class="pull-right">
<a href="#" onclick="javascript: $(this).closest('.condition').remove(); <a href="#" onclick="javascript: $(this).closest('.condition').remove();
return false;
"><i class="icon-trash"></i></a> "><i class="icon-trash"></i></a>
</div> </div>
<?php echo $label ?: $field->getLabel(); ?> <?php echo $label ?: $field->getLabel(); ?>
...@@ -67,7 +68,7 @@ foreach ($condition->getProperties() as $prop=>$v) { ...@@ -67,7 +68,7 @@ foreach ($condition->getProperties() as $prop=>$v) {
<select onchange="javascript: <select onchange="javascript:
var $this = $(this), var $this = $(this),
selected = $this.find(':selected'), selected = $this.find(':selected'),
container = $this.closest('.properties'); container = $this.closest('div');
$.ajax({ $.ajax({
url: 'ajax.php/queue/condition/addProperty', url: 'ajax.php/queue/condition/addProperty',
data: { prop: selected.val(), condition: <?php echo $id; ?> }, data: { prop: selected.val(), condition: <?php echo $id; ?> },
......
...@@ -118,8 +118,8 @@ $data_form = $column->getDataConfigForm($_POST); ...@@ -118,8 +118,8 @@ $data_form = $column->getDataConfigForm($_POST);
if ($column->getConditions()) { if ($column->getConditions()) {
$fields = SavedSearch::getSearchableFields($column->getQueue()->getRoot()); $fields = SavedSearch::getSearchableFields($column->getQueue()->getRoot());
foreach ($column->getConditions() as $i=>$condition) { foreach ($column->getConditions() as $i=>$condition) {
$id = $column->getId() * 40 + $i; $id = QueueColumnCondition::getUid();
$field = $condition->getField(); list($label, $field) = $condition->getField();
$field_name = $condition->getFieldName(); $field_name = $condition->getFieldName();
include STAFFINC_DIR . 'templates/queue-column-condition.tmpl.php'; include STAFFINC_DIR . 'templates/queue-column-condition.tmpl.php';
} }
...@@ -137,8 +137,8 @@ if ($column->getConditions()) { ...@@ -137,8 +137,8 @@ if ($column->getConditions()) {
</select> </select>
<script> <script>
$(function() { $(function() {
var colid = <?php echo $colid ?: 0 ?>, var colid = <?php echo $colid ?: 0; ?>,
nextid = colid * 40; nextid = <?php echo QueueColumnCondition::getUid(); ?>;
$('#' + colid + '-conditions select.add-condition').change(function() { $('#' + colid + '-conditions select.add-condition').change(function() {
var $this = $(this), var $this = $(this),
container = $this.closest('div'), container = $this.closest('div'),
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment