diff --git a/@salix/crud/src/client/addresses-data-create/index.html b/@salix/crud/src/client/addresses-data-create/index.html new file mode 100644 index 0000000000..4ec22b2ab4 --- /dev/null +++ b/@salix/crud/src/client/addresses-data-create/index.html @@ -0,0 +1,33 @@ +
\ No newline at end of file diff --git a/@salix/crud/src/client/addresses-data-create/index.js b/@salix/crud/src/client/addresses-data-create/index.js new file mode 100644 index 0000000000..8722ab58f2 --- /dev/null +++ b/@salix/crud/src/client/addresses-data-create/index.js @@ -0,0 +1,32 @@ +import template from './index.html'; +import {module} from '../../module'; + +export const NAME = 'vnClientAddressesDataCreate'; +export const COMPONENT = { + template: template, + controllerAs: 'addressData', + controller: function($http) + { + this.address = {}; + + $http.get('/client/api/Agencies').then( + json => this.agencies = json.data, + json => console.error(json.data.error.message) + ); + + $http.get('/client/api/Provinces').then( + json => this.provinces = json.data, + json => console.error(json.data.error.message) + ); + + this.submit = function(){ + $http.post('/client/api/Addresses', this.address).then( + json => console.log(json.statusText), + json => console.error(json.data.error.message) + ); + } + } +} + +COMPONENT.controller.$inject = ['$http']; +module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/addresses-data/index.html b/@salix/crud/src/client/addresses-data-edit/index.html similarity index 100% rename from @salix/crud/src/client/addresses-data/index.html rename to @salix/crud/src/client/addresses-data-edit/index.html diff --git a/@salix/crud/src/client/addresses-data/index.js b/@salix/crud/src/client/addresses-data-edit/index.js similarity index 74% rename from @salix/crud/src/client/addresses-data/index.js rename to @salix/crud/src/client/addresses-data-edit/index.js index 1980a72ad2..7883fd0b04 100644 --- a/@salix/crud/src/client/addresses-data/index.js +++ b/@salix/crud/src/client/addresses-data-edit/index.js @@ -1,13 +1,13 @@ import template from './index.html'; import {module} from '../../module'; -export const NAME = 'vnClientAddressesData'; +export const NAME = 'vnClientAddressesDataEdit'; export const COMPONENT = { template: template, controllerAs: 'addressData', controller: function($http,$stateParams) { - this.address = {} + this.address = {}; $http.get(`/client/api/Addresses/${$stateParams.addressId}`).then( json => this.address = json.data, json => console.error(json.data.error.message) @@ -24,23 +24,13 @@ export const COMPONENT = { ); this.submit = function(){ - if($stateParams.addressId){ $http.put('/client/api/Addresses', this.address).then( json => console.log(json.statusText), json => console.error(json.data.error.message) ); } - else{ - $http.post('/client/api/Addresses', this.address).then( - json => console.log(json.statusText), - json => console.error(json.data.error.message) - ); - } - }; - } - -}; +} COMPONENT.controller.$inject = ['$http' , '$stateParams']; module.component(NAME, COMPONENT); diff --git a/@salix/crud/src/client/addresses/index.html b/@salix/crud/src/client/addresses/index.html index 6c172b366e..aa605c131c 100644 --- a/@salix/crud/src/client/addresses/index.html +++ b/@salix/crud/src/client/addresses/index.html @@ -3,7 +3,7 @@