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