Merge branch 'master' into master

This commit is contained in:
Jim LAURIE 2018-07-23 15:42:28 +02:00 committed by GitHub
commit a64e12e5dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 16 additions and 10 deletions

View File

@ -1,6 +1,6 @@
# Configurations
The main configurations of the project are located in the `./config` directory. Additional configs can be added in the `./api/**/config` folder of each APIs and plugins by creating JavaScript or JSON files.
The main configurations of the project are located in the `./config` directory. Additional configs can be added in the `./api/**/config` folder of each API and plugin by creating JavaScript or JSON files.
## Application
@ -153,7 +153,7 @@ Each JSON file located in the folder must have the name of its corresponding tra
Most of the application's configurations are defined by environment. It means that you can specify settings for each environment (`development`, `production`, `test`, etc.).
> Note: You can access to the config of the current environment through `strapi.config.currentEnvironment`.
> Note: You can access the config of the current environment through `strapi.config.currentEnvironment`.
***

View File

@ -10,15 +10,17 @@ const _ = require('lodash');
// Utils
const { models: { getValuePrimaryKey } } = require('strapi-utils');
const transformToArrayID = (array) => {
const transformToArrayID = (array, association) => {
if(_.isArray(array)) {
return array.map(value => {
array = array.map(value => {
if (_.isPlainObject(value)) {
return value._id || value.id;
return value._id || value.id || false;
}
return value;
});
return array.filter(n => n);
}
if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) {
@ -140,8 +142,8 @@ module.exports = {
case 'manyToMany':
if (response[current] && _.isArray(response[current]) && current !== 'id') {
// Compare array of ID to find deleted files.
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
const storedValue = transformToArrayID(params.values[current]).map(id => id.toString());
const currentValue = transformToArrayID(response[current], association).map(id => id.toString());
const storedValue = transformToArrayID(params.values[current], association).map(id => id.toString());
const toAdd = _.difference(storedValue, currentValue);
const toRemove = _.difference(currentValue, storedValue);
@ -229,8 +231,8 @@ module.exports = {
case 'oneToManyMorph':
case 'manyToManyMorph': {
// Compare array of ID to find deleted files.
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
const storedValue = transformToArrayID(params.values[current]).map(id => id.toString());
const currentValue = transformToArrayID(response[current], association).map(id => id.toString());
const storedValue = transformToArrayID(params.values[current], association).map(id => id.toString());
const toAdd = _.difference(storedValue, currentValue);
const toRemove = _.difference(currentValue, storedValue);

View File

@ -168,6 +168,9 @@ module.exports = {
case 'float':
type = 'Float';
break;
case 'json':
type = 'JSON';
break;
case 'time':
case 'date':
case 'datetime':

View File

@ -101,6 +101,8 @@ module.exports = {
},
remove: async (params, config) => {
params.id = (params._id || params.id);
const file = await strapi.plugins['upload'].services.upload.fetch(params);
// get upload provider settings to configure the provider to use
@ -116,7 +118,6 @@ module.exports = {
// Use Content Manager business logic to handle relation.
if (strapi.plugins['content-manager']) {
params.model = 'file';
params.id = (params._id || params.id);
await strapi.plugins['content-manager'].services['contentmanager'].delete(params, {source: 'upload'});
}