Testseite für part autocomplete
authorSven Schöling <s.schoeling@linet-services.de>
Tue, 11 Oct 2011 13:06:39 +0000 (15:06 +0200)
committerSven Schöling <s.schoeling@linet-services.de>
Tue, 11 Oct 2011 13:06:39 +0000 (15:06 +0200)
Conflicts:

templates/webpages/part/ajax_autocomplete.html

templates/webpages/part/ajax_autocomplete.html
templates/webpages/part/testpage.html [new file with mode: 0644]

index 9d2a492..53fa6f0 100644 (file)
@@ -1,4 +1,4 @@
-[%- USE HTML %][%  USE JSON %][
+[%- USE HTML %][% USE JSON %][
 [%- FOREACH part = SELF.parts %]
 [%- ajax_autocomplete__label = part.partnumber _ " " _ part.description %]
  {
diff --git a/templates/webpages/part/testpage.html b/templates/webpages/part/testpage.html
new file mode 100644 (file)
index 0000000..551220f
--- /dev/null
@@ -0,0 +1,40 @@
+[% USE L %]
+[% USE T8 %]
+[% USE LxERP %]
+[% L.javascript_tag('jquery', 'jquery-ui') %]
+<link rel="stylesheet" href="css/ui-lightness/jquery-ui-1.8.12.custom.css" type="text/css" />
+
+<p>Pick a part</p>
+id: [% L.input_tag('part_id', '') %]
+nr: [% L.input_tag('part_partnumber', '') %]
+desc: [% L.input_tag('part_description', '') %]
+
+<script type='text/javascript'>
+function autocomplete_part (selector, column, type) {
+  $(function(){ $(selector).autocomplete({
+    source: function(req, rsp) {
+      $.ajax({
+        url: 'controller.pl?action=Part/ajax_autocomplete',
+        dataType: "json",
+        data: {
+          column: column,
+          term: req.term,
+          current: function() { $('#part_id').val() },
+          type: type,
+          obsolete: 0,
+        },
+        success: function (data){ rsp(data) }
+      });
+    },
+    limit: 20,
+    delay: 50,
+    select: function(event, ui) {
+      $('#part_id').val(ui.item.id);
+      $('#part_partnumber').val(ui.item.partnumber);
+      $('#part_description').val(ui.item.description);
+    },
+  })});
+}
+autocomplete_part('#part_partnumber', 'partnumber', ['part', 'assembly']);
+autocomplete_part('#part_description', 'description', ['part', 'assembly']);
+</script>