$_[0]->render('project/test_page');
}
+sub action_project_picker_search {
+ $_[0]->render('project/project_picker_search', { layout => 0 });
+}
+
+sub action_project_picker_result {
+ $_[0]->render('project/_project_picker_result', { layout => 0 });
+}
+
#
# filters
#
}
.chart_picker,
-.part_picker {
+.part_picker,
+.project_picker,
display: inline-block;
}
.chart_picker:before,
-.part_picker:before {
+.part_picker:before,
+.project_picker:before {
display: inline-block;
vertical-align: middle;
height: 100%;
font-style: italic;
}
+div.project_picker_project,
div.part_picker_part,
div.chart_picker_chart {
padding: 5px;
background-color: white;
cursor: pointer;
}
+div.project_picker_project:hover,
div.part_picker_part:hover,
div.chart_picker_chart:hover {
color: #FE5F14;
background-size: contain;
}
span.chart_picker input,
-span.part_picker input {
+span.part_picker input,
+span.project_picker input {
padding-right: 20px;
box-sizing: padding-box;
-moz-box-sizing: padding-box;
-webkit-box-sizing: padding-box;
}
span.chart_picker,
-span.part_picker {
+span.part_picker,
+span.project_picker {
white-space: nowrap;
}
div.ppp_block span.ppp_block_number,
}
.chart_picker,
-.part_picker {
+.part_picker,
+.project_picker {
}
.kivi-validator-invalid,
.customer-vendor-picker-undefined,
font-style: italic;
}
div.part_picker_part,
-div.chart_picker_chart {
+div.chart_picker_chart,
+div.project_picker_project {
padding: 5px;
margin: 5px;
border: 1px;
cursor: pointer;
}
div.part_picker_part:hover,
-div.chart_picker_chart:hover {
+div.chart_picker_chart:hover,
+div.project_picker_project:hover {
background-color: lightgray;
border-color: gray;
}
margin-left: -13px;
}
span.chart_picker input,
-span.part_picker input {
+span.part_picker input,
+span.project_picker input {
padding-right: 20px;
background: white url("../../image/search.svg") no-repeat center right;
background-size: contain;
td span.chart_picker input,
th span.chart_picker input,
td span.part_picker input,
-th span.part_picker input {
+th span.part_picker input,
+td span.project_picker input,
+th span.project_picker input {
+
padding-right: 15px;
}
span.chart_picker,
-span.part_picker {
+span.part_picker,
+span.project_picker {
/* white-space: nowrap;*/
}
float:left;
margin-left:1em;
}
+
div.ppp_line span.ppp_block_description,
div.cpc_line span.cpc_block_description
{
var last_dummy = $dummy.val();
var timer;
+ function open_dialog () {
+ k.popup_dialog({
+ url: 'controller.pl?action=Project/project_picker_search',
+ // data that can be accessed in template project_picker_search via FORM.boss
+ data: $.extend({ // add id of part to the rest of the data in ajax_data, e.g. no_paginate, booked, ...
+ real_id: real_id,
+ select: 1,
+ }, ajax_data($dummy.val())),
+ id: 'project_selection',
+ dialog: {
+ title: k.t8('Project picker'),
+ width: 800,
+ height: 800,
+ },
+ load: function() { init_search(); }
+ });
+ window.clearTimeout(timer);
+ return true;
+ }
+
+ function init_search() {
+ $('#project_picker_filter').keypress(function(e) { result_timer(e) }).focus();
+ $('#no_paginate').change(function() { update_results() });
+ $('#project_picker_clear_filter').click(function() {
+ $('#project_picker_filter').val('').focus();
+ update_results();
+ });
+ update_results();
+ }
+
function ajax_data(term) {
var data = {
'filter.all:substr:multi::ilike': term,
'filter.valid': 'valid',
+ 'filter.active': 'active',
no_paginate: $('#no_paginate').prop('checked') ? 1 : 0,
current: $real.val(),
};
if ($customer_id && $customer_id.val())
data['filter.customer_id'] = $customer_id.val().split(',');
-
return data;
}
data: $.extend({
'real_id': $real.val(),
}, ajax_data(function(){ var val = $('#project_picker_filter').val(); return val === undefined ? '' : val })),
- success: function(data){ $('#project_picker_result').html(data) }
+ success: function(data){
+ $('#project_picker_result').html(data);
+ }
});
}
timer = window.setTimeout(update_results, 100);
}
+ function close_popup() {
+ $('#project_selection').dialog('close');
+ }
+
function handle_changed_text(callbacks) {
$.ajax({
url: 'controller.pl?action=Project/ajax_autocomplete',
});
// now add a picker div after the original input
- var pcont = $('<span>').addClass('position-absolute');
- var picker = $('<div>');
- $dummy.after(pcont);
- pcont.append(picker);
-
+ var popup_button = $('<span>').addClass('ppp_popup_button');
+ $dummy.after(popup_button);
+ popup_button.click(open_dialog);
var pp = {
real: function() { return $real },
dummy: function() { return $dummy },
set_item: set_item,
reset: make_defined_state,
is_defined_state: function() { return state == STATES.PICKED },
- init_results: function () {
+ init_results: function() {
$('div.project_picker_project').each(function(){
$(this).click(function(){
set_item({
id: $(this).children('input.project_picker_id').val(),
name: $(this).children('input.project_picker_description').val(),
});
+ close_popup();
$dummy.focus();
return true;
- });
- });
+ }); });
$('#project_selection').keydown(function(e){
- if (e.which == KEY.ESCAPE) {
- $dummy.focus();
- }
+ if (e.which == KEY.ESCAPE) {
+ close_popup();
+ $dummy.focus();
+ }
});
}
}
--- /dev/null
+[%- USE T8 %]
+[%- USE HTML %]
+[%- USE L %]
+[%- USE LxERP %]
+
+[% FOREACH project = SELF.projects %]
+<div class='project_picker_project [% FORM.hide_project_details ? 'ppp_line' : 'ppp_block' %]'>
+ <input type='hidden' class='project_picker_id' value='[% project.id %]'>
+ <input type='hidden' class='project_picker_description' value='[% project.displayable_name %]'>
+ <span class='ppp_block_number'>[% project.projectnumber | html %]</span>
+ <span class='ppp_block_description'>[% project.description | html %]</span>
+</div>
+[%- END %]
+
+<div style='clear:both'></div>
+
+[% L.paginate_controls(target='#project_picker_result', selector='#project_picker_result', models=SELF.models) %]
+<script type='text/javascript'>
+ kivi.ProjectPicker($('#'+$('#project_picker_real_id').val())).init_results();
+</script>
--- /dev/null
+[%- USE HTML %]
+[%- USE L %]
+[%- USE P %]
+[%- USE LxERP %]
+[%- USE T8 %]
+
+[% L.hidden_tag('project_picker_real_id', FORM.real_id) %]
+[% LxERP.t8("Filter") %]: [% L.input_tag('project_picker_filter', SELF.models.filtered.laundered.all_substr_multi__ilike, class='project_picker_filter') %]
+[% P.link_tag("javascript:void(0);", "x", id='project_picker_clear_filter') %]
+<div class='float-right'>
+ [% L.checkbox_tag('no_paginate', checked=FORM.no_paginate, id='no_paginate', for_submit=1, label=LxERP.t8('All as list')) %]
+</div>
+
+<div id='project_picker_result'>
+</div>