Commit ecce565d authored by Andreas Fernandez's avatar Andreas Fernandez Committed by Christian Kuhn
Browse files

[BUGFIX] Expose interfaces of AjaxDataHandler

Since the AjaxDataHandler is meant to be used in other modules as well,
the interfaces responsible for the response and the messages need to be
public to be able to write type-safe callbacks.

Resolves: #84172
Releases: master
Change-Id: Ib49f25181bc8c83a0cdc89da3a9b466b6bd25d59
Reviewed-on: https://review.typo3.org/56041


Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Nägler's avatarFrank Naegler <frank.naegler@typo3.org>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
parent 417d2b56
......@@ -12,6 +12,8 @@
*/
import {SeverityEnum} from './Enum/Severity';
import MessageInterface from './AjaxDataHandler/MessageInterface';
import ResponseInterface from './AjaxDataHandler/ResponseInterface';
import * as $ from 'jquery';
import Icons = require('./Icons');
import Modal = require('./Modal');
......@@ -24,18 +26,6 @@ enum Identifiers {
icon = '.t3js-icon'
}
interface Message {
title: string;
message: string;
severity: SeverityEnum;
}
interface Response {
redirect: string;
messages: Array<Message>;
hasErrors: boolean;
}
/**
* Module: TYPO3/CMS/Backend/AjaxDataHandler
* AjaxDataHandler - Javascript functions to work with AJAX and interacting with tce_db.php
......@@ -63,7 +53,7 @@ class AjaxDataHandler {
* @returns {JQueryPromise<any>}
*/
public process(parameters: Object): JQueryPromise<any> {
return this._call(parameters).done((result: Response): void => {
return this._call(parameters).done((result: ResponseInterface): void => {
if (result.hasErrors) {
this.handleErrors(result);
}
......@@ -83,7 +73,7 @@ class AjaxDataHandler {
this._showSpinnerIcon($iconElement);
// make the AJAX call to toggle the visibility
this._call(params).done((result: Response): void => {
this._call(params).done((result: ResponseInterface): void => {
// print messages on errors
if (result.hasErrors) {
this.handleErrors(result);
......@@ -193,7 +183,7 @@ class AjaxDataHandler {
this._showSpinnerIcon($iconElement);
// make the AJAX call to toggle the visibility
this._call(params).done((result: Response): void => {
this._call(params).done((result: ResponseInterface): void => {
// revert to the old class
Icons.getIcon('actions-edit-delete', Icons.sizes.small).done((icon: string): void => {
$iconElement = $anchorElement.find(Identifiers.icon);
......@@ -237,8 +227,8 @@ class AjaxDataHandler {
*
* @param {Object} result
*/
private handleErrors(result: Response): void {
$.each(result.messages, (position: number, message: Message): void => {
private handleErrors(result: ResponseInterface): void {
$.each(result.messages, (position: number, message: MessageInterface): void => {
Notification.error(message.title, message.message);
});
}
......
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
export default interface MessageInterface {
title: string;
message: string;
severity: number;
}
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
import MessageInterface from './MessageInterface';
export default interface ResponseInterface {
redirect: string;
messages: Array<MessageInterface>;
hasErrors: boolean;
}
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports"],function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})});
\ No newline at end of file
/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/
define(["require","exports"],function(e,r){"use strict";Object.defineProperty(r,"__esModule",{value:!0})});
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment