Todos heredan de MyModel
This commit is contained in:
parent
5f9160c172
commit
726bb73ca0
|
@ -13,9 +13,9 @@
|
|||
</vn-horizontal>
|
||||
</vn-card>
|
||||
<vn-card margin-medium-top>
|
||||
<vn-item-client ng-repeat="client in index.model" title="View client" client="client"></vn-item-client>
|
||||
<vn-item-client ng-repeat="client in index.model.instances" title="View client" client="client"></vn-item-client>
|
||||
</vn-card>
|
||||
<vn-paging index="index"></vn-paging>
|
||||
<vn-paging index="index" total="index.model.count"></vn-paging>
|
||||
</div>
|
||||
<a ui-sref="create" fixed-bottom-right>
|
||||
<vn-float-button icon="person_add"></vn-float-button>
|
||||
|
|
|
@ -13,9 +13,11 @@ export default class Paging {
|
|||
this.numItems = 0;
|
||||
$scope.$watch('$ctrl.index.model.length', () => this.onModelUpdated());
|
||||
}
|
||||
$onChanges() {
|
||||
$onChanges(changes) {
|
||||
if (!this.index) return;
|
||||
this.numPerPage = this.index.filter.size;
|
||||
if(changes.total)
|
||||
this.numItems = changes.total.currentValue;
|
||||
}
|
||||
onModelUpdated() {
|
||||
let index = this.index;
|
||||
|
@ -36,7 +38,8 @@ export const NAME = 'vnPaging';
|
|||
export const COMPONENT = {
|
||||
template: require('./index.html'),
|
||||
bindings: {
|
||||
index: '<'
|
||||
index: '<',
|
||||
total: '<'
|
||||
},
|
||||
controller: Paging
|
||||
};
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Address",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "AgencyService",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "ClientObservation",
|
||||
"description": "Notas de los clientes.",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "ContactChannel",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Country",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Employee",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -25,6 +25,12 @@ module.exports = function(self) {
|
|||
for(let method in disableMethods) {
|
||||
//this.disableRemoteMethod(method, disableMethods[method]);
|
||||
}
|
||||
|
||||
var find = self.find;
|
||||
self.find = function(filter,cb){
|
||||
cb(null,'This is a overridden method')
|
||||
}
|
||||
console.log(self.find);
|
||||
}
|
||||
|
||||
self.installMethod = function(methodName, filterCb) {
|
||||
|
@ -55,9 +61,30 @@ module.exports = function(self) {
|
|||
|
||||
this.filter = (params, cb) => {
|
||||
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) {
|
||||
if(!err) {
|
||||
cb(null, instances);
|
||||
data.instances = instances;
|
||||
check();
|
||||
}
|
||||
else{
|
||||
error();
|
||||
}
|
||||
})
|
||||
};
|
||||
|
@ -94,3 +121,4 @@ function removeEmpty(o) {
|
|||
function isEmpty(value) {
|
||||
return value === undefined || value === "";
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "PayMethod",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "Province",
|
||||
"base": "PersistedModel",
|
||||
"base": "MyModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
|
|
Loading…
Reference in New Issue