mgCrud v2
This commit is contained in:
parent
034c3214fc
commit
0f360db06e
|
@ -1,3 +1,10 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/Addresses"
|
||||
id-field="id"
|
||||
data="addressData.address"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="addressData.onSubmit()" pad-medium>
|
||||
<vn-card >
|
||||
<vn-vertical pad-large>
|
||||
|
@ -37,10 +44,3 @@
|
|||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/Addresses"
|
||||
id-field="id"
|
||||
data="addressData.address"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
get="true"
|
||||
url="/client/api/Addresses"
|
||||
id-field="id"
|
||||
data="addressData.address"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="addressData.onSubmit()" pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
|
@ -38,11 +46,3 @@
|
|||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
get="true"
|
||||
url="/client/api/Addresses"
|
||||
id-field="id"
|
||||
data="addressData.address"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<mg-ajax path="/client/api/Clients/{{index.params.id}}/Addresses" options="vnIndex"></mg-ajax>
|
||||
<mg-ajax path="/client/api/Clients/{{index.params.id}}/addressesList" options="vnIndex"></mg-ajax>
|
||||
<vn-vertical pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
|
|
|
@ -1,5 +1,10 @@
|
|||
<mg-ajax path="/client/api/Clients/{{put.params.id}}" options="vnPut"></mg-ajax>
|
||||
<vn-watcher vn-id="watcher" data="$ctrl.client" form="form" save="put"></vn-watcher>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="$ctrl.client"
|
||||
form="form"
|
||||
save="put">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" pad-medium>
|
||||
<vn-card >
|
||||
<vn-vertical pad-large>
|
||||
|
|
|
@ -1,29 +1,28 @@
|
|||
<div margin-medium>
|
||||
<mg-ajax path="/client/api/Clients/{{put.params.id}}" options="vnPost"></mg-ajax>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" style="max-width: 70em; margin: 0 auto;">
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Crear Cliente</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Nombre" field="$ctrl.client.name" vn-focus></vn-textfield>
|
||||
<vn-textfield vn-one label="NIF/CIF" field="$ctrl.client.fi"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Razón social" field="$ctrl.client.socialName"></vn-textfield>
|
||||
<vn-one></vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Crear y continuar"></vn-submit>
|
||||
<vn-button label="Crear" ng-click="$ctrl.onCreate()"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
</div>
|
||||
<mg-ajax path="/client/api/Clients" options="vnPost"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/Clients"
|
||||
id-field="id"
|
||||
data="$ctrl.client"
|
||||
form="form">
|
||||
form="form"
|
||||
save="post">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" margin-medium>
|
||||
<div style="max-width: 70em; margin: 0 auto;">
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Crear Cliente</vn-title>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Nombre" field="$ctrl.client.name" vn-focus></vn-textfield>
|
||||
<vn-textfield vn-one label="NIF/CIF" field="$ctrl.client.fi"></vn-textfield>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-textfield vn-one label="Razón social" field="$ctrl.client.socialName"></vn-textfield>
|
||||
<vn-one></vn-one>
|
||||
</vn-horizontal>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-button-bar>
|
||||
<vn-submit label="Crear y continuar"></vn-submit>
|
||||
<vn-button label="Crear" ng-click="$ctrl.onCreate()"></vn-button>
|
||||
</vn-button-bar>
|
||||
</div>
|
||||
</form>
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<mg-ajax path="/client/api/Clients/{{put.params.id}}" options="vnPut"></mg-ajax>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="fiscal.client"
|
||||
form="form"
|
||||
save="put">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" pad-medium>
|
||||
<vn-card margin-small-bottom>
|
||||
<vn-vertical pad-large>
|
||||
|
@ -65,11 +72,3 @@
|
|||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/Clients"
|
||||
id-field="id"
|
||||
form="form"
|
||||
data="fiscal.client"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
|
|
|
@ -1,3 +1,10 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/ClientObservations"
|
||||
id-field="id"
|
||||
data="newNote.note"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="newNote.onSubmit()" pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
|
@ -8,11 +15,4 @@
|
|||
<vn-button-bar>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/ClientObservations"
|
||||
id-field="id"
|
||||
data="newNote.note"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
</form>
|
|
@ -1,3 +1,11 @@
|
|||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
url="/client/api/Accounts"
|
||||
id-field="id"
|
||||
data="$ctrl.client.account"
|
||||
to="$ctrl.account"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="watcher.submit()" pad-medium>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
|
@ -11,14 +19,6 @@
|
|||
<vn-button label="Cambiar contraseña" vn-dialog="change-pass"></vn-button>
|
||||
</vn-button-bar>
|
||||
</form>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
id-field="id"
|
||||
url="/client/api/Accounts"
|
||||
watch="$ctrl.client.account"
|
||||
to="$ctrl.account"
|
||||
form="form">
|
||||
</vn-watcher>
|
||||
<vn-dialog
|
||||
vn-id="change-pass"
|
||||
on-open="$ctrl.onPassOpen()"
|
||||
|
|
|
@ -27,6 +27,7 @@ module.factory('vnPut', put);
|
|||
post.$inject = ['mgCreate'];
|
||||
function post(mgCreate) {
|
||||
return angular.extend(mgCreate, {
|
||||
as: 'post',
|
||||
success: 'vnSuccessFactoryCreate'
|
||||
});
|
||||
}
|
||||
|
|
|
@ -4,21 +4,16 @@
|
|||
<vn-icon icon="language" translate-attr="{title: 'Change language'}" ng-click="mainMenu.onChangeLanguage()"></vn-icon>
|
||||
<vn-icon icon="exit_to_app" translate-attr="{title: 'Logout'}" ng-click="mainMenu.onLogoutClick()"></vn-icon>
|
||||
<vn-icon icon="account_circle" translate-attr="{title: 'Profile'}" style="font-size: 35px;"></vn-icon>
|
||||
<!--
|
||||
<vn-popover pad-medium for="apps">
|
||||
<a ui-sref="clients"><vn-icon icon=""></vn-icon></a>
|
||||
</vn-popover>
|
||||
-->
|
||||
<ul class="mdl-menu mdl-js-menu mdl-menu--bottom-right" pad-medium for="apps">
|
||||
<vn-horizontal>
|
||||
<vn-vertical>
|
||||
<a ui-sref="clients">
|
||||
<button vn-one class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored popover-button">
|
||||
<vn-icon vn-one icon="person" style="font-size:40px"></vn-icon>
|
||||
</button>
|
||||
</a>
|
||||
<vn-label class="popover-label" text="Clientes"></vn-label>
|
||||
</vn-vertical>
|
||||
</vn-horizontal>
|
||||
<vn-horizontal>
|
||||
<vn-vertical>
|
||||
<a ui-sref="clients">
|
||||
<button vn-one class="mdl-button mdl-js-button mdl-button--raised mdl-button--colored popover-button">
|
||||
<vn-icon vn-one icon="person" style="font-size:40px"></vn-icon>
|
||||
</button>
|
||||
</a>
|
||||
<vn-label class="popover-label" text="Clientes"></vn-label>
|
||||
</vn-vertical>
|
||||
</vn-horizontal>
|
||||
</ul>
|
||||
</div>
|
||||
|
|
10
db.json
10
db.json
|
@ -2,10 +2,10 @@
|
|||
"ids": {
|
||||
"User": 2,
|
||||
"AccessToken": 2,
|
||||
"Client": 22,
|
||||
"Client": 23,
|
||||
"PaymentMethod": 4,
|
||||
"SalesPerson": 11,
|
||||
"Address": 86,
|
||||
"Address": 87,
|
||||
"Country": 10,
|
||||
"Province": 44,
|
||||
"Agency": 4,
|
||||
|
@ -25,7 +25,8 @@
|
|||
"15": "{\"name\":\"Florsiteria Pepa\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\",\"email\":\"pepa@flores.es\",\"phone\":\"963242101\",\"city\":\"Alfarp\",\"postcode\":\"46985\"}",
|
||||
"16": "{\"name\":\"Floristeria Antonieta\",\"fi\":\"2345234523d\",\"socialName\":\"23452345assdfgsdfgt\",\"active\":true,\"dueDay\":5,\"id\":16,\"modify\":\"FiscalData\",\"email\":\"antonieta@gmail.com\",\"phone\":\"654654654\",\"mobile\":\"654456456\",\"fax\":\"456456456\",\"street\":\"asdfasdf\",\"salesPerson\":8,\"city\":\"Albalat de la Ribera\",\"postcode\":\"46532\"}",
|
||||
"19": "{\"name\":\"Planticas Eustaquio\",\"fi\":\"789456123B\",\"socialName\":\"Eustaquio Martinez\",\"active\":true,\"dueDay\":5,\"id\":19,\"email\":\"peustaquio@hotmail.es\",\"city\":\"Polinya\",\"postcode\":\"46231\",\"phone\":\"963215486\"}",
|
||||
"21": "{\"name\":\"Ramos Antonieta\",\"fi\":\"B89564289\",\"socialName\":\"Antonia SL\",\"active\":true,\"dueDay\":5,\"id\":21,\"email\":\"ramos@rantonieta.es\",\"salesPerson\":8,\"phone\":\"986574232\"}"
|
||||
"21": "{\"name\":\"Ramos Antonieta\",\"fi\":\"B89564289\",\"socialName\":\"Antonia SL\",\"active\":true,\"dueDay\":5,\"id\":21,\"email\":\"ramos@rantonieta.es\",\"salesPerson\":8,\"phone\":\"986574232\"}",
|
||||
"22": "{\"name\":\"Plantas Raimundo\",\"fi\":\"2536418B\",\"socialName\":\"Plantas Raimundo SL\",\"dueDay\":5,\"id\":22,\"email\":\"jose@plantasraimundo.com\",\"phone\":\"963254289\",\"mobile\":\"641967586\",\"salesPerson\":3,\"city\":\"Sueca\",\"postcode\":\"46985\"}"
|
||||
},
|
||||
"PaymentMethod": {
|
||||
"1": "{\"name\":\"Tarjeta\",\"id\":1}",
|
||||
|
@ -58,7 +59,8 @@
|
|||
"82": "{\"street\":\"Polígono\",\"consignee\":\"Verdnatura Levante SL\",\"city\":\"Picasent\",\"enabled\":true,\"client\":12,\"id\":82,\"province\":1,\"agency\":2,\"phone\":\"963242100\",\"mobile\":\"698357618\"}",
|
||||
"83": "{\"street\":\"San Nicolau de Bari, 6\",\"consignee\":\"Casa\",\"city\":\"Algemesi\",\"postcode\":\"46680\",\"enabled\":true,\"phone\":\"962480949\",\"client\":12,\"province\":1,\"agency\":1,\"id\":83,\"mobile\":\"658965745\"}",
|
||||
"84": "{\"street\":\"Poligono\",\"consignee\":\"Madrid\",\"city\":\"Madrid\",\"enabled\":true,\"client\":12,\"id\":84,\"postcode\":\"46001\",\"province\":2,\"agency\":2,\"phone\":\"912356489\",\"mobile\":\"654236589\"}",
|
||||
"85": "{\"street\":\"Avenida la Parra, 43\",\"consignee\":\"Ramos Antonienta\",\"city\":\"Llombai\",\"enabled\":true,\"client\":21,\"province\":1,\"id\":85,\"phone\":\"965874583\",\"mobile\":\"675418958\",\"postcode\":\"46985\",\"agency\":2,\"default\":true}"
|
||||
"85": "{\"street\":\"Avenida la Parra, 43\",\"consignee\":\"Ramos Antonienta\",\"city\":\"Llombai\",\"enabled\":true,\"client\":21,\"province\":1,\"id\":85,\"phone\":\"965874583\",\"mobile\":\"675418958\",\"postcode\":\"46985\",\"agency\":2,\"default\":true}",
|
||||
"86": "{\"street\":\"Poligono industrial\",\"consignee\":\"Verdnatura\",\"city\":\"Barcelona\",\"enabled\":true,\"client\":12,\"province\":7,\"agency\":2,\"id\":86}"
|
||||
},
|
||||
"Country": {
|
||||
"1": "{\"id\":1,\"name\":\"Spain\"}",
|
||||
|
|
|
@ -51,22 +51,21 @@ module.exports = function(Client) {
|
|||
arg: 'id',
|
||||
type: 'number',
|
||||
required: true,
|
||||
http: function(ctx) {
|
||||
var id = ctx && ctx.req && ctx.req.params.id
|
||||
return id;
|
||||
}
|
||||
description: 'Model id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
returns: {
|
||||
arg: 'active',
|
||||
type: 'boolean'
|
||||
},
|
||||
http: {
|
||||
path: '/:id/activate',
|
||||
verb: 'put'
|
||||
verb: 'put',
|
||||
path: '/:id/activate'
|
||||
}
|
||||
});
|
||||
|
||||
Client.activate = function(id, cb) {
|
||||
console.log(id);
|
||||
Client.findById(id, function(err, client) {
|
||||
if(!err) {
|
||||
Client.update({id: client.id}, {active: !client.active});
|
||||
|
@ -95,14 +94,53 @@ module.exports = function(Client) {
|
|||
};
|
||||
}
|
||||
|
||||
installMethod(Client, 'filter', filterAddresses);
|
||||
function filterAddresses(p){
|
||||
return {
|
||||
// Client addresses
|
||||
|
||||
Client.remoteMethod('addressesList', {
|
||||
description: 'List items using a filter',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
{
|
||||
arg: 'id',
|
||||
type: 'string',
|
||||
required: true,
|
||||
description: 'Model id',
|
||||
http: {source: 'path'}
|
||||
},
|
||||
{
|
||||
arg: 'filter',
|
||||
type: 'object',
|
||||
required: true,
|
||||
description: 'Filter defining where',
|
||||
http: function(ctx) {
|
||||
return ctx.req.query;
|
||||
}
|
||||
}
|
||||
],
|
||||
returns: {
|
||||
arg: 'data',
|
||||
type: ['Address'],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/:id/addressesList`,
|
||||
verb: 'get'
|
||||
}
|
||||
});
|
||||
|
||||
Client.addressesList = function(id, p, cb) {
|
||||
let filter = {
|
||||
where: {
|
||||
client: p.client,
|
||||
client: id,
|
||||
},
|
||||
skip: (p.page - 1) * p.size,
|
||||
limit: p.size
|
||||
};
|
||||
}
|
||||
|
||||
Client.app.models.Address.find(filter, function(err, instances) {
|
||||
if(!err) {
|
||||
cb(null, instances);
|
||||
}
|
||||
})
|
||||
};
|
||||
};
|
|
@ -1,8 +1,8 @@
|
|||
|
||||
module.exports = installMethod;
|
||||
|
||||
function installMethod(Model, methodName, filterCb) {
|
||||
Model.remoteMethod(methodName, {
|
||||
function installMethod(model, methodName, filterCb) {
|
||||
model.remoteMethod(methodName, {
|
||||
description: 'List items using a filter',
|
||||
accessType: 'READ',
|
||||
accepts: [
|
||||
|
@ -18,18 +18,18 @@ function installMethod(Model, methodName, filterCb) {
|
|||
],
|
||||
returns: {
|
||||
arg: 'data',
|
||||
type: [Model.modelName],
|
||||
type: [model.modelName],
|
||||
root: true
|
||||
},
|
||||
http: {
|
||||
path: `/${methodName}`,
|
||||
verb: 'get'
|
||||
verb: 'get',
|
||||
path: `/${methodName}`
|
||||
}
|
||||
});
|
||||
|
||||
Model.filter = function(params, cb) {
|
||||
model.filter = function(params, cb) {
|
||||
let filter = removeEmpty(filterCb(params));
|
||||
Model.find(filter, function(err, instances) {
|
||||
model.find(filter, function(err, instances) {
|
||||
if(!err) {
|
||||
cb(null, instances);
|
||||
}
|
||||
|
|
|
@ -61,12 +61,12 @@ var config = {
|
|||
};
|
||||
|
||||
if (!devMode) {
|
||||
config.plugins.push (
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
minimize: true,
|
||||
compress: { warnings: false }
|
||||
})
|
||||
);
|
||||
config.plugins.push (
|
||||
new webpack.optimize.UglifyJsPlugin({
|
||||
minimize: true,
|
||||
compress: { warnings: false }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
||||
module.exports = config;
|
||||
|
|
Loading…
Reference in New Issue