<div class="row page-titles">
    <div class="col-md-6 col-8 align-self-center">
        <h3 class="text-themecolor m-b-0 m-t-0">{{phrase.staticPages}}</h3>
    </div>
    <div class="col-md-6 col-4 align-self-center">

    </div>
</div>

<div class="row" ng-show="views.list">
    <div class="col-12">
        <div class="card">
            <div class="card-block">
                <button ng-show="$root.can('staticPages.addPage')" ng-click="changeView('add')" class="btn pull-right btn-success card-block-input-item">{{phrase.addPage}}</button>
                <div class="pull-right card-block-input-group card-block-input-item">
                    <div class="input-group input-group-sm">
                        <input type="text" name="table_search" ng-model="searchText" placeholder="{{phrase.Search}}" class="form-control">
                        <span class="input-group-addon"><i class="fa fa-search"></i></span>
                    </div>
                </div>
                <h4 class="card-title">{{phrase.listPages}}</h4>
                <div class="table-responsive">

                    <table class="table table-bordered table-hover">
                        <tbody>
                            <tr>
                                <th>{{phrase.pageTitle}}</th>
                                <th>{{phrase.Status}}</th>
                                <th ng-show="$root.can('staticPages.editPage') || $root.can('staticPages.delPage')">{{phrase.Operations}}</th>
                            </tr>
                            <tr ng-repeat="page in staticPages | filter:searchText">
                                <td>{{page.pageTitle}}</td>
                                <td>
                                    <span ng-show="page.pageActive == 1">{{phrase.Active}}</span>
                                    <span ng-show="page.pageActive == 0">{{phrase.Inactive}}</span>
                                </td>
                                <td>
                                    <button ng-show="$root.can('staticPages.editPage')" ng-click="pageActive(page.id)" type="button" class="btn btn-success btn-circle" title="{{phrase.Active}} / {{phrase.Inactive}}" tooltip><i class="fa fa-magic"></i></button>
                                    <button ng-show="$root.can('staticPages.editPage')" ng-click="edit(page.id)" type="button" class="btn btn-info btn-circle" title="{{phrase.Edit}}" tooltip><i class="fa fa-pencil"></i></button>
                                    <button ng-show="$root.can('staticPages.delPage')" ng-click="remove(page,$index)" type="button" class="btn btn-danger btn-circle" title="{{phrase.Remove}}" tooltip><i class="fa fa-trash-o"></i></button>
                                </td>
                            </tr>
                            <tr ng-show="!staticPages.length"><td class="noTableData" colspan="5">No pages</td></tr>
                        </tbody>
                    </table>

                </div>
            </div>
        </div>
    </div>
</div>

<div class="row" ng-show="views.add">
    <div class="col-12">
        <div class="card">
            <div class="card-block">
                <button ng-click="changeView('list')" class="btn btn-danger btn-flat pull-right card-block-input-item">{{phrase.cancelAdd}}</button>
                <h4 class="card-title">{{phrase.addPage}}</h4>
                <div class="table-responsive">

                    <form class="form-horizontal" name="addPage" role="form" ng-submit="saveAdd()" novalidate>
                        <div class="form-group row" ng-class="{'has-error': addPage.pageTitle.$invalid}">
                            <label class="col-sm-2 text-right control-label col-form-label">{{phrase.pageTitle}} *</label>
                            <div class="col-sm-10">
                                <input type="text" name="pageTitle" ng-model="form.pageTitle" class="form-control" required placeholder="{{phrase.pageTitle}}">
                            </div>
                        </div>

                        <div class="form-group row" ng-class="{'has-error': addPage.pageContent.$invalid}">
                            <label class="col-sm-2 text-right control-label col-form-label">{{phrase.pageContent}}</label>
                            <div class="col-sm-10">
                                <textarea name="pageContent" class="form-control" ng-model="form.pageContent" required placeholder="{{phrase.pageContent}}" ck-editor></textarea>
                            </div>
                        </div>

                        <div class="form-group row" ng-class="{'has-error': addPage.pageActive.$invalid}">
                            <label class="col-sm-2 text-right control-label col-form-label">{{phrase.Status}}</label>
                            <div class="col-sm-10">
                                <div class="radio-list">
                                    <label>
                                        <input type="radio" name="pageActive" value="1" ng-model="form.pageActive" checked="checked" required>
                                        {{phrase.Active}}
                                    </label>
                                </div>
                                <div class="radio-list">
                                    <label>
                                        <input type="radio" name="pageActive" value="0" ng-model="form.pageActive" required>
                                        {{phrase.Inactive}}
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group m-b-0">
                            <div class="offset-sm-2 col-sm-10">
                                <button type="submit" class="btn btn-info waves-effect waves-light" ng-disabled="addPage.$invalid">{{phrase.addPage}}</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

<div class="row" ng-show="views.edit">
    <div class="col-12">
        <div class="card">
            <div class="card-block">
                <button ng-click="changeView('list')" class="btn btn-danger btn-flat pull-right card-block-input-item">{{phrase.cancelEdit}}</button>
                <h4 class="card-title">{{phrase.editPage}}</h4>
                <div class="table-responsive">

                    <form class="form-horizontal" name="editPage" role="form" ng-submit="saveEdit()" novalidate>
                        <div class="form-group row" ng-class="{'has-error': editPage.pageTitle.$invalid}">
                            <label class="col-sm-2 text-right control-label col-form-label">{{phrase.pageTitle}} *</label>
                            <div class="col-sm-10">
                                <input type="text" name="pageTitle" ng-model="form.pageTitle" class="form-control" required placeholder="{{phrase.pageTitle}}">
                            </div>
                        </div>

                        <div class="form-group row" ng-class="{'has-error': editPage.pageContent.$invalid}">
                            <label class="col-sm-2 text-right control-label col-form-label">{{phrase.pageContent}}</label>
                            <div class="col-sm-10">
                                <textarea name="pageContent" class="form-control" ng-model="form.pageContent" required placeholder="{{phrase.pageContent}}" ck-editor></textarea>
                            </div>
                        </div>

                        <div class="form-group row" ng-class="{'has-error': editPage.pageActive.$invalid}">
                            <label class="col-sm-2 text-right control-label col-form-label">{{phrase.Status}}</label>
                            <div class="col-sm-10">
                                <div class="radio-list">
                                    <label>
                                        <input type="radio" name="pageActive" value="1" ng-model="form.pageActive" checked="checked" required>
                                        {{phrase.Active}}
                                    </label>
                                </div>
                                <div class="radio-list">
                                    <label>
                                        <input type="radio" name="pageActive" value="0" ng-model="form.pageActive" required>
                                        {{phrase.Inactive}}
                                    </label>
                                </div>
                            </div>
                        </div>

                        <div class="form-group m-b-0">
                            <div class="offset-sm-2 col-sm-10">
                                <button type="submit" class="btn btn-info waves-effect waves-light" ng-disabled="editPage.$invalid">{{phrase.editPage}}</button>
                            </div>
                        </div>
                    </form>

                </div>
            </div>
        </div>
    </div>
</div>

<div class="row" ng-show="views.show">
    <div class="col-12">
        <div class="card">
            <div class="card-block">
                <h4 class="card-title">{{form.pageTitle}}</h4>
                <div class="table-responsive">

                    <div ng-bind-html="pageContent"></div>

                </div>
            </div>
        </div>
    </div>
</div>
