jsf.js_next_gen 1.0.0-beta-19 → 1.0.0-beta-20
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 +5 -2
- package/dist/docs/index.html +5 -2
- package/dist/window/jsf-development.js +51 -74
- package/dist/window/jsf-development.js.map +1 -1
- package/dist/window/jsf.js +1 -1
- package/dist/window/jsf.js.br +0 -0
- package/dist/window/jsf.js.gz +0 -0
- package/dist/window/jsf.js.map +1 -1
- package/package.json +1 -1
- package/src/main/typescript/myfaces/OamSubmit.ts +49 -81
- package/src/main/typescript/test/frameworkBase/_ext/monadish/MonadTest.spec.ts +0 -5
- package/src/main/typescript/test/frameworkBase/_ext/shared/StandardInits.ts +4 -4
- package/src/main/typescript/test/impl/SeparatorCharsTest.spec.ts +0 -1
- package/src/main/typescript/test/myfaces/OamSubmit.spec.ts +107 -16
- package/src/main/typescript/tsconfig.json +1 -0
- package/target/myfaces/OamSubmit.js +50 -73
- package/target/myfaces/OamSubmit.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js +24 -1
- package/target/test/frameworkBase/_ext/monadish/DomQueryTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js +0 -5
- package/target/test/frameworkBase/_ext/monadish/MonadTest.spec.js.map +1 -1
- package/target/test/frameworkBase/_ext/shared/StandardInits.js +32 -6
- package/target/test/frameworkBase/_ext/shared/StandardInits.js.map +1 -1
- package/target/test/impl/ImplTest.spec.js +24 -1
- package/target/test/impl/ImplTest.spec.js.map +1 -1
- package/target/test/impl/SeparatorCharsTest.spec.js +24 -2
- package/target/test/impl/SeparatorCharsTest.spec.js.map +1 -1
- package/target/test/myfaces/OamSubmit.spec.js +92 -13
- package/target/test/myfaces/OamSubmit.spec.js.map +1 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js +24 -1
- package/target/test/queue/AsynchronousQueueTest.spec.js.map +1 -1
- package/target/test/xhrCore/EventTests.spec.js +24 -1
- package/target/test/xhrCore/EventTests.spec.js.map +1 -1
- package/target/test/xhrCore/FileUploadTest.spec.js +24 -1
- package/target/test/xhrCore/FileUploadTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js +24 -1
- package/target/test/xhrCore/RequestParamsTest.spec.js.map +1 -1
- package/target/test/xhrCore/RequestTest.spec.js +24 -1
- package/target/test/xhrCore/RequestTest.spec.js.map +1 -1
- package/target/test/xhrCore/ResponseTest.spec.js +24 -1
- package/target/test/xhrCore/ResponseTest.spec.js.map +1 -1
- package/target/test/xhrCore/ShadowDomTest.spec.js +24 -1
- package/target/test/xhrCore/ShadowDomTest.spec.js.map +1 -1
- package/target/test/xhrCore/WebsocketTest.js +24 -1
- package/target/test/xhrCore/WebsocketTest.js.map +1 -1
- package/target/test/xhrCore/XhrFormDataTest.spec.js +24 -1
- package/target/test/xhrCore/XhrFormDataTest.spec.js.map +1 -1
package/package.json
CHANGED
|
@@ -14,10 +14,12 @@
|
|
|
14
14
|
* limitations under the License.
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
|
+
import {DQ, Stream} from "mona-dish";
|
|
18
|
+
|
|
17
19
|
/**
|
|
18
20
|
* legacy code to enable various aspects
|
|
19
21
|
* of myfaces, used to be rendered inline
|
|
20
|
-
* for jsf 2.0 we can
|
|
22
|
+
* for jsf 2.0 we can externalize it into its own custom resource
|
|
21
23
|
*
|
|
22
24
|
* note this is a straight 1:1 port from the existing codebase
|
|
23
25
|
* (not too much work has been spent here, the important thing is, that
|
|
@@ -28,124 +30,90 @@
|
|
|
28
30
|
declare const window: any;
|
|
29
31
|
declare const myfaces: any;
|
|
30
32
|
|
|
33
|
+
//TODO add unit tests to check all this here that it works just as before
|
|
31
34
|
export module oam {
|
|
32
|
-
|
|
33
35
|
/**
|
|
34
36
|
* sets a hidden input field
|
|
35
|
-
* @param
|
|
37
|
+
* @param formName the formName
|
|
36
38
|
* @param name the hidden field
|
|
37
39
|
* @param value the value to be rendered
|
|
38
40
|
*/
|
|
39
|
-
export const setHiddenInput = function (
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
newInput.setAttribute('name', name);
|
|
52
|
-
newInput.setAttribute('value', value);
|
|
53
|
-
form.appendChild(newInput);
|
|
54
|
-
}
|
|
41
|
+
export const setHiddenInput = function (formName: string, name: string, value: string) {
|
|
42
|
+
DQ.byId(document.forms[formName])
|
|
43
|
+
.each(form => {
|
|
44
|
+
const input = form.querySelectorAll(`input[type='hidden'][name='${name}']`);
|
|
45
|
+
if (input.isPresent()) {
|
|
46
|
+
input.inputValue.value = value;
|
|
47
|
+
} else {
|
|
48
|
+
const newInput = DQ.fromMarkup(`<input type='hidden' id='${name}' name='${name}'>`);
|
|
49
|
+
newInput.inputValue.value = value;
|
|
50
|
+
newInput.appendTo(form);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
55
53
|
};
|
|
56
54
|
|
|
57
55
|
/**
|
|
58
56
|
* clears a hidden input field
|
|
59
57
|
*
|
|
60
|
-
* @param
|
|
58
|
+
* @param formName formName for the input
|
|
61
59
|
* @param name the name of the input field
|
|
62
60
|
*/
|
|
63
|
-
export const clearHiddenInput = function (
|
|
64
|
-
let
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
form = document.getElementById(formname) as HTMLFormElement;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
let hInput = form.elements[name];
|
|
71
|
-
if (typeof hInput != 'undefined') {
|
|
72
|
-
form.removeChild(hInput);
|
|
61
|
+
export const clearHiddenInput = function (formName: string, name: string) {
|
|
62
|
+
let element = document.forms?.[formName]?.elements?.[name];
|
|
63
|
+
if(!element) {
|
|
64
|
+
return;
|
|
73
65
|
}
|
|
66
|
+
DQ.byId(element).delete();
|
|
74
67
|
};
|
|
75
68
|
|
|
76
69
|
// noinspection JSUnusedGlobalSymbols
|
|
77
70
|
/**
|
|
78
71
|
* does special form submit remapping
|
|
79
|
-
*
|
|
80
|
-
*
|
|
72
|
+
* re-maps the issuing command link into something,
|
|
73
|
+
* a decode of the command link on the server can understand
|
|
81
74
|
*
|
|
82
75
|
* @param formName
|
|
83
76
|
* @param linkId
|
|
84
77
|
* @param target
|
|
85
78
|
* @param params
|
|
86
79
|
*/
|
|
87
|
-
export const submitForm = function (formName: string, linkId: string, target:
|
|
88
|
-
|
|
80
|
+
export const submitForm = function (formName: string, linkId: string, target: string, params: { [key: string]: any }) {
|
|
89
81
|
let clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
|
|
90
|
-
|
|
91
|
-
window[clearFn](formName);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
let form = document.forms[formName];
|
|
95
|
-
if (typeof form == 'undefined') {
|
|
96
|
-
form = document.getElementById(formName);
|
|
97
|
-
}
|
|
82
|
+
window?.[clearFn]?.(formName);
|
|
98
83
|
|
|
99
84
|
//autoscroll code
|
|
100
|
-
if (
|
|
85
|
+
if (window?.myfaces?.core?.config?.autoScroll && window?.getScrolling) {
|
|
101
86
|
myfaces.oam.setHiddenInput(formName, 'autoScroll', window?.getScrolling());
|
|
102
87
|
}
|
|
88
|
+
Stream.ofAssoc(params).each((param: [string, any]) => {
|
|
89
|
+
myfaces.oam.setHiddenInput(formName, param[0], param[1]);
|
|
90
|
+
});
|
|
103
91
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
form.target = target;
|
|
107
|
-
}
|
|
108
|
-
if ((typeof params != 'undefined') && params != null) {
|
|
109
|
-
for (let i = 0, param; (param = params[i]); i++) {
|
|
110
|
-
myfaces.oam.setHiddenInput(formName, param[0], param[1]);
|
|
111
|
-
}
|
|
92
|
+
//we call the namespaced function, to allow decoration, via a direct call we would
|
|
93
|
+
myfaces.oam.setHiddenInput(formName, `${formName}:_idcl`, linkId);
|
|
112
94
|
|
|
113
|
-
|
|
95
|
+
DQ.byId(document.forms[formName]).each(form => {
|
|
96
|
+
const ATTR_TARGET = "target";
|
|
97
|
+
const formElement = form.getAsElem(0).value as HTMLFormElement;
|
|
98
|
+
const oldTarget = form.attr(ATTR_TARGET).value;
|
|
99
|
+
form.attr(ATTR_TARGET).value = target;
|
|
114
100
|
|
|
115
|
-
|
|
101
|
+
const result = formElement?.onsubmit?.(null);
|
|
116
102
|
|
|
117
|
-
if (form.onsubmit) {
|
|
118
|
-
let result = form.onsubmit();
|
|
119
|
-
if ((typeof result == 'undefined') || result) {
|
|
120
|
-
try {
|
|
121
|
-
form.submit();
|
|
122
|
-
} catch (e) {
|
|
123
|
-
if (window.console) {
|
|
124
|
-
console.error(e);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
103
|
try {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
if (window.console) {
|
|
134
|
-
console.error(e);
|
|
104
|
+
if ((!!result) || 'undefined' == typeof result) {
|
|
105
|
+
formElement.submit();
|
|
135
106
|
}
|
|
107
|
+
} catch (e) {
|
|
108
|
+
window?.console.error(e);
|
|
136
109
|
}
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
form.target = oldTarget;
|
|
140
|
-
if ((typeof params != 'undefined') && params != null) {
|
|
141
|
-
|
|
142
|
-
for (let i = 0, param; (param = params[i]); i++) {
|
|
143
|
-
myfaces.oam.clearHiddenInput(formName, param[0], param[1]);
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
}
|
|
147
110
|
|
|
148
|
-
|
|
111
|
+
form.attr(ATTR_TARGET).value = oldTarget;
|
|
112
|
+
Stream.ofAssoc(params).each((param: [string, any]) => {
|
|
113
|
+
myfaces.oam.clearHiddenInput(formName, param[0]);
|
|
114
|
+
});
|
|
115
|
+
myfaces.oam.clearHiddenInput(formName, `${formName}:_idcl`);
|
|
116
|
+
});
|
|
149
117
|
return false;
|
|
150
118
|
};
|
|
151
119
|
}
|
|
@@ -119,7 +119,6 @@ describe('Config tests', () => {
|
|
|
119
119
|
it('array config', () => {
|
|
120
120
|
let config = setup();
|
|
121
121
|
config.assign("hello[5]", "world[3]", "from[5]").value = "me";
|
|
122
|
-
console.debug(JSON.stringify(config.toJson()));
|
|
123
122
|
expect(config.getIf("hello[5]", "world[3]", "from[5]").value).to.be.eq("me");
|
|
124
123
|
expect(config.value.hello[5].world[3].from[5]).to.be.eq("me");
|
|
125
124
|
structure(config.value);
|
|
@@ -129,7 +128,6 @@ describe('Config tests', () => {
|
|
|
129
128
|
let config = setup();
|
|
130
129
|
config.assign("[5]", "world[3]", "from").value = "me";
|
|
131
130
|
expect(config.getIf("[5]", "world[3]", "from").value).to.be.eq("me");
|
|
132
|
-
console.debug(JSON.stringify(config.toJson()));
|
|
133
131
|
expect(config.value[5].world[3].from).to.be.eq("me");
|
|
134
132
|
structureBroken(config.value);
|
|
135
133
|
});
|
|
@@ -138,7 +136,6 @@ describe('Config tests', () => {
|
|
|
138
136
|
let config = setup();
|
|
139
137
|
config.assign("[5]", "[3]", "from").value = "me";
|
|
140
138
|
expect(config.getIf("[5]", "[3]", "from").value).to.be.eq("me");
|
|
141
|
-
console.debug(JSON.stringify(config.toJson()));
|
|
142
139
|
expect(config.value[5][3].from).to.be.eq("me");
|
|
143
140
|
structureBroken(config.value);
|
|
144
141
|
});
|
|
@@ -147,7 +144,6 @@ describe('Config tests', () => {
|
|
|
147
144
|
let config = setup();
|
|
148
145
|
config.assign("[5]", "[3]", "[2]").value = "me";
|
|
149
146
|
expect(config.getIf("[5]", "[3]", "[2]").value).to.be.eq("me");
|
|
150
|
-
console.debug(JSON.stringify(config.toJson()));
|
|
151
147
|
expect(config.value[5][3][2]).to.be.eq("me");
|
|
152
148
|
structureBroken(config.value);
|
|
153
149
|
});
|
|
@@ -156,7 +152,6 @@ describe('Config tests', () => {
|
|
|
156
152
|
let config = setup();
|
|
157
153
|
config.assign("[5]", "world[3]", "from[2]").value = "me";
|
|
158
154
|
expect(config.getIf("[5]", "world[3]", "from[2]").value).to.be.eq("me");
|
|
159
|
-
console.debug(JSON.stringify(config.toJson()));
|
|
160
155
|
expect(config.value[5].world[3].from[2]).to.be.eq("me");
|
|
161
156
|
structureBroken(config.value);
|
|
162
157
|
});
|
|
@@ -223,8 +223,6 @@ export module StandardInits {
|
|
|
223
223
|
var target = "./test.mockup";
|
|
224
224
|
|
|
225
225
|
function emitPPR(source, event, action, useIframe, formName) {
|
|
226
|
-
debugger;
|
|
227
|
-
console.debug("emitting;");
|
|
228
226
|
document.getElementById(formName || "form1").action = target;
|
|
229
227
|
|
|
230
228
|
jsf.ajax.request(/*String|Dom Node*/ source, /*|EVENT|*/ (window.event) ? window.event : event, /*{|OPTIONS|}*/ {op: action});
|
|
@@ -317,10 +315,12 @@ export module StandardInits {
|
|
|
317
315
|
let initJSDOM = async function (template: string) {
|
|
318
316
|
// @ts-ignore
|
|
319
317
|
return import('jsdom-global').then((domIt) => {
|
|
320
|
-
|
|
318
|
+
let params = {
|
|
321
319
|
contentType: "text/html",
|
|
322
320
|
runScripts: "dangerously"
|
|
323
|
-
}
|
|
321
|
+
};
|
|
322
|
+
//we have two different apis depending whether we allow module interop with sinon or not
|
|
323
|
+
return domIt?.default?.(template, params) ?? domIt?.(template, params);
|
|
324
324
|
});
|
|
325
325
|
};
|
|
326
326
|
|
|
@@ -15,22 +15,20 @@
|
|
|
15
15
|
*/
|
|
16
16
|
|
|
17
17
|
import {describe, it} from "mocha";
|
|
18
|
-
|
|
18
|
+
|
|
19
19
|
import {expect} from "chai";
|
|
20
20
|
import {StandardInits} from "../frameworkBase/_ext/shared/StandardInits";
|
|
21
21
|
import defaultMyFaces = StandardInits.defaultMyFaces;
|
|
22
|
+
import {oam} from "../../myfaces/OamSubmit";
|
|
23
|
+
import setHiddenInput = oam.setHiddenInput;
|
|
24
|
+
import {DomQuery} from "mona-dish";
|
|
25
|
+
import clearHiddenInput = oam.clearHiddenInput;
|
|
26
|
+
import submitForm = oam.submitForm;
|
|
27
|
+
import Sinon from "sinon";
|
|
22
28
|
|
|
23
|
-
declare var jsf: any;
|
|
24
|
-
declare var Implementation: any;
|
|
25
29
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
execute: "input_1",
|
|
29
|
-
render: "@form",
|
|
30
|
-
pass1: "pass1",
|
|
31
|
-
pass2: "pass2"
|
|
32
|
-
});
|
|
33
|
-
};
|
|
30
|
+
declare var myfaces: any;
|
|
31
|
+
|
|
34
32
|
/**
|
|
35
33
|
* specialized tests testing the xhr core behavior when it hits the xmlHttpRequest object
|
|
36
34
|
*/
|
|
@@ -38,13 +36,106 @@ describe('Tests on the xhr core when it starts to call the request', function ()
|
|
|
38
36
|
|
|
39
37
|
beforeEach(() => {
|
|
40
38
|
return defaultMyFaces();
|
|
41
|
-
})
|
|
39
|
+
})
|
|
42
40
|
|
|
43
41
|
it('namespace must exist', function() {
|
|
44
|
-
expect(!!
|
|
45
|
-
expect(!!
|
|
46
|
-
expect(!!
|
|
47
|
-
expect(!!
|
|
42
|
+
expect(!!myfaces?.oam).to.eq(true);
|
|
43
|
+
expect(!!myfaces?.oam?.setHiddenInput).to.eq(true);
|
|
44
|
+
expect(!!myfaces?.oam?.clearHiddenInput).to.eq(true);
|
|
45
|
+
expect(!!myfaces?.oam?.submitForm).to.eq(true);
|
|
48
46
|
});
|
|
47
|
+
|
|
48
|
+
it('hidden input setting must work', function() {
|
|
49
|
+
let FORM_ID = "blarg";
|
|
50
|
+
setHiddenInput(FORM_ID, "new_hidden", "hiddenvalue");
|
|
51
|
+
expect(DomQuery.byId(FORM_ID).querySelectorAll("input[name='new_hidden']").isPresent());
|
|
52
|
+
expect(DomQuery.byId(FORM_ID).querySelectorAll("input[name='new_hidden']").inputValue.value).to.eq("hiddenvalue");
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
it('resetting the hidden input must work', function() {
|
|
56
|
+
let FORM_ID = "blarg";
|
|
57
|
+
setHiddenInput(FORM_ID, "new_hidden", "hiddenvalue");
|
|
58
|
+
clearHiddenInput(FORM_ID, "new_hidden");
|
|
59
|
+
expect(DomQuery.byId(FORM_ID).querySelectorAll("input[name='new_hidden']").isAbsent()).to.eq(true);
|
|
60
|
+
})
|
|
61
|
+
|
|
62
|
+
it('submit form must work', function() {
|
|
63
|
+
let FORM_ID = "blarg";
|
|
64
|
+
let form = DomQuery.byId(FORM_ID);
|
|
65
|
+
let submitCalled;
|
|
66
|
+
(form.value.value as any).submit = () => {
|
|
67
|
+
submitCalled = true;
|
|
68
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').isPresent()).to.eq(true);
|
|
69
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').length == 1).to.eq(true);
|
|
70
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').inputValue.value == 'val_booga1').to.eq(true);
|
|
71
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').isPresent()).to.eq(true);
|
|
72
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').length == 1).to.eq(true);
|
|
73
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').inputValue.value == 'val_booga2').to.eq(true);
|
|
74
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isPresent()).to.eq(true);
|
|
75
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).length == 1).to.eq(true);
|
|
76
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).inputValue.value == 'mylink').to.eq(true);
|
|
77
|
+
expect(form.attr("target").value).to.eq('target1');
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
submitForm(FORM_ID, 'mylink', 'target1', {
|
|
82
|
+
booga1: "val_booga1",
|
|
83
|
+
booga2: "val_booga2"
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
expect(submitCalled).to.eq(true);
|
|
87
|
+
form = DomQuery.byId(FORM_ID);
|
|
88
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').isAbsent()).to.eq(true);
|
|
89
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').isAbsent()).to.eq(true);
|
|
90
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isAbsent()).to.eq(true);
|
|
91
|
+
|
|
92
|
+
//const os_spy = Sinon.spy(form.getAsElem(0).value, 'onsubmit' as keyof Element);
|
|
93
|
+
const submit_spy = Sinon.spy(form.getAsElem(0).value, 'submit' as keyof Element);
|
|
94
|
+
expect
|
|
95
|
+
|
|
96
|
+
//we also have to interceot onsbumit
|
|
97
|
+
// expect(os_spy.called).to.eq(true);
|
|
98
|
+
// expect(submit_spy.called).to.eq(true);
|
|
99
|
+
})
|
|
100
|
+
|
|
101
|
+
it('onsubmit form must work', function() {
|
|
102
|
+
let FORM_ID = "blarg";
|
|
103
|
+
let form = DomQuery.byId(FORM_ID);
|
|
104
|
+
let onSubmitCalled;
|
|
105
|
+
(form.value.value as any).onsubmit = () => {
|
|
106
|
+
onSubmitCalled = true;
|
|
107
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').isPresent()).to.eq(true);
|
|
108
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').length == 1).to.eq(true);
|
|
109
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').inputValue.value == 'val_booga1').to.eq(true);
|
|
110
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').isPresent()).to.eq(true);
|
|
111
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').length == 1).to.eq(true);
|
|
112
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').inputValue.value == 'val_booga2').to.eq(true);
|
|
113
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isPresent()).to.eq(true);
|
|
114
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).length == 1).to.eq(true);
|
|
115
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).inputValue.value == 'mylink').to.eq(true);
|
|
116
|
+
expect(form.attr("target").value).to.eq('target1');
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
submitForm(FORM_ID, 'mylink', 'target1', {
|
|
121
|
+
booga1: "val_booga1",
|
|
122
|
+
booga2: "val_booga2"
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
expect(onSubmitCalled).to.eq(true);
|
|
126
|
+
form = DomQuery.byId(FORM_ID);
|
|
127
|
+
expect(form.querySelectorAll('input[name=\'booga1\']').isAbsent()).to.eq(true);
|
|
128
|
+
expect(form.querySelectorAll('input[name=\'booga2\']').isAbsent()).to.eq(true);
|
|
129
|
+
expect(form.querySelectorAll(`input[name='${FORM_ID}:_idcl']`).isAbsent()).to.eq(true);
|
|
130
|
+
|
|
131
|
+
//const os_spy = Sinon.spy(form.getAsElem(0).value, 'onsubmit' as keyof Element);
|
|
132
|
+
const submit_spy = Sinon.spy(form.getAsElem(0).value, 'submit' as keyof Element);
|
|
133
|
+
expect
|
|
134
|
+
|
|
135
|
+
//we also have to interceot onsbumit
|
|
136
|
+
// expect(os_spy.called).to.eq(true);
|
|
137
|
+
// expect(submit_spy.called).to.eq(true);
|
|
138
|
+
})
|
|
139
|
+
|
|
49
140
|
// further tests will follow if needed, for now the namespace must be restored
|
|
50
141
|
});
|
|
@@ -16,52 +16,49 @@
|
|
|
16
16
|
*/
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.oam = void 0;
|
|
19
|
+
var mona_dish_1 = require("mona-dish");
|
|
20
|
+
//TODO add unit tests to check all this here that it works just as before
|
|
19
21
|
var oam;
|
|
20
22
|
(function (oam) {
|
|
21
23
|
/**
|
|
22
24
|
* sets a hidden input field
|
|
23
|
-
* @param
|
|
25
|
+
* @param formName the formName
|
|
24
26
|
* @param name the hidden field
|
|
25
27
|
* @param value the value to be rendered
|
|
26
28
|
*/
|
|
27
|
-
oam.setHiddenInput = function (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
newInput.setAttribute('value', value);
|
|
41
|
-
form.appendChild(newInput);
|
|
42
|
-
}
|
|
29
|
+
oam.setHiddenInput = function (formName, name, value) {
|
|
30
|
+
mona_dish_1.DQ.byId(document.forms[formName])
|
|
31
|
+
.each(function (form) {
|
|
32
|
+
var input = form.querySelectorAll("input[type='hidden'][name='".concat(name, "']"));
|
|
33
|
+
if (input.isPresent()) {
|
|
34
|
+
input.inputValue.value = value;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
var newInput = mona_dish_1.DQ.fromMarkup("<input type='hidden' id='".concat(name, "' name='").concat(name, "'>"));
|
|
38
|
+
newInput.inputValue.value = value;
|
|
39
|
+
newInput.appendTo(form);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
43
42
|
};
|
|
44
43
|
/**
|
|
45
44
|
* clears a hidden input field
|
|
46
45
|
*
|
|
47
|
-
* @param
|
|
46
|
+
* @param formName formName for the input
|
|
48
47
|
* @param name the name of the input field
|
|
49
48
|
*/
|
|
50
|
-
oam.clearHiddenInput = function (
|
|
51
|
-
var
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var hInput = form.elements[name];
|
|
56
|
-
if (typeof hInput != 'undefined') {
|
|
57
|
-
form.removeChild(hInput);
|
|
49
|
+
oam.clearHiddenInput = function (formName, name) {
|
|
50
|
+
var _a, _b, _c;
|
|
51
|
+
var element = (_c = (_b = (_a = document.forms) === null || _a === void 0 ? void 0 : _a[formName]) === null || _b === void 0 ? void 0 : _b.elements) === null || _c === void 0 ? void 0 : _c[name];
|
|
52
|
+
if (!element) {
|
|
53
|
+
return;
|
|
58
54
|
}
|
|
55
|
+
mona_dish_1.DQ.byId(element).delete();
|
|
59
56
|
};
|
|
60
57
|
// noinspection JSUnusedGlobalSymbols
|
|
61
58
|
/**
|
|
62
59
|
* does special form submit remapping
|
|
63
|
-
*
|
|
64
|
-
*
|
|
60
|
+
* re-maps the issuing command link into something,
|
|
61
|
+
* a decode of the command link on the server can understand
|
|
65
62
|
*
|
|
66
63
|
* @param formName
|
|
67
64
|
* @param linkId
|
|
@@ -69,59 +66,39 @@ var oam;
|
|
|
69
66
|
* @param params
|
|
70
67
|
*/
|
|
71
68
|
oam.submitForm = function (formName, linkId, target, params) {
|
|
72
|
-
var _a, _b;
|
|
69
|
+
var _a, _b, _c, _d;
|
|
73
70
|
var clearFn = 'clearFormHiddenParams_' + formName.replace(/-/g, '\$:').replace(/:/g, '_');
|
|
74
|
-
|
|
75
|
-
window[clearFn](formName);
|
|
76
|
-
}
|
|
77
|
-
var form = document.forms[formName];
|
|
78
|
-
if (typeof form == 'undefined') {
|
|
79
|
-
form = document.getElementById(formName);
|
|
80
|
-
}
|
|
71
|
+
(_a = window === null || window === void 0 ? void 0 : window[clearFn]) === null || _a === void 0 ? void 0 : _a.call(window, formName);
|
|
81
72
|
//autoscroll code
|
|
82
|
-
if (((
|
|
73
|
+
if (((_d = (_c = (_b = window === null || window === void 0 ? void 0 : window.myfaces) === null || _b === void 0 ? void 0 : _b.core) === null || _c === void 0 ? void 0 : _c.config) === null || _d === void 0 ? void 0 : _d.autoScroll) && (window === null || window === void 0 ? void 0 : window.getScrolling)) {
|
|
83
74
|
myfaces.oam.setHiddenInput(formName, 'autoScroll', window === null || window === void 0 ? void 0 : window.getScrolling());
|
|
84
75
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
var result =
|
|
97
|
-
if ((typeof result == 'undefined') || result) {
|
|
98
|
-
try {
|
|
99
|
-
form.submit();
|
|
100
|
-
}
|
|
101
|
-
catch (e) {
|
|
102
|
-
if (window.console) {
|
|
103
|
-
console.error(e);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
else {
|
|
76
|
+
mona_dish_1.Stream.ofAssoc(params).each(function (param) {
|
|
77
|
+
myfaces.oam.setHiddenInput(formName, param[0], param[1]);
|
|
78
|
+
});
|
|
79
|
+
//we call the namespaced function, to allow decoration, via a direct call we would
|
|
80
|
+
myfaces.oam.setHiddenInput(formName, "".concat(formName, ":_idcl"), linkId);
|
|
81
|
+
mona_dish_1.DQ.byId(document.forms[formName]).each(function (form) {
|
|
82
|
+
var _a;
|
|
83
|
+
var ATTR_TARGET = "target";
|
|
84
|
+
var formElement = form.getAsElem(0).value;
|
|
85
|
+
var oldTarget = form.attr(ATTR_TARGET).value;
|
|
86
|
+
form.attr(ATTR_TARGET).value = target;
|
|
87
|
+
var result = (_a = formElement === null || formElement === void 0 ? void 0 : formElement.onsubmit) === null || _a === void 0 ? void 0 : _a.call(formElement, null);
|
|
109
88
|
try {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
catch (e) {
|
|
113
|
-
if (window.console) {
|
|
114
|
-
console.error(e);
|
|
89
|
+
if ((!!result) || 'undefined' == typeof result) {
|
|
90
|
+
formElement.submit();
|
|
115
91
|
}
|
|
116
92
|
}
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
if ((typeof params != 'undefined') && params != null) {
|
|
120
|
-
for (var i = 0, param = void 0; (param = params[i]); i++) {
|
|
121
|
-
myfaces.oam.clearHiddenInput(formName, param[0], param[1]);
|
|
93
|
+
catch (e) {
|
|
94
|
+
window === null || window === void 0 ? void 0 : window.console.error(e);
|
|
122
95
|
}
|
|
123
|
-
|
|
124
|
-
|
|
96
|
+
form.attr(ATTR_TARGET).value = oldTarget;
|
|
97
|
+
mona_dish_1.Stream.ofAssoc(params).each(function (param) {
|
|
98
|
+
myfaces.oam.clearHiddenInput(formName, param[0]);
|
|
99
|
+
});
|
|
100
|
+
myfaces.oam.clearHiddenInput(formName, "".concat(formName, ":_idcl"));
|
|
101
|
+
});
|
|
125
102
|
return false;
|
|
126
103
|
};
|
|
127
104
|
})(oam = exports.oam || (exports.oam = {}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OamSubmit.js","sourceRoot":"","sources":["../../src/main/typescript/myfaces/OamSubmit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;
|
|
1
|
+
{"version":3,"file":"OamSubmit.js","sourceRoot":"","sources":["../../src/main/typescript/myfaces/OamSubmit.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;GAcG;;;AAEH,uCAAqC;AAgBrC,yEAAyE;AACzE,IAAc,GAAG,CAqFhB;AArFD,WAAc,GAAG;IACb;;;;;OAKG;IACU,kBAAc,GAAG,UAAU,QAAgB,EAAE,IAAY,EAAE,KAAa;QACjF,cAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;aAC5B,IAAI,CAAC,UAAA,IAAI;YACN,IAAM,KAAK,GAAG,IAAI,CAAC,gBAAgB,CAAC,qCAA8B,IAAI,OAAI,CAAC,CAAC;YAC5E,IAAI,KAAK,CAAC,SAAS,EAAE,EAAE;gBACnB,KAAK,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC;aAClC;iBAAM;gBACH,IAAM,QAAQ,GAAG,cAAE,CAAC,UAAU,CAAC,mCAA4B,IAAI,qBAAW,IAAI,OAAI,CAAC,CAAC;gBACpF,QAAQ,CAAC,UAAU,CAAC,KAAK,GAAG,KAAK,CAAC;gBAClC,QAAQ,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;aAC3B;QACL,CAAC,CAAC,CAAC;IACX,CAAC,CAAC;IAEF;;;;;OAKG;IACU,oBAAgB,GAAG,UAAU,QAAgB,EAAE,IAAY;;QACpE,IAAI,OAAO,GAAG,MAAA,MAAA,MAAA,QAAQ,CAAC,KAAK,0CAAG,QAAQ,CAAC,0CAAE,QAAQ,0CAAG,IAAI,CAAC,CAAC;QAC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(o, m, k, k2) {
|
|
4
|
+
if (k2 === undefined) k2 = k;
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
+
}
|
|
9
|
+
Object.defineProperty(o, k2, desc);
|
|
10
|
+
}) : (function(o, m, k, k2) {
|
|
11
|
+
if (k2 === undefined) k2 = k;
|
|
12
|
+
o[k2] = m[k];
|
|
13
|
+
}));
|
|
14
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
16
|
+
}) : function(o, v) {
|
|
17
|
+
o["default"] = v;
|
|
18
|
+
});
|
|
19
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
20
|
+
if (mod && mod.__esModule) return mod;
|
|
21
|
+
var result = {};
|
|
22
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
23
|
+
__setModuleDefault(result, mod);
|
|
24
|
+
return result;
|
|
25
|
+
};
|
|
3
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
27
|
/* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
5
28
|
* contributor license agreements. See the NOTICE file distributed with
|
|
@@ -19,7 +42,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
42
|
var chai_1 = require("chai");
|
|
20
43
|
var mocha_1 = require("mocha");
|
|
21
44
|
var mona_dish_1 = require("mona-dish");
|
|
22
|
-
var sinon = require("sinon");
|
|
45
|
+
var sinon = __importStar(require("sinon"));
|
|
23
46
|
var trim = mona_dish_1.Lang.trim;
|
|
24
47
|
var ExtDomQuery_1 = require("../../../../impl/util/ExtDomQuery");
|
|
25
48
|
var jsdom = require("jsdom");
|