diff --git a/Message/Request/Request.js b/Message/Request/Request.js index 9c3b7cf..338c51b 100644 --- a/Message/Request/Request.js +++ b/Message/Request/Request.js @@ -56,6 +56,8 @@ return 'application/json'; case jsOMS.Message.Request.RequestType.URL_ENCODE: return 'application/x-www-form-urlencoded'; + case jsOMS.Message.Request.RequestType.FILE: + return ''; default: return 'text/plain'; } @@ -308,7 +310,8 @@ */ setType(type) { - this.type = type; + this.type = type; + this.requestHeader['Content-Type'] = this.setContentTypeBasedOnType(this.type); }; /** @@ -365,12 +368,14 @@ this.xhr.open(this.method, jsOMS.Uri.UriFactory.build(this.uri)); for (let p in this.requestHeader) { - if (this.requestHeader.hasOwnProperty(p)) { + if (this.requestHeader.hasOwnProperty(p) && this.requestHeader[p] !== '') { this.xhr.setRequestHeader(p, this.requestHeader[p]); } } } + console.log(this.xhr); + this.xhr.onreadystatechange = function() { switch (self.xhr.readyState) { @@ -381,12 +386,6 @@ self.result[self.xhr.status](self.xhr); } break; - case 2: - // todo: handle server received request - break; - case 3: - // todo: server is handling request - break; default: // todo: create handler for error returns } @@ -394,7 +393,9 @@ if (this.type === jsOMS.Message.Request.RequestType.JSON) { this.xhr.send(JSON.stringify(this.data)); - } else if (this.type === jsOMS.Message.Request.RequestType.RAW) { + } else if (this.type === jsOMS.Message.Request.RequestType.RAW + || this.type === jsOMS.Message.Request.RequestType.FILE + ) { this.xhr.send(this.data); } else if (this.type === jsOMS.Message.Request.RequestType.URL_ENCODE) { this.xhr.send(this.queryfy(this.data)); diff --git a/Message/Request/RequestType.js b/Message/Request/RequestType.js index fdb98a4..6b6efe1 100644 --- a/Message/Request/RequestType.js +++ b/Message/Request/RequestType.js @@ -16,6 +16,7 @@ jsOMS.Message.Request.RequestType = Object.freeze({ JSON: 'json', RAW: 'raw', + FILE: 'file', URL_ENCODE: 'url' }); }(window.jsOMS = window.jsOMS || {})); diff --git a/UI/Component/Form.js b/UI/Component/Form.js index 31e310f..222f445 100644 --- a/UI/Component/Form.js +++ b/UI/Component/Form.js @@ -177,7 +177,9 @@ } } - this.app.eventManager.trigger(form.getId()); + if (counter < 1) { + this.app.eventManager.trigger(form.getId()); + } }; /** diff --git a/Views/FormView.js b/Views/FormView.js index e6acd2a..8fe7c97 100644 --- a/Views/FormView.js +++ b/Views/FormView.js @@ -93,9 +93,9 @@ getSubmit () { return document.querySelectorAll( - '#' + this.id + ' input[type=submit],' - + ' button[form=' + this.id + '][type=submit],' - + ' #' + this.id + ' button[type=submit]' + '#' + this.id + ' input[type=submit], ' + + 'button[form=' + this.id + '][type=submit], ' + + '#' + this.id + ' button[type=submit]' ); };