Fix #2947: Allow json success result on modalSubmit

This commit is contained in:
buddh4 2018-01-19 14:43:56 +01:00
parent 1dfcfb2e1e
commit 55319a0302
2 changed files with 18 additions and 5 deletions

View File

@ -13,6 +13,8 @@ HumHub Change Log
- Fix: Typo in password recovery (@acs-ferreira)
- Fix: Profile posts of friends not appears on dashboard
- Fix #2745: Yii2 2.0.13 will break the admin interface
- Enh: Allow auto detection of response dataType
- Fix #2947: Allow json success result on modalSubmit
1.2.4 (December 13, 2017)

View File

@ -1,7 +1,7 @@
/**
* Module for creating an manipulating modal dialoges.
* Normal layout of a dialog:
*
*
* <div class="modal">
* <div class="modal-dialog">
* <div class="modal-content">
@ -11,7 +11,7 @@
* </div>
* </div>
* </div>
*
*
* @param {type} param1
* @param {type} param2
*/
@ -33,7 +33,7 @@ humhub.module('ui.modal', function (module, require, $) {
* The Modal class can be used to create new modals or manipulate existing modals.
* If the constructor finds an element with the given id we use the existing modal,
* if the id is not already used, we create a new modal dom element.
*
*
* @param {string} id - id of the modal
*/
var Modal = function (node, options) {
@ -93,7 +93,7 @@ humhub.module('ui.modal', function (module, require, $) {
this.set(options);
};
Modal.prototype.checkAriaLabel = function () {
var $title = this.$.find('.modal-title');
if($title.length) {
@ -190,6 +190,7 @@ humhub.module('ui.modal', function (module, require, $) {
Modal.prototype.load = function (url, cfg, originalEvent) {
var that = this;
var cfg = cfg || {};
cfg.dataType = cfg.dataType || 'html';
return new Promise(function (resolve, reject) {
if (!that.isVisible()) {
that.loader();
@ -204,6 +205,7 @@ humhub.module('ui.modal', function (module, require, $) {
Modal.prototype.post = function (url, cfg, originalEvent) {
var that = this;
var cfg = cfg || {};
cfg.dataType = cfg.dataType || 'html';
return new Promise(function (resolve, reject) {
if (!that.isVisible()) {
that.loader();
@ -346,6 +348,7 @@ humhub.module('ui.modal', function (module, require, $) {
* @returns {undefined}
*/
Modal.prototype.setHeader = function (title) {
debugger;
var $header = this.getHeader();
if (!$header.length) {
$header = $(this.getTemplate('header'));
@ -415,7 +418,7 @@ humhub.module('ui.modal', function (module, require, $) {
Modal.prototype.setBody = function (content) {
var $body = this.getBody();
if (!$body.length) {
this.setContent($(this.getTemplate('body')));
this.getContent().append($(this.getTemplate('body')));
$body = this.getBody();
}
$body.html(content);
@ -610,7 +613,9 @@ humhub.module('ui.modal', function (module, require, $) {
});
};
debugger;
var submit = function (evt, options) {
debugger;
evt.$form = evt.$form || evt.$trigger.closest('form');
if (!evt.$form.length) {
@ -628,6 +633,11 @@ humhub.module('ui.modal', function (module, require, $) {
var modal = (id) ? module.get(id) : module.global;
return client.submit(evt, _defaultRequestOptions(evt, options)).then(function (response) {
if(response.success) {
modal.close();
return response;
}
modal.setDialog(response);
if (!modal.$.is(':visible')) {
modal.show();
@ -681,6 +691,7 @@ humhub.module('ui.modal', function (module, require, $) {
};
var get = function (id, options) {
debugger;
var modal = !(modals[id]) ? new Modal(id) : modals[id];
if (options) {
modal.set(options);