refactor(zerofill): deprecated zerofill and removed function
gitea/salix/pipeline/head This commit looks good Details

Refs: #5207
This commit is contained in:
Joan Sanchez 2023-02-17 11:19:35 +01:00
parent bbbb89d814
commit 527caf9ca0
24 changed files with 21 additions and 84 deletions

View File

@ -3,5 +3,4 @@ import './ucwords';
import './dash-if-empty';
import './percentage';
import './currency';
import './zero-fill';
import './id';

View File

@ -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');
});
});

View File

@ -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);

View File

@ -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>

View File

@ -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>

View File

@ -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

View File

@ -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>

View File

@ -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"

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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}"

View File

@ -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

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -4,5 +4,4 @@ require('./uppercase');
require('./currency');
require('./percentage');
require('./number');
require('./zerofill');

View File

@ -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');
});
});

View File

@ -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;

View File

@ -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>

View File

@ -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>

View File

@ -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>