header.js

This commit is contained in:
nelo 2017-05-18 11:54:39 +02:00
parent 2aa7c9731d
commit b4d167bbb7
3 changed files with 30 additions and 31 deletions

View File

@ -13,9 +13,9 @@
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>
<vn-card margin-medium-top> <vn-card margin-medium-top>
<vn-item-client ng-repeat="client in index.model.instances" title="View client" client="client"></vn-item-client> <vn-item-client ng-repeat="client in index.model" title="View client" client="client"></vn-item-client>
</vn-card> </vn-card>
<vn-paging index="index" total="index.model.count"></vn-paging> <vn-paging index="index"></vn-paging>
</div> </div>
<a ui-sref="create" fixed-bottom-right> <a ui-sref="create" fixed-bottom-right>
<vn-float-button icon="person_add"></vn-float-button> <vn-float-button icon="person_add"></vn-float-button>

View File

@ -26,11 +26,13 @@ module.exports = function(self) {
//this.disableRemoteMethod(method, disableMethods[method]); //this.disableRemoteMethod(method, disableMethods[method]);
} }
var find = self.find; self.on('find', function() {
self.find = function(filter,cb){ self.printModelName();
cb(null,'This is a overridden method') });
}
console.log(self.find); self.list = function(filter, cb){
self.find(filter, cb);
}
} }
self.installMethod = function(methodName, filterCb) { self.installMethod = function(methodName, filterCb) {
@ -61,31 +63,9 @@ module.exports = function(self) {
this.filter = (params, cb) => { this.filter = (params, cb) => {
let filter = removeEmpty(filterCb(params)); let filter = removeEmpty(filterCb(params));
data = {};
function check () {
if (data.count && data.instances)
cb(null, data);
}
function error(){
cb(null, data);
}
this.count(filter, function (err, count) {
if(!err) {
data.count = count;
check();
}
else{
error();
}
})
this.find(filter, function(err, instances) { this.find(filter, function(err, instances) {
if(!err) { if(!err)
data.instances = instances; cb(null, instances);
check();
}
else{
error();
}
}) })
}; };
}; };

View File

@ -0,0 +1,19 @@
module.exports = function(app) {
/*function modifyResponse(ctx, model, next) {
var result = ctx.result;
var status = ctx.res.statusCode;
if(Array.isArray(result)){
/*app.models.Client.count(null, function (err, count) {
if(!err) {
ctx.res.set('Count-elements', count);
}
})
ctx.res.set('Count-elements', 3);
ctx.res.status(status).next();
}
}
app.models.Client.afterRemote('**', modifyResponse);*/
};