UNPKG

intervention-pages

Version:
168 lines (162 loc) 6.47 kB
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; import { getStore } from '../../utils/redux-store-access'; import { css, html, customElement, LitElement, property } from 'lit-element'; import { gridLayoutStylesLit } from '../../common/styles/grid-layout-styles-lit'; import { selectInterventionResultLinks } from './results-structure.selectors'; import { ResultStructureStyles } from './results-structure.styles'; import '@unicef-polymer/etools-data-table'; import '@unicef-polymer/etools-content-panel'; import './cp-output-level'; import './pd-indicators'; import './pd-activities'; import { connect } from 'pwa-helpers/connect-mixin'; /** * @customElement */ let ResultsStructure = class ResultsStructure extends connect(getStore())(LitElement) { constructor() { super(...arguments); this.resultLinks = []; this.showCPOLevel = true; this.showIndicators = true; this.showActivities = true; } static get styles() { // language=CSS return [ gridLayoutStylesLit, ResultStructureStyles, css ` etools-content-panel { --ecp-content-padding: 0; } iron-icon[icon='create'] { margin-left: 50px; } .view-toggle-button { height: 28px; margin-left: 40px; padding: 0 19px; font-weight: 500; font-size: 14px; border-radius: 50px; background-color: #d0d0d0; color: #fff; cursor: pointer; } .view-toggle-button[active] { background-color: #009688; } ` ]; } render() { // language=HTML return html ` <style> :host { display: block; margin-bottom: 24px; } etools-data-table-row { --list-row-collapse-wrapper: { padding: 0 !important; border-bottom: 1px solid var(--main-border-color) !important; } --list-row-wrapper: { background-color: var(--secondary-background-color); min-height: 55px; border-bottom: 1px solid var(--main-border-color) !important; } } </style> <etools-content-panel panel-title="Results Structure"> <div slot="panel-btns" class="layout-horizontal align-items-center"> <div class="view-toggle-button layout-horizontal align-items-center" ?active="${this.showIndicators && !this.showActivities}" @click="${() => this.updateTableView(true, false)}" > Result view </div> <div class="view-toggle-button layout-horizontal align-items-center" ?active="${this.showIndicators && this.showActivities}" @click="${() => this.updateTableView(true, true)}" > Combined view </div> <div class="view-toggle-button layout-horizontal align-items-center" ?active="${!this.showIndicators && this.showActivities}" @click="${() => this.updateTableView(false, true)}" > Budget view </div> </div> ${this.resultLinks.map((result) => html ` <cp-output-level ?show-cpo-level="${this.showCPOLevel}" .resultLink="${result}"> ${result.ll_results.map((pdOutput) => html ` <etools-data-table-row> <div slot="row-data" class="layout-horizontal align-items-center"> <div class="flex-1 flex-fix"> <div class="heading">Program Document output</div> <div class="data bold-data">${pdOutput.name}</div> </div> <div class="flex-none"> <div class="heading">Total Cache budget</div> <div class="data">TTT 1231.144</div> </div> <iron-icon icon="create" class="flex-none" ?hidden="${result.cp_output}"></iron-icon> </div> <div slot="row-data-details"> <pd-indicators ?hidden="${!this.showIndicators}" .indicators="${pdOutput.applied_indicators}" ></pd-indicators> <pd-activities ?hidden="${!this.showActivities}"></pd-activities> </div> </etools-data-table-row> `)} </cp-output-level> `)} <!-- If CP Output level is shown - 'Add PD' button will be present inside cp-output-level component --> ${!this.showCPOLevel ? html ` <div ?hidden="${this.showCPOLevel}" class="add-pd row-h align-items-center"> <iron-icon icon="add-box"></iron-icon>Add PD Output </div> ` : ''} </etools-content-panel> `; } stateChanged(state) { this.resultLinks = selectInterventionResultLinks(state); } updateTableView(indicators, activities) { this.showIndicators = indicators; this.showActivities = activities; } }; __decorate([ property() ], ResultsStructure.prototype, "resultLinks", void 0); __decorate([ property({ type: Boolean }) ], ResultsStructure.prototype, "showCPOLevel", void 0); __decorate([ property({ type: Boolean }) ], ResultsStructure.prototype, "showIndicators", void 0); __decorate([ property({ type: Boolean }) ], ResultsStructure.prototype, "showActivities", void 0); ResultsStructure = __decorate([ customElement('results-structure') ], ResultsStructure); export { ResultsStructure };