forms-angular 0.12.0-beta.31 → 0.12.0-beta.310

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.
@@ -0,0 +1,136 @@
1
+ import { Error, FilterQuery, Model, Types } from "mongoose";
2
+ import {Express} from "express";
3
+
4
+ declare module fngServer {
5
+ export interface ISearchResult {
6
+ id: any,
7
+ text: string,
8
+ url?: string,
9
+ additional?: string,
10
+ resource?: string,
11
+ resourceText: string,
12
+ resourceTab?: string,
13
+ weighting: number,
14
+ }
15
+
16
+ interface IInternalSearchResult extends ISearchResult {
17
+ // for use in internal find - handles search result ordering etc.
18
+ searchImportance? : number;
19
+ addHits?: number;
20
+ matched: number[];
21
+ resourceCollection: string;
22
+ // the next two are only set where the resource options includes disambiguation instructions and multiple search results with the same text value are found...:
23
+ disambiguationId?: any; // this will identify the record (from another resource) that will be used to disambiguate them
24
+ disambiguationResource?: string ;// ...and this will identify that resource
25
+ }
26
+
27
+ export interface IIdIsList {
28
+ params: string;
29
+ }
30
+
31
+ export interface Path {
32
+ }
33
+
34
+ export interface Paths {
35
+ [pathName: string]: Path;
36
+ }
37
+
38
+ export type ISearchResultFormatter = () => Promise<ISearchResult>;
39
+
40
+ export type Dependency = {
41
+ resource: Resource;
42
+ keys: string[];
43
+ }
44
+
45
+ export type DependencyList = Dependency[];
46
+
47
+ export type ForeignKeys = { resourceName: string, key: string, id: Types.ObjectId};
48
+ export type ForeignKeyList = ForeignKeys[];
49
+
50
+ export interface ResourceOptions {
51
+ suppressDeprecatedMessage?: boolean;
52
+ onRemove?: (doc, req, cb) => void;
53
+ handleRemove?: 'allow' | 'cascade'; // default behaviour is to prevent deletion if record is used as a foreign key
54
+ searchImportance?: boolean | number,
55
+ onSave?: (doc, req, cb) => void,
56
+ onSaveError?: (err:Error, req: Express.Request, res: Express.Response) => void,
57
+ findFunc?: (req: Express.Request, cb: (err:Error, criteria?: FilterQuery<any>) => void) => void,
58
+ getOrgCriteria?: (userOrganisation: string) => Promise<any>
59
+ idIsList?: IIdIsList,
60
+ searchResultFormat?: ISearchResultFormatter,
61
+ searchOrder?: any,
62
+ doNotCacheSchema?: boolean, // useful if bespoke fields can be added at runtime, for instance
63
+ listOrder?: any,
64
+ onAccess?: (req, cb) => void,
65
+ searchFunc?: SearchFunc;
66
+ synonyms? : {name: string, filter?: any}[], // name must be lower case
67
+ resourceName?: string, // allows a resource to have diference modelName specified
68
+ // when performing a search, two results from this resource with the same value for .text will be disambiguated by
69
+ // appending the description of the record from disambiguation.resource whose id matches result[disambiguation.field]
70
+ disambiguation?: {
71
+ field: string;
72
+ resource: string;
73
+ }
74
+ // below here are autogenerated
75
+ listFields?: ListField[]; // added after preprocess
76
+ dependents?: DependencyList; // can be added by generateDependencyList
77
+ hide? : string[]; // added after preprocess
78
+ searchFields? : string[]; // added after preprocess
79
+ paths?: Paths;
80
+ }
81
+
82
+ type SearchFunc = (resource: Resource,
83
+ req: Express.Request,
84
+ aggregationParam: any,
85
+ findParam: any,
86
+ sortOrder: any,
87
+ limit: number | null,
88
+ skip: number | null,
89
+ callback: (err: Error, docs?: any[]) => void
90
+ ) => void;
91
+
92
+ interface ResourceExport {
93
+ model?: Model<any>; // TODO TS Get rid of the ? here
94
+ options?: ResourceOptions;
95
+ }
96
+
97
+ interface Resource extends ResourceExport {
98
+ resourceName: string;
99
+ resourceNameLower: string;
100
+ preprocessed?: {[formName: string] : any};
101
+ }
102
+
103
+ interface ListParams {
104
+ ref: Boolean; // The object is this a lookup?
105
+ }
106
+
107
+ interface ListField {
108
+ field: string;
109
+ params?: ListParams;
110
+ }
111
+
112
+ interface IFngPlugin {
113
+ plugin: (fng: any, processArgs: (options: FngOptions, array: any[]) => any[], options: any) => Partial<IFngPlugin>;
114
+ options: any;
115
+ dependencyChecks? : { [resourceName: string] : DependencyList; };
116
+ }
117
+
118
+ interface IPluginMap {
119
+ [key: string]: IFngPlugin;
120
+ }
121
+
122
+ interface FngOptions {
123
+ urlPrefix?: string,
124
+ plugins?: IPluginMap,
125
+ authentication?: (() => void)[];
126
+ modelFilter? : (p1: any, req: Request, resources: Resource[]) => Resource[]
127
+ }
128
+
129
+ type AmbiguousRecordStore<t> = { [resource: string]: t[] };
130
+
131
+ interface DisambiguatableLookupItem {
132
+ id: string;
133
+ text: string;
134
+ disambiguationId?: string;
135
+ }
136
+ }
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "Mark Chapman <support@forms-angular.org>",
4
4
  "description": "A form builder that sits on top of Angular.js, Twitter Bootstrap, jQuery UI, Angular-UI, Express and Mongoose. Opinionated or what?",
5
5
  "homepage": "http://forms-angular.org",
6
- "version": "0.12.0-beta.31",
6
+ "version": "0.12.0-beta.310",
7
7
  "engines": {
8
8
  "node": ">=8.x",
9
9
  "npm": ">=5.x"
@@ -12,10 +12,10 @@
12
12
  "build": "If this is not a production install we need bootstrap less files for building, and use bower to load them. Couldn't figure out how to load two versions of same library with npm - PRs welcome."
13
13
  },
14
14
  "scripts": {
15
- "pretest": "npm run build",
16
15
  "test": "gulp test",
17
16
  "tidy": "find . -name '*.js' -not -path '**/node_modules/**' -and -not -path '**/website/**' -and -not -path '**/test/**' -and -not -path '**/models/**' -and -not -name 'gulpfile.js' -and -not -name 'index.js' -and -not -name 'Gruntfile.js' -and -not -name '*.conf.js' -delete && find . -name '*.map' -not -path '**/node_modules/**' -delete",
18
- "build": "if [ -d 'node_modules/bower' ]; then bower install --config.directory=node_modules --production jquery@2.0.3 bootstrap-2-3-2=git://github.com/twbs/bootstrap.git#v2.3.2 bootstrap-3-4-0=git://github.com/twbs/bootstrap.git#v3.4.0; fi && gulp build"
17
+ "build": "if [ -d 'node_modules/bower' ]; then npx bower install --config.directory=node_modules --production jquery@2.0.3 bootstrap-2-3-2=git://github.com/twbs/bootstrap.git#v2.3.2 bootstrap-3-4-0=git://github.com/twbs/bootstrap.git#v3.4.0; fi && gulp build",
18
+ "reset": "cd website && rm -rf node_modules && npm install && cd .. && rm -rf node_modules && npm install && npm run build"
19
19
  },
20
20
  "files": [
21
21
  "dist"
@@ -42,58 +42,58 @@
42
42
  "RESTful API"
43
43
  ],
44
44
  "dependencies": {
45
- "angular": "1.7.8",
45
+ "angular": "1.8.3",
46
46
  "angular-elastic": "2.5.1",
47
- "angular-messages": "1.7.8",
48
- "angular-sanitize": "1.7.8",
47
+ "angular-messages": "1.8.3",
48
+ "angular-sanitize": "1.8.3",
49
49
  "angular-ui-bootstrap": "1.3.2 || 2.5.6",
50
- "angular-ui-grid": "^4.7.1",
51
- "async": "2.6.2",
52
- "fng-reports": "^0.12.0-beta.31",
53
- "fng-ui-select": "^0.12.0-beta.31",
54
- "lodash": "4.17.11",
50
+ "angular-ui-grid": "4.12.7",
51
+ "async": "3.2.5",
52
+ "lodash": "^4.17.21",
55
53
  "ng-infinite-scroll": "1.3.0",
56
- "node.extend": "2.0.2"
54
+ "node.extend": "2.0.3"
57
55
  },
58
56
  "peerDependencies": {
59
- "express": "^4.16.4",
60
- "mongoose": "^5.4.10"
57
+ "express": "^4",
58
+ "mongoose": "^7.3.3 || ^8"
61
59
  },
62
60
  "devDependencies": {
63
- "@types/angular": "1.6.54",
64
- "@types/lodash": "4.14.123",
65
- "@types/mongoose": "5.3.22",
66
- "@types/node": "^10.14.1",
67
- "angular-mocks": "1.7.8",
68
- "body-parser": "1.18.3",
69
- "bower": "^1.8.8",
70
- "del": "4.0.0",
71
- "express": "4.16.4",
72
- "gulp": "^4.0.0",
73
- "gulp-angular-templatecache": "2.2.6",
74
- "gulp-clean-css": "4.0.0",
61
+ "@types/angular": "1.8.9",
62
+ "@types/lodash": "4.17.5",
63
+ "@types/mocha": "^10.0.7",
64
+ "@types/node": "=20.0.0",
65
+ "@types/vinyl": "^2.0.12",
66
+ "angular-mocks": "1.8.3",
67
+ "body-parser": "1.20.2",
68
+ "bower": "^1.8.14",
69
+ "del": "=6.1.1",
70
+ "express": "4.19.2",
71
+ "gulp": "^4.0.2",
72
+ "gulp-angular-templatecache": "3.0.1",
73
+ "gulp-clean-css": "4.3.0",
75
74
  "gulp-concat": "2.6.1",
76
- "gulp-less": "4.0.1",
77
- "gulp-mocha": "6.0.0",
75
+ "gulp-less": "5.0.0",
76
+ "gulp-mocha": "=9.0.0",
78
77
  "gulp-ng-annotate": "2.1.0",
79
- "gulp-rename": "1.4.0",
80
- "gulp-replace": "^1.0.0",
81
- "gulp-typescript": "5.0.1",
78
+ "gulp-rename": "2.0.0",
79
+ "gulp-replace": "^1.1.4",
80
+ "gulp-typescript": "6.0.0-alpha.1",
82
81
  "gulp-uglify": "3.0.2",
83
82
  "gulp-umd": "2.0.0",
84
- "jasmine-core": "3.3.0",
85
- "karma": "^4.0.1",
86
- "karma-chrome-launcher": "2.2.0",
87
- "karma-firefox-launcher": "^1.1.0",
88
- "karma-jasmine": "2.0.1",
89
- "karma-junit-reporter": "1.2.0",
83
+ "jasmine-core": "5.1.2",
84
+ "karma": "^6.4.3",
85
+ "karma-chrome-launcher": "^3.2.0",
86
+ "karma-firefox-launcher": "^2.1.3",
87
+ "karma-jasmine": "5.1.0",
88
+ "karma-junit-reporter": "2.0.1",
90
89
  "karma-ng-html2js-preprocessor": "1.0.0",
91
90
  "matchdep": "2.0.0",
92
- "mocha": "6.0.2",
93
- "mongoose": "5.4.19",
94
- "prettier": "1.16.4",
91
+ "mocha": "^10.4.0",
92
+ "mongoose": "=7.6.8",
93
+ "mongodb": "=5.9.1",
94
+ "prettier": "3.3.2",
95
95
  "pump": "3.0.0",
96
- "typescript": "3.3.3333"
96
+ "typescript": "=4.9.5"
97
97
  },
98
98
  "license": "MIT"
99
99
  }
package/CHANGELOG.md DELETED
@@ -1,256 +0,0 @@
1
- # forms-angular
2
-
3
- ## 0.12.0
4
- * Added $scope.prepareForSave API which enables easier persistence from forms not under the controller of baseCtrl (forms in modal dialogs, for example).
5
- * Handle date fields properly without a plugin
6
- * Fix duplicate ids in _select_ elements
7
- ### BREAKING CHANGES
8
- * Removed $data service (global stash). In almost all places $data.xx can be replaced by $scope.sharedData.xx
9
- * Deprecate dataEventFunctions.onInitialiseNewRecord(data) - a synchronous function in favour of dataEventFunctions.onInitialiseNewRecord(data, cb(err))
10
-
11
- ## 0.11.0 - 8 Dec 2017
12
- * Menu options can now be added after a promise is resolved by creating a contextMenuPromise on the controller $scope which resolves to a contextMenu array.
13
- * Added new registerAction method on the routing service (used by the fng-audit plugin)
14
- * Replaced underscore with lodash
15
- * Numerous small fixes (mostly to code that interacts with plugins)
16
- * Improved styling of invalid fields
17
-
18
-
19
- ## 0.10.x
20
- Skipped to keep version numbers in sync with plugins
21
-
22
- ## 0.8.x to 0.9.0
23
- * Remove support for (long deprecated) [fng-select2](https://github.com/forms-angular/fng-select2) in favour of (improved)
24
- [fng-ui-select](https://github.com/forms-angular/fng-ui-select).
25
- * Use [Angular UI Grid](http://ui-grid.info/) instead of older [ng-grid](https://github.com/angular-ui/ui-grid/tree/2.x)
26
- in [fng-reports](https://github.com/forms-angular/fng-reports).
27
-
28
- ## 0.7.0 to 0.8.1
29
- * Move to Angular 1.6.x
30
- * Allow adding _id to list fields
31
- * Fix bug with routing to specific tab (such as /#/collection/id/edit/tab1)
32
- ### BREAKING CHANGES
33
- * The server side of forms angular is now passed a Mongoose instance:
34
- ```
35
- var formsAngular = require('forms-angular');
36
- var express = require('express');
37
- var mongoose = require('mongoose');
38
-
39
- var app = express();
40
- var fng = new (formsAngular)(mongoose, app, {});
41
- ```
42
- * If your application calls recordHandler.handleError (typically from a controller) then you will need
43
- to pass a response object rather than (data:any, status: number)
44
-
45
- ## 0.6.0 to 0.7.0
46
- * Removed support for Bootstrap 2 (just in time for Bootstrap 4?)
47
- * Fixed bug with ui-router setup which meant that full routes were not parsed.
48
- * Added internal templates for lists, edit forms and report forms (previously they were in the Yeoman generator).
49
- * Internal templates can be over-ridden by specifying a templateFolder property in the routing config.
50
- ### BREAKING CHANGES
51
- * To use the edit / list / report templates from a pre 0.7.0 application you must specify a templateFolder property of 'partials' when starting the routingService when configuring forms-angular
52
- * Removed support for Bootstrap 2 (though your BS2 apps should still work - www.forms-angular.org is still BS2)
53
- * Some changes required by updating angular-ui-bootstrap dependency. In particular drop down menus now need uib-dropdown-menu to be an attribute not a class
54
-
55
- ## 0.5.1 to 0.6.0
56
- * Upgrade to angular-ui-bootstrap 0.14.x, which drops support for Bootstrap 2 (but seems to work fine for the forms-angular.org website, which is BS2)
57
- * Start specifying versions in npm and bower.
58
- * Several small fixes
59
-
60
- ## 0.5.0 to 0.5.1
61
- * Fix stupid dependency error for Angular
62
-
63
- ## 0.4 to 0.5
64
- ### Summary
65
- * Changed development language to typescript and added _some_ types
66
- * Moved to gulp for build processing
67
- * Added ng-messages for field level errors
68
- * Required and readonly now work consistently across input types
69
- * Added error-display directive for form level errors
70
- * Some styling improvements for required fields and mobile
71
- * Added support for ui-select plugin, and in so doing added new services (formMarkupHelper, pluginHelper) that make it
72
- much easier to add new plugins.
73
-
74
- ### BREAKING CHANGES
75
- * Changed id generation to remove . characters. This may break some tests (but the . characters themselves were upsetting
76
- some testing software).
77
- * Removed body padding from styling. If you use a navbar you should put body {padding-top: 40px} (or required navbar height) in your styling.
78
- * Hidden fields that are also list fields are still not displayed on forms, but now _are_ added to the list schema (so appear in lookups etc).
79
-
80
- ## 0.3 to 0.4
81
- ### Summary
82
- * Split the project into multiple repos and made a yeoman generator
83
- * Removes dependence on jQuery
84
- * ngRoute is no longer a dependency - either ngRoute or ui.router can be used, and a new provider allows the choice to be
85
- set up as follows:
86
- ```
87
- formsAngular.config(['routingServiceProvider', function (routingService) {
88
- routingService.setOptions({html5Mode: true, routing: 'ngroute'});
89
- }]);
90
- ```
91
- This service incorporates some of the functionality of the old form routes provider and supersedes urlService and
92
- locationParse.
93
-
94
- For example in 0.3.x where you had something like:
95
- ```
96
- plaitApp.config(['formRoutesProvider', function (formRoutes) {
97
- formRoutes.setRoutes([
98
- {route: '/index', options: {templateUrl: 'partials/menu.html'}},
99
- {route: '/login', options: {templateUrl: 'partials/login.html' }},
100
- {route: '/client/referral', options: {templateUrl: 'partials/upload', controller: 'ClientReferralCtrl'}}
101
- ], '/index');
102
- ```
103
- you would have something like
104
- ```
105
- formsAngular.config(['routingServiceProvider', function (routingService) {
106
- routingService.start({
107
- routing: 'ngroute',
108
- fixedRoutes: [
109
- {route: '/index', options: {templateUrl: 'partials/menu.html'}},
110
- {route: '/login', options: {templateUrl: 'partials/login.html' }},
111
- {route: '/404', options: {templateUrl: 'partials/404.html'}},
112
- {route: '/client/referral', options: {templateUrl: 'partials/upload', controller: 'ClientReferralCtrl'}}
113
- ]
114
- });
115
- ```
116
- * The ability to add a routing prefix has been added
117
-
118
- ### BREAKING CHANGES
119
- * List API returns only one field when no list fields defined (as happens on the client).
120
- * Hidden list fields now appear on list API response.
121
- * In BaseCtrl $scope.new() and $scope.delete() have been renamed ('Click' added)
122
- *
123
-
124
- ## 0.2 to 0.3
125
- ### Summary
126
- * Improvements to routing:
127
- * Module specific routes are now specified with a call to the setRoutes(appRoutes, defaultRoute) method of an injected
128
- formRoutesProvider - see the breaking changes section for an example and details.
129
- * Support for HTML5Mode and hashPrefix, including a service to simplify use
130
- * Support for Twitter Bootstrap 3, including a service to simplify use. To use Bootstrap 3 you need to upgrade a few of the
131
- libraries that Bower installs. Change the following lines in bower.json:
132
- ```
133
- "angular-ui-bootstrap-bower": "0.8.0",
134
- "bootstrap": "2.3.2",
135
- "select2-bootstrap-css": "~1.2",
136
- ```
137
- to
138
- ```
139
- "angular-ui-bootstrap-bower": "0.11.0",
140
- "bootstrap": "3.1.1",
141
- "select2-bootstrap-css": "~1.3",
142
- ```
143
-
144
-
145
- ### BREAKING CHANGES
146
- * Routing has changed - replace
147
- ```
148
- myModule.config(['$routeProvider', function ($routeProvider) {
149
- $routeProvider.
150
- when('/index', {templateUrl: 'partials/landing-page.html'}).
151
- when('/someRoute', {templateUrl: 'partials/someTemplate.html'}).
152
- ... etc ...
153
- when('/analyse/:model/:reportSchemaName', {templateUrl: 'partials/base-analysis.html'}).
154
- when('/analyse/:model', {templateUrl: 'partials/base-analysis.html'}).
155
- when('/:model/:id/edit', {templateUrl: 'partials/base-edit.html'}).
156
- when('/:model/new', {templateUrl: 'partials/base-edit.html'}).
157
- when('/:model', {templateUrl: 'partials/base-list.html'}).
158
- when('/:model/:form/:id/edit', {templateUrl: 'partials/base-edit.html'}). // non default form (different fields etc)
159
- when('/:model/:form/new', {templateUrl: 'partials/base-edit.html'}). // non default form (different fields etc)
160
- when('/:model/:form', {templateUrl: 'partials/base-list.html'}). // list page with links to non default form
161
- otherwise({redirectTo: '/index'});
162
- }]);
163
- ```
164
- with
165
- ```
166
- myModule.config(['formRoutesProvider', function (formRoutes) {
167
- formRoutes.setRoutes([
168
- {route:'/index', options:{templateUrl: 'partials/landing-page.html'}},
169
- {route:'/someRoute', options:{templateUrl: 'partials/someTemplate.html'}}
170
- ], '/index');
171
- }]);
172
- ```
173
- where the first parameter is an array of objects containing a route and a set of options (which are passed straight to
174
- [$routeProvider](http://docs.angularjs.org/api/ngRoute/provider/$routeProvider) and the second parameter is the default route.
175
- * Stylesheets have moved down into a ./css folder relative to where they were, and there
176
- are now Bootstrap 2 and Bootstrap 3 versions.
177
- * You should initialise formsAngular with something similar to:
178
- ```
179
- formsAngular.config(['urlServiceProvider', 'cssFrameworkServiceProvider', function (urlService, cssFrameworkService) {
180
- urlService.setOptions({html5Mode: false, hashPrefix: '!'});
181
- cssFrameworkService.setOptions({framework: 'bs2'}); // bs2 and bs3 are supported
182
- }]);
183
- ```
184
- * Report drilldowns now start from the model
185
- ```
186
- drilldown: '/#/g_conditional_fields/!_id!/edit'
187
- drilldown: '/#!/g_conditional_fields/|_id|/edit'
188
- ```
189
- both become
190
- ```
191
- drilldown: 'g_conditional_fields/|_id|/edit'
192
- ```
193
-
194
- ## 0.1 to 0.2
195
- ### Summary
196
- * Support for radio button groups, CKEditor
197
- * Internal changes to make better use of Angular JS forms capabilities
198
- * Added support for HTML5 input capabilities: pattern, min, max, step
199
- * All lookups are now handled as {id:xxx, text:yyy} on the client
200
- * default ids now generated by form directive (and no longer by BaseCtrl)
201
- * Added customFooter and customSubDoc for sub docs
202
- * Improvements to search: now a directive; makes use of arrow keys and escape; some bug fixes
203
- * showWhen conditional field display introduced (showIf will probably be deprecated)
204
-
205
- ### BREAKING CHANGES
206
- * Changed form-input directive so that it creates a form tag, and rather than creating a <form-input>
207
- per sub document it now creates a <ng-form> and builds the sub-form in the same pass. Only when using
208
- directives are multiple passes required.
209
- * Bespoke directives that use schema need to be modified (changes will normally be from something like
210
- ```
211
- var info = scope[attrs.schema][0];
212
- ```
213
- to
214
- ```
215
- var info = scope[attrs.schema];
216
- ```
217
- * Password type is still used generated automatically if the label contains the string 'password', but the override
218
- method is now to use the form type (password is it is a password, text if not).
219
- * We have followed ui-bootstrap's renaming of tabs / panes to tabsets / tabs, so any use of "pane" in your form objects
220
- needs to be changed to tab.
221
- * Support for allowing crawling meant that !(shriek) had to be replaced with |(pipe) in report drill down urls replacement
222
- * Some default id formats changed in subdocuments, which may affect tests etc
223
-
224
- ## 0.0.x to 0.1.0
225
- ### Summary
226
- * Started CHANGELOG.md (but for now it is far from definitive, but is intended to include all breaking changes)
227
- * Added support for containers (documented in Custom Form Schemas section of documentation)
228
- * Added reporting capability
229
- * New website
230
-
231
- ### BREAKING CHANGES
232
- * Changes form-input directive so that it expects
233
- ```
234
- <form-input schema="formSchema">
235
- ```
236
- instead of
237
- ```
238
- <form-input ng-repeat="field in formSchema" info={{field}}>
239
- ```
240
- * findFunc option now returns a query object such as
241
- ```
242
- {field:'value'}
243
- ```
244
- rather than a MongooseJS Query such as
245
- ```
246
- model.find().where('field', 'value')
247
- ```
248
- * Bespoke directives that use schema need to be modified (changes will normally be from something like
249
- ```
250
- var info = JSON.parse(attrs.info);
251
- ```
252
- to
253
- ```
254
- var info = scope[attrs.schema][0];
255
- ```
256
- * One formInputDone is broadcast per form (instead of per field).