Added form dialog
gitea/salix/2113-item_data_add_instrastat There was a failure building this commit Details

This commit is contained in:
Joan Sanchez 2020-02-17 07:22:55 +01:00
parent 84bf95db13
commit d9ed7cda38
4 changed files with 115 additions and 68 deletions

View File

@ -55,6 +55,9 @@ module.exports = Self => {
}
}]
}
},
{
relation: 'taxClass'
}
]
};

View File

@ -1,13 +1,13 @@
{
"name": "Item",
"base": "Loggable",
"log": {
"model":"ItemLog",
"base": "Loggable",
"log": {
"model": "ItemLog",
"showField": "id"
},
},
"options": {
"mysql": {
"table": "item"
"table": "item"
}
},
"properties": {
@ -125,55 +125,55 @@
}
},
"relations": {
"itemType": {
"type": "belongsTo",
"model": "ItemType",
"foreignKey": "typeFk"
},
"ink": {
"type": "belongsTo",
"model": "Ink",
"foreignKey": "inkFk"
},
"origin": {
"type": "belongsTo",
"model": "Origin",
"foreignKey": "originFk"
},
"producer": {
"type": "belongsTo",
"model": "Producer",
"foreignKey": "producerFk"
},
"intrastat": {
"type": "belongsTo",
"model": "Intrastat",
"foreignKey": "intrastatFk"
},
"expense": {
"type": "belongsTo",
"model": "Expense",
"foreignKey": "expenseFk"
},
"tags": {
"type": "hasMany",
"model": "ItemTag",
"foreignKey": "itemFk"
},
"itemBarcode": {
"type": "hasMany",
"model": "ItemBarcode",
"foreignKey": "itemFk"
},
"taxes": {
"type": "hasMany",
"model": "ItemTaxCountry",
"foreignKey": "itemFk"
},
"itemNiche": {
"type": "hasMany",
"model": "ItemNiche",
"foreignKey": "itemFk"
}
"itemType": {
"type": "belongsTo",
"model": "ItemType",
"foreignKey": "typeFk"
},
"ink": {
"type": "belongsTo",
"model": "Ink",
"foreignKey": "inkFk"
},
"origin": {
"type": "belongsTo",
"model": "Origin",
"foreignKey": "originFk"
},
"producer": {
"type": "belongsTo",
"model": "Producer",
"foreignKey": "producerFk"
},
"intrastat": {
"type": "belongsTo",
"model": "Intrastat",
"foreignKey": "intrastatFk"
},
"expense": {
"type": "belongsTo",
"model": "Expense",
"foreignKey": "expenseFk"
},
"tags": {
"type": "hasMany",
"model": "ItemTag",
"foreignKey": "itemFk"
},
"itemBarcode": {
"type": "hasMany",
"model": "ItemBarcode",
"foreignKey": "itemFk"
},
"taxes": {
"type": "hasMany",
"model": "ItemTaxCountry",
"foreignKey": "itemFk"
},
"itemNiche": {
"type": "hasMany",
"model": "ItemNiche",
"foreignKey": "itemFk"
}
}
}
}

View File

@ -55,6 +55,13 @@
<div style="width: 6em; text-align: right; padding-right: 1em;">{{::id}}</div>
<div>{{::description}}</div>
</tpl-item>
<append>
<vn-icon-button
icon="add_circle"
vn-tooltip="New intrastat"
ng-click="$ctrl.showIntrastat($event)">
</vn-icon-button>
</append>
</vn-autocomplete>
<vn-autocomplete vn-one
url="Expenses"
@ -69,7 +76,7 @@
value-field="id"
ng-model="$ctrl.item.originFk"
initial-data="$ctrl.item.origin">
</vn-autocomplete>
</vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-textfield
@ -123,7 +130,7 @@
</vn-check>
<vn-textarea
vn-one
label="description"
label="Description"
ng-model="$ctrl.item.description"
rule>
</vn-textarea>
@ -134,3 +141,38 @@
<vn-button label="Undo changes" ng-if="$ctrl.$scope.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>
<!-- Create custom agent dialog -->
<vn-dialog class="edit"
vn-id="intrastat"
on-accept="$ctrl.onIntrastatAccept()">
<tpl-body>
<h5 class="vn-py-sm" translate>New intrastat</h5>
<vn-horizontal>
<vn-textfield vn-one vn-focus
label="Identifier"
ng-model="$ctrl.newIntrastat.id"
required="true">
</vn-textfield>
<vn-textfield vn-one
label="Description"
ng-model="$ctrl.newIntrastat.description"
required="true">
</vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one
url="TaxClasses"
label="Tax class"
show-field="description"
value-field="id"
ng-model="$ctrl.newIntrastat.taxClassFk"
initial-data="$ctrl.item.taxClass">
</vn-autocomplete>
</vn-horizontal>
</tpl-body>
<tpl-buttons>
<input type="button" response="cancel" translate-attr="{value: 'Cancel'}"/>
<button response="accept" translate>Create</button>
</tpl-buttons>
</vn-dialog>

View File

@ -1,20 +1,22 @@
import ngModule from '../module';
import Component from 'core/lib/component';
class Controller extends Component {
showIntrastat(event) {
if (event.defaultPrevented) return;
event.preventDefault();
class Controller {
constructor($scope, $timeout) {
this.$scope = $scope;
this.$timeout = $timeout;
this.newIntrastat = {
taxClassFk: this.item.taxClassFk
};
this.$.intrastat.show();
}
$onChanges(data) {
this.$timeout(() => {
this.$scope.watcher.data = data.item.currentValue;
});
onCustomAgentAccept() {
return this.$http.post(`CustomsAgents`, this.newCustomsAgent)
.then(res => this.address.customsAgentFk = res.data.id);
}
}
Controller.$inject = ['$scope', '$timeout'];
ngModule.component('vnItemBasicData', {
template: require('./index.html'),
bindings: {