<div class="corporateNewsEditWebpart">
    <div class="modal-header">
        <button type="button" class="close closebtn" data-ng-click="cancel()" aria-hidden="true">&times;</button>
        <h1 class="modal-title">{{'Corporate news' | translate}}</h1>
    </div>
    <div class="container-fluid wt-navRowContainer">
        <div class="row wt-navRow">
            <div class="col-sm-12 wt-fullHeightColumn wt-navContentColumn">
                <div class="modal-body">
                    <form>
                        <div class="form-group">
                            <label class="control-label">{{'Template' | translate}}</label>
                            <wizdom365-template-picker template-url="data.templateUrl" directory-path="CorporateNews/Templates/ViewTemplates"></wizdom365-template-picker>
                        </div>
                        <div class="row">
                            <div class="col-sm-8">
                                <div class="form-group">
                                    <label class="control-label">{{'Classic News Url' | translate}}</label>
                                    <input type="text" class="form-control" ng-model="data.path" ng-required="data.queryMode" />

                                </div>
                                <div class="form-group">
                                    <label class="control-label">{{'Modern News Url' | translate}}</label>
                                    <input type="text" class="form-control" ng-model="data.pathModern" ng-required="data.queryMode" />

                                </div>

                            </div>
                            <div class="col-sm-4">
                                <label class="control-label">&nbsp;</label>
                                <button class="form-control btn btn-default" ng-click="chooseSpSite();">{{'Browse...' | translate}}</button>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">{{'News type' | translate}}</label>
                            <div class="radio"><label><input type="radio" ng-model="data.typeNews" value="1">{{'Top News' | translate}}</label></div>
                            <div class="radio"><label><input type="radio" ng-model="data.typeNews" value="0">{{'Not Top News' | translate}}</label></div>
                            <div class="radio"><label><input type="radio" ng-model="data.typeNews" value="2">{{'Show all' | translate}}</label></div>
                        </div>
                        <div class="form-group">
                            <label class="control-label">{{'Number of Items' | translate}}</label>
                            <input type="number" class="form-control" ng-model="data.numberOfNews" />
                        </div>
                        <div class="row">
                            <div class="col-sm-12">
                                <div class="advancedSettingsExpander" ng-click="isAdvancedSettingsOpen = !isAdvancedSettingsOpen">
                                    <span class="advancedSettingsExpanderArrow"><i class="ms-Icon" ng-class="isAdvancedSettingsOpen == true ? 'ms-Icon--ChevronDownMed' : 'ms-Icon--ChevronRightMed'"></i></span>
                                    <span class="advancedSettingsExpanderText">{{'Advanced' | translate}}</span>
                                </div>
                                <div class="advancedSettingsDeviderLine" ng-show="isAdvancedSettingsOpen"></div>
                            </div>
                        </div>

                        <!-- Advanced settings start -->
                        <div class="advancedSettings" ng-show="isAdvancedSettingsOpen" id="advancedSettings">
                            <div class="form-group">
                                <label class="control-label">{{'Rotation speed in milliseconds (1s = 1000ms)' | translate}}</label>
                                <input type="number" class="form-control" ng-model="data.speed" />
                            </div>
                            <div class="row">
                                <div class="col-sm-8">
                                    <div class="form-group">
                                        <label class="control-label">{{'Order by' | translate}}</label>
                                        <input type="text" class="form-control" ng-model="data.orderBy" />
                                    </div>
                                </div>
                                <div class="col-sm-4">
                                    <div class="form-group">
                                        <label class="control-label">&nbsp;</label>
                                        <select ng-model="data.ascending" class="form-control">
                                            <option value="true">{{'Ascending' | translate}}</option>
                                            <option value="false">{{'Descending' | translate}}</option>
                                        </select>
                                    </div>
                                </div>
                            </div>


                            <div class="form-group">
                                <label class="control-label">{{'Language filter' | translate }}</label>
                                <div class="checkbox">
                                    <div ng-show="data.languageFilterUseDynamic == false">
                                        <div wizdom365-taxonomypicker selected-terms="data.languageFilter" field-name="W365_Language" allow-only-one-term=""></div>
                                    </div>
                                    <div ng-show="data.languageFilterUseDynamic == true">
                                        <select ng-model="data.languageFilterDynamic" class="form-control">
                                            <option value="{{item.title}}" ng-repeat="item in userprofileProperties | orderBy:'title'">{{item.title}}</option>
                                        </select>
                                    </div>
                                    <div>
                                        <span ng-if="data.languageFilterUseDynamic == false">{{'Filter corporate news items based on term(s)' | translate}}</span>
                                        <span ng-if="data.languageFilterUseDynamic == true">{{'Filter corporate news items based on terms associated with user profile property' | translate}}</span>
                                    </div>
                                    <label class="control-label">
                                        <input type="checkbox" ng-checked="data.languageFilterUseDynamic" class="linkcollection-checkbox" ng-model="data.languageFilterUseDynamic" />
                                        {{'Use userprofile property' | translate}}
                                    </label>

                                </div>
                            </div>


                            <div class="form-group">
                                <label class="control-label">{{'Location filter' | translate }}</label>
                                <div class="checkbox">
                                    <div ng-show="data.locationFilterUseDynamic == false">
                                        <div wizdom365-taxonomypicker selected-terms="data.locationFilter" term-set-id="b49f64b3-4722-4336-9a5c-56c326b344d4" allow-only-one-term=""></div>
                                    </div>
                                    <div ng-show="data.locationFilterUseDynamic == true">
                                        <select ng-model="data.locationFilterDynamic" class="form-control">
                                            <option value="{{item.title}}" ng-repeat="item in userprofileProperties | orderBy:'title'">{{item.title}}</option>
                                        </select>
                                    </div>
                                    <div>
                                        <span ng-if="data.locationFilterUseDynamic == false">{{'Filter corporate news items based on term(s)' | translate}}</span>
                                        <span ng-if="data.locationFilterUseDynamic == true">{{'Filter corporate news items based on terms associated with user profile property' | translate}}</span>
                                    </div>
                                    <label class="control-label">
                                        <input type="checkbox" ng-checked="data.locationFilterUseDynamic" class="linkcollection-checkbox" ng-model="data.locationFilterUseDynamic" />
                                        {{'Use userprofile property' | translate}}
                                    </label>

                                </div>
                            </div>


                            <div class="form-group">
                                <label class="control-label">{{'Department filter' | translate }}</label>
                                <div class="checkbox">
                                    <div ng-show="data.departmentFilterUseDynamic == false">
                                        <div wizdom365-taxonomypicker selected-terms="data.departmentFilter" term-set-id="8ed8c9ea-7052-4c1d-a4d7-b9c10bffea6f" allow-only-one-term=""></div>
                                    </div>
                                    <div ng-show="data.departmentFilterUseDynamic == true">
                                        <select ng-model="data.departmentFilterDynamic" class="form-control">
                                            <option value="{{item.title}}" ng-repeat="item in userprofileProperties | orderBy:'title'">{{item.title}}</option>
                                        </select>
                                    </div>
                                    <div>
                                        <span ng-if="data.departmentFilterUseDynamic == false">{{'Filter corporate news items based on term(s)' | translate}}</span>
                                        <span ng-if="data.departmentFilterUseDynamic == true">{{'Filter corporate news items based on terms associated with user profile property' | translate}}</span>
                                    </div>
                                    <label class="control-label">
                                        <input type="checkbox" ng-checked="data.departmentFilterUseDynamic" class="linkcollection-checkbox" ng-model="data.departmentFilterUseDynamic" />
                                        {{'Use userprofile property' | translate}}
                                    </label>

                                </div>
                            </div>



                            <div class="form-group" ng-show="data.queryMode === '0'">
                                <label class="control-label">{{'Search result source (GUID)' | translate}}</label>
                                <input type="text" class="form-control" ng-model="data.resultSource" />
                            </div>

                            <div class="form-group">
                                <label class="control-label">
                                    <input type="checkbox" ng-checked="data.includeModernNews" class="linkcollection-checkbox" ng-model="data.includeModernNews" />
                                    {{'Include SharePoint Modern News pages' | translate}}
                                </label>
                            </div>

                            <div class="form-group">
                                <label class="control-label">
                                    <input type="checkbox" ng-checked="data.includeClassicNews" class="linkcollection-checkbox" ng-model="data.includeClassicNews" />
                                    {{'Include SharePoint Classic News pages' | translate}}
                                </label>
                            </div>


                            <div class="form-group">
                                <label class="control-label">{{'Query mode' | translate}}</label>
                                <div class="radio">
                                    <label><input type="radio" ng-change="queryModeChanged();" ng-model="data.queryMode" value="0">{{'SharePoint Search Based' | translate}}</label>
                                    <div class="wt-fieldInfo">{{'Retrieves results faster, but requires SharePoint Search to crawl and index news pages before they are shown.' | translate}}</div>
                                </div>
                                <div class="radio">
                                    <label><input type="radio" ng-change="queryModeChanged();" ng-model="data.queryMode" value="1">{{'CAML Query Based' | translate}}</label>
                                    <div class="wt-fieldInfo">{{'News are shown immediately after publishing. However, query is slower and impacts performance of the page, particular in case of large quantities of news and/or high traffic.' | translate}}</div>
                                </div>
                            </div>
                            <div class="form-group" ng-show="data.queryMode === '0'">
                                <label class="control-label">{{'Caching' | translate}}</label>
                                <div class="radio"><label><input type="radio" ng-model="data.cachingType" value="0">{{'Per user' | translate}}</label></div>
                                <div class="radio"><label><input type="radio" ng-model="data.cachingType" value="1">{{'Group: Everyone except external users' | translate}}</label></div>
                            </div>
                            <div class="form-group" ng-show="data.queryMode === '0'">
                                <label class="control-label">{{'Managed properties' | translate}}</label>
                                <div class="input-group">
                                    <input type="text" class="form-control" ng-model="newProp" />
                                    <span class="input-group-addon" style="cursor: pointer;" ng-click="addProp();">{{'Add' | translate}}</span>
                                </div>
                                <br />
                                <ul class="list-group" ui-sortable="" ng-model="data.selectProperties">
                                    <li class="list-group-item" ng-repeat="prop in data.selectProperties track by $index">
                                        <span style="cursor:move;">{{prop}}</span>
                                        <span class="badge" style="cursor:pointer" ng-click="removeProp($index,data.selectProperties)">{{'Remove' | translate}}</span>
                                    </li>
                                </ul>
                            </div>
                        </div>
                        <!-- Advanced settings end -->
                    </form>
                </div>
                <div class="modal-footer">
                    <button class="btn btn-success wiz-btn-padding" ng-click="updateConfig();" >{{'Save' | translate}}</button>
                    <button class="btn btn-default wiz-btn-padding" ng-disabled="loading" ng-click="cancel();">{{"Cancel" | translate}}</button>
                </div>
            </div>
        </div>
    </div>
</div>

