<div id="divHelpContents" class="uk-container">

        <div class="menubar ">

            <div *ngIf="!selectedPageId" class="divHelpContent-title uk-article-title">Class Help Contents</div>
            <div *ngIf="selectedPageId && page && community" class="divHelpContent-title uk-article-title">'{{page.name}}' Help Contents of community {{community.name}}</div>

            <form target="BSFormPanel_Admin_1" class="search">
                <input #inputstring (keyup.enter)="filterBySearch(inputstring.value)" placeholder="Class Help Content..." type="text" class="uk-input uk-width-medium"/>
                <button class="uk-button" type="submit">Search</button>
            </form>
            <a *ngIf="!selectedPageId" [queryParams]="{community: selectedCommunityPid}" routerLink="/classContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New Page Content </a>
            <a *ngIf="selectedPageId" [queryParams]="{community: selectedCommunityPid, pageId: selectedPageId}" routerLink="/classContents/new" class="uk-button uk-button-primary uk-float-right"><i></i> New Page Content </a>
        </div>

        <div class="content-wrapper" id="contentWrapper">
            <div>
                <div class="contentPanel">
                    <div class="uk-alert-danger" uk-alert style="display: none;" aria-hidden="true">
                        <span></span><span></span><span></span></div>
                    <div class="uk-alert-success" uk-alert style="display: none;" aria-hidden="true">
                        <span></span><span></span><span></span></div>
                    <div class="uk-alert" uk-alert style="display: none;" aria-hidden="true"><span></span><span></span><span></span></div>

                    <div class="page-controls">
                        <div class="  filters ">
                            <div class="show-options uk-float-right">
                              <button class="uk-button" type="button"> Bulk Actions</button>
                              <div uk-dropdown="mode: click">
                                <ul class="uk-nav uk-dropdown-nav">
                                    <li><a (click)="toggleDivHelpContents(true,getSelectedDivHelpContents())"><i></i> Activate </a></li>
                                    <li><a (click)="toggleDivHelpContents(false,getSelectedDivHelpContents())"><i></i> Deactivate </a></li>
                                    <li><a (click)="confirmDeleteSelectedDivHelpContents()"><i></i> Delete </a></li>
                                </ul>
                              </div>
                            </div>
                        </div>
                    </div>

                    <div>
                        <div class="gwt-HTML">
                            <div class="row users-list">
                                <div class="col-md-12">

                                  <div *ngIf="!selectedPageId" class="filters marginBottom20">
                                      <div class="links form-group form-inline">
                                          <span>Filter by community:</span>
                                          <select class="uk-select uk-width-medium" (change)="filterByCommunity($event)">
                                              <option *ngFor="let community of communities" value="{{community.pid}}">{{community.name}}</option>
                                          </select>
                                      </div>
                                  </div>
                                  <div *ngIf="!selectedPageId" class="filters marginBottom20">
                                      <div class="links form-group form-inline">
                                          <span>Filter by page:</span>
                                          <select class="uk-select uk-width-medium" (change)="filterByPage($event)">
                                              <option value="">-- none selected --</option>
                                              <option *ngFor="let page of pages" value="{{page._id}}">{{page.name}}</option>
                                          </select>
                                      </div>
                                  </div>

                                  <span class="gwt-Label filterLabel">Filter page contents:</span>
                                  <ul uk-tab class="links">
                                      <li [ngClass]="{'uk-active' : filters.active==null}" (click)="displayAllDivHelpContents()">
                                          <a>All Class Contents <span class="uk-badge">{{counter.all}}</span></a>
                                      </li>
                                      <li [ngClass]="{'uk-active' : filters.active==true}" (click)="displayActiveDivHelpContents()">
                                          <a>Active <span class="uk-badge">{{counter.active}}</span></a>
                                      </li>
                                      <li [ngClass]="{'uk-active' : filters.active==false}" (click)="displayInactiveDivHelpContents()">
                                          <a>Inactive <span class="uk-badge">{{counter.inactive}}</span></a>
                                      </li>
                                  </ul>

                                  <table class="uk-table uk-table-striped">
                                    <thead>
                                        <tr>
                                            <th><input id="allDivHelpContentsCheckbox" type="checkbox" (change)="toggleCheckBoxes($event)"></th>
                                            <th *ngIf="!selectedPageId">Page</th>
                                            <th *ngIf="!selectedPageId">Community</th>
                                            <th>Class</th>
                                            <th>Content</th>
                                            <th>Active</th>
                                            <th>Actions</th>
                                        </tr>
                                    </thead>
                                    <tbody >
                                        <tr *ngFor="let check of checkboxes; let i=index">
                                            <td><input id="{{check.divHelpContent._id}}" class="checkBox" type="checkbox"
                                                                                name="entitiescb[]" value="{{check.divHelpContent._id}}" [(ngModel)]="check.checked">
                                            </td>
                                            <td *ngIf="!selectedPageId">
                                                <!-- <div class="page" href="#">{{check.divHelpContent.divId.page.name}}</div> -->
                                                <div class="pages" href="#">
                                                  <span *ngFor="let page of check.divHelpContent.divId.pages let i=index">{{page.name}}<span *ngIf="i<(check.divHelpContent.divId.pages.length-1)">, </span></span>
                                                </div>
                                            </td>
                                            <td *ngIf="!selectedPageId">
                                                <div class="community" href="#">{{check.divHelpContent.divId.community.name}}</div>
                                            </td>
                                            <td>
                                                <div class="divId" href="#">{{check.divHelpContent.divId.name}}</div>
                                            </td>
                                            <td>
                                                <div class="content" href="#">{{check.divHelpContent.content}}</div>
                                            </td>
                                            <td>
                                                <div *ngIf="check.divHelpContent.isActive" class="activated" >
                                                    <input (click)="toggleDivHelpContents(false,[check.divHelpContent._id])" class="deactivate" src="imgs/check-icon.png" title="Deactivate" width="20" type="image" height="20">
                                                </div>
                                                <div *ngIf="!check.divHelpContent.isActive" class="deactivated" >
                                                    <input (click)="toggleDivHelpContents(true,[check.divHelpContent._id])" class="activate" src="imgs/x-icon.png" title="Activate" width="20" type="image" height="20">
                                                </div>
                                            </td>
                                            <td>
                                                <div class="actions" href="#">
                                                    <input title="Edit" src="imgs/icn_edit.png" class="edit" type="image" (click)="editDivHelpContent(check.divHelpContent._id)">
                                                    <input title="Delete" src="imgs/icn_trash.png" class="delete" type="image" (click)="confirmDeleteDivHelpContent(check.divHelpContent._id)">
                                                </div>
                                            </td>
                                        </tr>
                                    </tbody>
                                </table>

                                    <div *ngIf="checkboxes.length==0" class="col-md-12">
                                        <div class="uk-alert-warning" uk-alert>No page contents found</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <a *ngIf="selectedPageId && page" [queryParams]="{type: page.type}" routerLink="/pages">Go back to {{page.type}} pages</a>
                    </div>
                </div>
            </div>
        </div>
</div>

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