Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
orm,
(state) => state.orm,
(session) => {
return session.Sticky.all().toRefArray();
}
);
export const nodes = createSelector(
orm,
(state) => state.orm,
(session) => {
return session.Node.all().toRefArray();
}
);
export const languageNames = createSelector(
orm,
(state) => state.orm,
(session) => {
return session.Language.all()
.toModelArray()
.map((language) => language.name);
}
);
export const nodesWithParameters = createSelector(
orm,
(state) => state.orm,
(session) => {
// #TODO: this graph is quite some antipattern to functional
// programming...
const nodes = session.Node.all().toModelArray();
(session) => {
return session.Node.all().toRefArray();
}
);
export const languageNames = createSelector(
orm,
(state) => state.orm,
(session) => {
return session.Language.all()
.toModelArray()
.map((language) => language.name);
}
);
export const nodesWithParameters = createSelector(
orm,
(state) => state.orm,
(session) => {
// #TODO: this graph is quite some antipattern to functional
// programming...
const nodes = session.Node.all().toModelArray();
const graph = Graph.getInstance();
let sorted;
try {
const order = GraphAlgorithms.topsort(graph);
sorted = nodes.sort((a, b) => order.findIndex((id) => id === a.id)
- order.findIndex((id) => id === b.id));
} catch (error) {
// #TODO not sure how to check this:
// if (error instanceof CycleException) {
return (lastItem ? lastItem.position : 0) + Config.POSITION_GAP;
}
const prevItem = filteredItems[index - 1];
const nextItem = filteredItems[index];
const prevPosition = prevItem ? prevItem.position : 0;
if (!nextItem) {
return prevPosition + Config.POSITION_GAP;
}
return prevPosition + (nextItem.position - prevPosition) / 2;
};
export const nextBoardPositionSelector = createSelector(
orm,
(_, projectId) => projectId,
(_, __, index) => index,
(_, __, ___, excludedId) => excludedId,
({ Project }, projectId, index, excludedId) => {
const projectModel = Project.withId(projectId);
if (!projectModel) {
return projectModel;
}
return nextPosition(projectModel.getOrderedBoardsQuerySet().toRefArray(), index, excludedId);
},
);
export const nextListPositionSelector = createSelector(
});
});
const firstBoard = projectModel.boards.first();
const firstBoardId = firstBoard && firstBoard.id;
return {
...projectModel.ref,
notificationsTotal,
firstBoardId,
};
});
},
);
export const notificationsForCurrentUserSelector = createSelector(
orm,
(state) => currentUserIdSelector(state),
({ User }, id) => {
if (!id) {
return id;
}
const userModel = User.withId(id);
if (!userModel) {
return userModel;
}
return userModel
.getOrderedUnreadNotificationsQuerySet()
.toModelArray()
import { createSelector } from 'redux-orm';
import orm from '../orm';
import { currentUserIdSelector } from './current';
export const allUsersSelector = createSelector(
orm,
({ User }) => User.getOrderedUndeletedQuerySet().toRefArray(),
);
export const allUsersExceptCurrentSelector = createSelector(
orm,
(state) => currentUserIdSelector(state),
({ User }, currentUserId) => User.getOrderedUndeletedQuerySet()
.exclude({
id: currentUserId,
})
.toRefArray(),
);
({ Card }, id) => {
if (!id) {
return id;
}
const cardModel = Card.withId(id);
if (!cardModel) {
return cardModel;
}
return cardModel.labels.toRefArray();
},
);
export const tasksForCurrentCardSelector = createSelector(
orm,
(state) => pathSelector(state).cardId,
({ Card }, id) => {
if (!id) {
return id;
}
const cardModel = Card.withId(id);
if (!cardModel) {
return cardModel;
}
return cardModel
.getOrderedTasksQuerySet()
.toRefArray()
case types.CREATE_OFFICEHOLDERS:
action.officeholders.map(officeholder => Officeholder.upsert(officeholder));
break;
case types.CREATE_PARTIES:
action.parties.map(party => Party.upsert(party));
break;
case types.CREATE_PEOPLE:
action.people.map(person => Person.upsert(person));
break;
default:
break;
}
return session.state;
};
export const officeSelector = createSelector(
orm,
state => state.orm,
session => {
return session.Office
.all()
.toModelArray()
.map(office => {
if (!office.division) return null;
const officeholder = office.officeholderSet.toModelArray()[0];
if (!officeholder.person) return null;
const obj = office.serialize();
return Object.assign({}, obj, {
division: office.division.serialize(),
officeholder: {
import { createSelector } from 'reselect';
import { createSelector as ormCreateSelector } from 'redux-orm';
import orm from '../orm';
import { toInteger } from '../utils';
export const ormSelector = state => state.orm;
export const posts = createSelector(
ormSelector,
ormCreateSelector(orm, session => {
return session.Post.all().toModelArray().map(post => ({
...post.ref,
...post.labels.toRefArray(),
user: post.user.ref,
})).sort((a, b) => a.id > b.id ? -1 : 1);
})
);
export const post = createSelector(
ormSelector,
state => toInteger(state.router.params.postId),
ormCreateSelector(orm, (session, selectedPostId) => {
if (session.Post.hasId(selectedPostId)) {
const post = session.Post.withId(selectedPostId);
const obj = Object.assign({}, post.ref);
const labelModels = post.labels.toModelArray();
if (!cardModel) {
return cardModel;
}
return cardModel
.getOrderedTasksQuerySet()
.toRefArray()
.map((task) => ({
...task,
isPersisted: !isLocalId(task.id),
}));
},
);
export const actionsForCurrentCardSelector = createSelector(
orm,
(state) => pathSelector(state).cardId,
(state) => currentUserIdSelector(state),
({ Card }, id, currentUserId) => {
if (!id) {
return id;
}
const cardModel = Card.withId(id);
if (!cardModel) {
return cardModel;
}
return cardModel
.getOrderedInCardActionsQuerySet()
};
});
}),
);
export const getDefaultAddress = createSelector(
ormSelector,
createOrmSelector(schema, (session) => {
const { defaultAddress } = session.Session.first() || {};
return defaultAddress && defaultAddress.ref;
}),
);
export const getSigningModalData = createSelector(
ormSelector,
createOrmSelector(schema, session => (session.Session.first() || {}).signingModalData),
);