1 | /** |
---|
2 | * Copyright (c) 2008-2010 The Open Source Geospatial Foundation |
---|
3 | * |
---|
4 | * Published under the BSD license. |
---|
5 | * See http://svn.geoext.org/core/trunk/geoext/license.txt for the full text |
---|
6 | * of the license. |
---|
7 | */ |
---|
8 | |
---|
9 | /** |
---|
10 | * @include GeoExt/widgets/form/SearchAction.js |
---|
11 | */ |
---|
12 | |
---|
13 | /** api: (define) |
---|
14 | * module = GeoExt.form |
---|
15 | * class = BasicForm |
---|
16 | * base_link = `Ext.form.BasicForm <http://dev.sencha.com/deploy/dev/docs/?class=Ext.form.BasicForm>`_ |
---|
17 | */ |
---|
18 | |
---|
19 | Ext.namespace("GeoExt.form"); |
---|
20 | |
---|
21 | /** api: constructor |
---|
22 | * .. class:: BasicForm(config) |
---|
23 | * |
---|
24 | * A specific ``Ext.form.BasicForm`` whose doAction method creates |
---|
25 | * a :class:`GeoExt.form.SearchAction` if it is passed the string |
---|
26 | * "search" as its first argument. |
---|
27 | * |
---|
28 | * In most cases one would not use this class directly, but |
---|
29 | * :class:`GeoExt.form.FormPanel` instead. |
---|
30 | */ |
---|
31 | GeoExt.form.BasicForm = Ext.extend(Ext.form.BasicForm, { |
---|
32 | /** private: property[protocol] |
---|
33 | * ``OpenLayers.Protocol`` The protocol configured in this |
---|
34 | * instance. |
---|
35 | */ |
---|
36 | protocol: null, |
---|
37 | |
---|
38 | /** |
---|
39 | * private: property[prevResponse] |
---|
40 | * ``OpenLayers.Protocol.Response`` The response return by a call to |
---|
41 | * protocol.read method. |
---|
42 | */ |
---|
43 | prevResponse: null, |
---|
44 | |
---|
45 | /** |
---|
46 | * api: config[autoAbort] |
---|
47 | * ``Boolean`` Tells if pending requests should be aborted |
---|
48 | * when a new action is performed. |
---|
49 | */ |
---|
50 | autoAbort: true, |
---|
51 | |
---|
52 | /** api: method[doAction] |
---|
53 | * :param action: ``String or Ext.form.Action`` Either the name |
---|
54 | * of the action or a ``Ext.form.Action`` instance. |
---|
55 | * :param options: ``Object`` The options passed to the Action |
---|
56 | * constructor. |
---|
57 | * :return: :class:`GeoExt.form.BasicForm` This form. |
---|
58 | * |
---|
59 | * Performs the action, if the string "search" is passed as the |
---|
60 | * first argument then a :class:`GeoExt.form.SearchAction` is created. |
---|
61 | */ |
---|
62 | doAction: function(action, options) { |
---|
63 | if(action == "search") { |
---|
64 | options = Ext.applyIf(options || {}, { |
---|
65 | protocol: this.protocol, |
---|
66 | abortPrevious: this.autoAbort |
---|
67 | }); |
---|
68 | action = new GeoExt.form.SearchAction(this, options); |
---|
69 | } |
---|
70 | return GeoExt.form.BasicForm.superclass.doAction.call( |
---|
71 | this, action, options |
---|
72 | ); |
---|
73 | }, |
---|
74 | |
---|
75 | /** api: method[search] |
---|
76 | * :param options: ``Object`` The options passed to the Action |
---|
77 | * constructor. |
---|
78 | * :return: :class:`GeoExt.form.BasicForm` This form. |
---|
79 | * |
---|
80 | * Shortcut to do a search action. |
---|
81 | */ |
---|
82 | search: function(options) { |
---|
83 | return this.doAction("search", options); |
---|
84 | } |
---|
85 | }); |
---|