Simplify access to details fields in createTermEntry
This commit is contained in:
parent
06183ec124
commit
025b1f398b
@ -44,13 +44,15 @@ class DisplayGenerator {
|
|||||||
const debugInfoContainer = node.querySelector('.debug-info');
|
const debugInfoContainer = node.querySelector('.debug-info');
|
||||||
const bodyContainer = node.querySelector('.term-entry-body');
|
const bodyContainer = node.querySelector('.term-entry-body');
|
||||||
|
|
||||||
|
const {termTags, expressions, definitions} = details;
|
||||||
|
|
||||||
const pitches = this._getPitchInfos(details);
|
const pitches = this._getPitchInfos(details);
|
||||||
const pitchCount = pitches.reduce((i, v) => i + v[1].length, 0);
|
const pitchCount = pitches.reduce((i, v) => i + v[1].length, 0);
|
||||||
|
|
||||||
const expressionMulti = Array.isArray(details.expressions);
|
const expressionMulti = Array.isArray(expressions);
|
||||||
const definitionMulti = Array.isArray(details.definitions);
|
const definitionMulti = Array.isArray(definitions);
|
||||||
const expressionCount = expressionMulti ? details.expressions.length : 1;
|
const expressionCount = expressionMulti ? expressions.length : 1;
|
||||||
const definitionCount = definitionMulti ? details.definitions.length : 1;
|
const definitionCount = definitionMulti ? definitions.length : 1;
|
||||||
const uniqueExpressionCount = Array.isArray(details.expression) ? new Set(details.expression).size : 1;
|
const uniqueExpressionCount = Array.isArray(details.expression) ? new Set(details.expression).size : 1;
|
||||||
|
|
||||||
node.dataset.expressionMulti = `${expressionMulti}`;
|
node.dataset.expressionMulti = `${expressionMulti}`;
|
||||||
@ -66,15 +68,11 @@ class DisplayGenerator {
|
|||||||
(pitches.length > 0 ? 1 : 0)
|
(pitches.length > 0 ? 1 : 0)
|
||||||
}`;
|
}`;
|
||||||
|
|
||||||
const termTags = details.termTags;
|
this._appendMultiple(expressionsContainer, this._createTermExpression.bind(this), expressionMulti ? expressions : [details], termTags);
|
||||||
let expressions = details.expressions;
|
|
||||||
expressions = Array.isArray(expressions) ? expressions : [details];
|
|
||||||
|
|
||||||
this._appendMultiple(expressionsContainer, this._createTermExpression.bind(this), expressions, termTags);
|
|
||||||
this._appendMultiple(reasonsContainer, this._createTermReason.bind(this), details.reasons);
|
this._appendMultiple(reasonsContainer, this._createTermReason.bind(this), details.reasons);
|
||||||
this._appendMultiple(frequenciesContainer, this._createFrequencyTag.bind(this), details.frequencies);
|
this._appendMultiple(frequenciesContainer, this._createFrequencyTag.bind(this), details.frequencies);
|
||||||
this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches);
|
this._appendMultiple(pitchesContainer, this._createPitches.bind(this), pitches);
|
||||||
this._appendMultiple(definitionsContainer, this._createTermDefinitionItem.bind(this), definitionMulti ? details.definitions : [details]);
|
this._appendMultiple(definitionsContainer, this._createTermDefinitionItem.bind(this), definitionMulti ? definitions : [details]);
|
||||||
|
|
||||||
if (debugInfoContainer !== null) {
|
if (debugInfoContainer !== null) {
|
||||||
debugInfoContainer.textContent = JSON.stringify(details, null, 4);
|
debugInfoContainer.textContent = JSON.stringify(details, null, 4);
|
||||||
|
Loading…
Reference in New Issue
Block a user