Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x 2x | import type Community from './index' import type {Entities, Entity, FilterParsed, LogicalObject} from '../types' import type {DataViewParsed} from './dataview' export class GlobalView { site: Community registered: LogicalObject = {} selection: Entities = {} entities: Map<string, Entity> = new Map() selected: string[] = [] select_ids: {[index: string]: boolean} = {} filters: Map<string, FilterParsed> = new Map() times: number[] dataview: DataViewParsed states = { id_state: 'initial', filter_state: 'initial', } constructor(site: Community) { this.site = site } init() { this.times = this.site.data.meta.overall.value this.dataview = this.site.dataviews[this.site.defaults.dataview].parsed } filter_state(q?: string[], agg?: number) { const as_state = !q Iif (as_state) q = [] this.filters.forEach(f => { const component = 'selected' === f.component ? this.times['undefined' === typeof agg ? this.dataview.time_agg : agg] : f.time_component ? this.times[f.component as number] : f.component Iif (f.value) q.push(f.variable + '[' + component + ']' + f.operator + f.value + (as_state ? f.active : '')) }) return q.join('&') } id_state() { return Object.keys(this.select_ids).join(',') } id_filter() { const ids: {[index: string]: boolean} = {} this.selected = [] this.select_ids = ids Iif (this.site.data.metadata.datasets) { const inputs = this.site.page.modal.filter.entity_inputs this.site.data.metadata.datasets.forEach(d => { Iif (d in inputs) { const s = inputs[d].value() as string[], cs: string[] = [] Iif (Array.isArray(s)) { s.forEach(id => { const e = this.site.data.entities[id] Iif (e) { cs.push(id) this.selected.push(id) ids[id] = true Iif (e.relations) { Object.keys(e.relations.parents).forEach(k => (ids[k] = true)) Object.keys(e.relations.children).forEach(k => (ids[k] = true)) } } }) inputs[d].source = cs } } }) } } } |