diff --git a/modules/supplier/back/methods/supplier/new.js b/modules/supplier/back/methods/supplier/new.js new file mode 100644 index 000000000..9fb807532 --- /dev/null +++ b/modules/supplier/back/methods/supplier/new.js @@ -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); + }; +}; diff --git a/modules/supplier/back/models/supplier.js b/modules/supplier/back/models/supplier.js index c9af7b297..a2831845a 100644 --- a/modules/supplier/back/models/supplier.js +++ b/modules/supplier/back/models/supplier.js @@ -10,6 +10,7 @@ module.exports = Self => { require('../methods/supplier/freeAgencies')(Self); require('../methods/supplier/campaignMetricsPdf')(Self); require('../methods/supplier/campaignMetricsEmail')(Self); + require('../methods/supplier/new')(Self); Self.validatesPresenceOf('name', { message: 'The social name cannot be empty' diff --git a/modules/supplier/front/create/index.html b/modules/supplier/front/create/index.html new file mode 100644 index 000000000..71fe3b488 --- /dev/null +++ b/modules/supplier/front/create/index.html @@ -0,0 +1,36 @@ + + + + +
+ + + + + + + + + + + + +
diff --git a/modules/supplier/front/create/index.js b/modules/supplier/front/create/index.js new file mode 100644 index 000000000..8708aacd6 --- /dev/null +++ b/modules/supplier/front/create/index.js @@ -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 +}); diff --git a/modules/supplier/front/index.js b/modules/supplier/front/index.js index ba2768854..9216d0781 100644 --- a/modules/supplier/front/index.js +++ b/modules/supplier/front/index.js @@ -20,3 +20,4 @@ import './address/create'; import './address/edit'; import './agency-term/index'; import './agency-term/create'; +import './create/index'; diff --git a/modules/supplier/front/index/index.html b/modules/supplier/front/index/index.html index 87e822eea..5d29ba0eb 100644 --- a/modules/supplier/front/index/index.html +++ b/modules/supplier/front/index/index.html @@ -58,4 +58,9 @@ - \ No newline at end of file + + + + + \ No newline at end of file diff --git a/modules/supplier/front/index/index.js b/modules/supplier/front/index/index.js index 77b2e8347..b9b43321d 100644 --- a/modules/supplier/front/index/index.js +++ b/modules/supplier/front/index/index.js @@ -10,6 +10,11 @@ export default class Controller extends Section { this.supplierSelected = supplier; this.$.dialogSummarySupplier.show(); } + + test() { + // eslint-disable-next-line no-console + console.log('Creating new supplier'); + } } ngModule.vnComponent('vnSupplierIndex', { diff --git a/modules/supplier/front/index/locale/es.yml b/modules/supplier/front/index/locale/es.yml index ad8a4f0bb..ce06f462c 100644 --- a/modules/supplier/front/index/locale/es.yml +++ b/modules/supplier/front/index/locale/es.yml @@ -2,4 +2,5 @@ Payment deadline: Plazo de pago Pay day: Dia de pago Account: Cuenta Pay method: Metodo de pago -Tax number: Nif \ No newline at end of file +Tax number: Nif +New supplier: Nuevo proveedor \ No newline at end of file diff --git a/modules/supplier/front/routes.json b/modules/supplier/front/routes.json index 61420b40d..03efea0f3 100644 --- a/modules/supplier/front/routes.json +++ b/modules/supplier/front/routes.json @@ -30,7 +30,13 @@ "abstract": true, "component": "vn-supplier", "description": "Suppliers" - }, + }, + { + "url": "/create", + "state": "supplier.create", + "component": "vn-supplier-create", + "description": "New supplier" + }, { "url": "/index?q", "state": "supplier.index",