<div class="panel panel-default">
    <div class="panel-heading">
        <h2 ng-if="!vm.isEditMode">{{::vm.translate.get('Create Simple Product Widget')}}</h2>
        <h2 ng-if="vm.isEditMode">{{::vm.translate.get('Edit Simple Product Widget')}}</h2>
    </div>
    <div class="panel-body">
        <form name="simpleProductWidget" class="form-horizontal">
            <div class="col-sm-offset-2 bg-danger" ng-show="vm.validationErrors">
                <ul>
                    <li ng-repeat="error in vm.validationErrors">{{error}}</li>
                </ul>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Widget Name')}}</label>
                <div class="col-sm-10">
                    <input name="name" ng-model="vm.widgetInstance.name" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Widget Zone')}}</label>
                <div class="col-sm-10">
                    <select ng-model="vm.widgetInstance.widgetZoneId" class="form-control" ng-options="zone.id as zone.name for zone in vm.widgetZones"></select>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Publish Start')}}</label>
                <div class="col-sm-10">
                    <p class="input-group">
                        <input type="text" class="form-control" datetime-picker="dd MMM yyyy HH:mm" ng-model="vm.widgetInstance.publishStart" is-open="vm.datePickerPublishStart.open" datepicker-options="vm.datePickerPublishStart.datepickerOptions" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="vm.openCalendar($event, 'datePickerPublishStart')"><i class="fa fa-calendar"></i></button>
                        </span>
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Publish End')}}</label>
                <div class="col-sm-10">
                    <p class="input-group">
                        <input type="text" class="form-control" datetime-picker="dd MMM yyyy HH:mm" ng-model="vm.widgetInstance.publishEnd" is-open="vm.datePickerPublishEnd.open" datepicker-options="vm.datePickerPublishEnd.datepickerOptions" />
                        <span class="input-group-btn">
                            <button type="button" class="btn btn-default" ng-click="vm.openCalendar($event, 'datePickerPublishEnd')"><i class="fa fa-calendar"></i></button>
                        </span>
                    </p>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Display Order')}}</label>
                <div class="col-sm-10">
                    <input type="number" name="displayOrder" ng-model="vm.widgetInstance.displayOrder" class="form-control" />
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">{{::vm.translate.get('Products')}}</label>
                <div class="col-sm-10">
                    <product-selection-directive model-id="productRelationSelector" title="Add related products" is-visible-individually="true" selected-products="vm.widgetInstance.setting.products"></product-selection-directive>
                    <p><button type="button" class="btn btn-default" data-toggle="modal" data-target="#productRelationSelector">{{::vm.translate.get('Manage Products')}}</button></p>
                    <table class="table table-striped">
                        <tr>
                            <th>{{::vm.translate.get('Name')}}</th>
                            <th class="text-center">{{::vm.translate.get('Is Published')}}</th>
                        </tr>
                        <tr ng-repeat="product in vm.widgetInstance.setting.products">
                            <td>{{product.name}}</td>
                            <td class="text-center"><i ng-attr-class="{{product.isPublished && 'fa fa-circle' || 'fa fa-circle-o'}}"></i></td>
                        </tr>
                    </table>
                </div>
            </div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <button class="btn btn-primary" ng-click="vm.save()"><span class="glyphicon glyphicon-ok"></span> {{::vm.translate.get('Save')}}</button>
                    <button ui-sref="widget" class="btn btn-default">{{::vm.translate.get('Cancel')}}</button>
                </div>
            </div>
        </form>
    </div>
</div>