<div class="modal-header">
    <button type="button" class="close" ng-click="close()" aria-label="Close"><span aria-hidden="true">&times;</span></button>
    <h4 class="modal-title"><i class="fa fa-cubes"></i> Collections <small>{{cipher.name}}</small></h4>
</div>
<form name="form" ng-submit="form.$valid && submit()" api-form="submitPromise" autocomplete="off">
    <div class="modal-body">
        <p>Edit the collections that this item is being shared with.</p>
        <div class="callout callout-danger validation-errors" ng-show="form.$errors">
            <h4>Errors have occurred</h4>
            <ul>
                <li ng-repeat="e in form.$errors">{{e}}</li>
            </ul>
        </div>
        <div ng-show="!collections.length" class="callout callout-default">
            <p>There are no collections yet for your organization.</p>
        </div>
        <div class="table-responsive" ng-show="collections.length" style="margin: 0;">
            <table class="table table-striped table-hover" style="margin: 0;">
                <thead>
                    <tr>
                        <th style="width: 40px;">
                            <input type="checkbox"
                                   ng-checked="allSelected()"
                                   ng-click="toggleCollectionSelectionAll($event)">
                        </th>
                        <th>Name</th>
                    </tr>
                </thead>
                <tbody>
                    <tr ng-repeat="collection in collections | orderBy: ['name'] track by collection.id">
                        <td valign="middle">
                            <input type="checkbox"
                                   name="selectedCollections[]"
                                   value="{{collection.id}}"
                                   ng-checked="collectionSelected(collection)"
                                   ng-click="toggleCollectionSelection(collection.id)">
                        </td>
                        <td valign="middle" ng-click="toggleCollectionSelection(collection.id)">
                            {{collection.name}}
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>
    <div class="modal-footer">
        <button type="submit" class="btn btn-primary btn-flat" ng-disabled="form.$loading" ng-show="collections.length">
            <i class="fa fa-refresh fa-spin loading-icon" ng-show="form.$loading"></i>Save
        </button>
        <button type="button" class="btn btn-default btn-flat" ng-click="close()">Close</button>
    </div>
</form>