mirror of
https://github.com/strapi/strapi.git
synced 2025-10-28 00:22:51 +00:00
Merge branch 'master' into master
This commit is contained in:
commit
a64e12e5dd
@ -1,6 +1,6 @@
|
|||||||
# Configurations
|
# 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
|
## 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.).
|
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`.
|
||||||
|
|
||||||
***
|
***
|
||||||
|
|
||||||
|
|||||||
@ -10,15 +10,17 @@ const _ = require('lodash');
|
|||||||
// Utils
|
// Utils
|
||||||
const { models: { getValuePrimaryKey } } = require('strapi-utils');
|
const { models: { getValuePrimaryKey } } = require('strapi-utils');
|
||||||
|
|
||||||
const transformToArrayID = (array) => {
|
const transformToArrayID = (array, association) => {
|
||||||
if(_.isArray(array)) {
|
if(_.isArray(array)) {
|
||||||
return array.map(value => {
|
array = array.map(value => {
|
||||||
if (_.isPlainObject(value)) {
|
if (_.isPlainObject(value)) {
|
||||||
return value._id || value.id;
|
return value._id || value.id || false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
return array.filter(n => n);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) {
|
if (association.type === 'model' || (association.type === 'collection' && _.isObject(array))) {
|
||||||
@ -140,8 +142,8 @@ module.exports = {
|
|||||||
case 'manyToMany':
|
case 'manyToMany':
|
||||||
if (response[current] && _.isArray(response[current]) && current !== 'id') {
|
if (response[current] && _.isArray(response[current]) && current !== 'id') {
|
||||||
// Compare array of ID to find deleted files.
|
// Compare array of ID to find deleted files.
|
||||||
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
|
const currentValue = transformToArrayID(response[current], association).map(id => id.toString());
|
||||||
const storedValue = transformToArrayID(params.values[current]).map(id => id.toString());
|
const storedValue = transformToArrayID(params.values[current], association).map(id => id.toString());
|
||||||
|
|
||||||
const toAdd = _.difference(storedValue, currentValue);
|
const toAdd = _.difference(storedValue, currentValue);
|
||||||
const toRemove = _.difference(currentValue, storedValue);
|
const toRemove = _.difference(currentValue, storedValue);
|
||||||
@ -229,8 +231,8 @@ module.exports = {
|
|||||||
case 'oneToManyMorph':
|
case 'oneToManyMorph':
|
||||||
case 'manyToManyMorph': {
|
case 'manyToManyMorph': {
|
||||||
// Compare array of ID to find deleted files.
|
// Compare array of ID to find deleted files.
|
||||||
const currentValue = transformToArrayID(response[current]).map(id => id.toString());
|
const currentValue = transformToArrayID(response[current], association).map(id => id.toString());
|
||||||
const storedValue = transformToArrayID(params.values[current]).map(id => id.toString());
|
const storedValue = transformToArrayID(params.values[current], association).map(id => id.toString());
|
||||||
|
|
||||||
const toAdd = _.difference(storedValue, currentValue);
|
const toAdd = _.difference(storedValue, currentValue);
|
||||||
const toRemove = _.difference(currentValue, storedValue);
|
const toRemove = _.difference(currentValue, storedValue);
|
||||||
|
|||||||
@ -168,6 +168,9 @@ module.exports = {
|
|||||||
case 'float':
|
case 'float':
|
||||||
type = 'Float';
|
type = 'Float';
|
||||||
break;
|
break;
|
||||||
|
case 'json':
|
||||||
|
type = 'JSON';
|
||||||
|
break;
|
||||||
case 'time':
|
case 'time':
|
||||||
case 'date':
|
case 'date':
|
||||||
case 'datetime':
|
case 'datetime':
|
||||||
|
|||||||
@ -101,6 +101,8 @@ module.exports = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
remove: async (params, config) => {
|
remove: async (params, config) => {
|
||||||
|
params.id = (params._id || params.id);
|
||||||
|
|
||||||
const file = await strapi.plugins['upload'].services.upload.fetch(params);
|
const file = await strapi.plugins['upload'].services.upload.fetch(params);
|
||||||
|
|
||||||
// get upload provider settings to configure the provider to use
|
// get upload provider settings to configure the provider to use
|
||||||
@ -116,7 +118,6 @@ module.exports = {
|
|||||||
// Use Content Manager business logic to handle relation.
|
// Use Content Manager business logic to handle relation.
|
||||||
if (strapi.plugins['content-manager']) {
|
if (strapi.plugins['content-manager']) {
|
||||||
params.model = 'file';
|
params.model = 'file';
|
||||||
params.id = (params._id || params.id);
|
|
||||||
|
|
||||||
await strapi.plugins['content-manager'].services['contentmanager'].delete(params, {source: 'upload'});
|
await strapi.plugins['content-manager'].services['contentmanager'].delete(params, {source: 'upload'});
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user