forms-angular 0.12.0-beta.192 → 0.12.0-beta.194

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.
@@ -1,19 +1,57 @@
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}
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[];
5
38
  }
6
39
  var formsAngular: IFng;
7
40
 
8
41
  /*
9
42
  Type definitions for types that are used on both the client and the server
10
43
  */
11
- type formStyle = 'inline' | 'vertical' | 'horizontal' | 'horizontalCompact' | 'stacked';
44
+ type formStyle = "inline" | "vertical" | "horizontal" | "horizontalCompact" | "stacked";
12
45
 
13
46
  export interface IBaseArrayLookupReference {
14
47
  property: string;
15
48
  value: string;
16
49
  }
50
+
51
+ interface ILookupItem {
52
+ id: string;
53
+ text: string;
54
+ }
17
55
  /*
18
56
  IInternalLookupreference makes it possible to look up from a list (of key / value pairs) in the current record. For example
19
57
 
@@ -28,7 +66,7 @@ declare module fng {
28
66
  });
29
67
  */
30
68
  export interface IFngInternalLookupReference extends IBaseArrayLookupReference {
31
- noConvert? : boolean; // can be used by a tricksy hack to get around nesting limitations
69
+ noConvert?: boolean; // can be used by a tricksy hack to get around nesting limitations
32
70
  }
33
71
 
34
72
  /*
@@ -42,7 +80,7 @@ declare module fng {
42
80
  };
43
81
  */
44
82
  export interface IFngLookupListReference extends IBaseArrayLookupReference {
45
- collection: string; // collection that contains the list
83
+ collection: string; // collection that contains the list
46
84
  /*
47
85
  Some means of calculating _id in collection. If it starts with $ then it is property in record
48
86
  */
@@ -65,7 +103,7 @@ declare module fng {
65
103
  */
66
104
  export interface IFngShowWhen {
67
105
  lhs: any;
68
- comp: 'eq' | 'ne' | 'gt' | 'gte' | 'lt' | 'lte';
106
+ comp: "eq" | "ne" | "gt" | "gte" | "lt" | "lte";
69
107
  rhs: any;
70
108
  }
71
109
 
@@ -73,14 +111,14 @@ declare module fng {
73
111
  link allows the setting up of hyperlinks for lookup reference fields
74
112
  */
75
113
  export interface IFngLinkSetup {
76
- linkOnly?: boolean; // if true then the input element is not generated (this overrides label)
77
- label?: boolean; // Make a link out of the label (causes text to be overridden) (this overrides text)
78
- form?: string; // can be used to generate a link to a custom schema
79
- linktab?: string; // can be used to generate a link to a tab on a form
80
- 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.
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.
81
119
  }
82
120
 
83
- export type FieldSizeString = 'mini' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'block-level'; // sets control width. Default is 'medium''
121
+ export type FieldSizeString = "mini" | "small" | "medium" | "large" | "xlarge" | "xxlarge" | "block-level"; // sets control width. Default is 'medium''
84
122
 
85
123
  export interface IFngSchemaTypeFormOpts {
86
124
  /*
@@ -100,35 +138,36 @@ declare module fng {
100
138
  */
101
139
  type?: string;
102
140
 
103
- hidden?: boolean; // inhibits this schema key from appearing on the generated form.
104
- label?: string | null; // overrides the default input label. label:null suppresses the label altogether.
105
- ref?: string; // reference to another collection
106
- internalRef? : IFngInternalLookupReference;
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;
107
145
  lookupListRef?: IFngLookupListReference;
108
146
  id?: string; // specifies the id of the input field (which defaults to f_name)
109
147
 
110
- placeHolder?: string // adds placeholder text to the input (depending on data type).
111
- help?: string; // adds help text under the input.
112
- helpInline?: string; // adds help to the right of the input.
113
- popup?: string; // adds title (popup help) as specified.
114
- ariaLabel?: string; // adds aria-label as specified.
115
- order?: number; // allows user to specify the order / tab order of this field in the form. This overrides the position in the Mongoose schema.
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.
116
154
  size?: FieldSizeString;
117
- readonly?: boolean | string; // adds the readonly or ng-readonly attribute to the generated input (currently doesn't work with date - and perhaps other types).
118
- 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.
119
- tab?: string; // Used to divide a large form up into a tabset with multiple tabs
120
- showWhen?: IFngShowWhen | string; // allows conditional display of fields based on values elsewhere. string must be an abular expression.
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.
121
159
 
122
160
  /*
123
161
  add: 'class="myClass"' allows custom styling of a specific input
124
162
  Angular model options can be used - for example add: 'ng-model-options="{updateOn: \'default blur\', debounce: { \'default\': 500, \'blur\': 0 }}" '
125
163
  custom validation directives, such as the timezone validation in this schema
126
164
  */
127
- add?: string; // allows arbitrary attributes to be added to the input tag.
165
+ add?: string; // allows arbitrary attributes to be added to the input tag.
128
166
 
129
- class?: string; // allows arbitrary classes to be added to the input tag.
130
- inlineRadio?: boolean; // (only valid when type is radio) should be set to true to present all radio button options in a single line
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
131
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.
132
171
 
133
172
  /*
134
173
  With a select / radio type you can specify the options.
@@ -154,12 +193,18 @@ declare module fng {
154
193
  noAdd?: boolean | string; // inhibits an Add button being generated for arrays.
155
194
  noneIndicator?: boolean; // show "None" where there's no add button and no array items
156
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.
157
- noRemove?: boolean | string; // inhibits a Remove button being generated for array elements.
158
- formstyle?: formStyle; // (only valid on a sub schema) sets style of sub form.
159
- sortable? : boolean | string; // Allows drag and drop sorting of arrays - requires angular-ui-sortable
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
160
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
161
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)
162
- subDocContainerType?: 'fieldset' | 'well' | 'well-large' | 'well-small' | string | ((info) => {before: '', after: ''}); // allows each element in the array to be nested in a container
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
163
208
  subDocContainerProps?: any; // the parameters that will be passed if subDocContainerType is a function
164
209
 
165
210
  /*
@@ -173,7 +218,7 @@ declare module fng {
173
218
  Suppresses warnings about attenpting deep nesting which would be logged to console in some circumstances when a
174
219
  directive fakes deep nesting
175
220
  */
176
- suppressNestingWarning? : boolean;
221
+ suppressNestingWarning?: boolean;
177
222
  }
178
223
 
179
224
  // Schema passed from server - derived from Mongoose schema
@@ -181,34 +226,51 @@ declare module fng {
181
226
  name: string;
182
227
  schema?: Array<IFieldViewInfo>;
183
228
  array?: boolean;
184
- showIf? : any;
229
+ showIf?: any;
185
230
  required?: boolean;
186
- step? : number;
231
+ step?: number;
187
232
  }
188
233
 
189
- export type fieldType = 'string' | 'text' | 'textarea' | 'number' | 'select' | 'link' | 'date' | 'checkbox' | 'password' | 'radio';
234
+ export type fieldType =
235
+ | "string"
236
+ | "text"
237
+ | "textarea"
238
+ | "number"
239
+ | "select"
240
+ | "link"
241
+ | "date"
242
+ | "checkbox"
243
+ | "password"
244
+ | "radio";
190
245
 
191
246
  // Schema used internally on client - often derived from IFieldViewInfo passed from server
192
247
  export interface IFormInstruction extends IFieldViewInfo {
193
- id? : string; // id of generated DOM element
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.
194
250
  type?: fieldType;
195
- defaultValue? : any;
196
- rows? : number;
251
+ defaultValue?: any;
252
+ rows?: number;
197
253
  label?: string;
198
254
  options?: any;
199
255
  ids?: any;
200
256
  hidden?: boolean;
201
257
  tab?: string;
202
- add? : string;
203
- ref? : any;
204
- link? : any;
258
+ add?: string;
259
+ ref?: any;
260
+ link?: any;
205
261
  linktext?: string;
206
262
  linklabel?: boolean;
207
- form?: string; // the form that is linked to
208
- select2? : any; // deprecated
209
- schema?: IFormInstruction[]; // If the field is an array of fields
210
- intType? : 'date';
211
- [ directiveOptions: string] : any;
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;
268
+ }
269
+
270
+ interface IContainerInstructions {
271
+ before?: string;
272
+ after?: string;
273
+ omit?: boolean;
212
274
  }
213
275
 
214
276
  export interface IContainer {
@@ -218,14 +280,14 @@ declare module fng {
218
280
  In the case of a string which does not match one of the predefined options
219
281
  the generated container div is given the class of the name
220
282
  */
221
- containerType: 'fieldset' | 'well' | 'tabset' | 'tab' | 'well-large' | 'well-small' | string;
283
+ containerType: "fieldset" | "well" | "tabset" | "tab" | "well-large" | "well-small" | string | ((info: IContainer) => IContainerInstructions);
222
284
  title?: string;
223
285
 
224
286
  /*
225
287
  h1...h6 will use a header style
226
288
  anything else will be used as a paragraph stype
227
289
  */
228
- titleTagOrClass? : string;
290
+ titleTagOrClass?: string;
229
291
  content: IFormInstruction[];
230
292
  }
231
293
 
@@ -237,46 +299,67 @@ declare module fng {
237
299
  export interface IEnumInstruction {
238
300
  repeat: string;
239
301
  value: string;
240
- label? : string;
302
+ label?: string;
241
303
  }
242
304
 
243
305
  export interface IFngCtrlState {
244
306
  master: any;
245
- allowLocationChange: boolean; // Do we allow location change or prompt for permission
307
+ allowLocationChange: boolean; // Do we allow location change or prompt for permission
246
308
  }
247
309
  export interface IRecordHandler {
248
310
  convertToMongoModel(schema: IControlledFormSchema, anObject: any, prefixLength: number, scope: IFormScope): any;
249
311
  createNew(dataToSave: any, options: any, scope: IFormScope, ctrlState: IFngCtrlState): void;
250
312
  deleteRecord(id: string, scope: IFormScope, ctrlState: IFngCtrlState): void;
251
- updateDocument(dataToSave : any, options: any, scope: IFormScope, ctrlState: IFngCtrlState) : void;
313
+ updateDocument(dataToSave: any, options: any, scope: IFormScope, ctrlState: IFngCtrlState): void;
252
314
  readRecord($scope: IFormScope, ctrlState);
253
315
  scrollTheList($scope: IFormScope);
254
316
  getListData(record, fieldName, listSchema?, $scope?: IFormScope);
255
317
  suffixCleanId(inst, suffix);
256
- setData(object, fieldname, element, value);
318
+ setData(object, fieldname: string, element, value);
319
+ getData(object, fieldname: string, element?: any);
257
320
  setUpLookupOptions(lookupCollection, schemaElement, $scope: IFormScope, ctrlState, handleSchema);
258
- setUpLookupListOptions: (ref: IFngLookupListReference, formInstructions: IFormInstruction, $scope: IFormScope, ctrlState: IFngCtrlState) => void;
321
+ setUpLookupListOptions: (
322
+ ref: IFngLookupListReference,
323
+ formInstructions: IFormInstruction,
324
+ $scope: IFormScope,
325
+ ctrlState: IFngCtrlState
326
+ ) => void;
259
327
  handleInternalLookup($scope: IFormScope, formInstructions, ref): void;
260
328
  preservePristine(element, fn): void;
261
329
  convertIdToListValue(id, idsArray, valuesArray, fname);
262
- decorateScope($scope:IFormScope, $uibModal, recordHandlerInstance : IRecordHandler, ctrlState);
263
- fillFormFromBackendCustomSchema(schema, $scope:IFormScope, formGeneratorInstance, recordHandlerInstance, ctrlState);
330
+ decorateScope($scope: IFormScope, $uibModal, recordHandlerInstance: IRecordHandler, ctrlState);
331
+ fillFormFromBackendCustomSchema(
332
+ schema,
333
+ $scope: IFormScope,
334
+ formGeneratorInstance,
335
+ recordHandlerInstance,
336
+ ctrlState
337
+ );
264
338
  fillFormWithBackendSchema($scope: IFormScope, formGeneratorInstance, recordHandlerInstance, ctrlState);
265
339
  handleError($scope: IFormScope);
266
340
  }
267
341
 
268
342
  export interface IFormGenerator {
269
- generateEditUrl(obj, $scope:IFormScope): string;
270
- generateViewUrl(obj, $scope:IFormScope): string;
343
+ generateEditUrl(obj, $scope: IFormScope): string;
344
+ generateViewUrl(obj, $scope: IFormScope): string;
271
345
  generateNewUrl($scope: IFormScope): string;
272
346
  handleFieldType(formInstructions, mongooseType, mongooseOptions, $scope: IFormScope, ctrlState);
273
- handleSchema(description: string, source, destForm, destList, prefix, doRecursion: boolean, $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
+ );
274
357
  updateDataDependentDisplay(curValue, oldValue, force, $scope: IFormScope);
275
358
  add(fieldName: string, $event, $scope: IFormScope, modelOverride?: any);
276
359
  unshift(fieldName: string, $event, $scope: IFormScope, modelOverride?: any);
277
360
  remove(fieldName: string, value, $event, $scope: IFormScope, modelOverride?: any);
278
361
  hasError(formName, name, index, $scope: IFormScope);
279
- decorateScope($scope: IFormScope, formGeneratorInstance, recordHandlerInstance: IRecordHandler, sharedStuff);
362
+ decorateScope($scope: IFormScope, formGeneratorInstance, recordHandlerInstance: IRecordHandler, sharedStuff, pseudoUrl?: string);
280
363
  }
281
364
 
282
365
  export interface IFngSingleLookupHandler {
@@ -291,7 +374,7 @@ declare module fng {
291
374
  export interface IFngLookupHandler {
292
375
  lookupOptions: string[];
293
376
  lookupIds: string[];
294
- handlers: IFngSingleLookupHandler[]
377
+ handlers: IFngSingleLookupHandler[];
295
378
  }
296
379
 
297
380
  export interface IFngInternalLookupHandlerInfo extends IFngLookupHandler {
@@ -302,12 +385,26 @@ declare module fng {
302
385
  ref: IFngLookupListReference;
303
386
  }
304
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;
400
+ }
401
+
305
402
  /*
306
403
  The scope which contains form data
307
404
  */
308
- export interface IFormScope extends angular.IScope {
405
+ export interface IFormScope extends ISecurableScope {
309
406
  sharedData: any;
310
- modelNameDisplay : string;
407
+ modelNameDisplay: string;
311
408
  modelName: string;
312
409
  formName: string;
313
410
  alertTitle: any;
@@ -328,12 +425,12 @@ declare module fng {
328
425
  unconfirmedDelete: boolean;
329
426
  getVal: any;
330
427
  sortableOptions: any;
331
- tabs?: Array<any>; // In the case of forms that contain a tab set
332
- 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
333
430
  activeTabNo?: number;
334
- topLevelFormName: string; // The name of the form
431
+ topLevelFormName: string; // The name of the form
335
432
  record: any;
336
- originalData: any; // the unconverted data read from the server
433
+ originalData: any; // the unconverted data read from the server
337
434
  phase: any;
338
435
  disableFunctions: any;
339
436
  dataEventFunctions: any;
@@ -346,7 +443,7 @@ declare module fng {
346
443
  pageSize: any;
347
444
  pagesLoaded: any;
348
445
  cancel: () => any;
349
- showError: (error: any, alertTitle? : string) => void;
446
+ showError: (error: any, alertTitle?: string) => void;
350
447
  prepareForSave: (cb: (error: string, dataToSave?: any) => void) => void;
351
448
  setDefaults: (formSchema: IFormSchema, base?: string) => any;
352
449
  formSchema: IControlledFormSchema;
@@ -376,7 +473,12 @@ declare module fng {
376
473
  onSchemaProcessed?: (description: string, formSchema: IFormInstruction[]) => void;
377
474
  updateQueryForTab?: (tab: string) => void;
378
475
  tabDeselect?: ($event: any, $selectedIndex: number) => void;
379
- setUpCustomLookupOptions?: (schemaElement: IFormInstruction, ids: string[], options: string[], baseScope: any) => void;
476
+ setUpCustomLookupOptions?: (
477
+ schemaElement: IFormInstruction,
478
+ ids: string[],
479
+ options: string[],
480
+ baseScope: any
481
+ ) => void;
380
482
  }
381
483
 
382
484
  export interface IContextMenuDivider {
@@ -388,6 +490,9 @@ declare module fng {
388
490
  fn?: () => void;
389
491
  urlFunc?: () => string;
390
492
 
493
+ // provided to the security hook (see elemSecurityFuncName) - optional where that is not being used
494
+ id?: string;
495
+
391
496
  text?: string;
392
497
  textFunc?: () => string;
393
498
  isDisabled?: () => boolean;
@@ -400,10 +505,10 @@ declare module fng {
400
505
  }
401
506
 
402
507
  export interface IModelController extends IFormScope {
403
- onBaseCtrlReady? : (baseScope: IFormScope) => void; // Optional callback after form is instantiated
404
- onAllReady? : (baseScope: IFormScope) => void; // Optional callback after form is instantiated and populated
405
- contextMenu? : Array<IContextMenuOption | IContextMenuDivider>;
406
- contextMenuPromise? : Promise<Array<IContextMenuOption | IContextMenuDivider>>;
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>>;
407
512
  }
408
513
 
409
514
  export interface IBaseFormOptions {
@@ -417,7 +522,7 @@ declare module fng {
417
522
  * <li><strong>model</strong> the object in the scope to be bound to the model controller. Specifying
418
523
  * the model inhibits the generation of the <strong>form</strong> tag unless the <strong>forceform</strong> attribute is set to true</li>
419
524
  */
420
- model? : string;
525
+ model?: string;
421
526
  /**
422
527
  * The name to be given to the form - defaults to myForm
423
528
  */
@@ -430,65 +535,159 @@ declare module fng {
430
535
  Suppress the generation of element ids
431
536
  (sometimes required when using nested form-inputs in a directive)
432
537
  */
433
- noid? : boolean;
538
+ noid?: boolean;
434
539
  }
435
540
 
436
541
  export interface IFormAttrs extends IFormOptions, angular.IAttributes {
437
542
  /**
438
543
  * Schema used by the form
439
544
  */
440
- schema : string;
441
- forceform?: string; // Must be true or omitted. Forces generation of the <strong>form</strong> tag when model is specified
442
- noid? : boolean;
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;
443
548
  }
444
549
 
445
550
  export interface IFormOptions extends IBaseFormOptions {
446
- schema? : string;
551
+ schema?: string;
447
552
  subkey?: string;
448
553
  subkeyno?: number;
449
- subschema? : string;
450
- subschemaroot? : string;
451
- viewform? : boolean;
452
- suppressNestingWarning? : boolean;
554
+ subschema?: string;
555
+ subschemaroot?: string;
556
+ viewform?: boolean;
557
+ suppressNestingWarning?: boolean;
453
558
  }
454
559
 
455
560
  export interface IBuiltInRoute {
456
561
  route: string;
457
562
  state: string;
458
563
  templateUrl: string;
459
- options? : any;
564
+ options?: any;
460
565
  }
461
566
 
462
567
  export interface IRoutingConfig {
463
568
  hashPrefix: string;
464
569
  html5Mode: boolean;
465
- routing: string; // What sort of routing do we want? ngroute or uirouter.
466
- // TODO Should be enum
467
- 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)
468
- // for example '/db' that gets prepended to all the generated routes. This can be used to
469
- // prevent generated routes (which have a lot of parameters) from clashing with other routes in
470
- // the web app that have nothing to do with CRUD forms
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
471
576
  fixedRoutes?: Array<IBuiltInRoute>;
472
- 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/'
473
- add2fngRoutes?: any; // An object to add to the generated routes. One use case would be to add {authenticate: true}
474
- // so that the client authenticates for certain routes
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
475
580
 
476
- variantsForDemoWebsite? : any; // Just for demo website
477
- variants?: any; // Just for demo website
478
- 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
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
479
584
  }
480
585
 
481
586
  export interface IFngRoute {
482
- newRecord?: boolean;
483
- analyse?: boolean;
484
- modelName?: string;
485
- reportSchemaName? : string;
486
- id? : string;
487
- formName? : string;
488
- tab? : string;
489
- variant? : string; // TODO should be enum of supported frameworks
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
490
595
  }
491
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
+ }
492
691
  }
493
692
 
494
693
  declare var formsAngular: fng.IFng;