<mg-ajax path="Clients/{{post.params.id}}/setRating" options="vnPost"></mg-ajax>
<vn-watcher
    vn-id="watcher"
    url="Clients"
    data="$ctrl.client"
    id-value="$ctrl.$params.id"
    insert-mode="true"
    form="form"
    save="post">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
    <vn-card class="vn-pa-lg">
        <vn-horizontal>
            <vn-input-number
                vn-one
                label="Rating"
                ng-model="$ctrl.client.rating"
                vn-focus
                rule>
            </vn-input-number>
            <vn-input-number
                vn-one
                label="Recommended credit"
                ng-model="$ctrl.client.recommendedCredit"
                rule>
            </vn-input-number>
        </vn-horizontal>
    </vn-card>
    <vn-button-bar>
        <vn-submit
            disabled="!watcher.dataChanged()"
            label="Save">
        </vn-submit>
    </vn-button-bar>
</form>

<vn-crud-model
    vn-id="model"
    url="ClientInformas"
    filter="$ctrl.filter"
    link="{clientFk: $ctrl.$params.id}"
    limit="20"
    data="clientInformas"
    order="created DESC"
    auto-load="true">
</vn-crud-model>
<vn-data-viewer
    model="model"
    class="vn-w-md">
    <vn-card>
    <vn-table model="model" class="vn-mt-lg">
        <vn-thead>
            <vn-tr>
                <vn-th shrink-date field="created">Since</vn-th>
                <vn-th field="workerFk">Employee</vn-th>
                <vn-th field="rating" number>Rating</vn-th>
                <vn-th field="recommendedCredit" number>Recommended credit</vn-th>
            </vn-tr>
        </vn-thead>
        <vn-tbody>
            <vn-tr ng-repeat="clientInforma in clientInformas">
                <vn-td shrink-datetime>{{::clientInforma.created | date:'dd/MM/yyyy HH:mm'}}</vn-td>
                <vn-td shrink>
                    <span
                        ng-click="workerDescriptor.show($event, clientInforma.workerFk)"
                        class="link">
                        {{::clientInforma.worker.user.nickname}}
                    </span>
                </vn-td>
                <vn-td number>{{::clientInforma.rating}}</vn-td>
                <vn-td number>{{::clientInforma.recommendedCredit | currency: 'EUR'}}</vn-td>
            </vn-tr>
        </vn-tbody>
    </vn-table>
    </vn-card>
</vn-data-viewer>
<vn-worker-descriptor-popover
    vn-id="workerDescriptor">
</vn-worker-descriptor-popover>