pick
gitea/salix/master This commit looks good
Details
gitea/salix/master This commit looks good
Details
This commit is contained in:
parent
c7423f5580
commit
f56e4f4b7d
|
@ -33,8 +33,8 @@ export default {
|
|||
taxNumber: `${components.vnTextfield}[name="fi"]`,
|
||||
socialName: `${components.vnTextfield}[name="socialName"]`,
|
||||
street: `${components.vnTextfield}[name="street"]`,
|
||||
postcode: `vn-autocomplete[field="$ctrl.client.postcode"]`,
|
||||
city: `vn-autocomplete[field="$ctrl.client.city"]`,
|
||||
postcode: `${components.vnTextfield}[name="postcode"]`,
|
||||
city: `${components.vnTextfield}[name="city"]`,
|
||||
province: `vn-autocomplete[field="$ctrl.client.provinceFk"]`,
|
||||
country: `vn-autocomplete[field="$ctrl.client.countryFk"]`,
|
||||
userName: `${components.vnTextfield}[name="userName"]`,
|
||||
|
@ -65,8 +65,8 @@ export default {
|
|||
equalizationTaxCheckbox: 'vn-check[label="Is equalizated"] md-checkbox',
|
||||
acceptPropagationButton: 'vn-client-fiscal-data > vn-confirm button[response=ACCEPT]',
|
||||
addressInput: `${components.vnTextfield}[name="street"]`,
|
||||
postcodeAutocomplete: `vn-autocomplete[field="$ctrl.client.postcode"]`,
|
||||
cityAutocomplete: `vn-autocomplete[field="$ctrl.client.city"]`,
|
||||
postcodeInput: `${components.vnTextfield}[name="postcode"]`,
|
||||
cityInput: `${components.vnTextfield}[name="city"]`,
|
||||
provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]',
|
||||
countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]',
|
||||
activeCheckbox: 'vn-check[label="Active"] md-checkbox',
|
||||
|
@ -100,8 +100,8 @@ export default {
|
|||
defaultCheckboxInput: 'vn-check[label="Default"] md-checkbox',
|
||||
consigneeInput: `${components.vnTextfield}[name="nickname"]`,
|
||||
streetAddressInput: `${components.vnTextfield}[name="street"]`,
|
||||
postcodeAutocomplete: `vn-autocomplete[field="$ctrl.address.postalCode"]`,
|
||||
cityAutocomplete: `vn-autocomplete[field="$ctrl.address.city"]`,
|
||||
postcodeInput: `${components.vnTextfield}[name="postalCode"]`,
|
||||
cityInput: `${components.vnTextfield}[name="city"]`,
|
||||
provinceAutocomplete: 'vn-autocomplete[field="$ctrl.address.provinceFk"]',
|
||||
agencyAutocomplete: 'vn-autocomplete[field="$ctrl.address.agencyModeFk"]',
|
||||
phoneInput: `${components.vnTextfield}[name="phone"]`,
|
||||
|
|
|
@ -53,7 +53,10 @@ describe('Client create path', () => {
|
|||
.write(selectors.createClientView.name, 'Carol Danvers')
|
||||
.write(selectors.createClientView.socialName, 'AVG tax')
|
||||
.write(selectors.createClientView.street, 'Many places')
|
||||
.autocompleteSearch(selectors.createClientView.postcode, '46000')
|
||||
.autocompleteSearch(selectors.createClientView.country, 'España')
|
||||
.autocompleteSearch(selectors.createClientView.province, 'Province one')
|
||||
.write(selectors.createClientView.city, 'Valencia')
|
||||
.write(selectors.createClientView.postcode, '46000')
|
||||
.clearInput(selectors.createClientView.email)
|
||||
.write(selectors.createClientView.email, 'incorrect email format')
|
||||
.waitToClick(selectors.createClientView.createButton)
|
||||
|
@ -64,7 +67,7 @@ describe('Client create path', () => {
|
|||
|
||||
it(`should check for autocompleted city, province and country`, async() => {
|
||||
const clientCity = await nightmare
|
||||
.waitToGetProperty(`${selectors.createClientView.city} input`, 'value');
|
||||
.waitToGetProperty(`${selectors.createClientView.city}`, 'value');
|
||||
|
||||
const clientProvince = await nightmare
|
||||
.waitToGetProperty(`${selectors.createClientView.province} input`, 'value');
|
||||
|
|
|
@ -67,8 +67,12 @@ describe('Client Edit fiscalData path', () => {
|
|||
.write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!')
|
||||
.clearInput(selectors.clientFiscalData.addressInput)
|
||||
.write(selectors.clientFiscalData.addressInput, 'Somewhere edited')
|
||||
.autocompleteSearch(selectors.clientFiscalData.cityAutocomplete, 'Valencia')
|
||||
.autocompleteSearch(selectors.clientFiscalData.postcodeAutocomplete, '46000')
|
||||
.autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'España')
|
||||
.autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province one')
|
||||
.clearInput(selectors.clientFiscalData.cityInput)
|
||||
.write(selectors.clientFiscalData.cityInput, 'Valencia')
|
||||
.clearInput(selectors.clientFiscalData.postcodeInput)
|
||||
.write(selectors.clientFiscalData.postcodeInput, '46000')
|
||||
.waitToClick(selectors.clientFiscalData.activeCheckbox)
|
||||
.waitToClick(selectors.clientFiscalData.frozenCheckbox)
|
||||
.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox)
|
||||
|
@ -194,14 +198,14 @@ describe('Client Edit fiscalData path', () => {
|
|||
|
||||
it('should confirm the postcode have been edited', async() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(`${selectors.clientFiscalData.postcodeAutocomplete} input`, 'value');
|
||||
.waitToGetProperty(`${selectors.clientFiscalData.postcodeInput}`, 'value');
|
||||
|
||||
expect(result).toContain('46000');
|
||||
});
|
||||
|
||||
it('should confirm the city have been autocompleted', async() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(`${selectors.clientFiscalData.cityAutocomplete} input`, 'value');
|
||||
.waitToGetProperty(`${selectors.clientFiscalData.cityInput}`, 'value');
|
||||
|
||||
expect(result).toEqual('Valencia');
|
||||
});
|
||||
|
|
|
@ -24,7 +24,11 @@ describe('Client Add address path', () => {
|
|||
const result = await nightmare
|
||||
.waitToClick(selectors.clientAddresses.defaultCheckboxInput)
|
||||
.clearInput(selectors.clientAddresses.streetAddressInput)
|
||||
.autocompleteSearch(selectors.clientAddresses.postcodeAutocomplete, '46000')
|
||||
.autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one')
|
||||
.clearInput(selectors.clientAddresses.cityInput)
|
||||
.write(selectors.clientAddresses.cityInput, 'Valencia')
|
||||
.clearInput(selectors.clientAddresses.postcodeInput)
|
||||
.write(selectors.clientAddresses.postcodeInput, '46000')
|
||||
.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement')
|
||||
.write(selectors.clientAddresses.phoneInput, '999887744')
|
||||
.write(selectors.clientAddresses.mobileInput, '999887744')
|
||||
|
@ -36,14 +40,14 @@ describe('Client Add address path', () => {
|
|||
|
||||
it('should confirm the postcode have been edited', async() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(`${selectors.clientAddresses.postcodeAutocomplete} input`, 'value');
|
||||
.waitToGetProperty(`${selectors.clientAddresses.postcodeInput}`, 'value');
|
||||
|
||||
expect(result).toContain('46000');
|
||||
});
|
||||
|
||||
it('should confirm the city have been autocompleted', async() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(`${selectors.clientAddresses.cityAutocomplete} input`, 'value');
|
||||
.waitToGetProperty(`${selectors.clientAddresses.cityInput}`, 'value');
|
||||
|
||||
expect(result).toEqual('Valencia');
|
||||
});
|
||||
|
|
|
@ -49,5 +49,11 @@
|
|||
"This client can't be invoiced": "This client can't be invoiced",
|
||||
"The introduced hour already exists": "The introduced hour already exists",
|
||||
"Invalid parameters to create a new ticket": "Invalid parameters to create a new ticket",
|
||||
"Concept cannot be blank": "Concept cannot be blank"
|
||||
"Concept cannot be blank": "Concept cannot be blank",
|
||||
"Ticket id cannot be blank": "Ticket id cannot be blank",
|
||||
"Weekday cannot be blank": "Weekday cannot be blank",
|
||||
"This ticket can not be modified": "This ticket can not be modified",
|
||||
"You can't delete a confirmed order": "You can't delete a confirmed order",
|
||||
"Value has an invalid format": "Value has an invalid format",
|
||||
"The postcode doesn't exists. Ensure you put the correct format": "The postcode doesn't exists. Ensure you put the correct format"
|
||||
}
|
|
@ -97,5 +97,15 @@
|
|||
"This postcode already exists": "Este código postal ya existe",
|
||||
"Concept cannot be blank": "El concepto no puede quedar en blanco",
|
||||
"File doesn't exists": "El archivo no existe",
|
||||
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona"
|
||||
"You don't have privileges to change the zone": "No tienes permisos para cambiar la zona",
|
||||
"This ticket is already on weekly tickets": "Este ticket ya está en tickets programados",
|
||||
"Ticket id cannot be blank": "El id de ticket no puede quedar en blanco",
|
||||
"Weekday cannot be blank": "El día de la semana no puede quedar en blanco",
|
||||
"You can't delete a confirmed order": "No puedes borrar un pedido confirmado",
|
||||
"Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket",
|
||||
"Value has an invalid format": "El valor tiene un formato incorrecto",
|
||||
"Invalid quantity": "Cantidad invalida",
|
||||
"This postal code is not valid": "This postal code is not valid",
|
||||
"is invalid": "is invalid",
|
||||
"The postcode doesn't exists. Ensure you put the correct format": "El código postal no existe. Asegúrate de ponerlo con el formato correcto"
|
||||
}
|
|
@ -43,6 +43,21 @@ module.exports = Self => {
|
|||
next();
|
||||
});
|
||||
|
||||
Self.validateAsync('postalCode', hasValidPostcode, {
|
||||
message: `The postcode doesn't exists. Ensure you put the correct format`
|
||||
});
|
||||
|
||||
async function hasValidPostcode(err, done) {
|
||||
if (!this.postalCode)
|
||||
return done();
|
||||
|
||||
const models = Self.app.models;
|
||||
const postcode = await models.Postcode.findById(this.postalCode);
|
||||
|
||||
if (!postcode) err();
|
||||
done();
|
||||
}
|
||||
|
||||
// Helpers
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
|
|
|
@ -149,6 +149,31 @@ module.exports = Self => {
|
|||
done();
|
||||
}
|
||||
|
||||
Self.validateBinded('socialName', isAlpha, {
|
||||
message: 'Value has an invalid format'
|
||||
});
|
||||
|
||||
function isAlpha(value) {
|
||||
const regexp = new RegExp(/^[a-zA-Z\s]*$/);
|
||||
|
||||
return regexp.test(value);
|
||||
}
|
||||
|
||||
Self.validateAsync('postCode', hasValidPostcode, {
|
||||
message: `The postcode doesn't exists. Ensure you put the correct format`
|
||||
});
|
||||
|
||||
async function hasValidPostcode(err, done) {
|
||||
if (!this.postcode)
|
||||
return done();
|
||||
|
||||
const models = Self.app.models;
|
||||
const postcode = await models.Postcode.findById(this.postcode);
|
||||
|
||||
if (!postcode) err();
|
||||
done();
|
||||
}
|
||||
|
||||
Self.observe('before save', async function(ctx) {
|
||||
let changes = ctx.data || ctx.instance;
|
||||
let orgData = ctx.currentInstance;
|
||||
|
|
|
@ -31,7 +31,11 @@
|
|||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-id="town" vn-one
|
||||
<vn-textfield vn-one
|
||||
label="City"
|
||||
field="$ctrl.address.city">
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="/api/Towns"
|
||||
fields="['id', 'name']"
|
||||
|
@ -55,12 +59,16 @@
|
|||
{{code}}, {{town.name}} - {{town.province.name}}
|
||||
({{town.province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
<vn-icon-button vn-auto margin-medium-v
|
||||
</vn-autocomplete> -->
|
||||
<vn-textfield vn-one
|
||||
label="Postcode"
|
||||
field="$ctrl.address.postalCode">
|
||||
</vn-textfield>
|
||||
<!-- <vn-icon-button vn-auto margin-medium-v
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()">
|
||||
</vn-icon-button>
|
||||
</vn-icon-button> -->
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete
|
||||
|
|
|
@ -47,7 +47,11 @@
|
|||
value-field="id"
|
||||
label="Province">
|
||||
</vn-autocomplete>
|
||||
<vn-autocomplete vn-id="town" vn-one
|
||||
<vn-textfield vn-one
|
||||
label="City"
|
||||
field="$ctrl.address.city">
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="/api/Towns"
|
||||
fields="['id', 'name']"
|
||||
|
@ -66,12 +70,16 @@
|
|||
show-field="code"
|
||||
value-field="code"
|
||||
label="Postcode">
|
||||
</vn-autocomplete>
|
||||
<vn-icon-button vn-auto margin-medium-v
|
||||
</vn-autocomplete> -->
|
||||
<vn-textfield vn-one
|
||||
label="Postcode"
|
||||
field="$ctrl.address.postalCode">
|
||||
</vn-textfield>
|
||||
<!-- <vn-icon-button vn-auto margin-medium-v
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()">
|
||||
</vn-icon-button>
|
||||
</vn-icon-button> -->
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-one
|
||||
|
|
|
@ -50,7 +50,11 @@
|
|||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="town" vn-one
|
||||
<vn-textfield vn-one
|
||||
label="City"
|
||||
field="$ctrl.client.city">
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="/api/Towns"
|
||||
fields="['id', 'name']"
|
||||
|
@ -58,13 +62,17 @@
|
|||
show-field="name"
|
||||
value-field="name"
|
||||
field="$ctrl.client.city">
|
||||
</vn-autocomplete>
|
||||
<vn-icon-button vn-auto margin-medium-v
|
||||
</vn-autocomplete> -->
|
||||
<!-- <vn-icon-button vn-auto margin-medium-v
|
||||
icon="add_circle"
|
||||
vn-tooltip="New postcode"
|
||||
ng-click="postcode.open()">
|
||||
</vn-icon-button>
|
||||
<vn-autocomplete vn-one
|
||||
</vn-icon-button> -->
|
||||
<vn-textfield vn-one
|
||||
label="Postcode"
|
||||
field="$ctrl.client.postcode">
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-one
|
||||
url="/api/Postcodes/location"
|
||||
fields="['code', 'townFk']"
|
||||
field="$ctrl.client.postcode"
|
||||
|
@ -79,7 +87,7 @@
|
|||
{{code}}, {{town.name}} - {{town.province.name}}
|
||||
({{town.province.country.country}})
|
||||
</tpl-item>
|
||||
</vn-autocomplete>
|
||||
</vn-autocomplete> -->
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield
|
||||
|
|
|
@ -45,7 +45,15 @@
|
|||
</vn-autocomplete>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-autocomplete vn-id="town" vn-one
|
||||
<vn-textfield vn-one
|
||||
label="City"
|
||||
field="$ctrl.client.city">
|
||||
</vn-textfield>
|
||||
<vn-textfield vn-one
|
||||
label="Postcode"
|
||||
field="$ctrl.client.postcode">
|
||||
</vn-textfield>
|
||||
<!-- <vn-autocomplete vn-id="town" vn-one
|
||||
label="City"
|
||||
url="/api/Towns"
|
||||
fields="['id', 'name']"
|
||||
|
@ -64,7 +72,7 @@
|
|||
show-field="code"
|
||||
value-field="code"
|
||||
label="Postcode">
|
||||
</vn-autocomplete>
|
||||
</vn-autocomplete> -->
|
||||
</vn-horizontal>
|
||||
<vn-horizontal pad-small-v>
|
||||
<vn-check
|
||||
|
|
Loading…
Reference in New Issue