fng-ui-select 0.12.0-beta.17 → 0.12.0-beta.173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/cypress/integration/lists.spec.js +54 -0
- package/cypress/integration/lists.spec.ts +60 -0
- package/cypress/plugins/index.js +21 -0
- package/cypress/support/commands.js +25 -0
- package/cypress/support/index.js +20 -0
- package/cypress/tsconfig.json +14 -0
- package/cypress.json +4 -0
- package/package.json +7 -6
- package/src/fng-ui-select.js +71 -34
- package/styles/fng-ui-select.css +20 -4
- package/test/e2e/{multi-control.spec.js → protractor/multi-control.spec.js} +0 -0
- package/test/e2e/{multiple-control.spec.js → protractor/multiple-control.spec.js} +0 -0
- package/test/e2e/{protractor-chrome.conf.js → protractor/protractor-chrome.conf.js} +0 -0
- package/test/e2e/{protractor-firefox.conf.js → protractor/protractor-firefox.conf.js} +0 -0
- package/test/e2e/{protractor-phantom.conf.js → protractor/protractor-phantom.conf.js} +0 -0
- package/test/e2e/protractor/protractor-wip.conf.js +10 -0
- package/test/e2e/{single-control.spec.js → protractor/single-control.spec.js} +0 -0
- package/test/e2e/{single-within-array.spec.js → protractor/single-within-array.spec.js} +36 -36
- package/test/e2e/protractor-wip.conf.js +0 -11
- package/test/e2e/test/screen_tests/screenshots/firefox-Multi control-should convert multi ajax lookups into multiple controls.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multi control-should handle inside cached lookups.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multi control-should handle outside cached lookups.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multi control-should handle simple enum.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multiple controls array-should handle inside brackets ajax lookup.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multiple controls array-should handle inside brackets cached table lookups.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multiple controls array-should handle outside brackets ajax lookup.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multiple controls array-should handle outside brackets cached table lookups.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Multiple controls array-should handle simple enums.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Single control-should handle Ajax lookup.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Single control-should handle cached table lookup.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Single control-should handle filtered Ajax lookup.png +0 -0
- package/test/e2e/test/screen_tests/screenshots/firefox-Single control-should handle simple enum.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multi control-should convert multi ajax lookups into multiple controls.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multi control-should handle inside cached lookups.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multi control-should handle outside cached lookups.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multi control-should handle simple enum.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multiple controls array-should handle inside brackets ajax lookup.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multiple controls array-should handle inside brackets cached table lookups.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multiple controls array-should handle outside brackets ajax lookup.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multiple controls array-should handle outside brackets cached table lookups.png +0 -0
- package/test/screen_tests/screenshots/firefox-Multiple controls array-should handle simple enums.png +0 -0
- package/test/screen_tests/screenshots/firefox-Single control-should handle Ajax lookup.png +0 -0
- package/test/screen_tests/screenshots/firefox-Single control-should handle cached table lookup.png +0 -0
- package/test/screen_tests/screenshots/firefox-Single control-should handle filtered Ajax lookup.png +0 -0
- package/test/screen_tests/screenshots/firefox-Single control-should handle simple enum.png +0 -0
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@ Options can be added to a fngUiSelect object within the form object as follows:
|
|
|
27
27
|
back to _select2_.
|
|
28
28
|
* _fngAjax_ creates a control that queries the back end after each keystroke (with 100ms of debounce) for matches.
|
|
29
29
|
* Set to true to search the whole of the _ref_ collection (honouring any collection level filters)
|
|
30
|
-
* Assign a string starting with '/' to do your own query on the backend. The search string will be in _req.query.q_ and the current value of the existing record in _req.query.e_.
|
|
30
|
+
* Assign a string starting with '/' to do your own query on the backend. The search string will be in _req.query.q_ and the current value of the existing record in _req.query.e_. The $index will be in _req.query.i_.
|
|
31
31
|
* Use a mongo search object (converted to JSON and escaped) to apply a filter to the default search over _ref_ collection. For example to search
|
|
32
32
|
only amongst records where the value of *accountSuspended* is false you might do
|
|
33
33
|
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
describe('Lists', function () {
|
|
3
|
+
var width = 1800;
|
|
4
|
+
var height = 1500;
|
|
5
|
+
var unique = new Date().valueOf();
|
|
6
|
+
beforeEach(function () {
|
|
7
|
+
cy.viewport(width, height);
|
|
8
|
+
});
|
|
9
|
+
it('Creates a new record with multiple shelves', function () {
|
|
10
|
+
cy.visit('/#/k_referencing_self_collection/new');
|
|
11
|
+
cy.get('#f_warehouse_name').type("m" + unique + " Warehouse");
|
|
12
|
+
cy.get('#add_f_shelves_btn').click().click().click();
|
|
13
|
+
cy.get('#f_shelvesList_0 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Top');
|
|
14
|
+
cy.get('#f_shelvesList_1 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Middle');
|
|
15
|
+
cy.get('#f_shelvesList_2 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Bottom');
|
|
16
|
+
cy.get('#add_f_items_btn').click();
|
|
17
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_description > .controls > .ng-pristine').type('Item 1');
|
|
18
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_shelf > .controls > .ng-pristine').select('Middle');
|
|
19
|
+
cy.get('#add_f_cleanedShelves').click().click();
|
|
20
|
+
cy.get('#f_cleanedShelves_0').select('Middle');
|
|
21
|
+
cy.get('#f_cleanedShelves_1').select('Top');
|
|
22
|
+
cy.get('#f_favouriteShelf').select('Bottom');
|
|
23
|
+
cy.get('#saveButton').click();
|
|
24
|
+
});
|
|
25
|
+
it('Creates a new record with a single shelf', function () {
|
|
26
|
+
cy.visit('/#/k_referencing_self_collection/new');
|
|
27
|
+
cy.get('#f_warehouse_name').type("s" + unique + " Warehouse");
|
|
28
|
+
cy.get('#add_f_shelves_btn').click();
|
|
29
|
+
cy.get('#f_shelvesList_0 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Only');
|
|
30
|
+
cy.get('#add_f_items_btn').click();
|
|
31
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_description > .controls > .ng-pristine').type('Item 1');
|
|
32
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_shelf > .controls > .ng-pristine').select('Only');
|
|
33
|
+
cy.get('#add_f_cleanedShelves').click();
|
|
34
|
+
cy.get('#f_cleanedShelves_0').select('Only');
|
|
35
|
+
cy.get('#f_favouriteShelf').select('Only');
|
|
36
|
+
cy.get('#saveButton').click();
|
|
37
|
+
});
|
|
38
|
+
it('Uses record with multiple shelves', function () {
|
|
39
|
+
cy.visit('/#/l_referencing_list_in_other_document/new');
|
|
40
|
+
cy.get('#f_description').type('An item in multi');
|
|
41
|
+
cy.get('.select2-arrow > b').click();
|
|
42
|
+
cy.get('.ui-select-search').type("m" + unique);
|
|
43
|
+
cy.get('.select2-result-label > .ng-binding').click();
|
|
44
|
+
cy.get('#f_shelf').select('Top');
|
|
45
|
+
});
|
|
46
|
+
it('Uses record with single shelf', function () {
|
|
47
|
+
cy.visit('/#/l_referencing_list_in_other_document/new');
|
|
48
|
+
cy.get('#f_description').type('An item in single');
|
|
49
|
+
cy.get('.select2-arrow > b').click();
|
|
50
|
+
cy.get('.ui-select-search').type("s" + unique);
|
|
51
|
+
cy.get('.select2-result-label > .ng-binding').click();
|
|
52
|
+
cy.get('#f_shelf').select('Only');
|
|
53
|
+
});
|
|
54
|
+
});
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
describe('Lists', function () {
|
|
2
|
+
|
|
3
|
+
var width = 1800;
|
|
4
|
+
var height = 1500;
|
|
5
|
+
|
|
6
|
+
let unique = new Date().valueOf();
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
cy.viewport(width, height);
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('Creates a new record with multiple shelves', function () {
|
|
12
|
+
cy.visit('/#/k_referencing_self_collection/new');
|
|
13
|
+
cy.get('#f_warehouse_name').type(`m${unique} Warehouse`);
|
|
14
|
+
cy.get('#add_f_shelves_btn').click().click().click();
|
|
15
|
+
cy.get('#f_shelvesList_0 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Top');
|
|
16
|
+
cy.get('#f_shelvesList_1 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Middle');
|
|
17
|
+
cy.get('#f_shelvesList_2 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Bottom');
|
|
18
|
+
cy.get('#add_f_items_btn').click();
|
|
19
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_description > .controls > .ng-pristine').type('Item 1');
|
|
20
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_shelf > .controls > .ng-pristine').select('Middle');
|
|
21
|
+
cy.get('#add_f_cleanedShelves').click().click();
|
|
22
|
+
cy.get('#f_cleanedShelves_0').select('Middle');
|
|
23
|
+
cy.get('#f_cleanedShelves_1').select('Top');
|
|
24
|
+
cy.get('#f_favouriteShelf').select('Bottom');
|
|
25
|
+
cy.get('#saveButton').click();
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it('Creates a new record with a single shelf', function () {
|
|
29
|
+
cy.visit('/#/k_referencing_self_collection/new');
|
|
30
|
+
cy.get('#f_warehouse_name').type(`s${unique} Warehouse`);
|
|
31
|
+
cy.get('#add_f_shelves_btn').click();
|
|
32
|
+
cy.get('#f_shelvesList_0 > .row-fluid > #cg_f_shelves_location > .controls > .ng-pristine').type('Only');
|
|
33
|
+
cy.get('#add_f_items_btn').click();
|
|
34
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_description > .controls > .ng-pristine').type('Item 1');
|
|
35
|
+
cy.get('#f_itemsList_0 > .row-fluid > #cg_f_items_shelf > .controls > .ng-pristine').select('Only');
|
|
36
|
+
cy.get('#add_f_cleanedShelves').click();
|
|
37
|
+
cy.get('#f_cleanedShelves_0').select('Only');
|
|
38
|
+
cy.get('#f_favouriteShelf').select('Only');
|
|
39
|
+
cy.get('#saveButton').click();
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('Uses record with multiple shelves', function () {
|
|
43
|
+
cy.visit('/#/l_referencing_list_in_other_document/new');
|
|
44
|
+
cy.get('#f_description').type('An item in multi');
|
|
45
|
+
cy.get('.select2-arrow > b').click();
|
|
46
|
+
cy.get('.ui-select-search').type(`m${unique}`);
|
|
47
|
+
cy.get('.select2-result-label > .ng-binding').click();
|
|
48
|
+
cy.get('#f_shelf').select('Top');
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it('Uses record with single shelf', function () {
|
|
52
|
+
cy.visit('/#/l_referencing_list_in_other_document/new');
|
|
53
|
+
cy.get('#f_description').type('An item in single');
|
|
54
|
+
cy.get('.select2-arrow > b').click();
|
|
55
|
+
cy.get('.ui-select-search').type(`s${unique}`);
|
|
56
|
+
cy.get('.select2-result-label > .ng-binding').click();
|
|
57
|
+
cy.get('#f_shelf').select('Only');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/// <reference types="cypress" />
|
|
2
|
+
// ***********************************************************
|
|
3
|
+
// This example plugins/index.js can be used to load plugins
|
|
4
|
+
//
|
|
5
|
+
// You can change the location of this file or turn off loading
|
|
6
|
+
// the plugins file with the 'pluginsFile' configuration option.
|
|
7
|
+
//
|
|
8
|
+
// You can read more here:
|
|
9
|
+
// https://on.cypress.io/plugins-guide
|
|
10
|
+
// ***********************************************************
|
|
11
|
+
|
|
12
|
+
// This function is called when a project is opened or re-opened (e.g. due to
|
|
13
|
+
// the project's config changing)
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* @type {Cypress.PluginConfig}
|
|
17
|
+
*/
|
|
18
|
+
module.exports = (on, config) => {
|
|
19
|
+
// `on` is used to hook into various events Cypress emits
|
|
20
|
+
// `config` is the resolved Cypress config
|
|
21
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// ***********************************************
|
|
2
|
+
// This example commands.js shows you how to
|
|
3
|
+
// create various custom commands and overwrite
|
|
4
|
+
// existing commands.
|
|
5
|
+
//
|
|
6
|
+
// For more comprehensive examples of custom
|
|
7
|
+
// commands please read more here:
|
|
8
|
+
// https://on.cypress.io/custom-commands
|
|
9
|
+
// ***********************************************
|
|
10
|
+
//
|
|
11
|
+
//
|
|
12
|
+
// -- This is a parent command --
|
|
13
|
+
// Cypress.Commands.add("login", (email, password) => { ... })
|
|
14
|
+
//
|
|
15
|
+
//
|
|
16
|
+
// -- This is a child command --
|
|
17
|
+
// Cypress.Commands.add("drag", { prevSubject: 'element'}, (subject, options) => { ... })
|
|
18
|
+
//
|
|
19
|
+
//
|
|
20
|
+
// -- This is a dual command --
|
|
21
|
+
// Cypress.Commands.add("dismiss", { prevSubject: 'optional'}, (subject, options) => { ... })
|
|
22
|
+
//
|
|
23
|
+
//
|
|
24
|
+
// -- This will overwrite an existing command --
|
|
25
|
+
// Cypress.Commands.overwrite("visit", (originalFn, url, options) => { ... })
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// ***********************************************************
|
|
2
|
+
// This example support/index.js is processed and
|
|
3
|
+
// loaded automatically before your test files.
|
|
4
|
+
//
|
|
5
|
+
// This is a great place to put global configuration and
|
|
6
|
+
// behavior that modifies Cypress.
|
|
7
|
+
//
|
|
8
|
+
// You can change the location of this file or turn off
|
|
9
|
+
// automatically serving support files with the
|
|
10
|
+
// 'supportFile' configuration option.
|
|
11
|
+
//
|
|
12
|
+
// You can read more here:
|
|
13
|
+
// https://on.cypress.io/configuration
|
|
14
|
+
// ***********************************************************
|
|
15
|
+
|
|
16
|
+
// Import commands.js using ES2015 syntax:
|
|
17
|
+
import './commands'
|
|
18
|
+
|
|
19
|
+
// Alternatively you can use CommonJS syntax:
|
|
20
|
+
// require('./commands')
|
package/cypress.json
ADDED
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fng-ui-select",
|
|
3
3
|
"author": "Mark Chapman <support@forms-angular.org>",
|
|
4
|
-
"version": "0.12.0-beta.
|
|
4
|
+
"version": "0.12.0-beta.173",
|
|
5
5
|
"description": "angular-ui-select plugin for forms-angular",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "https://github.com/forms-angular/fng-ui-select"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"
|
|
12
|
-
"
|
|
11
|
+
"select2": "3.5.1",
|
|
12
|
+
"ui-select": "0.19.8"
|
|
13
13
|
},
|
|
14
14
|
"devDependencies": {
|
|
15
|
-
"
|
|
15
|
+
"cypress": "^8.7.0"
|
|
16
16
|
},
|
|
17
17
|
"engines": {
|
|
18
18
|
"node": ">=0.10.0"
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"license": "MIT",
|
|
24
24
|
"scripts": {
|
|
25
|
-
"test": "
|
|
26
|
-
"
|
|
25
|
+
"test": "npx cypress run --spec cypress/integration/lists.spec.js",
|
|
26
|
+
"old-test": "NODE_ENV=test node ../forms-angular/website/server.js & npx webdriver-manager update --versions.chrome=$(google-chrome --version | cut -d ' ' -f 3) && npx webdriver-manager start --versions.chrome=$(google-chrome --version | cut -d ' ' -f 3) & npx protractor test/e2e/protractor/protractor-chrome.conf.js",
|
|
27
|
+
"clear": "kill `ps -ef | grep '[0-9] node ../forms-angular/website/server.js' | egrep -o ' ([0-9]+) ' | head -1 | sed -e 's/ //'` -9"
|
|
27
28
|
}
|
|
28
29
|
}
|
package/src/fng-ui-select.js
CHANGED
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
var retVal;
|
|
42
42
|
if (typeof value === 'string') {
|
|
43
43
|
var obj = localLookups[formSchema.fngUiSelect.deriveOptions].find(function (test) {
|
|
44
|
-
return test.id
|
|
44
|
+
return test.id == value
|
|
45
45
|
});
|
|
46
46
|
retVal = {id: value, text: obj ? obj.text : ''}
|
|
47
47
|
} else {
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
}
|
|
50
50
|
cb(formSchema, retVal);
|
|
51
51
|
} else {
|
|
52
|
-
SubmissionsService.getListAttributes(
|
|
52
|
+
SubmissionsService.getListAttributes(formSchema.ref, value).then(function (response) {
|
|
53
53
|
cb(formSchema, {id: value, text: response.data.list});
|
|
54
54
|
});
|
|
55
55
|
}
|
|
@@ -95,28 +95,47 @@
|
|
|
95
95
|
} else {
|
|
96
96
|
var promise;
|
|
97
97
|
if (elem.filter && elem.filter[0] === '/') {
|
|
98
|
+
// HACK We want to pass the existing record in e, but we can fall foul of 431 errors if it is large, so we test for that
|
|
99
|
+
// using an arbitrary number and if so just send the _id (on the assumption that large records won't be new so will have an _id).
|
|
100
|
+
// According to https://stackoverflow.com/questions/57431355/how-to-fix-431-request-header-fields-too-large-in-react-redux-app the limit is 8KB
|
|
101
|
+
// but I have seen it fail at about 5k...
|
|
102
|
+
var record = JSON.stringify($scope.record).length >= (4 * 1024) ? {_id: $scope.record._id} : $scope.record;
|
|
98
103
|
// Custom URL
|
|
99
104
|
promise = $http({
|
|
100
105
|
method: 'GET',
|
|
101
106
|
url: elem.filter,
|
|
102
107
|
params: {
|
|
103
108
|
q: searchString,
|
|
104
|
-
e:
|
|
109
|
+
e: record,
|
|
110
|
+
i: $scope.$index
|
|
105
111
|
},
|
|
106
112
|
cache: false
|
|
107
113
|
});
|
|
108
114
|
} else {
|
|
109
|
-
promise = $http.get('/api/search/' + elem.ref
|
|
115
|
+
promise = $http.get('/api/search/' + elem.ref + '?q=' + searchString + (elem.filter ? ('&f=' + elem.filter) : ''));
|
|
110
116
|
}
|
|
111
117
|
promise.then(function (response) {
|
|
112
|
-
if (
|
|
113
|
-
|
|
114
|
-
result.text = result.text + (result.additional ? (', ' + result.additional) : '');
|
|
115
|
-
return result;
|
|
116
|
-
});
|
|
118
|
+
if (response.status >= 400) {
|
|
119
|
+
throw new Error(response.statusMessage)
|
|
117
120
|
} else {
|
|
118
|
-
|
|
121
|
+
if (elem.additional) {
|
|
122
|
+
$scope[id + '_options'] = response.data.results.map(function (result) {
|
|
123
|
+
result.text = result.text + (result.additional ? (', ' + result.additional) : '');
|
|
124
|
+
return result;
|
|
125
|
+
});
|
|
126
|
+
} else {
|
|
127
|
+
$scope[id + '_options'] = response.data.results;
|
|
128
|
+
}
|
|
119
129
|
}
|
|
130
|
+
})
|
|
131
|
+
.catch(function(err) {
|
|
132
|
+
var msg;
|
|
133
|
+
if (err && err.data && err.data.message) {
|
|
134
|
+
msg = err.data.message;
|
|
135
|
+
} else {
|
|
136
|
+
msg = 'Error ' + err.status + ': ' + err.statusText + ' - ' + err.data;
|
|
137
|
+
}
|
|
138
|
+
$scope.showError(msg);
|
|
120
139
|
});
|
|
121
140
|
}
|
|
122
141
|
} else {
|
|
@@ -142,6 +161,9 @@
|
|
|
142
161
|
function addToConversions(path, options) {
|
|
143
162
|
if (Object.keys(options).length > 0) {
|
|
144
163
|
var keys = path.split('.');
|
|
164
|
+
if (!scope.conversions) {
|
|
165
|
+
scope.conversions = {};
|
|
166
|
+
}
|
|
145
167
|
var target = scope.conversions;
|
|
146
168
|
for (var i = 0; i < keys.length; i++) {
|
|
147
169
|
var thisKey = keys[i];
|
|
@@ -162,9 +184,20 @@
|
|
|
162
184
|
addToConversions(processedAttr.info.name, processedAttr.directiveOptions);
|
|
163
185
|
|
|
164
186
|
// Sort out the theme, defaulting to select2 (so old users won't see the change). Bootstrap theme only works with Bootstrap 3
|
|
187
|
+
// and not with animate (see https://github.com/angular-ui/ui-select/issues/1731 and others)
|
|
165
188
|
var theme = processedAttr.directiveOptions.theme || 'select2';
|
|
166
|
-
if (
|
|
167
|
-
|
|
189
|
+
if (theme === 'bootstrap') {
|
|
190
|
+
if (cssFrameworkService.framework() !== 'bs3') {
|
|
191
|
+
theme = 'select2';
|
|
192
|
+
} else {
|
|
193
|
+
try {
|
|
194
|
+
if (angular.module('ngAnimate')) {
|
|
195
|
+
theme = 'select2';
|
|
196
|
+
}
|
|
197
|
+
} catch(e) {
|
|
198
|
+
; // module not present, so bootstrap theme will work
|
|
199
|
+
}
|
|
200
|
+
}
|
|
168
201
|
}
|
|
169
202
|
|
|
170
203
|
var multiControl = false;
|
|
@@ -185,22 +218,31 @@
|
|
|
185
218
|
} else {
|
|
186
219
|
allowClearStr = ' allow-clear';
|
|
187
220
|
}
|
|
221
|
+
var disabledStr = '';
|
|
222
|
+
if (processedAttr.directiveOptions.ngdisabled) {
|
|
223
|
+
disabledStr = ` ng-disabled="${processedAttr.directiveOptions.ngdisabled}"`
|
|
224
|
+
} else {
|
|
225
|
+
disabledStr = ' ng-disabled="disabled"';
|
|
226
|
+
}
|
|
188
227
|
|
|
189
228
|
// First of all add a hidden input field which we will use to set the width of the select
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
229
|
+
if (!angular.element('#' + processedAttr.info.id + '_width-helper').length > 0) {
|
|
230
|
+
var hiddenInputInfo = {
|
|
231
|
+
id: processedAttr.info.id + '_width-helper',
|
|
232
|
+
name: processedAttr.info.name + '_width-helper',
|
|
233
|
+
label: ''
|
|
234
|
+
};
|
|
235
|
+
if (processedAttr.info.size) {
|
|
236
|
+
hiddenInputInfo.size = processedAttr.info.size;
|
|
237
|
+
}
|
|
238
|
+
input = pluginHelper.buildInputMarkup(scope, attr.model, hiddenInputInfo, processedAttr.options, false, multiControl, function (buildingBlocks) {
|
|
239
|
+
return '<input id="' + hiddenInputInfo.id + '" type="text" class="form-control" disabled="" aria-label="unused input" style="position: absolute; left: -4200px;">';
|
|
240
|
+
});
|
|
241
|
+
input = input.replace('class="row', 'class="hidden-row row')
|
|
197
242
|
}
|
|
198
|
-
input = pluginHelper.buildInputMarkup(scope, attr.model, hiddenInputInfo, processedAttr.options, false, multiControl, function (buildingBlocks) {
|
|
199
|
-
return '<input id="' + hiddenInputInfo.id + '" type="text" class="form-control" disabled="" style="position: absolute; left: -4200px;">';
|
|
200
|
-
});
|
|
201
243
|
|
|
202
244
|
function optionsFromArray(multiControl, multi, array, arrayGetter) {
|
|
203
|
-
var isObjects = (scope[array].isObjects || typeof scope[array][0] === "object");
|
|
245
|
+
var isObjects = scope[array] && (scope[array].isObjects || typeof scope[array][0] === "object");
|
|
204
246
|
if (isObjects) {
|
|
205
247
|
addToConversions(processedAttr.info.name, {fngajax: uiSelectHelper.lookupFunc});
|
|
206
248
|
uiSelectHelper.addClientLookup(arrayGetter, scope[array]);
|
|
@@ -223,7 +265,7 @@
|
|
|
223
265
|
defaultPlaceholder = 'Start typing...'
|
|
224
266
|
}
|
|
225
267
|
// set up the ui-select directives
|
|
226
|
-
var select = '<ui-select ' + multiStr + buildingBlocks.common + requiredStr + ' theme="' + theme + '"
|
|
268
|
+
var select = '<ui-select ' + multiStr + buildingBlocks.common + requiredStr + disabledStr + ' theme="' + theme + '" style="width:300px;">'
|
|
227
269
|
select += '<ui-select-match' + allowClearStr + ' placeholder="' + (processedAttr.info.placeholder || defaultPlaceholder) + '">';
|
|
228
270
|
|
|
229
271
|
|
|
@@ -236,14 +278,6 @@
|
|
|
236
278
|
addToConversions(processedAttr.info.name, {fngajax: uiSelectHelper.lookupFunc});
|
|
237
279
|
// Use the forms-angular API to query the referenced collection
|
|
238
280
|
elemScope.ref = processedAttr.info.ref;
|
|
239
|
-
if (elemScope.ref) {
|
|
240
|
-
if (elemScope.ref[0] === '{') {
|
|
241
|
-
elemScope.ref = JSON.parse(elemScope.ref);
|
|
242
|
-
} else {
|
|
243
|
-
elemScope.ref = {type:'lookup', collection: elemScope.ref};
|
|
244
|
-
console.warn('Support for string type "ref" property is deprecated - use ref:' + JSON.stringify(elemScope.ref));
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
281
|
scope[processedAttr.info.id + '_options'] = [];
|
|
248
282
|
if (multiControl) {
|
|
249
283
|
select += '{{$select.selected.text}}';
|
|
@@ -258,7 +292,11 @@
|
|
|
258
292
|
select += 'refresh-delay="100"> ';
|
|
259
293
|
select += '<div ng-bind-html="option.text"></div>';
|
|
260
294
|
} else if (processedAttr.directiveOptions.deriveoptions) {
|
|
261
|
-
|
|
295
|
+
if (typeof scope[processedAttr.directiveOptions.deriveoptions] === "function") {
|
|
296
|
+
select += optionsFromArray(multiControl, multi, scope[processedAttr.directiveOptions.deriveoptions](), processedAttr.directiveOptions.deriveoptions);
|
|
297
|
+
} else {
|
|
298
|
+
throw new Error("In fng-ui-select " + processedAttr.directiveOptions.deriveoptions + " is not a function on the scope");
|
|
299
|
+
}
|
|
262
300
|
} else if (processedAttr.info.options) {
|
|
263
301
|
// Simple case - enumerated options on the form scope
|
|
264
302
|
select += optionsFromArray(multiControl, multi, processedAttr.info.options);
|
|
@@ -269,7 +307,6 @@
|
|
|
269
307
|
select += '</ui-select>';
|
|
270
308
|
return select;
|
|
271
309
|
});
|
|
272
|
-
scope.content = input + elementHtml;
|
|
273
310
|
element.append($compile(input + elementHtml)(scope));
|
|
274
311
|
}
|
|
275
312
|
}
|
package/styles/fng-ui-select.css
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
.ng-invalid-required
|
|
1
|
+
.ui-select-container.ng-invalid-required,
|
|
2
|
+
.ui-select-container.ng-invalid-required > a.select2-choice,
|
|
3
|
+
.ui-select-container.ng-invalid-required > a.select2-choice > .select2-chosen
|
|
4
|
+
{
|
|
2
5
|
background-color: rgba(255, 0, 0, 0.10);
|
|
3
6
|
}
|
|
4
7
|
|
|
@@ -11,6 +14,19 @@
|
|
|
11
14
|
background-color: rgba(255, 0, 0, 0.10);
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
+
fng-ui-select div[id$="width-helper"] {
|
|
18
|
+
margin-bottom: 0px!important;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
fng-ui-select div[id$="width-helper"] div {
|
|
22
|
+
min-height: 0px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
fng-ui-select div[id$="width-helper"] label.control-label {
|
|
26
|
+
padding-top: 0px!important;
|
|
27
|
+
min-height: 0px!important;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
.hidden-row {
|
|
31
|
+
display: none;
|
|
32
|
+
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -7,26 +7,26 @@ describe('Single control in array', function () {
|
|
|
7
7
|
var height = 768;
|
|
8
8
|
browser.driver.manage().window().setSize(width, height);
|
|
9
9
|
|
|
10
|
-
it('should handle simple enum', function () {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
});
|
|
10
|
+
// it('should handle simple enum', function () {
|
|
11
|
+
// browser.get('/#/test_nested_select/new');
|
|
12
|
+
//
|
|
13
|
+
// var field = element(by.model('record.surname'));
|
|
14
|
+
// field.clear();
|
|
15
|
+
// field.sendKeys('Smith');
|
|
16
|
+
// field = element(by.model('record.forename'));
|
|
17
|
+
// field.clear();
|
|
18
|
+
// field.sendKeys('One');
|
|
19
|
+
// element(by.css('#add_f_nested_btn')).click();
|
|
20
|
+
// field = element(by.model('record.nested[$index].someText'));
|
|
21
|
+
// field.clear();
|
|
22
|
+
// field.sendKeys('Sometext One');
|
|
23
|
+
//
|
|
24
|
+
// $('#cg_f_nested_anEnum .select2-arrow').click();
|
|
25
|
+
// element.all(by.css('.select2-result-label.ui-select-choices-row-inner')).get(2).click();
|
|
26
|
+
// expect(element(by.css('#cg_f_nested_anEnum .select2-choice.ui-select-match')).getText()).toMatch('C Option');
|
|
27
|
+
// element(by.css('#saveButton')).click();
|
|
28
|
+
// expect(element(by.css('#cg_f_nested_anEnum .select2-choice.ui-select-match')).getText()).toMatch('C Option');
|
|
29
|
+
// });
|
|
30
30
|
|
|
31
31
|
it('should handle cached table lookup', function () {
|
|
32
32
|
browser.get('/#/test_nested_select/new');
|
|
@@ -73,22 +73,22 @@ describe('Single control in array', function () {
|
|
|
73
73
|
expect(element(by.css('#cg_f_nested_singleAjax .select2-choice.ui-select-match')).getText()).toMatch('IsAccepted John true 89');
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
it('should handle filtered Ajax lookup', function () {
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
});
|
|
76
|
+
// it('should handle filtered Ajax lookup', function () {
|
|
77
|
+
// browser.get('/#/test_fng_ui_select/new');
|
|
78
|
+
// var match = $('#cg_f_filteredAjax a.select2-choice.ui-select-match');
|
|
79
|
+
// expect(match.getText()).toEqual('Start typing...');
|
|
80
|
+
// $('#cg_f_filteredAjax .select2-arrow').click();
|
|
81
|
+
// var field = $('#cg_f_filteredAjax input.select2-input');
|
|
82
|
+
// field.clear();
|
|
83
|
+
// field.sendKeys('J');
|
|
84
|
+
//
|
|
85
|
+
// expect(element.all(by.css('.select2-result-label.ui-select-choices-row-inner')).count()).toEqual(1);
|
|
86
|
+
// element.all(by.css('.select2-result-label.ui-select-choices-row-inner')).get(0).click();
|
|
87
|
+
// expect(match.getText()).toMatch('Jones Alan true 93');
|
|
88
|
+
// element(by.css('#saveButton')).click();
|
|
89
|
+
// match = $('#cg_f_filteredAjax a.select2-choice.ui-select-match');
|
|
90
|
+
// expect(match.getText()).toMatch('Jones Alan true 93');
|
|
91
|
+
// });
|
|
92
92
|
|
|
93
93
|
});
|
|
94
94
|
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
exports.config = {
|
|
2
|
-
specs: [
|
|
3
|
-
'./single-within-array.spec.js'
|
|
4
|
-
],
|
|
5
|
-
capabilities: {
|
|
6
|
-
browserName: 'chrome'
|
|
7
|
-
},
|
|
8
|
-
directConnect: true,// broken with firefox 38 - see https://github.com/angular/protractor/issues/2134
|
|
9
|
-
baseUrl: 'http://localhost:9000',
|
|
10
|
-
framework: 'jasmine2',
|
|
11
|
-
};
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/e2e/test/screen_tests/screenshots/firefox-Multi control-should handle simple enum.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/e2e/test/screen_tests/screenshots/firefox-Single control-should handle Ajax lookup.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/e2e/test/screen_tests/screenshots/firefox-Single control-should handle simple enum.png
DELETED
|
Binary file
|
|
Binary file
|
package/test/screen_tests/screenshots/firefox-Multi control-should handle inside cached lookups.png
DELETED
|
Binary file
|
package/test/screen_tests/screenshots/firefox-Multi control-should handle outside cached lookups.png
DELETED
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/screen_tests/screenshots/firefox-Multiple controls array-should handle simple enums.png
DELETED
|
Binary file
|
|
Binary file
|
package/test/screen_tests/screenshots/firefox-Single control-should handle cached table lookup.png
DELETED
|
Binary file
|