Browse Source

Fix RemoteStorage Content type

no-jquery
Artur Arseniev 8 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",
"description": "Free and Open Source Web Builder Framework",
"version": "0.11.3-rc",
"version": "0.11.4",
"author": "Artur Arseniev",
"license": "BSD-3-Clause",
"homepage": "http://grapesjs.com",

7
src/commands/view/SelectComponent.js

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

33
src/storage_manager/model/RemoteStorage.js

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

Loading…
Cancel
Save