Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,38 @@
import { NgModule } from '@angular/core';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from "@angular/core";
import { FormsModule, ReactiveFormsModule } from "@angular/forms";
import { BrowserModule } from "@angular/platform-browser";

import { TabsModule, ButtonsModule } from 'ngx-bootstrap';
import { NgMultiSelectDropDownModule } from '../ng-multiselect-dropdown/src';
import { TabsModule } from "ngx-bootstrap/tabs";
import { ButtonsModule } from "ngx-bootstrap/buttons";
import { NgMultiSelectDropDownModule } from "../ng-multiselect-dropdown/src";
// import { NgMultiSelectDropDownModule } from 'ng-multiselect-dropdown';

import { SelectSectionComponent } from './components/select-section';
import { SampleSectionComponent } from './components/sample-section.component';
import { SingleDemoComponent } from './components/select/single-demo';
import { MultipleDemoComponent } from './components/select/multiple-demo';
import { ShCodeViewer } from '../code-viewer/code-viewer.module';
import { SelectSectionComponent } from "./components/select-section";
import { SampleSectionComponent } from "./components/sample-section.component";
import { SingleDemoComponent } from "./components/select/single-demo";
import { MultipleDemoComponent } from "./components/select/multiple-demo";
import { ShCodeViewer } from "../code-viewer/code-viewer.module";

import { AppComponent } from './app.component';
import { AppComponent } from "./app.component";

@NgModule({
declarations: [SelectSectionComponent, SampleSectionComponent, SingleDemoComponent, MultipleDemoComponent, AppComponent],
declarations: [
SelectSectionComponent,
SampleSectionComponent,
SingleDemoComponent,
MultipleDemoComponent,
AppComponent,
],
imports: [
FormsModule,
ReactiveFormsModule,
BrowserModule,
TabsModule.forRoot(),
ButtonsModule.forRoot(),
NgMultiSelectDropDownModule.forRoot(),
ShCodeViewer
ShCodeViewer,
],
providers: [],
bootstrap: [AppComponent]
bootstrap: [AppComponent],
})
export class AppModule {}
105 changes: 86 additions & 19 deletions src/ng-multiselect-dropdown/src/multi-select.component.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,101 @@
<div tabindex="=0" (blur)="onTouched()" class="multiselect-dropdown" (clickOutside)="closeDropdown()">
<div
tabindex="=0"
(blur)="onTouched()"
class="multiselect-dropdown"
(clickOutside)="closeDropdown()"
>
<div [class.disabled]="disabled">
<span tabindex="-1" class="dropdown-btn" (click)="toggleDropdown($event)">
<span *ngIf="selectedItems.length == 0">{{_placeholder}}</span>
<span class="selected-item" *ngFor="let item of selectedItems;trackBy: trackByFn;let k = index" [hidden]="k > _settings.itemsShowLimit-1">
{{item.text}}
<a style="padding-top:2px;padding-left:2px;color:white" (click)="onItemClick($event,item)">x</a>
<span *ngIf="selectedItems.length == 0">{{ _placeholder }}</span>
<span
class="selected-item"
*ngFor="let item of selectedItems; trackBy: trackByFn; let k = index"
[hidden]="k > (_settings.itemsShowLimit || 0) - 1"
>
{{ item.text }}
<a
style="padding-top: 2px; padding-left: 2px; color: white;"
(click)="onItemClick($event, item)"
>x</a
>
</span>
<span style="float:right !important;padding-right:4px">
<span style="padding-right: 6px;" *ngIf="itemShowRemaining()>0">+{{itemShowRemaining()}}</span>
<span [ngClass]="_settings.defaultOpen ? 'dropdown-up' : 'dropdown-down'"></span>
<span style="float: right !important; padding-right: 4px;">
<span style="padding-right: 6px;" *ngIf="itemShowRemaining() > 0"
>+{{ itemShowRemaining() }}</span
>
<span
[ngClass]="_settings.defaultOpen ? 'dropdown-up' : 'dropdown-down'"
></span>
</span>
</span>
</div>
<div class="dropdown-list" [hidden]="!_settings.defaultOpen">
<ul class="item1">
<li (click)="toggleSelectAll()" *ngIf="(_data.length > 0 || _settings.allowRemoteDataSearch) && !_settings.singleSelection && _settings.enableCheckAll && _settings.limitSelection===-1" class="multiselect-item-checkbox" style="border-bottom: 1px solid #ccc;padding:10px">
<input type="checkbox" aria-label="multiselect-select-all" [checked]="isAllItemsSelected()" [disabled]="disabled || isLimitSelectionReached()" />
<div>{{!isAllItemsSelected() ? _settings.selectAllText : _settings.unSelectAllText}}</div>
<li
(click)="toggleSelectAll()"
*ngIf="
(_data.length > 0 || _settings.allowRemoteDataSearch) &&
!_settings.singleSelection &&
_settings.enableCheckAll &&
_settings.limitSelection === -1
"
class="multiselect-item-checkbox"
style="border-bottom: 1px solid #ccc; padding: 10px;"
>
<input
type="checkbox"
aria-label="multiselect-select-all"
[checked]="isAllItemsSelected()"
[disabled]="disabled || isLimitSelectionReached()"
/>
<div>
{{
!isAllItemsSelected()
? _settings.selectAllText
: _settings.unSelectAllText
}}
</div>
</li>
<li class="filter-textbox" *ngIf="(_data.length>0 || _settings.allowRemoteDataSearch) && _settings.allowSearchFilter">
<input type="text" aria-label="multiselect-search" [readOnly]="disabled" [placeholder]="_settings.searchPlaceholderText" [(ngModel)]="filter.text" (ngModelChange)="onFilterTextChange($event)">
<li
class="filter-textbox"
*ngIf="
(_data.length > 0 || _settings.allowRemoteDataSearch) &&
_settings.allowSearchFilter
"
>
<input
type="text"
aria-label="multiselect-search"
[readOnly]="disabled"
[placeholder]="_settings.searchPlaceholderText"
[(ngModel)]="filter.text"
(ngModelChange)="onFilterTextChange($event)"
/>
</li>
</ul>
<ul class="item2" [style.maxHeight]="_settings.maxHeight+'px'">
<li *ngFor="let item of _data | multiSelectFilter:filter; let i = index;" (click)="onItemClick($event,item)" class="multiselect-item-checkbox">
<input type="checkbox" aria-label="multiselect-item" [checked]="isSelected(item)" [disabled]="disabled || (isLimitSelectionReached() && !isSelected(item)) || item.isDisabled" />
<div>{{item.text}}</div>
<ul class="item2" [style.maxHeight]="_settings.maxHeight + 'px'">
<li
*ngFor="let item of _data | multiSelectFilter: filter; let i = index"
(click)="onItemClick($event, item)"
class="multiselect-item-checkbox"
>
<input
type="checkbox"
aria-label="multiselect-item"
[checked]="isSelected(item)"
[disabled]="
disabled ||
(isLimitSelectionReached() && !isSelected(item)) ||
item.isDisabled
"
/>
<div>{{ item.text }}</div>
</li>
<li class='no-data' *ngIf="_data.length == 0 && !_settings.allowRemoteDataSearch">
<h5>{{_settings.noDataAvailablePlaceholderText}}</h5>
<li
class="no-data"
*ngIf="_data.length == 0 && !_settings.allowRemoteDataSearch"
>
<h5>{{ _settings.noDataAvailablePlaceholderText }}</h5>
</li>
</ul>
</div>
Expand Down