Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
class Bucket extends CRUDModel {
denormalize() {
const data = Object.assign({}, this.ref)
delete data.id;
delete data.survey;
return data;
}
};
Bucket.modelName = 'Bucket';
Bucket.fields = {
id: attr(), // non-relational field for any value; optional but highly recommended
bucket_type: attr(),
bucket: attr(),
survey: fk('Survey', 'buckets')
};
class Logic extends CRUDModel {
denormalize() {
const data = Object.assign({}, this.ref)
delete data.id
delete data.question
return data
}
};
Logic.modelName = 'Logic';
Logic.fields = {
id: attr(),
.forEach((link) => {
// #TODO check if this is safe when REMOVE_NODE deletes nodeModel
if (link.portFromModel.outputParent.id == payload.parameterId) {
link.portToModel.inputParent.update(payload.newValues);
}
});
break;
}
return undefined;
}
}
Link.modelName = 'Link';
Link.fields = {
id: attr(),
portFrom: fk({
to: 'Port',
as: 'portFromModel',
relatedName: 'outputLinks',
}),
portTo: fk({
to: 'Port',
as: 'portToModel',
relatedName: 'inputLinks',
}),
};
export default Link;
Logic.modelName = 'Logic';
Logic.fields = {
id: attr(),
question: oneToOne('Question')
};
class Choice extends CRUDModel {};
Choice.modelName = 'Choice';
Choice.fields = {
id: attr(),
question: fk('Question', 'multiple_choices')
}
const orm = new ORM();
orm.register(Survey, Node, Question, Bucket, Logic, Choice);
console.log('new orm', orm)
export {Survey, Node, Question, Bucket, Logic, Choice, orm}
import {Model, many, fk, attr} from "redux-orm";
export default class Unit extends Model {
static modelName = "Unit";
static fields = {
id : attr(),
name : attr(),
affiliation : fk("Faction"),
color : attr(),
lances : many("Lance"),
pilots : many("Pilot"),
mechs : many("Mech")
};
static parse(unitData) {
const {Pilot, Mech, Lance} = this.session;
const parsedData = {
...unitData,
lances : unitData.lances.map(lanceEntry => Lance.parse(lanceEntry)),
pilots : unitData.pilots.map(pilotEntry => Pilot.parse(pilotEntry)),
mechs : unitData.mechs.map(mechEntry => Mech.parse(mechEntry)),
};
(config.form || []).forEach(field => {
if (field['wq:ForeignKey']) {
fields[field.name + '_id'] = fk({
to: field['wq:ForeignKey'],
as: field.name,
relatedName:
field['wq:related_name'] ||
config.url ||
config.name + 's'
});
} else if (field.type !== 'repeat') {
fields[field.name] = attr();
}
});
return fields;
import { attr, fk, Model } from 'redux-orm';
class Image extends Model {}
Image.modelName = 'image';
Image.fields = {
category: fk('category', 'images'),
checksum: attr(),
data: attr(),
id: attr()
};
export default Image;
}
});
break;
}
return undefined;
}
}
Link.modelName = "Link";
Link.fields = {
id: attr(),
portFrom: fk({
to: "Port",
as: "portFromModel",
relatedName: "outputLinks"
}),
portTo: fk({
to: "Port",
as: "portToModel",
relatedName: "inputLinks"
})
};
export default Link;
timer: attr(),
isSubscribed: attr({
getDefault: () => false,
}),
isActionsFetching: attr({
getDefault: () => false,
}),
isAllActionsFetched: attr({
getDefault: () => false,
}),
listId: fk({
to: 'List',
as: 'list',
relatedName: 'cards',
}),
boardId: fk({
to: 'Board',
as: 'board',
relatedName: 'cards',
}),
users: many('User', 'cards'),
labels: many('Label', 'cards'),
};
static reducer({ type, payload }, Card) {
switch (type) {
case ActionTypes.USER_TO_CARD_ADD: {
const cardModel = Card.withId(payload.cardId);
cardModel.users.add(payload.id);
if (payload.isCurrent) {
cardModel.isSubscribed = true;
import {Model, fk, attr} from "redux-orm";
export default class Mech extends Model {
static modelName = "Mech";
static fields = {
id : attr(),
type : fk("MechDesign"),
pilot : fk("Pilot"),
};
static parse(mechData) {
return this.create(mechData);
}
}
static get fields() {
return {
id: attr(),
body: attr(),
createdAt: attr(),
updatedAt: attr(),
user: fk('User', 'comments'),
post: fk('Post', 'comments'),
}
}