]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/web/js/dojo/openils/widget/PCrudAutocompleteBox.js
LP2045292 Color contrast for AngularJS patron bills
[working/Evergreen.git] / Open-ILS / web / js / dojo / openils / widget / PCrudAutocompleteBox.js
1 if (!dojo._hasResource["openils.widget.PCrudAutocompleteBox"]) {
2     dojo._hasResource["openils.widget.PCrudAutocompleteBox"] = true;
3     dojo.provide("openils.widget.PCrudAutocompleteBox");
4
5     dojo.require("openils.PermaCrud.Store");
6     dojo.require("dijit.form.FilteringSelect");
7
8     dojo.declare(
9         "openils.widget.PCrudAutocompleteBox", [dijit.form.FilteringSelect], {
10         //  summary:
11         //      An autocompleting textbox that uses PermaCrud to fetch
12         //      matches. openils.PermaCrud.Store does the work.
13         //
14         //  description:
15         //      Use just like a dijit.form.FilteringSelect except that there
16         //      are these additional properties supported in the args object:
17         //
18         //      The *fmclass* parameter.
19         //          The class hint for the kind of fieldmapper object you
20         //          want to work with. From the IDL.
21         //
22         //      The *store_options* parameter.
23         //          Another object of options such as you would pass to
24         //          openils.PermaCrud.Store. See the documentation for that
25         //          class (it's more thorough).
26         //
27         //      You should also use the existing *searchAttr* object to
28         //      specify what you want to search for as you type and what
29         //      you see in the box.
30             "store": "",
31             "fmclass": "",
32             "store_options": {},
33
34             "constructor": function(args) {
35                 if (!args.hasDownArrow)
36                     args.hasDownArrow = false;
37
38                 if (!args.store) {
39                     if (!args.fmclass)
40                         throw new Error("need either store or fmclass");
41                     var store_options = dojo.mixin(
42                         {"fmclass": args.fmclass}, args.store_options
43                     );
44                     args.store = new openils.PermaCrud.Store(store_options);
45                 }
46             }
47         }
48     );
49 }