Single file collections (#132)
* Files based collections skeleton * listing file based cards * create new entry with collection * moved lookupEntry to main backend * Editing single page Collections file * List widget basic implementation * Adjustments for test-repo * check if value exists before trying to iterate over
This commit is contained in:
@ -1,13 +1,21 @@
|
||||
import { OrderedMap, fromJS } from 'immutable';
|
||||
import { CONFIG_SUCCESS } from '../actions/config';
|
||||
import { FILES, FOLDER } from '../constants/collectionTypes';
|
||||
|
||||
const hasProperty = (config, property) => ({}.hasOwnProperty.call(config, property));
|
||||
|
||||
const collections = (state = null, action) => {
|
||||
switch (action.type) {
|
||||
case CONFIG_SUCCESS:
|
||||
const collections = action.payload && action.payload.collections;
|
||||
const configCollections = action.payload && action.payload.collections;
|
||||
return OrderedMap().withMutations((map) => {
|
||||
(collections || []).forEach(function(collection) {
|
||||
map.set(collection.name, fromJS(collection));
|
||||
(configCollections || []).forEach((configCollection) => {
|
||||
if (hasProperty(configCollection, 'folder')) {
|
||||
configCollection.type = FOLDER; // eslint-disable-line no-param-reassign
|
||||
} else if (hasProperty(configCollection, 'files')) {
|
||||
configCollection.type = FILES; // eslint-disable-line no-param-reassign
|
||||
}
|
||||
map.set(configCollection.name, fromJS(configCollection));
|
||||
});
|
||||
});
|
||||
default:
|
||||
|
Reference in New Issue
Block a user