2206 - Refactor popover table #237

Merged
carlosjr merged 2 commits from 2206-zone_delivery_days into dev 2020-03-27 10:05:18 +00:00
4 changed files with 61 additions and 15 deletions

View File

@ -33,10 +33,59 @@
</form> </form>
</vn-side-menu> </vn-side-menu>
<vn-crud-model vn-id="zoneModel"
url="Zones"
filter="::$ctrl.filter"
limit="20"
data="zones"
auto-load="false">
</vn-crud-model>
<!-- Zone Popover --> <!-- Zone Popover -->
<vn-popover vn-id="zoneEvents"> <vn-popover vn-id="zoneEvents">
<div class="zoneEvents"> <div class="zoneEvents">
<div class="header vn-pa-sm" translate>Zones</div> <div class="header vn-pa-sm" translate>Zones</div>
<vn-zone-index vn-id="zoneIndex"></vn-zone-index> <vn-data-viewer
model="zoneModel"
class="vn-w-md vn-mb-xl">
<vn-card>
<vn-table model="zoneModel">
<vn-thead>
<vn-tr>
<vn-th field="id" number>Id</vn-th>
<vn-th field="name" expand>Name</vn-th>
<vn-th field="agencyModeFk">Agency</vn-th>
<vn-th field="hour" shrink>Closing</vn-th>
<vn-th field="price" number>Price</vn-th>
<vn-th shrink></vn-th>
</vn-tr>
</vn-thead>
<vn-tbody>
<vn-tr
ng-repeat="zone in zoneModel.data"
ui-sref="zone.card.summary({id: zone.id})"
class="clickable search-result">
<vn-td number>{{::zone.id}}</vn-td>
<vn-td expand>{{::zone.name}}</vn-td>
<vn-td>{{::zone.agencyMode.name}}</vn-td>
<vn-td shrink>{{::zone.hour | date: 'HH:mm'}}</vn-td>
<vn-td number>{{::zone.price | currency: 'EUR':2}}</vn-td>
<vn-td shrink>
<vn-horizontal class="buttons">
<vn-icon-button
ng-click="$ctrl.preview($event, zone)"
vn-tooltip="Preview"
icon="desktop_windows">
</vn-icon-button>
</vn-horizontal>
</vn-td>
</vn-tr>
</vn-tbody>
</vn-table>
</vn-card>
</vn-data-viewer>
</div> </div>
</vn-popover> </vn-popover>
<vn-popup vn-id="summary">
<vn-zone-summary zone="$ctrl.selectedZone"></vn-zone-summary>
</vn-popup>

View File

@ -26,8 +26,7 @@ class Controller extends Section {
zones.push(event.zoneFk); zones.push(event.zoneFk);
this.$.zoneEvents.show($event.target); this.$.zoneEvents.show($event.target);
const zoneIndex = this.$.zoneIndex; const zoneModel = this.$.zoneModel;
const zoneModel = zoneIndex.$scope.model;
zoneModel.applyFilter({ zoneModel.applyFilter({
include: { include: {
relation: 'agencyMode', relation: 'agencyMode',
@ -38,6 +37,12 @@ class Controller extends Section {
} }
}); });
} }
preview(event, zone) {
this.stopEvent(event);
this.selectedZone = zone;
this.$.summary.show();
}
} }
ngModule.component('vnZoneDeliveryDays', { ngModule.component('vnZoneDeliveryDays', {

View File

@ -14,11 +14,7 @@ describe('Zone Component vnZoneDeliveryDays', () => {
$element = angular.element('<vn-zone-delivery-days></vn-zone-delivery-days'); $element = angular.element('<vn-zone-delivery-days></vn-zone-delivery-days');
controller = $componentController('vnZoneDeliveryDays', {$element}); controller = $componentController('vnZoneDeliveryDays', {$element});
controller.$.zoneEvents = popover; controller.$.zoneEvents = popover;
controller.$.zoneIndex = { controller.$.zoneModel = crudModel;
$scope: {
model: crudModel
}
};
})); }));
describe('onSubmit()', () => { describe('onSubmit()', () => {
@ -60,7 +56,7 @@ describe('Zone Component vnZoneDeliveryDays', () => {
}); });
it('should call the show() method and then call the applyFilter() method with the expected ids', () => { it('should call the show() method and then call the applyFilter() method with the expected ids', () => {
const zoneModel = controller.$.zoneIndex.$scope.model; const zoneModel = controller.$.zoneModel;
jest.spyOn(controller.$.zoneEvents, 'show'); jest.spyOn(controller.$.zoneEvents, 'show');
jest.spyOn(zoneModel, 'applyFilter'); jest.spyOn(zoneModel, 'applyFilter');

View File

@ -20,10 +20,6 @@ vn-zone-delivery-days {
width: 700px; width: 700px;
max-height: 450px; max-height: 450px;
vn-float-button {
display: none
}
vn-data-viewer { vn-data-viewer {
margin-bottom: 0; margin-bottom: 0;
vn-pagination { vn-pagination {