1
|
### Eclipse Workspace Patch 1.0
|
2
|
#P mod_listpicker
|
3
|
Index: forms/mod_listpicker.js
|
4
|
===================================================================
|
5
|
--- forms/mod_listpicker.js (revision 22)
|
6
|
+++ forms/mod_listpicker.js (working copy)
|
7
|
@@ -20,14 +20,43 @@
|
8
|
if (_bFirstShow) {
|
9
|
var _nFormWidth = _g_oListpicker.form.width,
|
10
|
_nBtnCancelWidth = elements.btnCancel.getWidth(),
|
11
|
- _nBtnNewWidth = elements.btnCreateNew.getWidth();
|
12
|
+ _nBtnNewWidth = elements.btnCreateNew.getWidth(),
|
13
|
+ _nBtnOkWidth = elements.btnOk.getWidth();
|
14
|
|
15
|
elements.btnCancel.text = _g_oListpicker.buttontext.cancel;
|
16
|
elements.btnCreateNew.text = _g_oListpicker.buttontext.createnew;
|
17
|
+ elements.btnOk.text = _g_oListpicker.buttontext.ok;
|
18
|
|
19
|
- // Set the position of the Cancel and New buttons
|
20
|
- if (_g_oListpicker.callback.createNewMethod == "") {
|
21
|
+ // Set the position of the Cancel, New and Ok buttons
|
22
|
+ if(_g_oListpicker.form.multiselect)
|
23
|
+ {
|
24
|
+ elements.btnOk.visible = true;
|
25
|
+ if(_g_oListpicker.callback.createNewMethod == "")
|
26
|
+ {
|
27
|
+ elements.btnCreateNew.visible = false;
|
28
|
+ elements.btnCancel.setLocation( (_nFormWidth / 4) - (_nBtnCancelWidth / 2), elements.btnCancel.getLocationY());
|
29
|
+ elements.btnOk.setLocation( (_nFormWidth * 3 / 4) - (_nBtnCancelWidth / 2), elements.btnCancel.getLocationY());
|
30
|
+ }
|
31
|
+ else
|
32
|
+ {
|
33
|
+ elements.btnCreateNew.visible = true;
|
34
|
+ if (application.getOSName() != 'Mac OS X')
|
35
|
+ {
|
36
|
+ elements.btnCreateNew.setLocation( (_nFormWidth / 4) - (_nBtnNewWidth / 2), elements.btnCreateNew.getLocationY());
|
37
|
+ elements.btnOk.setLocation( (_nFormWidth / 2) - (_nBtnOkWidth / 2), elements.btnOk.getLocationY());
|
38
|
+ elements.btnCancel.setLocation( (_nFormWidth * 3 / 4) - (_nBtnCancelWidth / 2), elements.btnCancel.getLocationY());
|
39
|
+ }
|
40
|
+ else
|
41
|
+ {
|
42
|
+ elements.btnCancel.setLocation( (_nFormWidth / 4) - (_nBtnCancelWidth / 2), elements.btnCancel.getLocationY());
|
43
|
+ elements.btnCreateNew.setLocation( (_nFormWidth / 2) * 2 - (_nBtnNewWidth / 2), elements.btnCreateNew.getLocationY());
|
44
|
+ elements.btnOk.setLocation( (_nFormWidth * 3 / 4) - (_nBtnOkWidth / 2), elements.btnOk.getLocationY());
|
45
|
+ }
|
46
|
+ }
|
47
|
+ }
|
48
|
+ else if (_g_oListpicker.callback.createNewMethod == "") {
|
49
|
elements.btnCreateNew.visible = false;
|
50
|
+ elements.btnOk.visible = false;
|
51
|
elements.btnCancel.setLocation( (_nFormWidth / 2) - (_nBtnCancelWidth / 2), elements.btnCancel.getLocationY());
|
52
|
} else {
|
53
|
elements.btnCreateNew.visible = true;
|
54
|
@@ -59,6 +88,7 @@
|
55
|
*/
|
56
|
function btnCancel(_oEvent) {
|
57
|
application.closeFormDialog();
|
58
|
+
|
59
|
}
|
60
|
|
61
|
/**
|
62
|
@@ -129,6 +159,9 @@
|
63
|
case "<=":
|
64
|
forms[_sForm][_g_oListpicker.form.filterParam[j][0]] = "<=" + _g_oListpicker.form.filterParam[j][2];
|
65
|
break;
|
66
|
+ case "!=":
|
67
|
+ forms[_sForm][_g_oListpicker.form.filterParam[j][0]] = "!" + _g_oListpicker.form.filterParam[j][2];
|
68
|
+ break;
|
69
|
}
|
70
|
}
|
71
|
}
|
72
|
@@ -199,3 +232,55 @@
|
73
|
doSearch();
|
74
|
return true
|
75
|
}
|
76
|
+
|
77
|
+/**
|
78
|
+ * @properties={typeid:24,uuid:"EE24A1D2-3B17-49F3-B1A3-0C153926CE57"}
|
79
|
+ */
|
80
|
+function selectOnAction(event)
|
81
|
+{
|
82
|
+ if(foundset[_g_oListpicker.form.tableName + '_to_selected'])
|
83
|
+ {
|
84
|
+ if(foundset[_g_oListpicker.form.tableName + '_to_selected'].selected)
|
85
|
+ {
|
86
|
+ databaseManager.saveData(foundset[_g_oListpicker.form.tableName + '_to_selected'].getSelectedRecord());
|
87
|
+ }
|
88
|
+ else
|
89
|
+ {
|
90
|
+ foundset[_g_oListpicker.form.tableName + '_to_selected'].deleteRecord();
|
91
|
+ }
|
92
|
+ }
|
93
|
+}
|
94
|
+
|
95
|
+/**
|
96
|
+ * Perform the element default action.
|
97
|
+ *
|
98
|
+ * @param {JSEvent} event the event that triggered the action
|
99
|
+ *
|
100
|
+ * @properties={typeid:24,uuid:"21F32558-89C5-4BB2-A449-10C39D4B91AE"}
|
101
|
+ */
|
102
|
+function btnOk(_oEvent) {
|
103
|
+ try {
|
104
|
+ // select record and return returnValue
|
105
|
+ var _sForm = _oEvent.getFormName();
|
106
|
+ var _oSelectedArray = _g_oListpicker.form.selectedDataset.getColumnAsArray(2);
|
107
|
+
|
108
|
+ if (_g_oListpicker.callback.methodName != "") {
|
109
|
+ // Method
|
110
|
+ if (_g_oListpicker.callback.methodFormName != "") {
|
111
|
+ forms[_g_oListpicker.callback.methodFormName][_g_oListpicker.callback.methodName](_oSelectedArray);
|
112
|
+ } else {
|
113
|
+ globals[_g_oListpicker.callback.methodName](_oSelectedArray);
|
114
|
+ }
|
115
|
+ } else if (_g_oListpicker.callback.formName == "") {
|
116
|
+ // Global variable
|
117
|
+ globals[_g_oListpicker.callback.columnName] = _oSelectedArray;
|
118
|
+ } else {
|
119
|
+ // Form + table column/form variable
|
120
|
+ forms[_g_oListpicker.callback.formName][_g_oListpicker.callback.columnName] = _oSelectedArray;
|
121
|
+ }
|
122
|
+ application.closeFormDialog();
|
123
|
+ } catch (e) {
|
124
|
+ // TODO: handle exception
|
125
|
+ application.output(e.msg, LOGGINGLEVEL.ERROR);
|
126
|
+ }
|
127
|
+}
|
128
|
Index: globals.js
|
129
|
===================================================================
|
130
|
--- globals.js (revision 22)
|
131
|
+++ globals.js (working copy)
|
132
|
@@ -57,8 +57,11 @@
|
133
|
loadAllRecords: false, // optional, load all records when no search criteria is given.
|
134
|
|
135
|
editableColumns: new Array(), // optional, only set to editable a columns if it name is in this array.
|
136
|
- columnValuelists: new Object() // optional. Must be filled {columnName: valuelistName}
|
137
|
+ columnValuelists: new Object(), // optional. Must be filled {columnName: valuelistName}
|
138
|
|
139
|
+ multiselect: false, // optional, enabled a multiselect form if true.
|
140
|
+ selectedDataset: databaseManager.createEmptyDataSet(0,['selected','pickColumID']) // used only when multiselect is enabled to store the selected records.
|
141
|
+
|
142
|
}
|
143
|
|
144
|
this.callback = {
|
145
|
@@ -75,7 +78,8 @@
|
146
|
|
147
|
this.buttontext = {
|
148
|
cancel: "Cancel", // optional, for use with i18n
|
149
|
- createnew: "Create New" // optional, for use with i18n
|
150
|
+ createnew: "Create New", // optional, for use with i18n
|
151
|
+ ok: "Ok" // optional, for use with i18n
|
152
|
}
|
153
|
|
154
|
this.show = function() {
|
155
|
@@ -115,14 +119,35 @@
|
156
|
_oForm = solutionModel.newForm(this.form.name, ("db:/" + this.form.serverName + "/" + this.form.tableName), this.form.stylesheet, false, this.form.width, this.form.height);
|
157
|
_oForm.extendsForm = "mod_listpicker"; // form inheritence, here we get all the settings and objects of the original form
|
158
|
|
159
|
- _oLabel = _oForm.newLabel("", 0, 30, 23, this.form.rowHeight, solutionModel.getForm("mod_listpicker").getFormMethod("btnSelect"));
|
160
|
- _oLabel.mediaOptions = SM_MEDIAOPTION.CROP
|
161
|
- _oLabel.imageMedia = solutionModel.getMedia("btn_select.png")
|
162
|
- _oLabel.verticalAlignment = SM_ALIGNMENT.TOP;
|
163
|
- _oLabel.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST;
|
164
|
- _oLabel.transparent = true;
|
165
|
- _oLabel.showClick = false;
|
166
|
- _oLabel.showFocus = false;
|
167
|
+ if(!this.form.multiselect)
|
168
|
+ {
|
169
|
+ _oLabel = _oForm.newLabel("", 0, 30, 23, this.form.rowHeight, solutionModel.getForm("mod_listpicker").getFormMethod("btnSelect"));
|
170
|
+ _oLabel.mediaOptions = SM_MEDIAOPTION.CROP
|
171
|
+ _oLabel.imageMedia = solutionModel.getMedia("btn_select.png")
|
172
|
+ _oLabel.verticalAlignment = SM_ALIGNMENT.TOP;
|
173
|
+ _oLabel.anchors = SM_ANCHOR.NORTH | SM_ANCHOR.WEST;
|
174
|
+ _oLabel.transparent = true;
|
175
|
+ _oLabel.showClick = false;
|
176
|
+ _oLabel.showFocus = false;
|
177
|
+ }
|
178
|
+ else
|
179
|
+ {
|
180
|
+ var _oSelectedDatasource = this.form.selectedDataset.createDataSource(this.form.name +'_select', [JSColumn.INTEGER,JSColumn.INTEGER]);
|
181
|
+ var _oRelation;
|
182
|
+
|
183
|
+ if(!solutionModel.getRelation(this.form.tableName + '_to_selected'))
|
184
|
+ {
|
185
|
+ _oRelation = solutionModel.newRelation(this.form.tableName + '_to_selected', this.form.serverName, this.form.tableName, _oSelectedDatasource, JSRelation.INNER_JOIN);
|
186
|
+ _oRelation.newRelationItem(this.form.pickColumn,'=','pickColumID');
|
187
|
+ _oRelation.allowCreationRelatedRecords = true;
|
188
|
+ }
|
189
|
+ _oField = _oForm.newField(this.form.tableName + '_to_selected.selected',JSField.CHECKS, 0, 30, 23, this.form.rowHeight);
|
190
|
+ _oField.onAction = solutionModel.getForm("mod_listpicker").getFormMethod("selectOnAction");
|
191
|
+ while(this.form.selectedDataset.getMaxRowIndex())
|
192
|
+ {
|
193
|
+ this.form.selectedDataset.removeRow(1);
|
194
|
+ }
|
195
|
+ }
|
196
|
|
197
|
for (i = 0; i < this.form.columnWidths.length; i++) {
|
198
|
if (this.form.columnWidths[i] > -1) {
|
199
|
@@ -153,6 +178,7 @@
|
200
|
}
|
201
|
_oField.valuelist = (this.form.columnValuelists[this.form.displayColumns[i]]) ? solutionModel.getValueList(this.form.columnValuelists[this.form.displayColumns[i]]) : null;
|
202
|
}
|
203
|
+
|
204
|
|
205
|
// Pass the JSListpicker object to the form-variable for further processing (like when clicking on form buttons)
|
206
|
forms[this.form.name]._g_oListpicker = this;
|
207
|
Index: forms/mod_listpicker.frm
|
208
|
===================================================================
|
209
|
--- forms/mod_listpicker.frm (revision 22)
|
210
|
+++ forms/mod_listpicker.frm (working copy)
|
211
|
@@ -112,6 +112,19 @@
|
212
|
transparent:true,
|
213
|
typeid:7,
|
214
|
uuid:"D5DAC86E-8721-47BD-86AA-51EC911D18BA"
|
215
|
+},
|
216
|
+{
|
217
|
+location:"470,466",
|
218
|
+mediaOptions:14,
|
219
|
+name:"btnOk",
|
220
|
+onActionMethodID:"21F32558-89C5-4BB2-A449-10C39D4B91AE",
|
221
|
+onDoubleClickMethodID:"-1",
|
222
|
+onRightClickMethodID:"-1",
|
223
|
+size:"120,26",
|
224
|
+text:"Ok",
|
225
|
+transparent:true,
|
226
|
+typeid:7,
|
227
|
+uuid:"F5A823D5-8D01-4F08-8F5E-AE0831CE795C"
|
228
|
}
|
229
|
],
|
230
|
name:"mod_listpicker",
|