feat(item_fixed-price): implement smart-table
gitea/salix/pipeline/head There was a failure building this commit
Details
gitea/salix/pipeline/head There was a failure building this commit
Details
This commit is contained in:
parent
7a45b6014a
commit
b4e5631cc7
|
@ -37,6 +37,10 @@ smart-table table {
|
||||||
&[centered] {
|
&[centered] {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
&[mid] {
|
||||||
|
width: 150px;
|
||||||
|
max-width: 150px;
|
||||||
|
}
|
||||||
&[shrink] {
|
&[shrink] {
|
||||||
width: 1px;
|
width: 1px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
url="FixedPrices/filter"
|
url="FixedPrices/filter"
|
||||||
limit="20"
|
limit="20"
|
||||||
data="prices"
|
data="prices"
|
||||||
auto-load="true"
|
order="itemFk"
|
||||||
order="itemFk">
|
auto-load="false">
|
||||||
</vn-crud-model>
|
</vn-crud-model>
|
||||||
<vn-crud-model
|
<vn-crud-model
|
||||||
auto-load="true"
|
auto-load="true"
|
||||||
|
@ -18,45 +18,56 @@
|
||||||
panel="vn-fixed-price-search-panel"
|
panel="vn-fixed-price-search-panel"
|
||||||
info="Search prices by item ID or code"
|
info="Search prices by item ID or code"
|
||||||
placeholder="Search fixed prices"
|
placeholder="Search fixed prices"
|
||||||
filter="{}"
|
|
||||||
model="model">
|
model="model">
|
||||||
</vn-searchbar>
|
</vn-searchbar>
|
||||||
</vn-portal>
|
</vn-portal>
|
||||||
<div class="vn-w-xl">
|
<div class="vn-w-xl">
|
||||||
<vn-card>
|
<vn-card>
|
||||||
<vn-table model="model">
|
<smart-table
|
||||||
<vn-thead>
|
model="model"
|
||||||
<vn-tr>
|
options="$ctrl.smartTableOptions"
|
||||||
<vn-th field="itemFk" shrink>Item ID</vn-th>
|
expr-builder="$ctrl.exprBuilder(param, value)">
|
||||||
<vn-th field="itemFk">Description</vn-th>
|
<slot-table>
|
||||||
<vn-th field="warehouseFk" shrink>Warehouse</vn-th>
|
<table>
|
||||||
<vn-th
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th field="itemFk">
|
||||||
|
<span translate>Item ID</span>
|
||||||
|
</th>
|
||||||
|
<th field="itemFk">
|
||||||
|
<span translate>Description</span>
|
||||||
|
</th>
|
||||||
|
<th field="warehouseFk">
|
||||||
|
<span translate>Warehouse</span>
|
||||||
|
</th>
|
||||||
|
<th
|
||||||
field="rate2"
|
field="rate2"
|
||||||
vn-tooltip="Price By Unit"
|
vn-tooltip="Price By Unit">
|
||||||
center>
|
<span translate>P.P.U.</span>
|
||||||
P.P.U.
|
</th>
|
||||||
</vn-th>
|
<th
|
||||||
<vn-th
|
|
||||||
field="rate3"
|
field="rate3"
|
||||||
vn-tooltip="Price By Package"
|
vn-tooltip="Price By Package">
|
||||||
center>
|
<span translate>P.P.P.</span>
|
||||||
P.P.P.
|
</th>
|
||||||
</vn-th>
|
<th field="minPrice">
|
||||||
<vn-th></vn-th>
|
<span translate>Min price</span>
|
||||||
<vn-th field="minPrice">Min price</vn-th>
|
</th>
|
||||||
<vn-th field="started" style="width: 90px">Started</vn-th>
|
<th field="started">
|
||||||
<vn-th field="ended" style="width: 90px">Ended</vn-th>
|
<span translate>Started</span>
|
||||||
<vn-th shrink></vn-th>
|
</th>
|
||||||
</vn-tr>
|
<th field="ended">
|
||||||
</vn-thead>
|
<span translate>Ended</span>
|
||||||
<vn-tbody>
|
</th>
|
||||||
<vn-tr ng-repeat="price in prices">
|
<th shrink></th>
|
||||||
<vn-td shrink>
|
</tr>
|
||||||
<text>{{price.itemFk}}</text>
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<tr ng-repeat="price in prices">
|
||||||
|
<td>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
class="dense"
|
|
||||||
ng-if="!price.itemFk"
|
|
||||||
vn-focus
|
vn-focus
|
||||||
|
class="dense"
|
||||||
url="Items/withName"
|
url="Items/withName"
|
||||||
ng-model="price.itemFk"
|
ng-model="price.itemFk"
|
||||||
show-field="name"
|
show-field="name"
|
||||||
|
@ -66,11 +77,11 @@
|
||||||
order="id DESC"
|
order="id DESC"
|
||||||
tabindex="1">
|
tabindex="1">
|
||||||
<tpl-item>
|
<tpl-item>
|
||||||
{{::id}} - {{::name}}
|
{{::id}}
|
||||||
</tpl-item>
|
</tpl-item>
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td vn-fetched-tags>
|
<td vn-fetched-tags>
|
||||||
<div>
|
<div>
|
||||||
<span
|
<span
|
||||||
vn-one
|
vn-one
|
||||||
|
@ -88,96 +99,85 @@
|
||||||
item="price"
|
item="price"
|
||||||
tabindex="-1">
|
tabindex="-1">
|
||||||
</vn-fetched-tags>
|
</vn-fetched-tags>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td shrink>
|
<td mid>
|
||||||
<vn-autocomplete
|
<vn-autocomplete
|
||||||
vn-one
|
vn-one
|
||||||
label="Warehouse"
|
label="Warehouse"
|
||||||
ng-model="price.warehouseFk"
|
ng-model="price.warehouseFk"
|
||||||
url="Warehouses"
|
data="warehouses"
|
||||||
on-change="$ctrl.upsertPrice(price)"
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
tabindex="2">
|
tabindex="2">
|
||||||
</vn-autocomplete>
|
</vn-autocomplete>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td-editable number>
|
<td mid>
|
||||||
<text>{{price.rate2 | currency: 'EUR':2}}</text>
|
<span>
|
||||||
<field>
|
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
|
||||||
vn-focus
|
|
||||||
ng-model="price.rate2"
|
ng-model="price.rate2"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</field>
|
</span>
|
||||||
</vn-td-editable>
|
</td>
|
||||||
<vn-td-editable number>
|
<td mid>
|
||||||
<text>{{price.rate3 | currency: 'EUR':2}}</text>
|
|
||||||
<field>
|
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
class="dense"
|
|
||||||
vn-focus
|
|
||||||
ng-model="price.rate3"
|
ng-model="price.rate3"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</field>
|
</td>
|
||||||
</vn-td-editable>
|
<td shrink-date>
|
||||||
<vn-td shrink>
|
|
||||||
<vn-check
|
<vn-check
|
||||||
vn-one
|
vn-one
|
||||||
ng-model="price.hasMinPrice">
|
ng-model="price.hasMinPrice">
|
||||||
</vn-check>
|
</vn-check>
|
||||||
</vn-td>
|
|
||||||
<vn-td-editable number>
|
|
||||||
<text>{{price.minPrice | currency: 'EUR':2}}</text>
|
|
||||||
<field>
|
|
||||||
<vn-input-number
|
<vn-input-number
|
||||||
disabled="!price.hasMinPrice"
|
disabled="!price.hasMinPrice"
|
||||||
class="dense"
|
|
||||||
vn-focus
|
|
||||||
ng-model="price.minPrice"
|
ng-model="price.minPrice"
|
||||||
on-change="$ctrl.upsertPrice(price)"
|
on-change="$ctrl.upsertPrice(price)"
|
||||||
step="0.01">
|
step="0.01">
|
||||||
</vn-input-number>
|
</vn-input-number>
|
||||||
</field>
|
</td>
|
||||||
</vn-td-editable>
|
<td shrink-date>
|
||||||
<vn-td>
|
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="Started"
|
label="Started"
|
||||||
ng-model="price.started"
|
ng-model="price.started"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td>
|
<td shrink-date>
|
||||||
<vn-date-picker
|
<vn-date-picker
|
||||||
vn-one
|
vn-one
|
||||||
label="Ended"
|
label="Ended"
|
||||||
ng-model="price.ended"
|
ng-model="price.ended"
|
||||||
on-change="$ctrl.upsertPrice(price)">
|
on-change="$ctrl.upsertPrice(price)">
|
||||||
</vn-date-picker>
|
</vn-date-picker>
|
||||||
</vn-td>
|
</td>
|
||||||
<vn-td shrink>
|
<td shrink>
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
icon="delete"
|
icon="delete"
|
||||||
vn-tooltip="Delete"
|
vn-tooltip="Delete"
|
||||||
ng-click="deleteFixedPrice.show({$index})">
|
ng-click="deleteFixedPrice.show({$index})">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</vn-td>
|
</td>
|
||||||
</vn-tr>
|
</tr>
|
||||||
</vn-tbody>
|
</tbody>
|
||||||
</vn-table>
|
</table>
|
||||||
<div class="vn-pa-md">
|
<div class="vn-pa-md">
|
||||||
<vn-icon-button
|
<vn-icon-button
|
||||||
vn-tooltip="Add fixed price"
|
vn-tooltip="Add fixed price"
|
||||||
icon="add_circle"
|
icon="add_circle"
|
||||||
vn-bind="+"
|
vn-bind="+"
|
||||||
ng-click="model.insert()">
|
ng-click="$ctrl.add()">
|
||||||
</vn-icon-button>
|
</vn-icon-button>
|
||||||
</div>
|
</div>
|
||||||
<vn-pagination
|
<vn-pagination
|
||||||
model="model"
|
model="model"
|
||||||
class="vn-pt-md">
|
class="vn-pt-md"
|
||||||
|
scroll-selector="vn-item-price-fixed vn-table"
|
||||||
|
scroll-offset="100">
|
||||||
</vn-pagination>
|
</vn-pagination>
|
||||||
|
</slot-table>
|
||||||
|
</smart-table>
|
||||||
</vn-card>
|
</vn-card>
|
||||||
</div>
|
</div>
|
||||||
<vn-item-descriptor-popover
|
<vn-item-descriptor-popover
|
||||||
|
|
|
@ -5,13 +5,36 @@ import './style.scss';
|
||||||
export default class Controller extends Section {
|
export default class Controller extends Section {
|
||||||
constructor($element, $) {
|
constructor($element, $) {
|
||||||
super($element, $);
|
super($element, $);
|
||||||
|
|
||||||
|
this.smartTableOptions = {
|
||||||
|
activeButtons: {
|
||||||
|
search: true
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Inserts a new instance
|
|
||||||
*/
|
|
||||||
add() {
|
add() {
|
||||||
this.$.model.insert({});
|
const lastId = this.$.model.data.length - 1;
|
||||||
|
const lastItem = this.$.model.data[lastId];
|
||||||
|
this.$.model.insert({
|
||||||
|
itemFk: lastItem.itemFk,
|
||||||
|
name: lastItem.name,
|
||||||
|
subName: lastItem.subName,
|
||||||
|
value5: lastItem.value5,
|
||||||
|
value6: lastItem.value6,
|
||||||
|
value7: lastItem.value7,
|
||||||
|
value8: lastItem.value8,
|
||||||
|
value9: lastItem.value9,
|
||||||
|
value10: lastItem.value10,
|
||||||
|
warehouseFk: lastItem.warehouseFk,
|
||||||
|
rate2: lastItem.rate2,
|
||||||
|
rate3: lastItem.rate3,
|
||||||
|
hasMinPrice: lastItem.hasMinPrice,
|
||||||
|
minPrice: lastItem.minPrice,
|
||||||
|
started: lastItem.started,
|
||||||
|
ended: lastItem.ended,
|
||||||
|
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
upsertPrice(price) {
|
upsertPrice(price) {
|
||||||
|
|
|
@ -14,6 +14,17 @@ describe('fixed price', () => {
|
||||||
controller = $componentController('vnFixedPrice', {$element, $scope});
|
controller = $componentController('vnFixedPrice', {$element, $scope});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
describe('$onInit()', () => {
|
||||||
|
it('should perform a query to GET warehouses', () => {
|
||||||
|
$httpBackend.expectGET('Warehouses').respond('foo');
|
||||||
|
|
||||||
|
controller.$onInit();
|
||||||
|
$httpBackend.flush();
|
||||||
|
|
||||||
|
expect(controller.warehousesData).toBe('foo');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
describe('upsertPrice()', () => {
|
describe('upsertPrice()', () => {
|
||||||
it('should do nothing if one or more required arguments are missing', () => {
|
it('should do nothing if one or more required arguments are missing', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
|
@ -55,6 +66,10 @@ describe('fixed price', () => {
|
||||||
jest.spyOn(controller.vnApp, 'showSuccess');
|
jest.spyOn(controller.vnApp, 'showSuccess');
|
||||||
jest.spyOn(controller.$.model, 'remove');
|
jest.spyOn(controller.$.model, 'remove');
|
||||||
|
|
||||||
|
// $httpBackend.whenRoute('GET', 'Warehouses').respond();
|
||||||
|
// $httpBackend.when('GET', 'Warehouses').respond();
|
||||||
|
$httpBackend.expectGET('Warehouses').respond();
|
||||||
|
|
||||||
controller.removePrice($index);
|
controller.removePrice($index);
|
||||||
|
|
||||||
expect(controller.vnApp.showSuccess).not.toHaveBeenCalled();
|
expect(controller.vnApp.showSuccess).not.toHaveBeenCalled();
|
||||||
|
|
|
@ -1,5 +0,0 @@
|
||||||
@import "variables";
|
|
||||||
|
|
||||||
vn-table vn-date-picker {
|
|
||||||
max-width: 90px;
|
|
||||||
}
|
|
Loading…
Reference in New Issue