<div class="w-assign-reviews-section" ng-controller="AssignReviewsToAnalystCtrl">
    <h4>
        Analysis Assignement
    </h4>
    <!-- ASSIGNMENTS -->
    <div>
        <span ng-if="!(analysts|filterByAssignedProduct:product) || (analysts|filterByAssignedProduct:product).length===0">
            No assignments
        </span>
    </div>
    <div ng-if="(analysts|filterByAssignedProduct:product) && (analysts|filterByAssignedProduct:product).length>0">
        Assignments:
        <span ng-repeat="analyst in (analysts|filterByAssignedProduct:product) track by $index">
            <span class="label label-info label-analyst-language-assignment" ng-repeat="productReviewsSection in analyst.assignedProducts[product._id] track by $index" style="margin-right:10px;">
                {{analyst.username}} - {{productReviewsSection.language}} - {{productReviewsSection.dataSource||'problem in detecting data source'}}
                <i class="clickable" ng-click="removeAssignedProduct(analyst, product, productReviewsSection.language)">
                    X
                </i>
            </span>
        </span>
    </div>
    <!-- FORM -->
    <div>
        <form class="w-assign-reviews-form" ng-submit="assignAnalystToProductAndLanguage(product, chosenLanguage, chosenAnalyst, chosenDataSource)">
            <span>
                Select analyst:
            </span>
            <select class="analyst-select w-assign-reviews-analyst-select" ng-model="chosenAnalyst" ng-options="analyst as analyst.username for analyst in analysts">
            </select>
            <span ng-show="chosenDataSource && chosenDataSource.length">
                Select language:
            </span>
            <select class="language-select w-assign-reviews-language-select" ng-model="chosenLanguage" ng-show="chosenDataSource && chosenDataSource.length">
                <option ng-repeat="lang in product.languages" value="{{lang}}">
                    {{lang}} ({{reviewsCountByLanguageIndex[$index]}})
                </option>
            </select>
            <span>
                Select data source:
            </span>
            <select class="data-source-select w-assign-reviews-data-source-select" ng-change="onDataSourceChange()" ng-model="chosenDataSource" ng-options="dataSource as dataSource for dataSource in ['reviews','call-center']">
            </select>
            <button class="btn assigning-btn w-assign-reviews-button">
                Assign
            </button>
        </form>
    </div>
</div>
<hr>
</hr>