diff --git a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl index 421e861e..95940ef2 100644 --- a/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl +++ b/src/main/resources/modules/SpringBoot/resources/templates/control/nav.ftl @@ -154,11 +154,11 @@ return Promise.resolve(rsp); }) }; - function Ajax(module, target, method) { + function Ajax(module, target, method, data) { this.mModule = module; this.mTarget = target; this.mMethod = method; - this.mData = {}; + this.mData = data ? data : {}; this.module = function (module) { this.mModule = module; @@ -177,10 +177,26 @@ return this; }; this.post = function (callback) { - jsonRequest({ - url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: JSON.stringify(this.mData), - }).then(callback) + switch (this.mMethod) { + case "upload": + case "imports": + return upRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: this.mData + }).then(callback); + break; + case "template": + return downRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: JSON.stringify(this.mData) + }).then(callback); + break; + default: + jsonRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: JSON.stringify(this.mData) + }).then(callback); + } }; this.create = function (callback) { this.mMethod = "create"; @@ -210,21 +226,28 @@ this.mMethod = "template"; return downRequest({ url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: JSON.stringify(this.mData), + data: JSON.stringify(this.mData) }).then(callback) }; this.imports = function (callback) { this.mMethod = "imports"; return upRequest({ url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: this.mData, + data: this.mData }).then(callback) }; this.exports = function (callback) { this.mMethod = "exports"; return downRequest({ url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, - data: JSON.stringify(this.mData), + data: JSON.stringify(this.mData) + }).then(callback) + }; + this.upload = function (callback) { + this.mMethod = "upload"; + return upRequest({ + url: '/ajax/' + this.mModule + "/" + this.mTarget + "/" + this.mMethod, + data: this.mData }).then(callback) }; }