diff --git a/backend/src/Squidex/wwwroot/scripts/editor-sdk.js b/backend/src/Squidex/wwwroot/scripts/editor-sdk.js index b7bf83aff..f46491125 100644 --- a/backend/src/Squidex/wwwroot/scripts/editor-sdk.js +++ b/backend/src/Squidex/wwwroot/scripts/editor-sdk.js @@ -3,7 +3,7 @@ function SquidexFormField() { var initHandler; var initCalled = false; var disabledHandler; - var disabled; + var disabled = false; var valueHandler; var value; var formValueHandler; @@ -42,9 +42,11 @@ function SquidexFormField() { var type = event.data.type; if (type === 'disabled') { - disabled = event.data.isDisabled; + if (disabled !== event.data.isDisabled) { + disabled = event.data.isDisabled; - raiseDisabled(); + raiseDisabled(); + } } else if (type === 'valueChanged') { value = event.data.value; @@ -113,9 +115,11 @@ function SquidexFormField() { /** * Notifies the control container that the value has been changed. */ - valueChanged: function (value) { + valueChanged: function (newValue) { + value = newValue; + if (window.parent) { - window.parent.postMessage({ type: 'valueChanged', value: value }, '*'); + window.parent.postMessage({ type: 'valueChanged', value: newValue }, '*'); } }, diff --git a/backend/src/Squidex/wwwroot/scripts/simple-log.html b/backend/src/Squidex/wwwroot/scripts/simple-log.html new file mode 100644 index 000000000..aee67a714 --- /dev/null +++ b/backend/src/Squidex/wwwroot/scripts/simple-log.html @@ -0,0 +1,49 @@ + + + +
+ + + + + + + + + + + + + \ No newline at end of file diff --git a/frontend/app/framework/angular/http/http-extensions.spec.ts b/frontend/app/framework/angular/http/http-extensions.spec.ts new file mode 100644 index 000000000..b303ad175 --- /dev/null +++ b/frontend/app/framework/angular/http/http-extensions.spec.ts @@ -0,0 +1,76 @@ +/* + * Squidex Headless CMS + * + * @license + * Copyright (c) Squidex UG (haftungsbeschränkt). All rights reserved. + */ + +import { parseError } from './http-extensions'; + +import { ErrorDto } from './../../utils/error'; + +describe('ErrorParsing', () => { + it('should return default when error is javascript exception', () => { + const response: any = new Error(); + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(500, 'Fallback', [], response)); + }); + + it('should just forward error dto', () => { + const response: any = new ErrorDto(500, 'error', []); + const result = parseError(response, 'Fallback'); + + expect(result).toBe(response); + }); + + it('should return default 412 error', () => { + const response: any = { status: 412 }; + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(412, 'Failed to make the update. Another user has made a change. Please reload.', [], response)); + }); + + it('should return default 429 error', () => { + const response: any = { status: 429 }; + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(429, 'You have exceeded the maximum limit of API calls.', [], response)); + }); + + it('should return error from error object', () => { + const error = { message: 'My-Message', details: ['My-Detail'] }; + + const response: any = { status: 400, error }; + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(400, 'My-Message', ['My-Detail'], response)); + }); + + it('should return error from error json', () => { + const error = { message: 'My-Message', details: ['My-Detail'] }; + + const response: any = { status: 400, error: JSON.stringify(error) }; + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(400, 'My-Message', ['My-Detail'], response)); + }); + + it('should return default when object is invalid', () => { + const error = { text: 'invalid' }; + + const response: any = { status: 400, error }; + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(500, 'Fallback', [], response)); + }); + + it('should return default when json is invalid', () => { + const error = '{{'; + + const response: any = { status: 400, error }; + const result = parseError(response, 'Fallback'); + + expect(result).toEqual(new ErrorDto(500, 'Fallback', [], response)); + }); +}); \ No newline at end of file diff --git a/frontend/app/framework/angular/http/http-extensions.ts b/frontend/app/framework/angular/http/http-extensions.ts index a36270172..1ed09caa1 100644 --- a/frontend/app/framework/angular/http/http-extensions.ts +++ b/frontend/app/framework/angular/http/http-extensions.ts @@ -86,37 +86,41 @@ export module HTTP { export const pretifyError = (message: string) =>