refactor(zerofill): deprecated zerofill and removed function
gitea/salix/pipeline/head This commit looks good
Details
gitea/salix/pipeline/head This commit looks good
Details
Refs: #5207
This commit is contained in:
parent
bbbb89d814
commit
527caf9ca0
|
@ -3,5 +3,4 @@ import './ucwords';
|
|||
import './dash-if-empty';
|
||||
import './percentage';
|
||||
import './currency';
|
||||
import './zero-fill';
|
||||
import './id';
|
||||
|
|
|
@ -1,25 +0,0 @@
|
|||
describe('ZeroFill filter', () => {
|
||||
let zeroFillFilter;
|
||||
|
||||
beforeEach(ngModule('vnCore'));
|
||||
|
||||
beforeEach(inject(_zeroFillFilter_ => {
|
||||
zeroFillFilter = _zeroFillFilter_;
|
||||
}));
|
||||
|
||||
it('should return null for a input null', () => {
|
||||
expect(zeroFillFilter(null, null)).toBeNull();
|
||||
});
|
||||
|
||||
it('should return a positive number pads a number with five zeros', () => {
|
||||
expect(zeroFillFilter(1, 5)).toBe('00001');
|
||||
});
|
||||
|
||||
it('should return negative number pads a number with five zeros', () => {
|
||||
expect(zeroFillFilter(-1, 5)).toBe('-00001');
|
||||
});
|
||||
|
||||
it('should return zero number with zero zeros', () => {
|
||||
expect(zeroFillFilter(0, 1)).toBe('0');
|
||||
});
|
||||
});
|
|
@ -1,17 +0,0 @@
|
|||
import ngModule from '../module';
|
||||
|
||||
/**
|
||||
* Pads a number with zeros.
|
||||
*
|
||||
* @param {Number} input The number to pad
|
||||
* @param {Number} padLength The resulting number of digits
|
||||
* @return {String} The zero-filled number
|
||||
*/
|
||||
export default function zeroFill() {
|
||||
return function(input, padLength) {
|
||||
if (input == null) return input;
|
||||
let sign = Math.sign(input) === -1 ? '-' : '';
|
||||
return sign + new Array(padLength).concat([Math.abs(input)]).join('0').slice(-padLength);
|
||||
};
|
||||
}
|
||||
ngModule.filter('zeroFill', zeroFill);
|
|
@ -101,7 +101,7 @@
|
|||
<vn-span
|
||||
ng-click="itemDescriptor.show($event, saleClaimed.itemFk)"
|
||||
class="link">
|
||||
{{::saleClaimed.itemFk | zeroFill:6}}
|
||||
{{::saleClaimed.itemFk}}
|
||||
</vn-span>
|
||||
</td>
|
||||
<td number>
|
||||
|
|
|
@ -115,7 +115,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, saleClaimed.sale.itemFk, saleClaimed.sale.id)"
|
||||
class="link">
|
||||
{{::saleClaimed.sale.itemFk | zeroFill:6}}
|
||||
{{::saleClaimed.sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td expand>{{::saleClaimed.sale.ticket.landed | date: 'dd/MM/yyyy'}}</vn-td>
|
||||
|
@ -241,7 +241,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, action.sale.itemFk, action.sale.id)"
|
||||
class="link">
|
||||
{{::action.sale.itemFk | zeroFill:6}}
|
||||
{{::action.sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
|
|
|
@ -60,7 +60,7 @@
|
|||
ng-if="buy.id"
|
||||
ng-click="itemDescriptor.show($event, buy.item.id)"
|
||||
class="link">
|
||||
{{::buy.item.id | zeroFill:6}}
|
||||
{{::buy.item.id}}
|
||||
</span>
|
||||
<vn-autocomplete ng-if="!buy.id" class="dense"
|
||||
vn-focus
|
||||
|
|
|
@ -148,7 +148,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, line.item.id)"
|
||||
class="link">
|
||||
{{::line.item.id | zeroFill:6}}
|
||||
{{::line.item.id}}
|
||||
</span>
|
||||
</td>
|
||||
<td number shrink>
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
show-field="description"
|
||||
rule
|
||||
vn-focus>
|
||||
<tpl-item>{{id | zeroFill:8}}: {{description}}</tpl-item>
|
||||
<tpl-item>{{id}}: {{description}}</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-input-number
|
||||
label="Amount"
|
||||
|
|
|
@ -141,7 +141,7 @@
|
|||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="intrastat in $ctrl.summary.invoiceInIntrastat">
|
||||
<vn-td>{{::intrastat.intrastatFk | zeroFill:8}}: {{::intrastat.intrastat.description}}</vn-td>
|
||||
<vn-td>{{::intrastat.intrastatFk}}: {{::intrastat.intrastat.description}}</vn-td>
|
||||
<vn-td>{{::intrastat.amount | currency: 'EUR':2}}</vn-td>
|
||||
<vn-td>{{::intrastat.net}}</vn-td>
|
||||
<vn-td>{{::intrastat.stems}}</vn-td>
|
||||
|
|
|
@ -39,7 +39,7 @@
|
|||
<vn-td number>
|
||||
<span ng-click="itemDescriptor.show($event, row.itemFk)"
|
||||
class="link">
|
||||
{{::row.itemFk | zeroFill:6}}
|
||||
{{::row.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td vn-fetched-tags>
|
||||
|
|
|
@ -95,7 +95,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, row.itemFk)"
|
||||
class="link">
|
||||
{{::row.itemFk | zeroFill:6}}
|
||||
{{::row.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td vn-fetched-tags>
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
title="{{::sale.item.name}}"
|
||||
vn-click-stop="itemDescriptor.show($event, sale.itemFk, sale.id)"
|
||||
class="link">
|
||||
{{::sale.itemFk | zeroFill:6}}
|
||||
{{::sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td vn-fetched-tags>
|
||||
|
|
|
@ -27,7 +27,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, sale.itemFk, sale.id)"
|
||||
class="link">
|
||||
{{sale.itemFk | zeroFill:6}}
|
||||
{{sale.itemFk}}
|
||||
</span>
|
||||
</td>
|
||||
<td rowspan="{{::sale.components.length + 1}}" vn-fetched-tags>
|
||||
|
|
|
@ -55,7 +55,7 @@
|
|||
ng-model="expedition.checked">
|
||||
</vn-check>
|
||||
</vn-td>
|
||||
<vn-td number expand>{{expedition.id | zeroFill:6}}</vn-td>
|
||||
<vn-td number expand>{{expedition.id}}</vn-td>
|
||||
<vn-td number>
|
||||
<span
|
||||
ng-class="{link: expedition.packagingItemFk}"
|
||||
|
|
|
@ -75,7 +75,7 @@
|
|||
ng-show="::request.saleFk"
|
||||
ng-click="itemDescriptor.show($event, request.sale.itemFk, request.sale.id)"
|
||||
class="link">
|
||||
{{::request.saleFk | zeroFill:6}}
|
||||
{{::request.saleFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number
|
||||
|
|
|
@ -365,7 +365,7 @@
|
|||
</vn-thead>
|
||||
<vn-tbody>
|
||||
<vn-tr ng-repeat="sale in $ctrl.transfer.sales">
|
||||
<vn-td number shrink>{{::sale.itemFk | zeroFill:6}}</vn-td>
|
||||
<vn-td number shrink>{{::sale.itemFk}}</vn-td>
|
||||
<vn-td>
|
||||
<span title="{{::sale.concept}}">{{::sale.concept}}</span>
|
||||
</vn-td>
|
||||
|
|
|
@ -177,7 +177,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, sale.itemFk, sale.id, $ctrl.ticket.shipped)"
|
||||
class="link">
|
||||
{{sale.itemFk | zeroFill:6}}
|
||||
{{sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number shrink>
|
||||
|
@ -312,7 +312,7 @@
|
|||
ng-show="::request.saleFk"
|
||||
ng-click="itemDescriptor.show($event, request.sale.itemFk, request.sale.id)"
|
||||
class="link">
|
||||
{{request.sale.itemFk | zeroFill:6}}
|
||||
{{request.sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td number>
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
<span
|
||||
ng-click="itemDescriptor.show($event, sale.itemFk, sale.id)"
|
||||
class="link">
|
||||
{{sale.itemFk | zeroFill:6}}
|
||||
{{sale.itemFk}}
|
||||
</span>
|
||||
</vn-td>
|
||||
<vn-td vn-fetched-tags>
|
||||
|
|
|
@ -4,5 +4,4 @@ require('./uppercase');
|
|||
require('./currency');
|
||||
require('./percentage');
|
||||
require('./number');
|
||||
require('./zerofill');
|
||||
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
import zerofill from '../zerofill.js';
|
||||
|
||||
describe('zerofill filter', () => {
|
||||
const superDuperNumber = 1984;
|
||||
|
||||
it('should filter the number filling it with zeros up to 6 characters length', () => {
|
||||
expect(zerofill(superDuperNumber, '000000')).toEqual('001984');
|
||||
});
|
||||
});
|
|
@ -1,10 +0,0 @@
|
|||
const Vue = require('vue');
|
||||
|
||||
const zerofill = function(value, pad) {
|
||||
const valueStr = String(value);
|
||||
return pad.substring(0, pad.length - valueStr.length) + valueStr;
|
||||
};
|
||||
|
||||
Vue.filter('zerofill', zerofill);
|
||||
|
||||
module.exports = zerofill;
|
|
@ -45,7 +45,7 @@
|
|||
</thead>
|
||||
<tbody v-for="sale in sales">
|
||||
<tr>
|
||||
<td>{{sale.itemFk | zerofill('000000')}}</td>
|
||||
<td>{{sale.itemFk}}</td>
|
||||
<td class="number">{{Math.trunc(sale.subtotal)}}</td>
|
||||
<td width="50%">{{sale.concept}}</td>
|
||||
</tr>
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
</thead>
|
||||
<tbody v-for="sale in sales" class="no-page-break">
|
||||
<tr>
|
||||
<td width="5%">{{sale.itemFk | zerofill('000000')}}</td>
|
||||
<td width="5%">{{sale.itemFk}}</td>
|
||||
<td class="number">{{sale.quantity}}</td>
|
||||
<td width="50%">{{sale.concept}}</td>
|
||||
<td class="number" v-if="showPrices">{{sale.price | currency('EUR', $i18n.locale)}}</td>
|
||||
|
@ -145,7 +145,7 @@
|
|||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="packaging in packagings">
|
||||
<td>{{packaging.itemFk | zerofill('000000')}}</td>
|
||||
<td>{{packaging.itemFk}}</td>
|
||||
<td class="number">{{packaging.quantity}}</td>
|
||||
<td width="85%">{{packaging.name}}</td>
|
||||
</tr>
|
||||
|
|
|
@ -96,7 +96,7 @@
|
|||
</thead>
|
||||
<tbody v-for="sale in ticket.sales" class="no-page-break">
|
||||
<tr>
|
||||
<td width="5%">{{sale.itemFk | zerofill('000000')}}</td>
|
||||
<td width="5%">{{sale.itemFk}}</td>
|
||||
<td class="number">{{sale.quantity}}</td>
|
||||
<td width="50%">{{sale.concept}}</td>
|
||||
<td class="number">{{sale.price | currency('EUR', $i18n.locale)}}</td>
|
||||
|
|
Loading…
Reference in New Issue