Revision e28ec811
Von Bernd Bleßmann vor mehr als 3 Jahren hinzugefügt
js/autocomplete_project.js | ||
---|---|---|
38 | 38 |
var last_dummy = $dummy.val(); |
39 | 39 |
var timer; |
40 | 40 |
|
41 |
function open_dialog () { |
|
42 |
k.popup_dialog({ |
|
43 |
url: 'controller.pl?action=Project/project_picker_search', |
|
44 |
// data that can be accessed in template project_picker_search via FORM.boss |
|
45 |
data: $.extend({ // add id of part to the rest of the data in ajax_data, e.g. no_paginate, booked, ... |
|
46 |
real_id: real_id, |
|
47 |
select: 1, |
|
48 |
}, ajax_data($dummy.val())), |
|
49 |
id: 'project_selection', |
|
50 |
dialog: { |
|
51 |
title: k.t8('Project picker'), |
|
52 |
width: 800, |
|
53 |
height: 800, |
|
54 |
}, |
|
55 |
load: function() { init_search(); } |
|
56 |
}); |
|
57 |
window.clearTimeout(timer); |
|
58 |
return true; |
|
59 |
} |
|
60 |
|
|
61 |
function init_search() { |
|
62 |
$('#project_picker_filter').keypress(function(e) { result_timer(e) }).focus(); |
|
63 |
$('#no_paginate').change(function() { update_results() }); |
|
64 |
$('#project_picker_clear_filter').click(function() { |
|
65 |
$('#project_picker_filter').val('').focus(); |
|
66 |
update_results(); |
|
67 |
}); |
|
68 |
update_results(); |
|
69 |
} |
|
70 |
|
|
41 | 71 |
function ajax_data(term) { |
42 | 72 |
var data = { |
43 | 73 |
'filter.all:substr:multi::ilike': term, |
44 | 74 |
'filter.valid': 'valid', |
75 |
'filter.active': 'active', |
|
45 | 76 |
no_paginate: $('#no_paginate').prop('checked') ? 1 : 0, |
46 | 77 |
current: $real.val(), |
47 | 78 |
}; |
48 | 79 |
|
49 | 80 |
if ($customer_id && $customer_id.val()) |
50 | 81 |
data['filter.customer_id'] = $customer_id.val().split(','); |
51 |
|
|
52 | 82 |
return data; |
53 | 83 |
} |
54 | 84 |
|
... | ... | |
99 | 129 |
data: $.extend({ |
100 | 130 |
'real_id': $real.val(), |
101 | 131 |
}, ajax_data(function(){ var val = $('#project_picker_filter').val(); return val === undefined ? '' : val })), |
102 |
success: function(data){ $('#project_picker_result').html(data) } |
|
132 |
success: function(data){ |
|
133 |
$('#project_picker_result').html(data); |
|
134 |
} |
|
103 | 135 |
}); |
104 | 136 |
} |
105 | 137 |
|
... | ... | |
118 | 150 |
timer = window.setTimeout(update_results, 100); |
119 | 151 |
} |
120 | 152 |
|
153 |
function close_popup() { |
|
154 |
$('#project_selection').dialog('close'); |
|
155 |
} |
|
156 |
|
|
121 | 157 |
function handle_changed_text(callbacks) { |
122 | 158 |
$.ajax({ |
123 | 159 |
url: 'controller.pl?action=Project/ajax_autocomplete', |
... | ... | |
204 | 240 |
}); |
205 | 241 |
|
206 | 242 |
// now add a picker div after the original input |
207 |
var pcont = $('<span>').addClass('position-absolute'); |
|
208 |
var picker = $('<div>'); |
|
209 |
$dummy.after(pcont); |
|
210 |
pcont.append(picker); |
|
211 |
|
|
243 |
var popup_button = $('<span>').addClass('ppp_popup_button'); |
|
244 |
$dummy.after(popup_button); |
|
245 |
popup_button.click(open_dialog); |
|
212 | 246 |
var pp = { |
213 | 247 |
real: function() { return $real }, |
214 | 248 |
dummy: function() { return $dummy }, |
... | ... | |
218 | 252 |
set_item: set_item, |
219 | 253 |
reset: make_defined_state, |
220 | 254 |
is_defined_state: function() { return state == STATES.PICKED }, |
221 |
init_results: function () {
|
|
255 |
init_results: function() {
|
|
222 | 256 |
$('div.project_picker_project').each(function(){ |
223 | 257 |
$(this).click(function(){ |
224 | 258 |
set_item({ |
225 | 259 |
id: $(this).children('input.project_picker_id').val(), |
226 | 260 |
name: $(this).children('input.project_picker_description').val(), |
227 | 261 |
}); |
262 |
close_popup(); |
|
228 | 263 |
$dummy.focus(); |
229 | 264 |
return true; |
230 |
}); |
|
231 |
}); |
|
265 |
}); }); |
|
232 | 266 |
$('#project_selection').keydown(function(e){ |
233 |
if (e.which == KEY.ESCAPE) { |
|
234 |
$dummy.focus(); |
|
235 |
} |
|
267 |
if (e.which == KEY.ESCAPE) { |
|
268 |
close_popup(); |
|
269 |
$dummy.focus(); |
|
270 |
} |
|
236 | 271 |
}); |
237 | 272 |
} |
238 | 273 |
} |
Auch abrufbar als: Unified diff
Projekt-Picker-Lupe: Copy/paste und Anpassungen vom Chart-Picker