|
|
@ -15,6 +15,9 @@ interface TraitsViewProps { |
|
|
categories: Categories; |
|
|
categories: Categories; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const ATTR_CATEGORIES = 'data-categories'; |
|
|
|
|
|
const ATTR_NO_CATEGORIES = 'data-no-categories'; |
|
|
|
|
|
|
|
|
export default class TraitsView extends DomainViews { |
|
|
export default class TraitsView extends DomainViews { |
|
|
reuseView = true; |
|
|
reuseView = true; |
|
|
em: EditorModel; |
|
|
em: EditorModel; |
|
|
@ -23,7 +26,6 @@ export default class TraitsView extends DomainViews { |
|
|
categories: Categories; |
|
|
categories: Categories; |
|
|
renderedCategories = new Map<string, CategoryView>(); |
|
|
renderedCategories = new Map<string, CategoryView>(); |
|
|
config: TraitManagerConfigModule; |
|
|
config: TraitManagerConfigModule; |
|
|
noCatClass: string; |
|
|
|
|
|
traitContClass: string; |
|
|
traitContClass: string; |
|
|
catsClass: string; |
|
|
catsClass: string; |
|
|
catsEl?: HTMLElement; |
|
|
catsEl?: HTMLElement; |
|
|
@ -44,7 +46,6 @@ export default class TraitsView extends DomainViews { |
|
|
this.pfx = ppfx + config.stylePrefix || ''; |
|
|
this.pfx = ppfx + config.stylePrefix || ''; |
|
|
this.className = `${this.pfx}traits`; |
|
|
this.className = `${this.pfx}traits`; |
|
|
this.categories = o.categories || ''; |
|
|
this.categories = o.categories || ''; |
|
|
this.noCatClass = `${ppfx}traits-no-cat`; |
|
|
|
|
|
this.traitContClass = `${ppfx}traits-c`; |
|
|
this.traitContClass = `${ppfx}traits-c`; |
|
|
this.catsClass = `${ppfx}trait-categories`; |
|
|
this.catsClass = `${ppfx}trait-categories`; |
|
|
this.listenTo(em, 'component:toggled', this.updatedCollection); |
|
|
this.listenTo(em, 'component:toggled', this.updatedCollection); |
|
|
@ -115,14 +116,14 @@ export default class TraitsView extends DomainViews { |
|
|
|
|
|
|
|
|
getCategoriesEl() { |
|
|
getCategoriesEl() { |
|
|
if (!this.catsEl) { |
|
|
if (!this.catsEl) { |
|
|
this.catsEl = this.el.querySelector(`.${this.catsClass}`)!; |
|
|
this.catsEl = this.el.querySelector(`[${ATTR_CATEGORIES}]`)!; |
|
|
} |
|
|
} |
|
|
return this.catsEl; |
|
|
return this.catsEl; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
getTraitsEl() { |
|
|
getTraitsEl() { |
|
|
if (!this.traitsEl) { |
|
|
if (!this.traitsEl) { |
|
|
this.traitsEl = this.el.querySelector(`.${this.noCatClass} .${this.traitContClass}`)!; |
|
|
this.traitsEl = this.el.querySelector(`[${ATTR_NO_CATEGORIES}]`)!; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
return this.traitsEl; |
|
|
return this.traitsEl; |
|
|
@ -134,16 +135,14 @@ export default class TraitsView extends DomainViews { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
render() { |
|
|
render() { |
|
|
const { ppfx, catsClass, noCatClass, traitContClass } = this; |
|
|
const { ppfx, catsClass, traitContClass } = this; |
|
|
const frag = document.createDocumentFragment(); |
|
|
const frag = document.createDocumentFragment(); |
|
|
delete this.catsEl; |
|
|
delete this.catsEl; |
|
|
delete this.traitsEl; |
|
|
delete this.traitsEl; |
|
|
this.renderedCategories = new Map(); |
|
|
this.renderedCategories = new Map(); |
|
|
this.el.innerHTML = ` |
|
|
this.el.innerHTML = ` |
|
|
<div class="${catsClass}"></div> |
|
|
<div class="${catsClass}" ${ATTR_CATEGORIES}></div> |
|
|
<div class="${noCatClass}"> |
|
|
<div class="${traitContClass}" ${ATTR_NO_CATEGORIES}></div> |
|
|
<div class="${traitContClass}"></div> |
|
|
|
|
|
</div> |
|
|
|
|
|
`;
|
|
|
`;
|
|
|
|
|
|
|
|
|
this.collection.forEach(model => this.add(model, frag)); |
|
|
this.collection.forEach(model => this.add(model, frag)); |
|
|
|