Zone.getLeaves() refactor
gitea/salix/master This commit looks good Details

This commit is contained in:
Juan Ferrer 2019-09-19 17:49:46 +02:00
parent 05fec10cf2
commit 40c555702d
3 changed files with 8 additions and 10 deletions

View File

@ -4,9 +4,10 @@ module.exports = Self => {
description: 'Returns the nodes for a zone', description: 'Returns the nodes for a zone',
accepts: [ accepts: [
{ {
arg: 'zoneFk', arg: 'id',
type: 'Number', type: 'Number',
required: true, http: {source: 'path'},
required: true
}, { }, {
arg: 'parentFk', arg: 'parentFk',
type: 'Number', type: 'Number',
@ -22,15 +23,15 @@ module.exports = Self => {
root: true root: true
}, },
http: { http: {
path: `/getLeaves`, path: `/:id/getLeaves`,
verb: 'GET' verb: 'GET'
} }
}); });
Self.getLeaves = async(zoneFk, parentFk = null, search) => { Self.getLeaves = async(id, parentFk = null, search) => {
let [res] = await Self.rawSql( let [res] = await Self.rawSql(
`CALL zone_getLeaves(?, ?, ?)`, `CALL zone_getLeaves(?, ?, ?)`,
[zoneFk, parentFk, search] [id, parentFk, search]
); );
let map = new Map(); let map = new Map();

View File

@ -1,8 +1,7 @@
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="/agency/api/Zones/getLeaves" url="/api/Zones/{{$ctrl.$stateParams.id}}/getLeaves"
filter="::$ctrl.filter" filter="::$ctrl.filter"
params="{zoneFk: $ctrl.$stateParams.id}"
auto-load="false"> auto-load="false">
</vn-crud-model> </vn-crud-model>
<div class="main-with-right-menu"> <div class="main-with-right-menu">

View File

@ -2,11 +2,9 @@ import ngModule from '../module';
class Controller { class Controller {
constructor($, $http, $stateParams) { constructor($, $http, $stateParams) {
this.$stateParams = $stateParams;
this.$ = $; this.$ = $;
this.$http = $http; this.$http = $http;
this.searchValue = ''; this.$stateParams = $stateParams;
this.filter = {};
} }
onSearch(params) { onSearch(params) {