Browse Source

Fix RemoteStorage Content type

no-jquery
Artur Arseniev 9 years ago
parent
commit
c9652ae6aa
  1. 4
      dist/grapes.min.js
  2. 2
      package.json
  3. 7
      src/commands/view/SelectComponent.js
  4. 33
      src/storage_manager/model/RemoteStorage.js

4
dist/grapes.min.js

File diff suppressed because one or more lines are too long

2
package.json

@ -1,7 +1,7 @@
{ {
"name": "grapesjs", "name": "grapesjs",
"description": "Free and Open Source Web Builder Framework", "description": "Free and Open Source Web Builder Framework",
"version": "0.11.3-rc", "version": "0.11.4",
"author": "Artur Arseniev", "author": "Artur Arseniev",
"license": "BSD-3-Clause", "license": "BSD-3-Clause",
"homepage": "http://grapesjs.com", "homepage": "http://grapesjs.com",

7
src/commands/view/SelectComponent.js

@ -327,12 +327,7 @@ module.exports = {
var modelToStyle; var modelToStyle;
var toggleBodyClass = (method, e, opts) => { var toggleBodyClass = (method, e, opts) => {
var handlerAttr = e.target.getAttribute(attrName); opts.docs && opts.docs.find('body')[method](resizeClass);
var resizeHndClass = pfx + 'resizing-' + handlerAttr;
var classToAdd = resizeClass;// + ' ' +resizeHndClass;
if (opts.docs) {
opts.docs.find('body')[method](classToAdd);
}
}; };

33
src/storage_manager/model/RemoteStorage.js

@ -56,7 +56,7 @@ module.exports = require('backbone').Model.extend({
const em = this.get('em'); const em = this.get('em');
const complete = this.get('onComplete'); const complete = this.get('onComplete');
const typeJson = this.get('contentTypeJson'); const typeJson = this.get('contentTypeJson');
const res = typeJson && typeof text === 'text' ? JSON.parse(text): text; const res = typeJson && typeof text === 'string' ? JSON.parse(text): text;
complete && complete(res); complete && complete(res);
clb && clb(res); clb && clb(res);
em && em.trigger('storage:response', res); em && em.trigger('storage:response', res);
@ -64,19 +64,17 @@ module.exports = require('backbone').Model.extend({
}, },
store(data, clb) { store(data, clb) {
const body = new FormData(); const body = {};
for (let key in data) { for (let key in data) {
body.append(key, data[key]); body[key] = data[key];
} }
this.request(this.get('urlStore'), {body}, clb); this.request(this.get('urlStore'), {body}, clb);
}, },
load(keys, clb) { load(keys, clb) {
const body = new FormData(); this.request(this.get('urlLoad'), {body: {keys}}, clb);
body.append('keys', keys);
this.request(this.get('urlLoad'), {body}, clb);
}, },
/** /**
@ -92,19 +90,32 @@ module.exports = require('backbone').Model.extend({
const params = this.get('params'); const params = this.get('params');
const reqHead = 'X-Requested-With'; const reqHead = 'X-Requested-With';
const typeHead = 'Content-Type'; const typeHead = 'Content-Type';
const body = opts.body; const bodyObj = opts.body || {};
let body;
for (let param in params) { for (let param in params) {
body && body.append(param, params[param]); bodyObj[param] = params[param];
} }
if (isUndefined(headers[reqHead])) { if (isUndefined(headers[reqHead])) {
headers[reqHead] = 'XMLHttpRequest'; headers[reqHead] = 'XMLHttpRequest';
} }
if (isUndefined(headers[typeHead])) { // With `fetch`, have to send FormData without any 'Content-Type'
headers[typeHead] = typeJson ? // https://stackoverflow.com/questions/39280438/fetch-missing-boundary-in-multipart-form-data-post
'application/json; charset=utf-8' : 'x-www-form-urlencoded';
if (isUndefined(headers[typeHead]) && typeJson) {
headers[typeHead] = 'application/json; charset=utf-8';
}
if (typeJson) {
body = JSON.stringify(bodyObj);
} else {
body = new FormData();
for (let bodyKey in bodyObj) {
body.append(bodyKey, bodyObj[bodyKey]);
}
} }
this.onStart(); this.onStart();

Loading…
Cancel
Save