-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from naturalsolutions/feat/remove-angular2-mul…
…tiselect chore: Remove "angular2-multiselect" and "ng-multiselect-dropdown" dependency and update package.json
- Loading branch information
Showing
86 changed files
with
379 additions
and
4,867 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
frontend/app/commonComponents/zh-multiselect/zh-multiselect.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
<small>{{ label }}</small> | ||
<ng-select class="Multiselect" | ||
#zhMultiselect | ||
[ngClass]="{'Multiselect--multiple': multiple, 'Multiselect--hightlightValue': hightlightValue}" | ||
[items]="values" | ||
[bindLabel]="keyLabel" | ||
[bindValue]="keyValue" | ||
[placeholder]="placeholder" | ||
[multiple]="multiple" | ||
[clearable]="true" | ||
[virtualScroll]="true" | ||
[formControl]="parentFormControl" | ||
(add)="onChange.emit($event)" | ||
(remove)="onDelete.emit($event)" | ||
(open)="onOpen.emit($event)" | ||
[closeOnSelect]="!multiple" | ||
[groupBy]="groupBy" | ||
[selectableGroup]="true" | ||
[selectableGroupAsModel]="false" | ||
> | ||
<ng-template ng-header-tmp> | ||
<div class="MultiselectHeader"> | ||
<input type="text" | ||
class="MultiselectHeader__search" | ||
id="inputValidation" | ||
placeholder="Search" | ||
(input)="zhMultiselect.filter($event.target.value)" /> | ||
<button *ngIf="zhMultiselect.multiple" | ||
class="MultiselectHeader__selectAll" | ||
mat-flat-button | ||
color="#219653" | ||
(click)="selectAllFiltered(zhMultiselect)"> | ||
Select all | ||
</button> | ||
</div> | ||
</ng-template> | ||
<ng-template ng-optgroup-tmp | ||
let-item="item" | ||
let-item$="item$" | ||
let-index="index" | ||
class="MultiselectOption"> | ||
<div class="MultiselectOptionItem"> | ||
<input class="MultiselectOptionItem__checkbox" | ||
id="item-{{index}}" | ||
type="checkbox" | ||
[ngModel]="item$.selected" | ||
[ngModelOptions]="{standalone: true}" /> | ||
<div class="MultiselectOptionItem__text">{{ item[groupBy] }}</div> | ||
</div> | ||
</ng-template> | ||
<ng-template ng-option-tmp | ||
let-item="item" | ||
let-item$="item$" | ||
let-index="index" | ||
class="MultiselectOption"> | ||
<div class="MultiselectOptionItem"> | ||
<input class="MultiselectOptionItem__checkbox" | ||
id="item-{{index}}" | ||
type="checkbox" | ||
[ngModel]="item$.selected" | ||
[ngModelOptions]="{standalone: true}" /> | ||
<div class="MultiselectOptionItem__text">{{ item[keyLabel] }}</div> | ||
</div> | ||
</ng-template> | ||
</ng-select> |
100 changes: 100 additions & 0 deletions
100
frontend/app/commonComponents/zh-multiselect/zh-multiselect.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
$primary: #219653; | ||
$primary-darken: #156035; | ||
$primary-lighten: #EFFCF4; | ||
$primary-text: #fff; | ||
|
||
$gray-lighten: #F5F5F5; | ||
$gray-darken: #dcdcdc; | ||
.Multiselect { | ||
color: $primary !important; | ||
::ng-deep .ng-value-container { | ||
max-height: 200px; | ||
overflow: auto; | ||
} | ||
|
||
::ng-deep &.ng-select-disabled > .ng-select-container { | ||
background-color: $gray-darken !important; | ||
max-height: 200px; | ||
} | ||
|
||
.MultiselectHeader{ | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: space-between; | ||
max-width: 100%; | ||
overflow: hidden; | ||
max-height: 24px; | ||
&__search{ | ||
&::placeholder { | ||
opacity: 0.5; | ||
} | ||
max-width: 60%; | ||
border: none; | ||
&:focus { | ||
outline: none; | ||
} | ||
} | ||
&__selectAll{ | ||
white-space: nowrap; | ||
max-height: 24px | ||
} | ||
|
||
} | ||
::ng-deep .ng-input { | ||
opacity: 0 !important; | ||
} | ||
::ng-deep .ng-value { | ||
max-width: 90%; | ||
padding-left: 5px; | ||
padding-right: 5px; | ||
} | ||
&--hightlightValue { | ||
::ng-deep .ng-value { | ||
background-color: $primary !important; | ||
color: $primary-text !important; | ||
} | ||
} | ||
// Chip items | ||
&--multiple{ | ||
::ng-deep .ng-value { | ||
display: flex; | ||
flex-flow: row nowrap; | ||
justify-content: center; | ||
.ng-value-icon{ | ||
align-self: center; | ||
} | ||
.ng-value-icon:hover{ | ||
background-color: $primary !important; | ||
color: $primary-darken !important; | ||
} | ||
.ng-value-label{ | ||
word-wrap: whitespace; | ||
white-space: normal; | ||
} | ||
} | ||
} | ||
|
||
// Option | ||
::ng-deep .ng-option:hover, | ||
::ng-deep .ng-option.ng-option-selected:hover { | ||
background-color: $gray-lighten !important; | ||
} | ||
::ng-deep .ng-option.ng-option-selected { | ||
background-color: $primary-lighten !important; | ||
} | ||
|
||
.MultiselectOptionItem { | ||
display: flex; | ||
flex: row nowrap; | ||
column-gap: 10px; | ||
input[type="checkbox"] { | ||
accent-color: $primary !important; | ||
} | ||
|
||
&__text { | ||
max-width: 80%; | ||
word-wrap: break-all; | ||
white-space: normal; | ||
} | ||
} | ||
} |
35 changes: 35 additions & 0 deletions
35
frontend/app/commonComponents/zh-multiselect/zh-multiselect.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; | ||
import { MultiSelectComponent } from '@geonature_common/form/multiselect/multiselect.component'; | ||
|
||
@Component({ | ||
selector: 'zh-multiselect', | ||
templateUrl: './zh-multiselect.component.html', | ||
styleUrls: ['./zh-multiselect.component.scss'], | ||
}) | ||
export class ZHMultiSelectComponent extends MultiSelectComponent implements OnInit { | ||
/** | ||
*/ | ||
@Input() multiple: boolean; | ||
@Input() hightlightValue: boolean; | ||
@Input() groupBy: string | null; | ||
@Input() placeholder: string; | ||
@Output() onOpen = new EventEmitter<any>(); | ||
constructor() { | ||
super(); | ||
this.multiple = true; | ||
this.hightlightValue = true; | ||
this.groupBy = null; | ||
this.placeholder = 'Sélectionner'; | ||
} | ||
ngOnInit() { | ||
super.ngOnInit(); | ||
} | ||
|
||
public selectAllFiltered(select: any) { | ||
for (const item of select.itemsList.filteredItems) { | ||
select.select(item); | ||
} | ||
// close popup | ||
select.close(); | ||
} | ||
} |
Oops, something went wrong.