Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onScoreEdit(response: contentTypes.Response, score: string) {
const {
itemModel,
partModel,
onEdit,
} = this.props;
const updated = response.with({ score: Maybe.just(score) });
const newPartModel = partModel.with(
{ responses: partModel.responses.set(updated.guid, updated) });
onEdit(itemModel, newPartModel, updated);
}
onScoreEdit(response: contentTypes.Response, score: string) {
const { partModel, itemModel, onEdit } = this.props;
const updatedScore = response.with({
score: score === '' ? Maybe.nothing() : Maybe.just(score),
});
const updatedPartModel = partModel.with(
{ responses: partModel.responses.set(updatedScore.guid, updatedScore) },
);
onEdit(itemModel, updatedPartModel, updatedPartModel);
}
onScoreEdit(response: contentTypes.Response, score: string) {
const { model, onEdit } = this.props;
onEdit(model.with({
responses: model.responses.set(
response.guid,
model.responses.get(response.guid).with({
score: score === '' ? Maybe.nothing() : Maybe.just(score),
}),
),
}));
}
onScoreEdit(response: contentTypes.Response, score: string) {
const { partModel, itemModel, onEdit } = this.props;
const updatedScore = response.with({
score: score === '' ? Maybe.nothing() : Maybe.just(score),
});
const updatedPartModel = partModel.with(
{ responses: partModel.responses.set(updatedScore.guid, updatedScore) },
);
onEdit(itemModel, updatedPartModel, updatedPartModel);
}
onScoreEdit = (response: contentTypes.Response, score: string) => {
const { partModel } = this.props;
this.onPartEdit(
partModel.with({
responses: partModel.responses.set(
response.guid,
response.with({
score: score === '' ? Maybe.nothing() : Maybe.just(score),
}),
),
}),
null,
);
}
function fromStr(value: string): Maybe {
switch (value) {
case 'note': return Maybe.just(PulloutType.Note);
case 'notation': return Maybe.just(PulloutType.Notation);
case 'observation': return Maybe.just(PulloutType.Observation);
case 'research': return Maybe.just(PulloutType.Research);
case 'tip': return Maybe.just(PulloutType.Tip);
case 'tosumup': return Maybe.just(PulloutType.ToSumUp);
default: return Maybe.nothing();
}
}
static fromPersistence(root: Object, guid: string, notify: () => void) : Dt {
const t = (root as any).dt;
let model = new Dt().with({ guid });
if (t['@title'] !== undefined) {
model = model.with({ title: Maybe.just(t['@title']) });
}
model = model.with({ content: ContentElements
.fromPersistence(t, createGuid(), INLINE_ELEMENTS, null, notify) });
return model;
}
static fromPersistence(root: Object, guid: string, notify: () => void): Anchor {
const t = (root as any).anchor;
let model = new Anchor({ guid });
const children = getChildren(t);
if (children instanceof Array
&& children.length === 1 && (children[0] as any).image !== undefined) {
model = model.with({ content: Maybe.just(Image.fromPersistence(children[0], '', notify)) });
}
return model;
}
static fromPersistence(root: Object, guid: string, notify: () => void) : Quote {
const t = (root as any).quote;
const text = ContentElements.fromPersistence(getChildren(t), '', TEXT_ELEMENTS, null, notify);
const entry = t['@entry'] === undefined
? Maybe.nothing()
: Maybe.just(t['@entry']);
return new Quote().with({ guid, text, entry });
}
static fromPersistence(root: Object, guid: string, notify: () => void) : BlockQuote {
const t = (root as any).quote;
const text = ContiguousText.fromPersistence(getChildren(t), '', ContiguousTextMode.SimpleText);
const entry = t['@entry'] === undefined
? Maybe.nothing()
: Maybe.just(t['@entry']);
return new BlockQuote({ guid, text, entry });
}