<div id="faqTopics">
    <div id="content">
        <div class="menubar fixed">
            <div class="sidebar-toggler visible-xs">
                <i class="ion-navicon"></i>
            </div>

            <div class="page-title">FAQ Topics</div>
            <form target="BSFormPanel_Admin_1" class="search">
                <!--<input class="gwt-TextBox" placeholder="Search topics (name, description)..." type="text">-->
                <input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Search topics (name, description)..." type="text"/>
                <input class="btn" type="submit">
            </form>
            <a (click)="showModal()" class="btn btn-success pull-right"><i></i> New Topic </a>
        </div>

        <div class="content-wrapper" id="contentWrapper">
            <div>
                <div class="contentPanel">
                    <div [hidden]="!errorMessage" class="alert alert-danger" aria-hidden="true">
                        {{errorMessage}}
                    </div>
                    <div [hidden]="!successMessage" class="alert alert-success"  aria-hidden="true">
                        {{successMessage}}
                    </div>
                    <div class="alert" style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>
                    <div class="row page-controls">
                        <div class="col-md-12 filters">
                            <div class="show-options">
                                <div class="btn-group"><a href="javascript:;" class="btn dropdown-toggle"
                                                          data-toggle="dropdown"><i></i> Bulk Actions <span
                                        class="caret"></span></a>
                                    <ul class="dropdown-menu">
                                        <li><a (click)="confirmDeleteSelectedTopics()"><i></i> Delete </a></li>
                                        <li><a (click)="toggleTopic('weight',getSelectedTopics())"><i></i> Order Questions By Weight </a></li>
                                        <li><a (click)="toggleTopic('hits',getSelectedTopics())"><i></i> Order Questions By Hit Count </a></li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div>
                        <div class="gwt-HTML">
                            <div class="row users-list">
                                <div class="col-md-12">
                                    <div class="row headers">
                                        <div class="col-sm-1 header select-users"><input id="allTopicsCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)">
                                        </div>
                                        <div class="col-sm-1 header hidden-xs"><label><a href="#">Date</a></label></div>
                                        <div class="col-sm-2 header hidden-xs"><label><a href="#">Name</a></label></div>
                                        <div class="col-sm-4 header hidden-xs"><label><a href="#">Description</a></label></div>
                                        <div class="col-sm-1 header hidden-xs"><label><a href="#">Weight</a></label></div>
                                        <div class="col-sm-2 header hidden-xs"><label><a href="#">Questions Order</a></label>
                                        </div>
                                        <div class="col-sm-1 header hidden-xs"><label><a href="#">Actions</a></label></div>
                                    </div>

                                    <ng-template [ngIf]="topicsCheckboxes && topicsCheckboxes.length>0">
                                        <div *ngFor="let check of topicsCheckboxes; let i=index" class="row user">
                                            <div class="col-sm-1 avatar"><input id="{{check.topic._id}}" class="checkBox" type="checkbox"
                                                                                name="topicscb[]" value="{{check.topic._id}}" [(ngModel)]="check.checked">
                                            </div>
                                            <div class="col-sm-1">
                                                <div class="date" href="#">{{check.topic.date | date:'yyyy-MM-dd'}}</div>
                                            </div>
                                            <div class="col-sm-2">
                                                <div class="name" href="#">{{check.topic.name}}</div>
                                            </div>
                                            <div class="col-sm-4">
                                                <div class="description" href="#">{{check.topic.description}}
                                                </div>
                                            </div>
                                            <div class="col-sm-1">
                                                <div class="weight" href="#">{{check.topic.weight}}</div>
                                            </div>
                                            <div class="col-sm-2">
                                                <div class="questionsOrder" href="#">{{check.topic.questionOrder}}</div>
                                            </div>
                                            <div class="col-sm-1">
                                                <div class="actions" href="#">
                                                    <input title="Edit" src="imgs/icn_edit.png" class="edit" type="image" (click)="editTopic(i)">
                                                    <input title="Delete" src="imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteTopic(check.topic._id)">
                                                </div>
                                            </div>
                                        </div>
                                    </ng-template>
                                    <div *ngIf="topicsCheckboxes.length==0" class="col-md-12">
                                        <div class="alert alert-warning">No topics found</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<modal-form #saveModal [saveText]="'Save'" [titleText]="'Add a new Topic'" [formGroup]="formGroup"
            [isModalShown]="isModalShown" (emmitObject)="topicSavedSuccessfully($event)" (emmitError)="handleError($event)">
    <topics-form [group]="formGroup"></topics-form>
</modal-form>

<modal-form #updateModal [saveText]="'Update'" [titleText]="'Update Topic'" [formGroup]="formGroup"
            [isModalShown]="isModalShown" (emmitObject)="topicUpdatedSuccessfully($event)" (emmitError)="handleError($event)">
    <topics-form [group]="formGroup"></topics-form>
</modal-form>

<delete-confirmation-dialog #deleteConfirmationModal [isModalShown]="isModalShown" (emmitObject)="confirmedDeleteTopic($event)">
    Are you sure you want to delete the selected topic(s)?
</delete-confirmation-dialog>
