refactor(geolocation): create province now uses autonomy instead of country
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Carlos Jimenez Ruiz 2021-09-02 11:56:59 +02:00
parent 84b8ed610d
commit 85844973d6
7 changed files with 60 additions and 9 deletions

View File

@ -65,6 +65,9 @@
"Province": {
"dataSource": "vn"
},
"Autonomy": {
"dataSource": "vn"
},
"Payment": {
"dataSource": "vn"
},

43
back/models/autonomy.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "Autonomy",
"description": "Autonomies of every country",
"base": "VnModel",
"options": {
"mysql": {
"table": "autonomy"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"name": {
"type": "string",
"required": true
}
},
"relations": {
"country": {
"type": "belongsTo",
"model": "Country",
"foreignKey": "countryFk"
}
},
"scopes": {
"location": {
"include": {
"relation": "country"
}
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -9,7 +9,7 @@
},
"properties": {
"id": {
"type": "Number",
"type": "number",
"id": true,
"description": "Identifier"
},
@ -24,6 +24,11 @@
"model": "Country",
"foreignKey": "countryFk"
},
"autonomy": {
"type": "belongsTo",
"model": "Autonomy",
"foreignKey": "autonomyFk"
},
"warehouse": {
"type": "belongsTo",
"model": "Warehouse",

View File

@ -123,6 +123,7 @@ export default {
addProvince: 'vn-autocomplete[ng-model="$ctrl.location.provinceFk"] vn-icon-button[icon="add_circle"]',
addCity: 'vn-autocomplete[ng-model="$ctrl.location.townFk"] vn-icon-button[icon="add_circle"]',
newProvinceName: 'vn-textfield[ng-model="$ctrl.province.name"]',
newProvinceAutonomy: 'vn-autocomplete[ng-model="$ctrl.province.autonomyFk"]',
newCityName: 'vn-textfield[ng-model="$ctrl.city.name"]',
newCityProvince: 'vn-autocomplete[ng-model="$ctrl.city.provinceFk"]',
newPostcode: 'vn-textfield[ng-model="$ctrl.location.code"]',
@ -130,7 +131,6 @@ export default {
city: 'vn-client-create vn-datalist[ng-model="$ctrl.client.city"]',
province: 'vn-autocomplete[ng-model="$ctrl.client.provinceFk"]',
country: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.countryFk"]',
dialogCountry: 'vn-autocomplete[ng-model="$ctrl.province.countryFk"]',
userName: 'vn-client-create vn-textfield[ng-model="$ctrl.client.userName"]',
email: 'vn-client-create vn-textfield[ng-model="$ctrl.client.email"]',
salesPerson: 'vn-client-create vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',

View File

@ -42,7 +42,7 @@ describe('Client create path', () => {
await page.waitToClick(selectors.createClientView.addPostCode);
await page.waitToClick(selectors.createClientView.addProvince);
await page.write(selectors.createClientView.newProvinceName, 'Massachusetts');
await page.autocompleteSearch(selectors.createClientView.dialogCountry, 'España');
await page.autocompleteSearch(selectors.createClientView.newProvinceAutonomy, 'Autonomy one');
await page.waitToClick(selectors.createClientView.saveNewProvicenButton);
const message = await page.waitForSnackbar();

View File

@ -12,11 +12,11 @@
label="Name">
</vn-textfield>
<vn-autocomplete vn-one
ng-model="$ctrl.province.countryFk"
url="Countries"
show-field="country"
ng-model="$ctrl.province.autonomyFk"
url="Autonomies"
show-field="name"
value-field="id"
label="Country">
label="Autonomy">
</vn-autocomplete>
</vn-horizontal>
</tpl-body>

View File

@ -13,8 +13,8 @@ class Controller extends Component {
try {
if (!this.province.name)
throw new Error(`The province name can't be empty`);
if (!this.province.countryFk)
throw new Error(`The country can't be empty`);
if (!this.province.autonomyFk)
throw new Error(`The autonomy can't be empty`);
this.$http.patch(`provinces`, this.province).then(res => {
this.vnApp.showMessage(this.$t('The province has been created'));