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:
Cássio Souza
2016-10-21 20:42:14 -02:00
committed by GitHub
parent cca338df79
commit 2496ec09a4
18 changed files with 190 additions and 102 deletions

View File

@ -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: