Added menu to create a new supplier, not working
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Pau 2022-10-11 11:43:01 +02:00
parent 4d4e446ff6
commit 012cd68c89
9 changed files with 111 additions and 3 deletions

View File

@ -0,0 +1,28 @@
/* eslint-disable no-console */
// eslint-disable-next-line no-unused-vars
let UserError = require('vn-loopback/util/user-error');
module.exports = Self => {
Self.remoteMethod('new', {
description: 'returns the created item',
accessType: 'WRITE',
accepts: [{
arg: 'params',
type: 'object',
http: {source: 'body'}
}],
returns: {
type: 'number',
root: true
},
http: {
path: `/new`,
verb: 'POST'
}
});
Self.new = async(params, options) => {
console.log(params);
console.log(options);
};
};

View File

@ -10,6 +10,7 @@ module.exports = Self => {
require('../methods/supplier/freeAgencies')(Self); require('../methods/supplier/freeAgencies')(Self);
require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsPdf')(Self);
require('../methods/supplier/campaignMetricsEmail')(Self); require('../methods/supplier/campaignMetricsEmail')(Self);
require('../methods/supplier/new')(Self);
Self.validatesPresenceOf('name', { Self.validatesPresenceOf('name', {
message: 'The social name cannot be empty' message: 'The social name cannot be empty'

View File

@ -0,0 +1,36 @@
<vn-watcher
vn-id="watcher"
url="supplier/new"
data="$ctrl.supplier"
insert-mode="true"
form="form">
</vn-watcher>
<vn-crud-model
auto-load="true"
url="Origins"
data="originsData"
order="name"
vn-id="origin-model">
</vn-crud-model>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg">
<vn-horizontal>
<vn-textfield
label="Supplier name"
ng-model="$ctrl.supplier.name"
vn-focus>
</vn-textfield>
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit
disabled="!watcher.dataChanged()"
label="Create">
</vn-submit>
<vn-button
class="cancel"
label="Cancel"
ui-sref="supplier.index">
</vn-button>
</vn-button-bar>
</form>

View File

@ -0,0 +1,25 @@
/* eslint-disable no-console */
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
constructor($element, $) {
super($element, $);
console.log($);
}
onSubmit() {
this.$.watcher.submit().then(
console.log('abc'),
json => this.$state.go('item.card.basicData', {id: json.data.id})
);
}
}
Controller.$inject = ['$element', '$scope'];
ngModule.vnComponent('vnSupplierCreate', {
template: require('./index.html'),
controller: Controller
});

View File

@ -20,3 +20,4 @@ import './address/create';
import './address/edit'; import './address/edit';
import './agency-term/index'; import './agency-term/index';
import './agency-term/create'; import './agency-term/create';
import './create/index';

View File

@ -58,4 +58,9 @@
<vn-supplier-summary <vn-supplier-summary
supplier="$ctrl.supplierSelected"> supplier="$ctrl.supplierSelected">
</vn-supplier-summary> </vn-supplier-summary>
</vn-popup> </vn-popup>
<!--vn-float-button vn-acl="administrative" icon="add" ng-click="$ctrl.test()" fixed-bottom-right vn-tooltip="New supplier"></vn-float-button>
-->
<a vn-acl="administrative" ui-sref="supplier.create" vn-tooltip="New supplier" vn-bind="+" fixed-bottom-right>
<vn-float-button icon="add"></vn-float-button>
</a>

View File

@ -10,6 +10,11 @@ export default class Controller extends Section {
this.supplierSelected = supplier; this.supplierSelected = supplier;
this.$.dialogSummarySupplier.show(); this.$.dialogSummarySupplier.show();
} }
test() {
// eslint-disable-next-line no-console
console.log('Creating new supplier');
}
} }
ngModule.vnComponent('vnSupplierIndex', { ngModule.vnComponent('vnSupplierIndex', {

View File

@ -2,4 +2,5 @@ Payment deadline: Plazo de pago
Pay day: Dia de pago Pay day: Dia de pago
Account: Cuenta Account: Cuenta
Pay method: Metodo de pago Pay method: Metodo de pago
Tax number: Nif Tax number: Nif
New supplier: Nuevo proveedor

View File

@ -30,7 +30,13 @@
"abstract": true, "abstract": true,
"component": "vn-supplier", "component": "vn-supplier",
"description": "Suppliers" "description": "Suppliers"
}, },
{
"url": "/create",
"state": "supplier.create",
"component": "vn-supplier-create",
"description": "New supplier"
},
{ {
"url": "/index?q", "url": "/index?q",
"state": "supplier.index", "state": "supplier.index",