supplier contact
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Bernat Exposito 2020-10-30 11:40:12 +01:00
parent 39de960b9d
commit 18ebbe80d7
7 changed files with 185 additions and 4 deletions

View File

@ -7,5 +7,8 @@
}, },
"SupplierLog": { "SupplierLog": {
"dataSource": "vn" "dataSource": "vn"
},
"SupplierContact": {
"dataSource": "vn"
} }
} }

View File

@ -0,0 +1,49 @@
{
"name": "SupplierContact",
"base": "VnModel",
"options": {
"mysql": {
"table": "supplierContact"
}
},
"properties": {
"id": {
"type": "Number",
"id": true,
"description": "Identifier"
},
"supplierFk": {
"type": "String"
},
"phone": {
"type": "String"
},
"mobile": {
"type": "String"
},
"email": {
"type": "String"
},
"observation": {
"type": "String"
},
"name": {
"type": "String"
}
},
"relations": {
"supplier": {
"type": "belongsTo",
"model": "Supplier",
"foreignKey": "supplierFk"
}
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
}
]
}

View File

@ -0,0 +1,77 @@
<vn-crud-model
vn-id="model"
url="SupplierContacts"
link="{supplierFk: $ctrl.$params.id}"
data="contacts"
auto-load="true">
</vn-crud-model>
<vn-watcher
vn-id="watcher"
data="contacts"
form="form">
</vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<div ng-repeat="contact in contacts" class="contact">
<vn-vertical>
<vn-horizontal>
<vn-textfield
vn-one
label="Name"
ng-model="contact.name"
rule="SupplierContact">
</vn-textfield>
<vn-textfield
vn-one
label="Phone"
ng-model="contact.phone"
rule="SupplierContact"
vn-focus>
</vn-textfield>
<vn-textfield
vn-one
label="Mobile"
ng-model="contact.mobile"
rule="SupplierContact"
vn-focus>
</vn-textfield>
<vn-textfield
vn-one
label="Email"
ng-model="contact.email"
rule="SupplierContact"
vn-focus>
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Notes"
ng-model="contact.observation"
rule="SupplierContact"
vn-focus>
</vn-textfield>
<vn-none>
<vn-icon-button
vn-tooltip="Remove contact"
icon="delete"
tabindex="-1"
ng-click="model.remove($index)">
</vn-icon-button>
</vn-none>
</vn-horizontal>
</vn-vertical>
</div>
<vn-one>
<vn-icon-button
vn-bind="+"
vn-tooltip="Add contact"
icon="add_circle"
ng-click="$ctrl.add()">
</vn-icon-button>
</vn-one>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
</vn-button-bar>
</form>

View File

@ -0,0 +1,27 @@
import ngModule from '../module';
import './style.scss';
import Section from 'salix/components/section';
class Controller extends Section {
add() {
this.$.model.insert({
supplierFk: this.supplier.id
});
}
onSubmit() {
this.$.watcher.check();
this.$.model.save().then(() => {
this.$.watcher.notifySaved();
this.$.watcher.updateOriginalData();
});
}
}
ngModule.vnComponent('vnSupplierContact', {
template: require('./index.html'),
controller: Controller,
bindings: {
supplier: '<'
}
});

View File

@ -0,0 +1,10 @@
@import "variables";
.contact {
max-width: $width-lg;
margin-bottom: 10px;
padding-right: 10px;
padding-left: 10px;
border: 1px solid $color-marginal;
}

View File

@ -7,3 +7,4 @@ import './index/';
import './search-panel'; import './search-panel';
import './log'; import './log';
import './summary'; import './summary';
import './contact';

View File

@ -9,6 +9,7 @@
{"state": "supplier.index", "icon": "icon-supplier"} {"state": "supplier.index", "icon": "icon-supplier"}
], ],
"card": [ "card": [
{"state": "supplier.card.contact", "icon": "contact_phone"},
{"state": "supplier.card.log", "icon": "history"} {"state": "supplier.card.log", "icon": "history"}
] ]
}, },
@ -19,17 +20,20 @@
"abstract": true, "abstract": true,
"component": "vn-supplier", "component": "vn-supplier",
"description": "Suppliers" "description": "Suppliers"
}, { },
{
"url": "/index?q", "url": "/index?q",
"state": "supplier.index", "state": "supplier.index",
"component": "vn-supplier-index", "component": "vn-supplier-index",
"description": "Suppliers" "description": "Suppliers"
}, { },
{
"url": "/:id", "url": "/:id",
"state": "supplier.card", "state": "supplier.card",
"abstract": true, "abstract": true,
"component": "vn-supplier-card" "component": "vn-supplier-card"
}, { },
{
"url": "/summary", "url": "/summary",
"state": "supplier.card.summary", "state": "supplier.card.summary",
"component": "vn-supplier-summary", "component": "vn-supplier-summary",
@ -37,11 +41,21 @@
"params": { "params": {
"supplier": "$ctrl.supplier" "supplier": "$ctrl.supplier"
} }
}, { },
{
"url" : "/log", "url" : "/log",
"state": "supplier.card.log", "state": "supplier.card.log",
"component": "vn-supplier-log", "component": "vn-supplier-log",
"description": "Log" "description": "Log"
},
{
"url": "/contact",
"state": "supplier.card.contact",
"component": "vn-supplier-contact",
"description": "Contacts",
"params": {
"supplier": "$ctrl.supplier"
}
} }
] ]
} }