<div class="card question d-flex mb-4 edit-quesiton drag">
    <div class="d-flex flex-grow-1 min-width-zero">
        <div
            class="card-body align-self-center d-flex flex-column flex-md-row justify-content-between min-width-zero align-items-md-center">
            <div class="list-item-heading mb-0 truncate w-80 mb-1 mt-1">
                <span class="heading-number d-inline-block">{{sort}}</span>{{question.title}}
            </div>
        </div>
        <div class="custom-control custom-checkbox pl-1 align-self-center pr-4">
            <button class="btn btn-outline-theme-3 icon-button mr-1" *ngIf="mode==='edit'"
                (click)="changeMode('preview')">
                <i class="simple-icon-eye"></i>
            </button>
            <button class="btn btn-outline-theme-3 icon-button mr-1" *ngIf="mode==='preview'"
                (click)="changeMode('edit')">
                <i class="simple-icon-pencil"></i>
            </button>
            <button class="btn btn-outline-theme-3 icon-button rotate-icon-click rotate" (click)="collapseToggle()">
                <i
                    [ngClass]="{'with-rotate-icon':true,'simple-icon-arrow-down':!showDetail,'simple-icon-arrow-up':showDetail}"></i>
            </button>
        </div>
    </div>
    <div class="question-collapse" [collapse]="!showDetail">
        <div class="card-body pt-0">
            <div *ngIf="mode=='edit'">
                <div class="form-group mb-3">
                    <label>Title</label>
                    <input class="form-control" type="text"  [(ngModel)]="question.title">
                </div>
                <div class="form-group mb-5">
                    <label>Question</label>
                    <input class="form-control" type="text"  [(ngModel)]="question.question">
                </div>

                <div class="separator mb-4"></div>
                <div class="form-group">
                    <label class="d-block">Answer Type</label>
                    <ng-select appearance="outline" [searchable]="false" [(ngModel)]="question.answerType">
                        <ng-option *ngFor="let item of answerTypes" [value]="item.value">{{item.label}}</ng-option>
                    </ng-select>
                </div>

                <div class="form-group" *ngIf="question.answerType !== 0">

                    <label class="d-block">Answers</label>
                    <div class="answers mb-3 sortable" [sortablejs]="[1,2,3,4]" [sortablejsOptions]="{ handle: '.handle' }">
                        <div class="mb-1 position-relative" *ngFor="let a of question.answers">
                            <input class="form-control" type="text"  [(ngModel)]="a.label">
                            <div class="input-icons">
                                <span class="badge badge-pill handle pr-0 mr-0"><i
                                        class="simple-icon-cursor-move"></i></span>
                                <span class="badge badge-pill" (click)="deleteAnswer(a.value)"><i
                                        class="simple-icon-ban"></i></span>
                            </div>
                        </div>
                    </div>
                    <div class="text-center">
                        <button class="btn btn-outline-primary btn-sm mb-2" (click)="addAnswer()"><i
                                class="simple-icon-plus btn-group-icon"></i> Add Answer</button>
                    </div>
                </div>

            </div>
            <div *ngIf="mode=='preview'">
                <label>{{question.question}}</label>
                <input class="form-control" type="text" *ngIf="question.answerType===0">
                <ng-select appearance="outline" [searchable]="false"  *ngIf="question.answerType===1">
                    <ng-option *ngFor="let item of question.answers" [value]="item.value">{{item.label}}</ng-option>
                </ng-select>
                <ng-select appearance="outline" [searchable]="false"  [multiple]="true" *ngIf="question.answerType===2">
                    <ng-option *ngFor="let item of question.answers" [value]="item.value">{{item.label}}</ng-option>
                </ng-select>
                <div *ngIf="question.answerType===3">
                  <div class="custom-control custom-checkbox"  *ngFor="let item of question.answers; let i = index">
                    <input type="checkbox" [name]="'customCheck_'+question.id"[id]="'customCheck_'+question.id+'_'+i" class="custom-control-input" [value]="item.value">
                    <label class="custom-control-label" [for]="'customCheck_'+question.id+'_'+i">{{ item.label }}</label>
                  </div>
                </div>
                <div *ngIf="question.answerType===4">
                  <div class="custom-control custom-radio"  *ngFor="let item of question.answers; let i = index">
                    <input type="radio" [name]="'customRadio_'+question.id" [id]="'customRadio_'+question.id+'_'+i" class="custom-control-input" [value]="item.value">
                    <label class="custom-control-label" [for]="'customRadio_'+question.id+'_'+i">{{ item.label }}</label>
                  </div>
                </div>
            </div>
        </div>
    </div>
</div>
