/* Copyright © 2016-2019 Lidor Systems. All rights reserved. This file is part of the "IntegralUI Web" Library. The contents of this file are subject to the IntegralUI Web License, and may not be used except in compliance with the License. A copy of the License should have been installed in the product's root installation directory or it can be found at http://www.lidorsystems.com/products/web/studio/license-agreement.aspx. This SOFTWARE is provided "AS IS", WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. Any infringement will be prosecuted under applicable laws. */ import { Component, ViewContainerRef, ViewChild, ViewChildren, ViewEncapsulation } from '@angular/core'; import { IntegralUIAccordion } from '../../integralui/components/integralui.accordion'; @Component({ selector: '', template: `

Accordion / Header with CheckBox

{{group.text}}
Content of {{group.name}}

A demonstration on how to lock specific group using a CheckBox in group header. When check box is checked, the group is locked, and cannot become selected. It will remain collapsed, unless it is already expanded.

To prevent group from expanding, the beforeSelect events is handled. This event is fired just before the beforeExpand event and it is better for this case. If the group is checked, the cancel field (from event data) is set to false. This cancels any further actions for specified group.

For more information check out the source code of this sample (accordion/accordion-header-checkbox.ts) file.

`, encapsulation: ViewEncapsulation.None }) export class AccordionHeaderCheckBoxSample { @ViewChild('accordion', { static: false }) accordion: IntegralUIAccordion; public data: Array = []; public ctrlStyle: any = { general: { normal: 'acc-hcb-normal' } } constructor(){ this.data = [ { name: "Group 1", text: 'Header 1', checked: false }, { name: "Group 2", text: 'Header 2', checked: false }, { name: "Group 3", text: 'Header 3', checked: false } ]; } onMouseDownCheckBox(e: any, group: any){ if (!group.checked && group == this.accordion.selectedGroup){ this.accordion.collapse(group); this.accordion.clearSelection(); } e.stopPropagation(); } onBeforeSelect(e: any){ if (e.group && e.group.checked) e.cancel = true; } }