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

Merge remote branch 'adriane/issues/misc-fixes' into develop-next

parents 5ccefb82 d4bd8654
No related branches found
No related tags found
No related merge requests found
...@@ -152,18 +152,8 @@ if ($_POST) ...@@ -152,18 +152,8 @@ if ($_POST)
<tr class="no_border" id="ccRow"> <tr class="no_border" id="ccRow">
<td width="160"><?php echo __('Cc'); ?>:</td> <td width="160"><?php echo __('Cc'); ?>:</td>
<td> <td>
<select name="ccs[]" id="cc_users_open" multiple="multiple" <select class="collabSelections" name="ccs[]" id="cc_users_open" multiple="multiple"
data-placeholder="<?php echo __('Select Contacts'); ?>"> data-placeholder="<?php echo __('Select Contacts'); ?>">
<option value=""></option>
<?php
$users = User::objects();
foreach ($users as $u) {
if($user && $u->id != $user->getId()) {
?>
<option value="<?php echo $u->id; ?>"
><?php echo $u->getName(); ?>
</option>
<?php } } ?>
</select> </select>
<br/><span class="error"><?php echo $errors['ccs']; ?></span> <br/><span class="error"><?php echo $errors['ccs']; ?></span>
</td> </td>
...@@ -171,18 +161,8 @@ if ($_POST) ...@@ -171,18 +161,8 @@ if ($_POST)
<tr class="no_border" id="bccRow"> <tr class="no_border" id="bccRow">
<td width="160"><?php echo __('Bcc'); ?>:</td> <td width="160"><?php echo __('Bcc'); ?>:</td>
<td> <td>
<select name="bccs[]" id="bcc_users_open" multiple="multiple" <select class="collabSelections" name="bccs[]" id="bcc_users_open" multiple="multiple"
data-placeholder="<?php echo __('Select Contacts'); ?>"> data-placeholder="<?php echo __('Select Contacts'); ?>">
<option value=""></option>
<?php
$users = User::objects();
foreach ($users as $u) {
if($user && $u->id != $user->getId()) {
?>
<option value="<?php echo $u->id; ?>"
><?php echo $u->getName(); ?>
</option>
<?php } } ?>
</select> </select>
<br/><span class="error"><?php echo $errors['ccs']; ?></span> <br/><span class="error"><?php echo $errors['ccs']; ?></span>
</td> </td>
...@@ -534,9 +514,33 @@ $(function() { ...@@ -534,9 +514,33 @@ $(function() {
$('div#org-profile').fadeIn(); $('div#org-profile').fadeIn();
return false; return false;
}); });
$("#cc_users_open").select2({width: '300px'});
$("#bcc_users_open").select2({width: '300px'}); $('.collabSelections').select2({
}); width: '350px',
minimumInputLength: 3,
ajax: {
url: "ajax.php/users/local",
dataType: 'json',
data: function (params) {
return {
q: params.term,
};
},
processResults: function (data) {
return {
results: $.map(data, function (item) {
return {
text: item.name,
slug: item.slug,
id: item.id
}
})
};
}
}
});
});
$(document).ready(function () { $(document).ready(function () {
$('#emailcollab').on('change', function(){ $('#emailcollab').on('change', function(){
......
...@@ -789,20 +789,18 @@ if ($errors['err'] && isset($_POST['a'])) { ...@@ -789,20 +789,18 @@ if ($errors['err'] && isset($_POST['a'])) {
<tr> <tr>
<td width="160"><b><?php echo __('Cc'); ?>:</b></td> <td width="160"><b><?php echo __('Cc'); ?>:</b></td>
<td> <td>
<select name="ccs[]" id="cc_users" multiple="multiple" <select class="collabSelections" name="ccs[]" id="cc_users" multiple="multiple"
data-placeholder="<?php echo __('Select Contacts'); ?>"> data-placeholder="<?php echo __('Select Contacts'); ?>">
<option value=""></option>
<option value="NEW">&mdash; <?php echo __('Add New');?> &mdash;</option>
<?php <?php
$users = User::objects(); foreach ($cc_cids as $u) {
foreach ($users as $u) { if($u != $ticket->user_id && !in_array($u, $bcc_cids)) {
if($u->id != $ticket->user_id && !in_array($u->getId(), $bcc_cids)) { ?>
<option value="<?php echo $u; ?>" <?php
if (in_array($u, $cc_cids))
echo 'selected="selected"'; ?>><?php echo User::lookup($u); ?>
</option>
<?php } } ?>
?> ?>
<option value="<?php echo $u->id; ?>" <?php
if (in_array($u->getId(), $cc_cids))
echo 'selected="selected"'; ?>><?php echo $u->getName(); ?>
</option>
<?php } } ?>
</select> </select>
<br/><span class="error"><?php echo $errors['ccs']; ?></span> <br/><span class="error"><?php echo $errors['ccs']; ?></span>
</td> </td>
...@@ -810,20 +808,18 @@ if ($errors['err'] && isset($_POST['a'])) { ...@@ -810,20 +808,18 @@ if ($errors['err'] && isset($_POST['a'])) {
<tr> <tr>
<td width="160"><b><?php echo __('Bcc'); ?>:</b></td> <td width="160"><b><?php echo __('Bcc'); ?>:</b></td>
<td> <td>
<select name="bccs[]" id="bcc_users" multiple="multiple" <select class="collabSelections" name="bccs[]" id="bcc_users" multiple="multiple"
data-placeholder="<?php echo __('Select Contacts'); ?>"> data-placeholder="<?php echo __('Select Contacts'); ?>">
<option value=""></option>
<option value="NEW">&mdash; <?php echo __('Add New');?> &mdash;</option>
<?php <?php
$users = User::objects(); foreach ($bcc_cids as $u) {
foreach ($users as $u) { if($u != $ticket->user_id && !in_array($u, $cc_cids)) {
if($u->id != $ticket->user_id && !in_array($u->getId(), $cc_cids)) { ?>
<option value="<?php echo $u; ?>" <?php
if (in_array($u, $bcc_cids))
echo 'selected="selected"'; ?>><?php echo User::lookup($u); ?>
</option>
<?php } } ?>
?> ?>
<option value="<?php echo $u->id; ?>" <?php
if (in_array($u->getId(), $bcc_cids))
echo 'selected="selected"'; ?>><?php echo $u->getName(); ?>
</option>
<?php } } ?>
</select> </select>
<br/><span class="error"><?php echo $errors['bccs']; ?></span> <br/><span class="error"><?php echo $errors['bccs']; ?></span>
</td> </td>
...@@ -1193,76 +1189,72 @@ $(function() { ...@@ -1193,76 +1189,72 @@ $(function() {
}); });
$(function() { $(function() {
$("#cc_users").select2({width: '350px'}); $('.collabSelections').on("select2:select", function(e) {
$("#bcc_users").select2({width: '350px'}); var el = $(this);
}); var tid = <?php echo $ticket->getThreadId(); ?>;
var target = e.currentTarget.id;
$(function() { var addTo = (target == 'cc_users') ? 'addcc' : 'addbcc';
$('#cc_users').on("select2:select", function(e) {
var el = $(this);
var tid = <?php echo $ticket->getThreadId(); ?>;
if(el.val().includes("NEW")) {
$("li[title='— Add New —']").remove();
var url = 'ajax.php/thread/' + tid + '/add-collaborator' ;
$.userLookup(url, function(user) {
e.preventDefault();
if($('.dialog#confirm-action').length) {
$('.dialog#confirm-action #action').val('addcc');
$('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />');
$('#overlay').show();
}
});
var arr = el.val();
var removeStr = "NEW";
arr.splice($.inArray(removeStr, arr),1);
$(this).val(arr);
}
});
$('#bcc_users').on("select2:select", function(e) {
var el = $(this);
var tid = <?php echo $ticket->getThreadId(); ?>;
if(el.val().includes("NEW")) { if(el.val().includes("NEW")) {
$("li[title='— Add New —']").remove(); $("li[title='— Add New —']").remove();
var url = 'ajax.php/thread/' + tid + '/add-collaborator' ; var url = 'ajax.php/thread/' + tid + '/add-collaborator' ;
$.userLookup(url, function(user) { $.userLookup(url, function(user) {
e.preventDefault(); e.preventDefault();
if($('.dialog#confirm-action').length) { if($('.dialog#confirm-action').length) {
$('.dialog#confirm-action #action').val('addbcc'); $('.dialog#confirm-action #action').val(addTo);
$('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />'); $('#confirm-form').append('<input type=hidden name=user_id value='+user.id+' />');
$('#overlay').show(); $('#overlay').show();
} }
}); });
var arr = el.val(); var arr = el.val();
var removeStr = "NEW"; var removeStr = "NEW";
arr.splice($.inArray(removeStr, arr),1); arr.splice($.inArray(removeStr, arr),1);
$(this).val(arr); $(this).val(arr);
} }
});
$('#cc_users').on("select2:unselecting", function(e) {
var confirmation = confirm(__("Are you sure you want to remove the collaborator from receiving this reply?"));
if (confirmation == false) {
$('#cc_users').on("select2:opening", function(e) {
return false;
});
return false;
}
}); });
$('#bcc_users').on("select2:unselecting", function(e) { $('.collabSelections').on("select2:unselecting", function(e) {
var el = $(this);
var target = '#' + e.currentTarget.id;
var confirmation = confirm(__("Are you sure you want to remove the collaborator from receiving this reply?")); var confirmation = confirm(__("Are you sure you want to remove the collaborator from receiving this reply?"));
if (confirmation == false) { if (confirmation == false) {
$('#bcc_users').on("select2:opening", function(e) { $(target).on("select2:opening", function(e) {
return false;
});
return false; return false;
});
return false;
}
});
$('.collabSelections').select2({
width: '350px',
minimumInputLength: 3,
ajax: {
url: "ajax.php/users/local",
dataType: 'json',
data: function (params) {
if (!params) {
params.term = 'test';
} }
return {
q: params.term,
};
},
processResults: function (data) {
data[0] = {name: "\u2014 Add New \u2014", id: "NEW"};
return {
results: $.map(data, function (item) {
return {
text: item.name,
slug: item.slug,
id: item.id
}
})
};
}
}
}); });
}); });
</script> </script>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment