forms-angular 0.12.0-beta.2 → 0.12.0-beta.200
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/client/forms-angular-bs-common.less +174 -4
- package/dist/client/forms-angular-bs2-specific.less +1 -1
- package/dist/client/forms-angular-bs3-specific.less +5 -2
- package/dist/client/forms-angular-with-bs2.css +2 -2
- package/dist/client/forms-angular-with-bs3.css +3 -3
- package/dist/client/forms-angular-with-bs3.less +1 -1
- package/dist/client/forms-angular.js +2344 -733
- package/dist/client/forms-angular.min.js +1 -1
- package/dist/client/index.d.ts +563 -92
- package/dist/server/data_form.js +1659 -953
- package/dist/server/index.d.ts +125 -0
- package/package.json +45 -44
- package/CHANGELOG.md +0 -255
package/dist/client/index.d.ts
CHANGED
|
@@ -1,91 +1,416 @@
|
|
|
1
1
|
declare module fng {
|
|
2
|
-
|
|
2
|
+
export interface IFng extends angular.IModule {
|
|
3
|
+
beforeProcess?: (scope: IFormScope, cb: (err?: Error) => void) => void;
|
|
4
|
+
title?: { prefix?: string; suffix?: string };
|
|
5
|
+
// when provided, the named function (assumed to be present on $rootscope) will be used to determine the visibility
|
|
6
|
+
// of menu items and control groups
|
|
7
|
+
hiddenSecurityFuncName?: string;
|
|
8
|
+
// when provided, the named function (assumed to be present on $rootscope) will be used to determine the disabled
|
|
9
|
+
// state of menu items and individual form input controls
|
|
10
|
+
disabledSecurityFuncName?: string;
|
|
11
|
+
// when provided, the named function (assumed to be present on $rootscope) will be called each time a new page
|
|
12
|
+
// or popup is accessed, providing the host app with the opportunity to confirm whether there are ANY hidden elements
|
|
13
|
+
// at all on that page. where there are not, we can optimise by skipping logic relating to DOM element visibility.
|
|
14
|
+
skipHiddenSecurityFuncName?: string;
|
|
15
|
+
// when provided, the named function (assumed to be present on $rootscope) will be called each time a new page
|
|
16
|
+
// or popup is accessed, providing the host app with the opportunity to confirm whether there are ANY disabled elements
|
|
17
|
+
// at all on that page. where there are not, we can optimise by skipping logic relating to disabling DOM elements.
|
|
18
|
+
skipDisabledSecurityFuncName?: string;
|
|
19
|
+
// when provided, the named function (assumed to be present on $rootscope) will be called each time a new page
|
|
20
|
+
// or popup is accessed, providing the host app with the opportunity to confirm whether there are ANY elements on that
|
|
21
|
+
// page that require their child elements to be disabled. where there are not, we can optimise by skipping
|
|
22
|
+
// disabled ancestor checks.
|
|
23
|
+
skipDisabledAncestorSecurityFuncName?: string;
|
|
24
|
+
// how the function identified by elemSecurityFuncName should be bound. "instant" means that it will be called
|
|
25
|
+
// as the markup is being constructed, with 'hidden' elements not included in the markup at all, and disable elements
|
|
26
|
+
// given a simple DISABLED attribute. this is the most efficient approach. "one-time" will add ng-hide and
|
|
27
|
+
// ng-disabled directives to the relevant elements, with one-time binding to the security function. this is
|
|
28
|
+
// also reasonably efficient (but not as efficient as "instant" due to the need for watches). "normal" will not use
|
|
29
|
+
// one-time binding, which has the potential to be highly resource-intensive on large forms. which
|
|
30
|
+
// option is chosen will depend upon when the function identified by elemSecurityFuncName will be ready to
|
|
31
|
+
// make the necessary determination.
|
|
32
|
+
elemSecurityFuncBinding?: "instant" | "one-time" | "normal";
|
|
33
|
+
hideableAttr?: string; // an attribute to mark all elements that can be hidden using security
|
|
34
|
+
disableableAttr?: string; // an attribute to mark all elements that can be disabled using security
|
|
35
|
+
disableableAncestorAttr?: string; // an attribute to mark all elements whose children can all be disabled using "disabled + children" security
|
|
36
|
+
// if an element's id is a partial match on any of this array's contents, it will never be marked with hideableAttr/disableableAttr
|
|
37
|
+
ignoreIdsForHideableOrDisableableAttrs?: string[];
|
|
38
|
+
}
|
|
39
|
+
var formsAngular: IFng;
|
|
40
|
+
|
|
41
|
+
/*
|
|
42
|
+
Type definitions for types that are used on both the client and the server
|
|
43
|
+
*/
|
|
44
|
+
type formStyle = "inline" | "vertical" | "horizontal" | "horizontalCompact" | "stacked";
|
|
45
|
+
|
|
46
|
+
export interface IBaseArrayLookupReference {
|
|
47
|
+
property: string;
|
|
48
|
+
value: string;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
interface ILookupItem {
|
|
52
|
+
id: string;
|
|
53
|
+
text: string;
|
|
54
|
+
}
|
|
55
|
+
/*
|
|
56
|
+
IInternalLookupreference makes it possible to look up from a list (of key / value pairs) in the current record. For example
|
|
57
|
+
|
|
58
|
+
var ShelfSchema = new Schema({
|
|
59
|
+
location: {type: String, required: true}
|
|
60
|
+
}); // Note that this schema needs an _id as it is an internal lookup
|
|
61
|
+
|
|
62
|
+
var ESchema = new Schema({
|
|
63
|
+
warehouse_name: {type: String, list: {}},
|
|
64
|
+
shelves: {type: [ShelfSchema]},
|
|
65
|
+
favouriteShelf: {type: Schema.Types.ObjectId, internalRef: {property: 'shelves', value:'location'};
|
|
66
|
+
});
|
|
67
|
+
*/
|
|
68
|
+
export interface IFngInternalLookupReference extends IBaseArrayLookupReference {
|
|
69
|
+
noConvert?: boolean; // can be used by a tricksy hack to get around nesting limitations
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/*
|
|
73
|
+
ILookupListReference makes it possible to look up from a list (of key / value pairs)
|
|
74
|
+
in a document in another collection for example:
|
|
75
|
+
|
|
76
|
+
const LSchemaDef : IFngSchemaDefinition = {
|
|
77
|
+
descriptin: {type: String, required: true, list: {}},
|
|
78
|
+
warehouse: {type: Schema.Types.ObjectId, ref:'k_referencing_self_collection', form: {directive: 'fng-ui-select', fngUiSelect: {fngAjax: true}}},
|
|
79
|
+
shelf: {type: Schema.Types.ObjectId, lookupListRef: {collection:'k_referencing_self_collection', id:'$warehouse', property: 'shelves', value:'location'}},
|
|
80
|
+
};
|
|
81
|
+
*/
|
|
82
|
+
export interface IFngLookupListReference extends IBaseArrayLookupReference {
|
|
83
|
+
collection: string; // collection that contains the list
|
|
84
|
+
/*
|
|
85
|
+
Some means of calculating _id in collection. If it starts with $ then it is property in record
|
|
86
|
+
*/
|
|
87
|
+
id: string;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/*
|
|
91
|
+
showWhen allows conditional display of fields based on values elsewhere.
|
|
92
|
+
|
|
93
|
+
For example having prompted whether someone is a smoker you may want a field asking how many they smoke a day:
|
|
94
|
+
smoker: {type: Boolean},
|
|
95
|
+
howManyPerDay: {type: Number, form:{showWhen:{lhs:"$smoker", comp:"eq", rhs:true}}}
|
|
96
|
+
|
|
97
|
+
As you can see from the example there are three parts to the showIf object:
|
|
98
|
+
|
|
99
|
+
lhs (left hand side) a value to be compared. To use the current value of another field in the document preceed it with $.
|
|
100
|
+
comp supported comparators are 'eq' for equality, 'ne' for not equals, 'gt' (greater than), 'gte' (greater than or equal to),
|
|
101
|
+
'lt' (less than) and 'lte' (less than or equal to)
|
|
102
|
+
rhs (right hand side) the other value to be compared. Details as for lhs.
|
|
103
|
+
*/
|
|
104
|
+
export interface IFngShowWhen {
|
|
105
|
+
lhs: any;
|
|
106
|
+
comp: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
|
|
107
|
+
rhs: any;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
/*
|
|
111
|
+
link allows the setting up of hyperlinks for lookup reference fields
|
|
112
|
+
*/
|
|
113
|
+
export interface IFngLinkSetup {
|
|
114
|
+
linkOnly?: boolean; // if true then the input element is not generated (this overrides label)
|
|
115
|
+
label?: boolean; // Make a link out of the label (causes text to be overridden) (this overrides text)
|
|
116
|
+
form?: string; // can be used to generate a link to a custom schema
|
|
117
|
+
linktab?: string; // can be used to generate a link to a tab on a form
|
|
118
|
+
text?: string; // the literal value used for the link. If this property is omitted then text is generated from the field values of the document referred to by the link.
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export type FieldSizeString = "mini" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "block-level"; // sets control width. Default is 'medium''
|
|
122
|
+
|
|
123
|
+
export interface IFngSchemaTypeFormOpts {
|
|
124
|
+
/*
|
|
125
|
+
The input type to be generated - which must be compatible with the Mongoose type.
|
|
126
|
+
Common examples are email, url.
|
|
127
|
+
|
|
128
|
+
In addition to the standard HTML5 types there are some 'special' types:
|
|
129
|
+
textarea: a textarea control
|
|
130
|
+
radio: a radio button control
|
|
131
|
+
select: a select control
|
|
132
|
+
|
|
133
|
+
Note that if the field type is String and the name (or label) contains the string
|
|
134
|
+
'password' then type="password" will be used unless type="text".
|
|
135
|
+
|
|
136
|
+
If the Mongoose schema has an enum array you can specify a radio button group
|
|
137
|
+
(instead of a select) by using a type of radio
|
|
138
|
+
*/
|
|
139
|
+
type?: string;
|
|
140
|
+
|
|
141
|
+
hidden?: boolean; // inhibits this schema key from appearing on the generated form.
|
|
142
|
+
label?: string | null; // overrides the default input label. label:null suppresses the label altogether.
|
|
143
|
+
ref?: string; // reference to another collection
|
|
144
|
+
internalRef?: IFngInternalLookupReference;
|
|
145
|
+
lookupListRef?: IFngLookupListReference;
|
|
146
|
+
id?: string; // specifies the id of the input field (which defaults to f_name)
|
|
147
|
+
|
|
148
|
+
placeHolder?: string; // adds placeholder text to the input (depending on data type).
|
|
149
|
+
help?: string; // adds help text under the input.
|
|
150
|
+
helpInline?: string; // adds help to the right of the input.
|
|
151
|
+
popup?: string; // adds title (popup help) as specified.
|
|
152
|
+
ariaLabel?: string; // adds aria-label as specified.
|
|
153
|
+
order?: number; // allows user to specify the order / tab order of this field in the form. This overrides the position in the Mongoose schema.
|
|
154
|
+
size?: FieldSizeString;
|
|
155
|
+
readonly?: boolean | string; // adds the readonly or ng-readonly attribute to the generated input (currently doesn't work with date - and perhaps other types).
|
|
156
|
+
rows?: number | "auto"; // sets the number of rows in inputs (such as textarea) that support this. Setting rows to "auto" makes the textarea expand to fit the content, rather than create a scrollbar.
|
|
157
|
+
tab?: string; // Used to divide a large form up into a tabset with multiple tabs
|
|
158
|
+
showWhen?: IFngShowWhen | string; // allows conditional display of fields based on values elsewhere. string must be an abular expression.
|
|
159
|
+
|
|
160
|
+
/*
|
|
161
|
+
add: 'class="myClass"' allows custom styling of a specific input
|
|
162
|
+
Angular model options can be used - for example add: 'ng-model-options="{updateOn: \'default blur\', debounce: { \'default\': 500, \'blur\': 0 }}" '
|
|
163
|
+
custom validation directives, such as the timezone validation in this schema
|
|
164
|
+
*/
|
|
165
|
+
add?: string; // allows arbitrary attributes to be added to the input tag.
|
|
166
|
+
|
|
167
|
+
class?: string; // allows arbitrary classes to be added to the input tag.
|
|
168
|
+
inlineRadio?: boolean; // (only valid when type is radio) should be set to true to present all radio button options in a single line
|
|
169
|
+
link?: IFngLinkSetup; // handles displaying links for ref lookups
|
|
170
|
+
asText?: boolean; // (only valid when type is ObjectId) should be set to true to force a simple text input rather than a select. presumed for advanced cases where the objectid is going to be pasted in.
|
|
171
|
+
|
|
172
|
+
/*
|
|
173
|
+
With a select / radio type you can specify the options.
|
|
174
|
+
You can either do this by putting the option values in an array and passing it directly, or by putting them in an
|
|
175
|
+
array on the scope and passing the name of the array (which allows run-time modification
|
|
176
|
+
*/
|
|
177
|
+
options?: Array<string> | string;
|
|
178
|
+
|
|
179
|
+
/* Directive allows you to specify custom behaviour.
|
|
180
|
+
|
|
181
|
+
Gets passed attributes from form-input (with schema replaced with the current element - so add can be used to pass data into directives).
|
|
182
|
+
*/
|
|
183
|
+
directive?: string;
|
|
184
|
+
/* Inhibits the forms-angular client from looking up the possible values for a
|
|
185
|
+
IFngLookupReference or IFngInternalLookupReference field
|
|
186
|
+
(when a directive has a an alternative way of handling things)
|
|
187
|
+
*/
|
|
188
|
+
noLookup?: boolean;
|
|
189
|
+
|
|
190
|
+
/*
|
|
191
|
+
The next few options relate to the handling and display of arrays (including arrays of subdocuments)
|
|
192
|
+
*/
|
|
193
|
+
noAdd?: boolean | string; // inhibits an Add button being generated for arrays.
|
|
194
|
+
noneIndicator?: boolean; // show "None" where there's no add button and no array items
|
|
195
|
+
unshift?: boolean; // (for arrays of sub documents) puts an add button in the sub schema header which allows insertion of new sub documents at the beginning of the array.
|
|
196
|
+
noRemove?: boolean | string; // inhibits a Remove button being generated for array elements.
|
|
197
|
+
formstyle?: formStyle; // (only valid on a sub schema) sets style of sub form.
|
|
198
|
+
sortable?: boolean | string; // Allows drag and drop sorting of arrays - requires angular-ui-sortable
|
|
199
|
+
ngClass?: string; // Allows for conditional per-item styling through the addition of an ng-class expression to the class list of li elements created for each item in the array
|
|
200
|
+
filterable?: boolean; // Add a data-ng-hide to all array elements, referring to subDoc._hidden. Does not actually (yet) provide a UI for managing this property, however (which needs to be done via an external directive)
|
|
201
|
+
subDocContainerType?:
|
|
202
|
+
| "fieldset"
|
|
203
|
+
| "well"
|
|
204
|
+
| "well-large"
|
|
205
|
+
| "well-small"
|
|
206
|
+
| string
|
|
207
|
+
| ((info) => { before: ""; after: "" }); // allows each element in the array to be nested in a container
|
|
208
|
+
subDocContainerProps?: any; // the parameters that will be passed if subDocContainerType is a function
|
|
209
|
+
|
|
210
|
+
/*
|
|
211
|
+
The next section relates to the display of sub documents
|
|
212
|
+
*/
|
|
213
|
+
customSubDoc?: string; // Allows you to specify custom HTML (which may include directives) for the sub doc
|
|
214
|
+
customHeader?: string; // Allows you to specify custom HTML (which may include directives) for the header of a group of sub docs
|
|
215
|
+
customFooter?: string; // Allows you to specify custom HTML (which may include directives) for the footer of a group of sub docs
|
|
216
|
+
|
|
217
|
+
/*
|
|
218
|
+
Suppresses warnings about attenpting deep nesting which would be logged to console in some circumstances when a
|
|
219
|
+
directive fakes deep nesting
|
|
220
|
+
*/
|
|
221
|
+
suppressNestingWarning?: boolean;
|
|
222
|
+
}
|
|
3
223
|
|
|
4
224
|
// Schema passed from server - derived from Mongoose schema
|
|
5
|
-
export interface IFieldViewInfo {
|
|
225
|
+
export interface IFieldViewInfo extends IFngSchemaTypeFormOpts {
|
|
6
226
|
name: string;
|
|
7
227
|
schema?: Array<IFieldViewInfo>;
|
|
8
228
|
array?: boolean;
|
|
9
|
-
showIf
|
|
10
|
-
showWhen? : string;
|
|
11
|
-
directive?: string;
|
|
229
|
+
showIf?: any;
|
|
12
230
|
required?: boolean;
|
|
13
|
-
step
|
|
14
|
-
noLookup? : boolean;
|
|
15
|
-
readonly? : boolean;
|
|
16
|
-
help? : string;
|
|
17
|
-
size? : string;
|
|
231
|
+
step?: number;
|
|
18
232
|
}
|
|
19
233
|
|
|
20
|
-
|
|
234
|
+
export type fieldType =
|
|
235
|
+
| "string"
|
|
236
|
+
| "text"
|
|
237
|
+
| "textarea"
|
|
238
|
+
| "number"
|
|
239
|
+
| "select"
|
|
240
|
+
| "link"
|
|
241
|
+
| "date"
|
|
242
|
+
| "checkbox"
|
|
243
|
+
| "password"
|
|
244
|
+
| "radio";
|
|
245
|
+
|
|
246
|
+
// Schema used internally on client - often derived from IFieldViewInfo passed from server
|
|
21
247
|
export interface IFormInstruction extends IFieldViewInfo {
|
|
22
|
-
id
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
248
|
+
id?: string; // id of generated DOM element
|
|
249
|
+
nonUniqueId?: string; // where this field is part of a sub-sub-schema, id is likely to include $index from the sub-schema, to ensure uniqueness. provide it here without reference to $parent.$index for use in security evaluations.
|
|
250
|
+
type?: fieldType;
|
|
251
|
+
defaultValue?: any;
|
|
252
|
+
rows?: number;
|
|
253
|
+
label?: string;
|
|
26
254
|
options?: any;
|
|
27
255
|
ids?: any;
|
|
28
256
|
hidden?: boolean;
|
|
29
257
|
tab?: string;
|
|
30
|
-
add
|
|
31
|
-
ref
|
|
32
|
-
link
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
258
|
+
add?: string;
|
|
259
|
+
ref?: any;
|
|
260
|
+
link?: any;
|
|
261
|
+
linktext?: string;
|
|
262
|
+
linklabel?: boolean;
|
|
263
|
+
form?: string; // the form that is linked to
|
|
264
|
+
select2?: any; // deprecated
|
|
265
|
+
schema?: IFormInstruction[]; // If the field is an array of fields
|
|
266
|
+
intType?: "date";
|
|
267
|
+
[directiveOptions: string]: any;
|
|
36
268
|
}
|
|
37
269
|
|
|
270
|
+
interface IContainerInstructions {
|
|
271
|
+
before?: string;
|
|
272
|
+
after?: string;
|
|
273
|
+
omit?: boolean;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
export interface IContainer {
|
|
277
|
+
/*
|
|
278
|
+
Type of container, which determines markup. This is currently only available when the schema is generated by
|
|
279
|
+
the client for use independent of the BaseController
|
|
280
|
+
In the case of a string which does not match one of the predefined options
|
|
281
|
+
the generated container div is given the class of the name
|
|
282
|
+
*/
|
|
283
|
+
containerType: "fieldset" | "well" | "tabset" | "tab" | "well-large" | "well-small" | string | ((info: IContainer) => IContainerInstructions);
|
|
284
|
+
title?: string;
|
|
285
|
+
|
|
286
|
+
/*
|
|
287
|
+
h1...h6 will use a header style
|
|
288
|
+
anything else will be used as a paragraph stype
|
|
289
|
+
*/
|
|
290
|
+
titleTagOrClass?: string;
|
|
291
|
+
content: IFormInstruction[];
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
export type IFormSchemaElement = IFormInstruction | IContainer;
|
|
295
|
+
|
|
296
|
+
export type IFormSchema = IFormSchemaElement[];
|
|
297
|
+
export type IControlledFormSchema = IFormInstruction[];
|
|
298
|
+
|
|
38
299
|
export interface IEnumInstruction {
|
|
39
300
|
repeat: string;
|
|
40
301
|
value: string;
|
|
41
|
-
label
|
|
302
|
+
label?: string;
|
|
42
303
|
}
|
|
43
304
|
|
|
305
|
+
export interface IFngCtrlState {
|
|
306
|
+
master: any;
|
|
307
|
+
allowLocationChange: boolean; // Do we allow location change or prompt for permission
|
|
308
|
+
}
|
|
44
309
|
export interface IRecordHandler {
|
|
45
|
-
convertToMongoModel(schema:
|
|
46
|
-
createNew(dataToSave: any, options: any, scope:
|
|
47
|
-
deleteRecord(
|
|
48
|
-
updateDocument(dataToSave
|
|
49
|
-
readRecord($scope:
|
|
50
|
-
scrollTheList($scope:
|
|
51
|
-
getListData(
|
|
310
|
+
convertToMongoModel(schema: IControlledFormSchema, anObject: any, prefixLength: number, scope: IFormScope): any;
|
|
311
|
+
createNew(dataToSave: any, options: any, scope: IFormScope, ctrlState: IFngCtrlState): void;
|
|
312
|
+
deleteRecord(id: string, scope: IFormScope, ctrlState: IFngCtrlState): void;
|
|
313
|
+
updateDocument(dataToSave: any, options: any, scope: IFormScope, ctrlState: IFngCtrlState): void;
|
|
314
|
+
readRecord($scope: IFormScope, ctrlState);
|
|
315
|
+
scrollTheList($scope: IFormScope);
|
|
316
|
+
getListData(record, fieldName, listSchema?, $scope?: IFormScope);
|
|
52
317
|
suffixCleanId(inst, suffix);
|
|
53
|
-
setData(object, fieldname, element, value);
|
|
54
|
-
|
|
318
|
+
setData(object, fieldname: string, element, value);
|
|
319
|
+
getData(object, fieldname: string, element?: any);
|
|
320
|
+
setUpLookupOptions(lookupCollection, schemaElement, $scope: IFormScope, ctrlState, handleSchema);
|
|
321
|
+
setUpLookupListOptions: (
|
|
322
|
+
ref: IFngLookupListReference,
|
|
323
|
+
formInstructions: IFormInstruction,
|
|
324
|
+
$scope: IFormScope,
|
|
325
|
+
ctrlState: IFngCtrlState
|
|
326
|
+
) => void;
|
|
327
|
+
handleInternalLookup($scope: IFormScope, formInstructions, ref): void;
|
|
55
328
|
preservePristine(element, fn): void;
|
|
56
329
|
convertIdToListValue(id, idsArray, valuesArray, fname);
|
|
57
|
-
decorateScope($scope:
|
|
58
|
-
fillFormFromBackendCustomSchema(
|
|
59
|
-
|
|
60
|
-
|
|
330
|
+
decorateScope($scope: IFormScope, $uibModal, recordHandlerInstance: IRecordHandler, ctrlState);
|
|
331
|
+
fillFormFromBackendCustomSchema(
|
|
332
|
+
schema,
|
|
333
|
+
$scope: IFormScope,
|
|
334
|
+
formGeneratorInstance,
|
|
335
|
+
recordHandlerInstance,
|
|
336
|
+
ctrlState
|
|
337
|
+
);
|
|
338
|
+
fillFormWithBackendSchema($scope: IFormScope, formGeneratorInstance, recordHandlerInstance, ctrlState);
|
|
339
|
+
handleError($scope: IFormScope);
|
|
61
340
|
}
|
|
62
341
|
|
|
63
342
|
export interface IFormGenerator {
|
|
64
|
-
generateEditUrl(obj, $scope:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
343
|
+
generateEditUrl(obj, $scope: IFormScope): string;
|
|
344
|
+
generateViewUrl(obj, $scope: IFormScope): string;
|
|
345
|
+
generateNewUrl($scope: IFormScope): string;
|
|
346
|
+
handleFieldType(formInstructions, mongooseType, mongooseOptions, $scope: IFormScope, ctrlState);
|
|
347
|
+
handleSchema(
|
|
348
|
+
description: string,
|
|
349
|
+
source,
|
|
350
|
+
destForm,
|
|
351
|
+
destList,
|
|
352
|
+
prefix,
|
|
353
|
+
doRecursion: boolean,
|
|
354
|
+
$scope: IFormScope,
|
|
355
|
+
ctrlState
|
|
356
|
+
);
|
|
357
|
+
updateDataDependentDisplay(curValue, oldValue, force, $scope: IFormScope);
|
|
358
|
+
add(fieldName: string, $event, $scope: IFormScope, modelOverride?: any);
|
|
359
|
+
unshift(fieldName: string, $event, $scope: IFormScope, modelOverride?: any);
|
|
360
|
+
remove(fieldName: string, value, $event, $scope: IFormScope, modelOverride?: any);
|
|
361
|
+
hasError(formName, name, index, $scope: IFormScope);
|
|
362
|
+
decorateScope($scope: IFormScope, formGeneratorInstance, recordHandlerInstance: IRecordHandler, sharedStuff, pseudoUrl?: string);
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
export interface IFngSingleLookupHandler {
|
|
366
|
+
formInstructions: IFormInstruction;
|
|
367
|
+
lastPart: string;
|
|
368
|
+
possibleArray: string;
|
|
369
|
+
// If the looked-up record changes, we use these fields to see if the old lookup value also exists in the new lookup record
|
|
370
|
+
oldValue?: string | string[];
|
|
371
|
+
oldId?: string | string[];
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
export interface IFngLookupHandler {
|
|
375
|
+
lookupOptions: string[];
|
|
376
|
+
lookupIds: string[];
|
|
377
|
+
handlers: IFngSingleLookupHandler[];
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
export interface IFngInternalLookupHandlerInfo extends IFngLookupHandler {
|
|
381
|
+
ref: IFngInternalLookupReference;
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
export interface IFngLookupListHandlerInfo extends IFngLookupHandler {
|
|
385
|
+
ref: IFngLookupListReference;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
// we cannot use an enum here, so this will have to do. these are the values expected to be returned by the
|
|
389
|
+
// function on $rootScope with the name formsAngular.disabledSecurityFuncName.
|
|
390
|
+
// false = not disabled,
|
|
391
|
+
// true = disabled,
|
|
392
|
+
// "+" = this and all child elements disabled
|
|
393
|
+
export type DisabledOutcome = boolean | "+";
|
|
394
|
+
|
|
395
|
+
export interface ISecurableScope extends angular.IScope {
|
|
396
|
+
// added by ISecurityService
|
|
397
|
+
isSecurelyHidden: (elemId: string) => boolean;
|
|
398
|
+
isSecurelyDisabled: (elemId: string) => boolean;
|
|
399
|
+
requiresDisabledChildren: (elemId: string) => boolean;
|
|
74
400
|
}
|
|
75
401
|
|
|
76
402
|
/*
|
|
77
403
|
The scope which contains form data
|
|
78
404
|
*/
|
|
79
|
-
export interface IFormScope extends
|
|
405
|
+
export interface IFormScope extends ISecurableScope {
|
|
80
406
|
sharedData: any;
|
|
81
|
-
modelNameDisplay
|
|
407
|
+
modelNameDisplay: string;
|
|
82
408
|
modelName: string;
|
|
83
409
|
formName: string;
|
|
84
|
-
cancel(): any;
|
|
85
|
-
showError: (error: any, alertTitle? : string) => void;
|
|
86
410
|
alertTitle: any;
|
|
411
|
+
errorVisible: boolean;
|
|
87
412
|
errorMessage: any;
|
|
88
|
-
|
|
413
|
+
errorHideTimer: number;
|
|
89
414
|
save: any;
|
|
90
415
|
newRecord: boolean;
|
|
91
416
|
initialiseNewRecord?: any;
|
|
@@ -96,30 +421,33 @@ declare module fng {
|
|
|
96
421
|
isCancelDisabled: any;
|
|
97
422
|
isNewDisabled: any;
|
|
98
423
|
isSaveDisabled: any;
|
|
99
|
-
|
|
424
|
+
whyDisabled: string;
|
|
100
425
|
unconfirmedDelete: boolean;
|
|
101
426
|
getVal: any;
|
|
102
427
|
sortableOptions: any;
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
tab?: string; // title of the active tab - from the route
|
|
428
|
+
tabs?: Array<any>; // In the case of forms that contain a tab set
|
|
429
|
+
tab?: string; // title of the active tab - from the route
|
|
106
430
|
activeTabNo?: number;
|
|
107
|
-
topLevelFormName: string;
|
|
431
|
+
topLevelFormName: string; // The name of the form
|
|
108
432
|
record: any;
|
|
109
|
-
originalData: any;
|
|
433
|
+
originalData: any; // the unconverted data read from the server
|
|
110
434
|
phase: any;
|
|
111
435
|
disableFunctions: any;
|
|
112
436
|
dataEventFunctions: any;
|
|
113
437
|
listSchema: any;
|
|
114
438
|
recordList: any;
|
|
115
439
|
dataDependencies: any;
|
|
440
|
+
internalLookups: IFngInternalLookupHandlerInfo[];
|
|
441
|
+
listLookups: IFngLookupListHandlerInfo[];
|
|
116
442
|
conversions: any;
|
|
117
443
|
pageSize: any;
|
|
118
444
|
pagesLoaded: any;
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
445
|
+
cancel: () => any;
|
|
446
|
+
showError: (error: any, alertTitle?: string) => void;
|
|
447
|
+
prepareForSave: (cb: (error: string, dataToSave?: any) => void) => void;
|
|
448
|
+
setDefaults: (formSchema: IFormSchema, base?: string) => any;
|
|
449
|
+
formSchema: IControlledFormSchema;
|
|
450
|
+
baseSchema: () => Array<any>;
|
|
123
451
|
setFormDirty: any;
|
|
124
452
|
add: any;
|
|
125
453
|
hasError: any;
|
|
@@ -130,17 +458,57 @@ declare module fng {
|
|
|
130
458
|
skipCols: any;
|
|
131
459
|
setPristine: any;
|
|
132
460
|
generateEditUrl: any;
|
|
461
|
+
generateViewUrl: any;
|
|
133
462
|
generateNewUrl: any;
|
|
134
463
|
scrollTheList: any;
|
|
135
464
|
getListData: any;
|
|
136
|
-
|
|
137
|
-
|
|
465
|
+
phaseWatcher: any;
|
|
466
|
+
dismissError: () => void;
|
|
467
|
+
stickError: () => void;
|
|
468
|
+
clearTimeout: () => void;
|
|
469
|
+
handleHttpError: (response: any) => void;
|
|
138
470
|
dropConversionWatcher: () => void;
|
|
471
|
+
readingRecord?: Promise<any>;
|
|
472
|
+
onSchemaFetch?: (description: string, source: IFieldViewInfo[]) => void;
|
|
473
|
+
onSchemaProcessed?: (description: string, formSchema: IFormInstruction[]) => void;
|
|
474
|
+
updateQueryForTab?: (tab: string) => void;
|
|
475
|
+
tabDeselect?: ($event: any, $selectedIndex: number) => void;
|
|
476
|
+
setUpCustomLookupOptions?: (
|
|
477
|
+
schemaElement: IFormInstruction,
|
|
478
|
+
ids: string[],
|
|
479
|
+
options: string[],
|
|
480
|
+
baseScope: any
|
|
481
|
+
) => void;
|
|
482
|
+
}
|
|
483
|
+
|
|
484
|
+
export interface IContextMenuDivider {
|
|
485
|
+
divider: boolean;
|
|
486
|
+
}
|
|
487
|
+
export interface IContextMenuOption {
|
|
488
|
+
// For it to make any sense, a menu option needs one of the next three properties
|
|
489
|
+
url?: string;
|
|
490
|
+
fn?: () => void;
|
|
491
|
+
urlFunc?: () => string;
|
|
492
|
+
|
|
493
|
+
// provided to the security hook (see elemSecurityFuncName) - optional where that is not being used
|
|
494
|
+
id?: string;
|
|
495
|
+
|
|
496
|
+
text?: string;
|
|
497
|
+
textFunc?: () => string;
|
|
498
|
+
isDisabled?: () => boolean;
|
|
499
|
+
isHidden?: () => boolean;
|
|
500
|
+
|
|
501
|
+
// Does the option appear in the following contexts?
|
|
502
|
+
listing: boolean;
|
|
503
|
+
creating: boolean;
|
|
504
|
+
editing: boolean;
|
|
139
505
|
}
|
|
140
506
|
|
|
141
507
|
export interface IModelController extends IFormScope {
|
|
142
|
-
onBaseCtrlReady
|
|
143
|
-
onAllReady
|
|
508
|
+
onBaseCtrlReady?: (baseScope: IFormScope) => void; // Optional callback after form is instantiated
|
|
509
|
+
onAllReady?: (baseScope: IFormScope) => void; // Optional callback after form is instantiated and populated
|
|
510
|
+
contextMenu?: Array<IContextMenuOption | IContextMenuDivider>;
|
|
511
|
+
contextMenuPromise?: Promise<Array<IContextMenuOption | IContextMenuDivider>>;
|
|
144
512
|
}
|
|
145
513
|
|
|
146
514
|
export interface IBaseFormOptions {
|
|
@@ -148,13 +516,13 @@ declare module fng {
|
|
|
148
516
|
* The style of the form layout. Supported values are horizontalcompact, horizontal, vertical, inline
|
|
149
517
|
*/
|
|
150
518
|
//TODO supported values should be in an enum
|
|
151
|
-
formstyle?:
|
|
519
|
+
formstyle?: formStyle;
|
|
152
520
|
/**
|
|
153
521
|
* Model on form scope (defaults to record).
|
|
154
522
|
* <li><strong>model</strong> the object in the scope to be bound to the model controller. Specifying
|
|
155
523
|
* the model inhibits the generation of the <strong>form</strong> tag unless the <strong>forceform</strong> attribute is set to true</li>
|
|
156
524
|
*/
|
|
157
|
-
model
|
|
525
|
+
model?: string;
|
|
158
526
|
/**
|
|
159
527
|
* The name to be given to the form - defaults to myForm
|
|
160
528
|
*/
|
|
@@ -163,60 +531,163 @@ declare module fng {
|
|
|
163
531
|
* Normally first field in a form gets autofocus set. Use this to prevent this
|
|
164
532
|
*/
|
|
165
533
|
noautofocus?: string;
|
|
534
|
+
/*
|
|
535
|
+
Suppress the generation of element ids
|
|
536
|
+
(sometimes required when using nested form-inputs in a directive)
|
|
537
|
+
*/
|
|
538
|
+
noid?: boolean;
|
|
166
539
|
}
|
|
167
540
|
|
|
168
541
|
export interface IFormAttrs extends IFormOptions, angular.IAttributes {
|
|
169
542
|
/**
|
|
170
543
|
* Schema used by the form
|
|
171
544
|
*/
|
|
172
|
-
schema
|
|
173
|
-
forceform?: string;
|
|
545
|
+
schema: string;
|
|
546
|
+
forceform?: string; // Must be true or omitted. Forces generation of the <strong>form</strong> tag when model is specified
|
|
547
|
+
noid?: boolean;
|
|
174
548
|
}
|
|
175
549
|
|
|
176
550
|
export interface IFormOptions extends IBaseFormOptions {
|
|
177
|
-
schema
|
|
551
|
+
schema?: string;
|
|
178
552
|
subkey?: string;
|
|
179
553
|
subkeyno?: number;
|
|
180
|
-
subschema
|
|
181
|
-
subschemaroot
|
|
554
|
+
subschema?: string;
|
|
555
|
+
subschemaroot?: string;
|
|
556
|
+
viewform?: boolean;
|
|
557
|
+
suppressNestingWarning?: boolean;
|
|
182
558
|
}
|
|
183
559
|
|
|
184
560
|
export interface IBuiltInRoute {
|
|
185
561
|
route: string;
|
|
186
562
|
state: string;
|
|
187
563
|
templateUrl: string;
|
|
188
|
-
options
|
|
564
|
+
options?: any;
|
|
189
565
|
}
|
|
190
566
|
|
|
191
567
|
export interface IRoutingConfig {
|
|
192
568
|
hashPrefix: string;
|
|
193
569
|
html5Mode: boolean;
|
|
194
|
-
routing: string;
|
|
195
|
-
|
|
196
|
-
prefix: string;
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
570
|
+
routing: string; // What sort of routing do we want? ngroute or uirouter.
|
|
571
|
+
// TODO Should be enum
|
|
572
|
+
prefix: string; // How do we want to prefix out routes? If not empty string then first character must be slash (which is added if not)
|
|
573
|
+
// for example '/db' that gets prepended to all the generated routes. This can be used to
|
|
574
|
+
// prevent generated routes (which have a lot of parameters) from clashing with other routes in
|
|
575
|
+
// the web app that have nothing to do with CRUD forms
|
|
200
576
|
fixedRoutes?: Array<IBuiltInRoute>;
|
|
201
|
-
templateFolder?: string;
|
|
202
|
-
add2fngRoutes?: any;
|
|
203
|
-
|
|
577
|
+
templateFolder?: string; // The folder where the templates for base-list, base-edit and base-analysis live. Internal templates used by default. For pre 0.7.0 behaviour use 'partials/'
|
|
578
|
+
add2fngRoutes?: any; // An object to add to the generated routes. One use case would be to add {authenticate: true}
|
|
579
|
+
// so that the client authenticates for certain routes
|
|
204
580
|
|
|
205
|
-
variantsForDemoWebsite
|
|
206
|
-
variants?: any;
|
|
581
|
+
variantsForDemoWebsite?: any; // Just for demo website
|
|
582
|
+
variants?: any; // Just for demo website
|
|
583
|
+
onDelete?: string; // Supports literal (such as '/') or 'new' (which will go to a /new of the model) default is to go to the list view
|
|
207
584
|
}
|
|
208
585
|
|
|
209
586
|
export interface IFngRoute {
|
|
210
|
-
newRecord?:
|
|
211
|
-
analyse?:
|
|
212
|
-
modelName?:
|
|
213
|
-
reportSchemaName
|
|
214
|
-
id
|
|
215
|
-
formName
|
|
216
|
-
tab
|
|
217
|
-
variant
|
|
587
|
+
newRecord?: boolean;
|
|
588
|
+
analyse?: boolean;
|
|
589
|
+
modelName?: string;
|
|
590
|
+
reportSchemaName?: string;
|
|
591
|
+
id?: string;
|
|
592
|
+
formName?: string;
|
|
593
|
+
tab?: string;
|
|
594
|
+
variant?: string; // TODO should be enum of supported frameworks
|
|
218
595
|
}
|
|
219
596
|
|
|
597
|
+
interface IBuildingBlocks {
|
|
598
|
+
common: string;
|
|
599
|
+
sizeClassBS3: string;
|
|
600
|
+
sizeClassBS2: string;
|
|
601
|
+
compactClass: string;
|
|
602
|
+
formControl: string;
|
|
603
|
+
modelString: string;
|
|
604
|
+
disableableAncestorStr: string;
|
|
605
|
+
}
|
|
606
|
+
|
|
607
|
+
interface IProcessedAttrs {
|
|
608
|
+
info: IFormInstruction;
|
|
609
|
+
options: IFormOptions;
|
|
610
|
+
directiveOptions: any;
|
|
611
|
+
}
|
|
612
|
+
|
|
613
|
+
interface IGenDisableStrParams {
|
|
614
|
+
forceNg?: boolean;
|
|
615
|
+
nonUniqueIdSuffix?: string;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
|
|
619
|
+
interface IPluginHelper {
|
|
620
|
+
extractFromAttr: (
|
|
621
|
+
attr: any,
|
|
622
|
+
directiveName: string
|
|
623
|
+
) => { info: IFormInstruction; options: IFormOptions; directiveOptions: any };
|
|
624
|
+
buildInputMarkup: (
|
|
625
|
+
scope: angular.IScope,
|
|
626
|
+
attrs: any,
|
|
627
|
+
params: {
|
|
628
|
+
processedAttrs?: IProcessedAttrs;
|
|
629
|
+
fieldInfoOverrides?: Partial<IFormInstruction>;
|
|
630
|
+
optionOverrides?: Partial<IFormOptions>;
|
|
631
|
+
addButtons?: boolean;
|
|
632
|
+
needsX?: boolean;
|
|
633
|
+
},
|
|
634
|
+
generateInputControl: (buildingBlocks: IBuildingBlocks) => string
|
|
635
|
+
) => string;
|
|
636
|
+
genIdString: (scope: angular.IScope, processedAttrs: IProcessedAttrs, idSuffix: string) => string;
|
|
637
|
+
genDisabledStr: (
|
|
638
|
+
scope: angular.IScope,
|
|
639
|
+
processedAttrs: IProcessedAttrs,
|
|
640
|
+
idSuffix: string,
|
|
641
|
+
params?: fng.IGenDisableStrParams
|
|
642
|
+
) => string;
|
|
643
|
+
genIdAndDisabledStr: (
|
|
644
|
+
scope: angular.IScope,
|
|
645
|
+
processedAttrs: IProcessedAttrs,
|
|
646
|
+
idSuffix: string,
|
|
647
|
+
params?: fng.IGenDisableStrParams
|
|
648
|
+
) => string;
|
|
649
|
+
genDateTimePickerDisabledStr: (scope: angular.IScope, processedAttrs: IProcessedAttrs, idSuffix: string) => string;
|
|
650
|
+
genDateTimePickerIdAndDisabledStr: (
|
|
651
|
+
scope: angular.IScope,
|
|
652
|
+
processedAttrs: IProcessedAttrs,
|
|
653
|
+
idSuffix: string
|
|
654
|
+
) => string;
|
|
655
|
+
genUiSelectIdAndDisabledStr: (
|
|
656
|
+
scope: angular.IScope,
|
|
657
|
+
processedAttrs: IProcessedAttrs,
|
|
658
|
+
idSuffix: string
|
|
659
|
+
) => string;
|
|
660
|
+
handlePseudos: (str: string) => string;
|
|
661
|
+
genDisableableAncestorStr: (processedAttrs: IProcessedAttrs) => string;
|
|
662
|
+
}
|
|
663
|
+
|
|
664
|
+
interface ISecurityVisibility {
|
|
665
|
+
omit?: boolean;
|
|
666
|
+
visibilityAttr?: string;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
interface IGenerateDisableAttrParams {
|
|
670
|
+
attr?: string;
|
|
671
|
+
attrRequiresValue?: boolean;
|
|
672
|
+
forceNg?: boolean;
|
|
673
|
+
}
|
|
674
|
+
|
|
675
|
+
type SecurityType = "hidden" | "disabled";
|
|
676
|
+
|
|
677
|
+
interface ISecurityService {
|
|
678
|
+
canDoSecurity: (type: SecurityType) => boolean;
|
|
679
|
+
canDoSecurityNow: (scope: fng.ISecurableScope, type: SecurityType) => boolean;
|
|
680
|
+
isSecurelyHidden: (elemId: string, pseudoUrl?: string) => boolean;
|
|
681
|
+
isSecurelyDisabled: (elemId: string, pseudoUrl?: string) => boolean;
|
|
682
|
+
decorateSecurableScope: (securableScope: ISecurableScope, params?: { pseudoUrl?: string, overrideSkipping?: boolean }) => void;
|
|
683
|
+
doSecurityWhenReady: (cb: () => void) => void;
|
|
684
|
+
considerVisibility: (id: string, scope: fng.ISecurableScope) => ISecurityVisibility;
|
|
685
|
+
considerContainerVisibility: (contentIds: string[], scope: fng.ISecurableScope) => fng.ISecurityVisibility;
|
|
686
|
+
getDisableableAttrs: (id: string) => string;
|
|
687
|
+
getHideableAttrs: (id: string) => string;
|
|
688
|
+
getDisableableAncestorAttrs: (id: string) => string;
|
|
689
|
+
generateDisabledAttr: (id: string, scope: fng.ISecurableScope, params?: IGenerateDisableAttrParams) => string;
|
|
690
|
+
}
|
|
220
691
|
}
|
|
221
692
|
|
|
222
|
-
declare var formsAngular:
|
|
693
|
+
declare var formsAngular: fng.IFng;
|