forms-angular 0.12.0-beta.18 → 0.12.0-beta.182

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,15 +1,18 @@
1
1
  declare module fng {
2
- var formsAngular: angular.IModule;
2
+ export interface IFng extends angular.IModule {
3
+ beforeProcess? : (scope: IFormScope, cb: (err?: Error) => void) => void;
4
+ }
5
+ var formsAngular: IFng;
3
6
 
4
7
  /*
5
8
  Type definitions for types that are used on both the client and the server
6
9
  */
10
+ type formStyle = 'inline' | 'vertical' | 'horizontal' | 'horizontalCompact' | 'stacked';
7
11
 
8
- export interface IFngLookupReference {
9
- type: 'lookup';
10
- collection: string
12
+ export interface IBaseArrayLookupReference {
13
+ property: string;
14
+ value: string;
11
15
  }
12
-
13
16
  /*
14
17
  IInternalLookupreference makes it possible to look up from a list (of key / value pairs) in the current record. For example
15
18
 
@@ -20,13 +23,11 @@ declare module fng {
20
23
  var ESchema = new Schema({
21
24
  warehouse_name: {type: String, list: {}},
22
25
  shelves: {type: [ShelfSchema]},
23
- favouriteShelf: {type: Schema.Types.ObjectId, ref: {type: 'internal', property: 'shelves', value:'location'};
26
+ favouriteShelf: {type: Schema.Types.ObjectId, internalRef: {property: 'shelves', value:'location'};
24
27
  });
25
28
  */
26
- export interface IFngInternalLookupReference {
27
- type: 'internal';
28
- property: string;
29
- value: string;
29
+ export interface IFngInternalLookupReference extends IBaseArrayLookupReference {
30
+ noConvert? : boolean; // can be used by a tricksy hack to get around nesting limitations
30
31
  }
31
32
 
32
33
  /*
@@ -36,18 +37,15 @@ declare module fng {
36
37
  const LSchemaDef : IFngSchemaDefinition = {
37
38
  descriptin: {type: String, required: true, list: {}},
38
39
  warehouse: {type: Schema.Types.ObjectId, ref:'k_referencing_self_collection', form: {directive: 'fng-ui-select', fngUiSelect: {fngAjax: true}}},
39
- shelf: {type: Schema.Types.ObjectId, ref: {type: 'lookupList', collection:'k_referencing_self_collection', id:'$warehouse', property: 'shelves', value:'location'}},
40
+ shelf: {type: Schema.Types.ObjectId, lookupListRef: {collection:'k_referencing_self_collection', id:'$warehouse', property: 'shelves', value:'location'}},
40
41
  };
41
42
  */
42
- export interface IFngLookupListReference {
43
- type: 'lookupList';
43
+ export interface IFngLookupListReference extends IBaseArrayLookupReference {
44
44
  collection: string; // collection that contains the list
45
45
  /*
46
46
  Some means of calculating _id in collection. If it starts with $ then it is property in record
47
47
  */
48
48
  id: string;
49
- property: string;
50
- value: string;
51
49
  }
52
50
 
53
51
  /*
@@ -74,11 +72,15 @@ declare module fng {
74
72
  link allows the setting up of hyperlinks for lookup reference fields
75
73
  */
76
74
  export interface IFngLinkSetup {
77
- linkOnly?: boolean; // if true (which at the time of writing is the only option supported) then the input element is not generated.
75
+ linkOnly?: boolean; // if true then the input element is not generated (this overrides label)
76
+ label?: boolean; // Make a link out of the label (causes text to be overridden) (this overrides text)
78
77
  form?: string; // can be used to generate a link to a custom schema
78
+ linktab?: string; // can be used to generate a link to a tab on a form
79
79
  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.
80
80
  }
81
81
 
82
+ export type FieldSizeString = 'mini' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'block-level'; // sets control width. Default is 'medium''
83
+
82
84
  export interface IFngSchemaTypeFormOpts {
83
85
  /*
84
86
  The input type to be generated - which must be compatible with the Mongoose type.
@@ -97,19 +99,21 @@ declare module fng {
97
99
  */
98
100
  type?: string;
99
101
 
100
- hidden?: boolean; // inhibits this schema key from appearing on the generated form.
101
- label?: string | null; // overrides the default input label. label:null suppresses the label altogether.
102
- ref?: IFngLookupReference | IFngInternalLookupReference;
103
-
102
+ hidden?: boolean; // inhibits this schema key from appearing on the generated form.
103
+ label?: string | null; // overrides the default input label. label:null suppresses the label altogether.
104
+ ref?: string; // reference to another collection
105
+ internalRef? : IFngInternalLookupReference;
106
+ lookupListRef?: IFngLookupListReference;
104
107
  id?: string; // specifies the id of the input field (which defaults to f_name)
105
108
 
106
109
  placeHolder?: string // adds placeholder text to the input (depending on data type).
107
110
  help?: string; // adds help text under the input.
108
111
  helpInline?: string; // adds help to the right of the input.
109
- popup?: string; // adds popup help as specified.
112
+ popup?: string; // adds title (popup help) as specified.
113
+ ariaLabel?: string; // adds aria-label as specified.
110
114
  order?: number; // allows user to specify the order / tab order of this field in the form. This overrides the position in the Mongoose schema.
111
- size?: 'mini' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge' | 'block-level'; // sets control width. Default is 'medium''
112
- readonly?: boolean; // adds the readonly attribute to the generated input (currently doesn't work with date - and perhaps other types).
115
+ size?: FieldSizeString;
116
+ readonly?: boolean | string; // adds the readonly or ng-readonly attribute to the generated input (currently doesn't work with date - and perhaps other types).
113
117
  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.
114
118
  tab?: string; // Used to divide a large form up into a tabset with multiple tabs
115
119
  showWhen?: IFngShowWhen | string; // allows conditional display of fields based on values elsewhere. string must be an abular expression.
@@ -123,8 +127,7 @@ declare module fng {
123
127
 
124
128
  class?: string; // allows arbitrary classes to be added to the input tag.
125
129
  inlineRadio?: boolean; // (only valid when type is radio) should be set to true to present all radio button options in a single line
126
- editor?: string; // (only valid when type is textarea) should be set to ckEditor to use CKEditor
127
- link?: IFngLinkSetup; // handles displaying links for IFngLookupReference lookups
130
+ link?: IFngLinkSetup; // handles displaying links for ref lookups
128
131
 
129
132
  /*
130
133
  With a select / radio type you can specify the options.
@@ -147,17 +150,28 @@ declare module fng {
147
150
  /*
148
151
  The next few options relate to the handling and display of arrays (including arrays of subdocuments)
149
152
  */
150
- noAdd?: boolean; // inhibits an Add button being generated for arrays.
153
+ noAdd?: boolean | string; // inhibits an Add button being generated for arrays.
154
+ noneIndicator?: boolean; // show "None" where there's no add button and no array items
151
155
  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.
152
- noRemove?: boolean; // inhibits a Remove button being generated for array elements.
153
- formstyle?: 'inline' | 'vertical' | 'horizontal' | 'horizontalCompact'; // (only valid on a sub schema) sets style of sub form.
154
- sortable? : boolean; // Allows drag and drop sorting of arrays - requires angular-ui-sortable
156
+ noRemove?: boolean | string; // inhibits a Remove button being generated for array elements.
157
+ formstyle?: formStyle; // (only valid on a sub schema) sets style of sub form.
158
+ sortable? : boolean | string; // Allows drag and drop sorting of arrays - requires angular-ui-sortable
159
+ 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
160
+ subDocContainerType?: 'fieldset' | 'well' | 'well-large' | 'well-small' | string | ((info) => {before: '', after: ''}); // allows each element in the array to be nested in a container
161
+ subDocContainerProps?: any; // the parameters that will be passed if subDocContainerType is a function
155
162
 
156
163
  /*
157
164
  The next section relates to the display of sub documents
158
165
  */
159
166
  customSubDoc?: string; // Allows you to specify custom HTML (which may include directives) for the sub doc
167
+ customHeader?: string; // Allows you to specify custom HTML (which may include directives) for the header of a group of sub docs
160
168
  customFooter?: string; // Allows you to specify custom HTML (which may include directives) for the footer of a group of sub docs
169
+
170
+ /*
171
+ Suppresses warnings about attenpting deep nesting which would be logged to console in some circumstances when a
172
+ directive fakes deep nesting
173
+ */
174
+ suppressNestingWarning? : boolean;
161
175
  }
162
176
 
163
177
  // Schema passed from server - derived from Mongoose schema
@@ -170,12 +184,15 @@ declare module fng {
170
184
  step? : number;
171
185
  }
172
186
 
187
+ export type fieldType = 'string' | 'text' | 'textarea' | 'number' | 'select' | 'link' | 'date' | 'checkbox' | 'password' | 'radio';
188
+
173
189
  // Schema used internally on client - often derived from IFieldViewInfo passed from server
174
190
  export interface IFormInstruction extends IFieldViewInfo {
175
191
  id? : string; // id of generated DOM element
176
- type?: 'string' | 'text' | 'textarea' | 'number' | 'select' | 'link' | 'date' | 'checkbox' | 'password';
177
- rows? : number
178
- label: string;
192
+ type?: fieldType;
193
+ defaultValue? : any;
194
+ rows? : number;
195
+ label?: string;
179
196
  options?: any;
180
197
  ids?: any;
181
198
  hidden?: boolean;
@@ -183,11 +200,38 @@ declare module fng {
183
200
  add? : string;
184
201
  ref? : any;
185
202
  link? : any;
186
- linkText?: string;
203
+ linktext?: string;
204
+ linklabel?: boolean;
187
205
  form?: string; // the form that is linked to
188
206
  select2? : any; // deprecated
207
+ schema?: IFormInstruction[]; // If the field is an array of fields
208
+ intType? : 'date';
209
+ [ directiveOptions: string] : any;
210
+ }
211
+
212
+ export interface IContainer {
213
+ /*
214
+ Type of container, which determines markup. This is currently only available when the schema is generated by
215
+ the client for use independent of the BaseController
216
+ In the case of a string which does not match one of the predefined options
217
+ the generated container div is given the class of the name
218
+ */
219
+ containerType: 'fieldset' | 'well' | 'tabset' | 'tab' | 'well-large' | 'well-small' | string;
220
+ title?: string;
221
+
222
+ /*
223
+ h1...h6 will use a header style
224
+ anything else will be used as a paragraph stype
225
+ */
226
+ titleTagOrClass? : string;
227
+ content: IFormInstruction[];
189
228
  }
190
229
 
230
+ export type IFormSchemaElement = IFormInstruction | IContainer;
231
+
232
+ export type IFormSchema = IFormSchemaElement[];
233
+ export type IControlledFormSchema = IFormInstruction[];
234
+
191
235
  export interface IEnumInstruction {
192
236
  repeat: string;
193
237
  value: string;
@@ -199,13 +243,13 @@ declare module fng {
199
243
  allowLocationChange: boolean; // Do we allow location change or prompt for permission
200
244
  }
201
245
  export interface IRecordHandler {
202
- convertToMongoModel(schema: Array<IFieldViewInfo>, anObject: any, prefixLength: number, scope: IFormScope): any;
203
- createNew(dataToSave: any, options: any, scope: IFormScope): void;
204
- deleteRecord(model: any, id: any, scope: IFormScope, ctrlState: any): void;
205
- updateDocument(dataToSave : any, options: any, scope: IFormScope, ctrlState: any) : void;
246
+ convertToMongoModel(schema: IControlledFormSchema, anObject: any, prefixLength: number, scope: IFormScope): any;
247
+ createNew(dataToSave: any, options: any, scope: IFormScope, ctrlState: IFngCtrlState): void;
248
+ deleteRecord(id: string, scope: IFormScope, ctrlState: IFngCtrlState): void;
249
+ updateDocument(dataToSave : any, options: any, scope: IFormScope, ctrlState: IFngCtrlState) : void;
206
250
  readRecord($scope: IFormScope, ctrlState);
207
251
  scrollTheList($scope: IFormScope);
208
- getListData($scope: IFormScope, record, fieldName, listSchema);
252
+ getListData(record, fieldName, listSchema?, $scope?: IFormScope);
209
253
  suffixCleanId(inst, suffix);
210
254
  setData(object, fieldname, element, value);
211
255
  setUpLookupOptions(lookupCollection, schemaElement, $scope: IFormScope, ctrlState, handleSchema);
@@ -221,13 +265,14 @@ declare module fng {
221
265
 
222
266
  export interface IFormGenerator {
223
267
  generateEditUrl(obj, $scope:IFormScope): string;
268
+ generateViewUrl(obj, $scope:IFormScope): string;
224
269
  generateNewUrl($scope: IFormScope): string;
225
270
  handleFieldType(formInstructions, mongooseType, mongooseOptions, $scope: IFormScope, ctrlState);
226
271
  handleSchema(description: string, source, destForm, destList, prefix, doRecursion: boolean, $scope: IFormScope, ctrlState);
227
272
  updateDataDependentDisplay(curValue, oldValue, force, $scope: IFormScope);
228
- add(fieldName, $event, $scope: IFormScope);
229
- unshift(fieldName, $event, $scope: IFormScope);
230
- remove(fieldName, value, $event, $scope: IFormScope);
273
+ add(fieldName: string, $event, $scope: IFormScope, modelOverride?: any);
274
+ unshift(fieldName: string, $event, $scope: IFormScope, modelOverride?: any);
275
+ remove(fieldName: string, value, $event, $scope: IFormScope, modelOverride?: any);
231
276
  hasError(formName, name, index, $scope: IFormScope);
232
277
  decorateScope($scope: IFormScope, formGeneratorInstance, recordHandlerInstance: IRecordHandler, sharedStuff);
233
278
  }
@@ -261,7 +306,9 @@ declare module fng {
261
306
  modelName: string;
262
307
  formName: string;
263
308
  alertTitle: any;
309
+ errorVisible: boolean;
264
310
  errorMessage: any;
311
+ errorHideTimer: number;
265
312
  save: any;
266
313
  newRecord: boolean;
267
314
  initialiseNewRecord?: any;
@@ -272,11 +319,10 @@ declare module fng {
272
319
  isCancelDisabled: any;
273
320
  isNewDisabled: any;
274
321
  isSaveDisabled: any;
275
- disabledText: any;
322
+ whyDisabled: string;
276
323
  unconfirmedDelete: boolean;
277
324
  getVal: any;
278
325
  sortableOptions: any;
279
- tabDeselect: any;
280
326
  tabs?: Array<any>; // In the case of forms that contain a tab set
281
327
  tab?: string; // title of the active tab - from the route
282
328
  activeTabNo?: number;
@@ -297,7 +343,8 @@ declare module fng {
297
343
  cancel: () => any;
298
344
  showError: (error: any, alertTitle? : string) => void;
299
345
  prepareForSave: (cb: (error: string, dataToSave?: any) => void) => void;
300
- formSchema: IFormInstruction[];
346
+ setDefaults: (formSchema: IFormSchema, base?: string) => any;
347
+ formSchema: IControlledFormSchema;
301
348
  baseSchema: () => Array<any>;
302
349
  setFormDirty: any;
303
350
  add: any;
@@ -309,24 +356,36 @@ declare module fng {
309
356
  skipCols: any;
310
357
  setPristine: any;
311
358
  generateEditUrl: any;
359
+ generateViewUrl: any;
312
360
  generateNewUrl: any;
313
361
  scrollTheList: any;
314
362
  getListData: any;
315
- dismissError: any;
363
+ phaseWatcher: any;
364
+ dismissError: () => void;
365
+ stickError: () => void;
366
+ clearTimeout: () => void;
316
367
  handleHttpError: (response: any) => void;
317
368
  dropConversionWatcher: () => void;
369
+ readingRecord?: Promise<any>;
370
+ onSchemaFetch?: (description: string, source: IFieldViewInfo[]) => void;
371
+ onSchemaProcessed?: (description: string, formSchema: IFormInstruction[]) => void;
372
+ updateQueryForTab?: (tab: string) => void;
373
+ tabDeselect?: ($event: any, $selectedIndex: number) => void;
374
+ setUpCustomLookupOptions?: (schemaElement: IFormInstruction, ids: string[], options: string[], baseScope: any) => void;
318
375
  }
319
376
 
320
377
  export interface IContextMenuDivider {
321
378
  divider: boolean;
322
379
  }
323
380
  export interface IContextMenuOption {
324
- // For it to make any sense, a menu option needs one of the next two properties
381
+ // For it to make any sense, a menu option needs one of the next three properties
325
382
  url?: string;
326
383
  fn?: () => void;
384
+ urlFunc?: () => string;
327
385
 
328
386
  text: string;
329
387
  isDisabled?: () => boolean;
388
+ isHidden?: () => boolean;
330
389
 
331
390
  // Does the option appear in the following contexts?
332
391
  listing: boolean;
@@ -337,7 +396,8 @@ declare module fng {
337
396
  export interface IModelController extends IFormScope {
338
397
  onBaseCtrlReady? : (baseScope: IFormScope) => void; // Optional callback after form is instantiated
339
398
  onAllReady? : (baseScope: IFormScope) => void; // Optional callback after form is instantiated and populated
340
- contextMenu? : Array<IContextMenuOption | IContextMenuDivider>
399
+ contextMenu? : Array<IContextMenuOption | IContextMenuDivider>;
400
+ contextMenuPromise? : Promise<Array<IContextMenuOption | IContextMenuDivider>>;
341
401
  }
342
402
 
343
403
  export interface IBaseFormOptions {
@@ -345,7 +405,7 @@ declare module fng {
345
405
  * The style of the form layout. Supported values are horizontalcompact, horizontal, vertical, inline
346
406
  */
347
407
  //TODO supported values should be in an enum
348
- formstyle?: string;
408
+ formstyle?: formStyle;
349
409
  /**
350
410
  * Model on form scope (defaults to record).
351
411
  * <li><strong>model</strong> the object in the scope to be bound to the model controller. Specifying
@@ -360,6 +420,11 @@ declare module fng {
360
420
  * Normally first field in a form gets autofocus set. Use this to prevent this
361
421
  */
362
422
  noautofocus?: string;
423
+ /*
424
+ Suppress the generation of element ids
425
+ (sometimes required when using nested form-inputs in a directive)
426
+ */
427
+ noid? : boolean;
363
428
  }
364
429
 
365
430
  export interface IFormAttrs extends IFormOptions, angular.IAttributes {
@@ -368,6 +433,7 @@ declare module fng {
368
433
  */
369
434
  schema : string;
370
435
  forceform?: string; // Must be true or omitted. Forces generation of the <strong>form</strong> tag when model is specified
436
+ noid? : boolean;
371
437
  }
372
438
 
373
439
  export interface IFormOptions extends IBaseFormOptions {
@@ -376,6 +442,8 @@ declare module fng {
376
442
  subkeyno?: number;
377
443
  subschema? : string;
378
444
  subschemaroot? : string;
445
+ viewform? : boolean;
446
+ suppressNestingWarning? : boolean;
379
447
  }
380
448
 
381
449
  export interface IBuiltInRoute {
@@ -401,6 +469,7 @@ declare module fng {
401
469
 
402
470
  variantsForDemoWebsite? : any; // Just for demo website
403
471
  variants?: any; // Just for demo website
472
+ 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
404
473
  }
405
474
 
406
475
  export interface IFngRoute {
@@ -416,4 +485,4 @@ declare module fng {
416
485
 
417
486
  }
418
487
 
419
- declare var formsAngular: angular.IModule;
488
+ declare var formsAngular: fng.IFng;