Merge
This commit is contained in:
commit
3a5e718066
|
@ -7,13 +7,23 @@ export const COMPONENT = {
|
|||
};
|
||||
module.component(NAME, COMPONENT);
|
||||
|
||||
vnAppInterceptor.$inject = ['$q', '$rootScope', '$document'];
|
||||
function vnAppInterceptor($q, $rootScope, $document) {
|
||||
$rootScope.loading = false;
|
||||
function showMessage(message) {
|
||||
let snackbar = $document.find('vn-snackbar').controller('vnSnackbar');
|
||||
snackbar.show({message: message});
|
||||
vnAppLogger.$inject = ['$document'];
|
||||
function vnAppLogger($document) {
|
||||
return {
|
||||
showMessage: function (message) {
|
||||
let snackbar = $document.find('vn-snackbar').controller('vnSnackbar');
|
||||
snackbar.show({message: message});
|
||||
},
|
||||
showError: function(message) {
|
||||
this.showMessage(`Error: ${message}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
module.provider('vnAppLogger', function() {this.$get = vnAppLogger;});
|
||||
|
||||
vnAppInterceptor.$inject = ['$q', '$rootScope', 'vnAppLogger'];
|
||||
function vnAppInterceptor($q, $rootScope, logger) {
|
||||
$rootScope.loading = false;
|
||||
return {
|
||||
request: function(config) {
|
||||
$rootScope.loading = true;
|
||||
|
@ -26,7 +36,7 @@ function vnAppInterceptor($q, $rootScope, $document) {
|
|||
switch (response.config.method) {
|
||||
case 'PUT':
|
||||
case 'POST':
|
||||
showMessage('Data saved!');
|
||||
logger.showMessage('Data saved!');
|
||||
}
|
||||
$rootScope.loading = false;
|
||||
return response;
|
||||
|
@ -34,7 +44,7 @@ function vnAppInterceptor($q, $rootScope, $document) {
|
|||
responseError: function(rejection) {
|
||||
$rootScope.loading = false;
|
||||
let message = rejection.data.error.message;
|
||||
showMessage(`Error: ${message}`);
|
||||
logger.showError(message);
|
||||
return $q.reject(rejection);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<div style="position: fixed; top: 0; right: 0; padding: .8em 1.5em; z-index: 10;">
|
||||
<vn-icon icon="exit_to_app" title="Logout" ng-click="mainMenu.onLogoutClick()"></vn-icon>
|
||||
<vn-icon icon="apps" id="apps" title="Applications"></vn-icon>
|
||||
<vn-icon icon="notifications" title="Notifications"></vn-icon>
|
||||
<vn-icon icon="exit_to_app" title="Logout" ng-click="mainMenu.onLogoutClick()"></vn-icon>
|
||||
<vn-icon icon="account_circle" title="Profile" style="font-size: 35px;"></vn-icon>
|
||||
<!--
|
||||
<vn-popover pad-medium for="apps">
|
||||
|
|
|
@ -22,6 +22,8 @@ export {NAME as CHECK_BT, factory as checkBt} from './check/check.bt';
|
|||
export {NAME as RADIO, directive as RadioDirective} from './radio/radio';
|
||||
export {NAME as RADIO_MDL, factory as radionMdl} from './radio/radio.mdl';
|
||||
export {NAME as RADIO_BT, factory as radioBt} from './radio/radio.bt';
|
||||
export {NAME as TEXTAREA, directive as TextareaDirective} from './textarea/textarea';
|
||||
export {NAME as TEXTAREA_MDL, factory as textareaMdl} from './textarea/textarea.mdl';
|
||||
export {NAME as TEXTFIELD, directive as TextfieldDirective} from './textfield/textfield';
|
||||
export {NAME as TEXTFIELD_MDL, factory as textfieldMdl} from './textfield/textfield.mdl';
|
||||
export {NAME as TEXTFIELD_BT, factory as textfieldBt} from './textfield/textfield.bt';
|
||||
|
|
|
@ -2,15 +2,13 @@ import {module} from '../module';
|
|||
import * as resolveFactory from '../resolveDefaultComponents';
|
||||
require('./style.css');
|
||||
|
||||
directive.$inject = ['$compile', '$document', 'vnDialog'];
|
||||
export function directive($compile, $document, dialog) {
|
||||
directive.$inject = ['vnDialog'];
|
||||
export function directive(dialog) {
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function($scope, $element, $attrs, $ctrl) {
|
||||
$element.on('click', function(event) {
|
||||
let child = $document[0].createElement($attrs.vnDialog);
|
||||
$compile(child)($scope);
|
||||
dialog.show(child);
|
||||
dialog.showComponent($attrs.vnDialog, $scope);
|
||||
event.preventDefault();
|
||||
});
|
||||
}
|
||||
|
@ -18,8 +16,8 @@ export function directive($compile, $document, dialog) {
|
|||
}
|
||||
module.directive('vnDialog', directive);
|
||||
|
||||
provider.$inject = ['$document'];
|
||||
function provider($document) {
|
||||
provider.$inject = ['$document', '$compile'];
|
||||
function provider($document, $compile) {
|
||||
let lastEvent;
|
||||
let popup;
|
||||
let background;
|
||||
|
@ -36,6 +34,11 @@ function provider($document) {
|
|||
background = null;
|
||||
popup = null;
|
||||
},
|
||||
showComponent: function(componentName, $scope) {
|
||||
let child = $document[0].createElement(componentName);
|
||||
$compile(child)($scope);
|
||||
this.show(child);
|
||||
},
|
||||
show: function(child) {
|
||||
background = $document[0].createElement('div');
|
||||
background.className = 'vn-background';
|
||||
|
|
|
@ -8,8 +8,8 @@ export function factory() {
|
|||
default: {
|
||||
enabled: 'enabled',
|
||||
icon: '',
|
||||
label: '',
|
||||
label: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
module.factory(NAME, factory);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<div class="mdl-js-snackbar mdl-snackbar *[className]*">
|
||||
<div class="mdl-js-snackbar mdl-snackbar *[className]*" style="z-index: 200;">
|
||||
<div class="mdl-snackbar__text"></div>
|
||||
<button class="mdl-snackbar__action" type="button"></button>
|
||||
</div>
|
||||
|
|
|
@ -1,19 +1,27 @@
|
|||
import {module as _module} from '../module';
|
||||
import * as resolveFactory from '../resolveDefaultComponents';
|
||||
import * as util from '../util';
|
||||
|
||||
const _NAME = 'textarea';
|
||||
export const NAME = util.getName(_NAME);
|
||||
|
||||
directive.$inject = [resolveFactory.NAME];
|
||||
export function directive(resolve) {
|
||||
return {
|
||||
require: 'E',
|
||||
template: function(_, attr) {
|
||||
return resolve.getTemplate(_NAME, attr);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_module.directive(NAME, directive);
|
||||
|
||||
import {module as _module} from '../module';
|
||||
import * as resolveFactory from '../resolveDefaultComponents';
|
||||
import * as util from '../util';
|
||||
|
||||
const _NAME = 'textarea';
|
||||
export const NAME = util.getName(_NAME);
|
||||
|
||||
directive.$inject = [resolveFactory.NAME];
|
||||
export function directive(resolve) {
|
||||
return {
|
||||
restrict: 'E',
|
||||
template: function(_, attr) {
|
||||
return resolve.getTemplate(_NAME, attr);
|
||||
},
|
||||
link: function(scope, element, attrs) {
|
||||
scope.$watch(attrs.model, () => {
|
||||
let mdlField = element[0].firstChild.MaterialTextfield;
|
||||
if (mdlField)
|
||||
mdlField.updateClasses_();
|
||||
});
|
||||
componentHandler.upgradeElement(element[0].firstChild);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_module.directive(NAME, directive);
|
||||
|
||||
|
|
|
@ -1,2 +1,4 @@
|
|||
<!-- por definir -->
|
||||
|
||||
<div class="mdl-textfield mdl-js-textfield">
|
||||
<textarea class="mdl-textfield__input" type="text" rows= "*[rows]*" ng-model="*[model]*" rule="*[rule]*" *[enabled]* *[focus]*></textarea>
|
||||
<label class="mdl-textfield__label" translate>*[label]*</label>
|
||||
</div>
|
|
@ -4,7 +4,9 @@ import * as constant from '../constants';
|
|||
import template from './textarea.mdl.html';
|
||||
|
||||
const _NAME = 'textarea';
|
||||
const DEFAULT_CLASS = '';
|
||||
const DEFAULT_LABEL = 'textarea';
|
||||
const DEFAULT_ROWS = 3;
|
||||
|
||||
|
||||
export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK);
|
||||
|
||||
|
@ -12,9 +14,10 @@ export function factory() {
|
|||
return {
|
||||
template: template,
|
||||
default: {
|
||||
className: DEFAULT_CLASS,
|
||||
label: DEFAULT_LABEL,
|
||||
rows: DEFAULT_ROWS
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
_module.factory(NAME, factory);
|
||||
|
|
|
@ -5,8 +5,7 @@ export const NAME = 'vnClientAddressesDataEdit';
|
|||
export const COMPONENT = {
|
||||
template: template,
|
||||
controllerAs: 'addressData',
|
||||
controller: function($http,$stateParams)
|
||||
{
|
||||
controller: function($http, $stateParams) {
|
||||
this.address = {};
|
||||
$http.get(`/client/api/Addresses/${$stateParams.addressId}`).then(
|
||||
json => this.address = json.data
|
||||
|
@ -17,12 +16,12 @@ export const COMPONENT = {
|
|||
$http.get('/client/api/Provinces').then(
|
||||
json => this.provinces = json.data
|
||||
);
|
||||
|
||||
this.submit = function(){
|
||||
$http.put('/client/api/Addresses', this.address);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
COMPONENT.controller.$inject = ['$http' , '$stateParams'];
|
||||
this.submit = function() {
|
||||
$http.put('/client/api/Addresses', this.address);
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
COMPONENT.controller.$inject = ['$http', '$stateParams'];
|
||||
module.component(NAME, COMPONENT);
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<form name="form" ng-submit="form.$valid && $ctrl.submit()" pad-large>
|
||||
<vn-vertical>
|
||||
<vn-textfield label="New password" field="$ctrl.newPassword" focus></vn-textfield>
|
||||
<vn-textfield label="Repeat password" field="$ctrl.repeatPassword"></vn-textfield>
|
||||
<vn-textfield label="New password" model="$ctrl.newPassword" focus></vn-textfield>
|
||||
<vn-textfield label="Repeat password" model="$ctrl.repeatPassword"></vn-textfield>
|
||||
</vn-vertical>
|
||||
<vn-horizontal margin-large-top>
|
||||
<vn-submit label="Change password"></vn-submit>
|
||||
</vn-horizontal>
|
||||
</form>
|
||||
</form>
|
|
@ -1,12 +1,30 @@
|
|||
export default {
|
||||
import {module} from '../../module';
|
||||
|
||||
const component = {
|
||||
template: require('./index.html'),
|
||||
bindings: {
|
||||
client: '<'
|
||||
client: '<',
|
||||
response: '&'
|
||||
},
|
||||
controller: controller
|
||||
};
|
||||
module.component('vnClientChangePassword', component);
|
||||
export default component;
|
||||
|
||||
controller.$inject = ['$element'];
|
||||
function controller($element) {
|
||||
this.submit = function () {};
|
||||
controller.$inject = ['$http', 'vnAppLogger'];
|
||||
function controller($http, logger) {
|
||||
this.response = function() {};
|
||||
this.submit = () => {
|
||||
try {
|
||||
if(!this.newPassword)
|
||||
throw new Error(`Passwords can't be empty`);
|
||||
if(this.newPassword != this.repeatPassword)
|
||||
throw new Error(`Passwords don't match`);
|
||||
|
||||
this.response();
|
||||
}
|
||||
catch(e) {
|
||||
logger.showError(e.message);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -27,7 +27,4 @@ export {NAME as CLIENT_ADDRESSES_DATA_EDIT_INDEX,
|
|||
export {NAME as CLIENT_CONFIRM_INDEX,
|
||||
COMPONENT as CLIENT_CONFIRM_INDEX_COMPONENT} from './confirm/index';
|
||||
|
||||
import {module} from '../module';
|
||||
|
||||
import {default as changePassword} from './change-password/index';
|
||||
module.component('vnClientChangePassword', changePassword);
|
|
@ -2,13 +2,17 @@
|
|||
<vn-card>
|
||||
<vn-vertical pad-large>
|
||||
<vn-title>Notas</vn-title>
|
||||
<vn-textfield label="Notas" field="notes.client.notes" focus padd-medium-top></vn-textfield>
|
||||
<vn-textarea label="Notas" model="notes.newNote" focus padd-medium-top></vn-textarea>
|
||||
</vn-vertical>
|
||||
</vn-card>
|
||||
<vn-submit margin-small-top label="Guardar"></vn-submit>
|
||||
<vn-card>
|
||||
<vn-vertical pad-large margin-small-top>
|
||||
<vn-textfield label="Notas" field="notes.client.notes" padd-medium-top></vn-textfield>
|
||||
</vn-vertical>
|
||||
<div margin-small-top>
|
||||
<vn-submit label="Guardar"></vn-submit>
|
||||
</div>
|
||||
<vn-card margin-small-top>
|
||||
<div ng-repeat="n in notes.notes">
|
||||
<p><b>{{n.date}}</b></p>
|
||||
<p>>{{n.text}}</p>
|
||||
</div>
|
||||
<div style="margin:0" pad-large>{{notes.client.notes}}</div>
|
||||
</vn-card>
|
||||
</form>
|
|
@ -9,10 +9,18 @@ export const COMPONENT = {
|
|||
client: '<'
|
||||
},
|
||||
controller: function($http) {
|
||||
this.notes = [];
|
||||
this.submit = function() {
|
||||
$http.put('/client/api/Clients', this.client);
|
||||
this.notes.push({
|
||||
text: this.newNote,
|
||||
salesPerson: 'user'
|
||||
});
|
||||
|
||||
$http.put('/client/api/ClientObservation', this.client).then(() => {
|
||||
this.newNote = "";
|
||||
});
|
||||
};
|
||||
}
|
||||
};
|
||||
COMPONENT.controller.$inject = ['$http'];
|
||||
module.component(NAME, COMPONENT);
|
||||
module.component(NAME, COMPONENT);
|
||||
|
|
|
@ -46,6 +46,9 @@
|
|||
url: "/notes",
|
||||
state: "clientCard.notes",
|
||||
component: "vn-client-notes",
|
||||
params: {
|
||||
client: "card.client"
|
||||
},
|
||||
description: "Notas",
|
||||
icon: "insert_drive_file"
|
||||
}, {
|
||||
|
|
|
@ -1,65 +1,65 @@
|
|||
import {module} from '../module'
|
||||
import template from './login.html'
|
||||
import style from './login.scss'
|
||||
import {module} from '../module';
|
||||
import template from './login.html';
|
||||
import style from './login.scss';
|
||||
|
||||
export const COMPONENT =
|
||||
{
|
||||
template: template,
|
||||
controller: controller,
|
||||
controllerAs: 'login'
|
||||
};
|
||||
{
|
||||
template: template,
|
||||
controller: controller,
|
||||
controllerAs: 'login'
|
||||
};
|
||||
|
||||
module.component('vnLogin', COMPONENT);
|
||||
|
||||
controller.$inject = ['$http', '$element'];
|
||||
function controller($http, $element) {
|
||||
var self = this;
|
||||
this.submit = function() {
|
||||
let model = this.model;
|
||||
var self = this;
|
||||
this.submit = function() {
|
||||
let model = this.model;
|
||||
|
||||
if(!(model && model.email && model.password)) {
|
||||
showMessage('Please insert your email and password');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
model.appId = window.location.href;
|
||||
$http.post('/account', this.model).then (
|
||||
if (!(model && model.email && model.password)) {
|
||||
showMessage('Please insert your email and password');
|
||||
return;
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
model.appId = window.location.href;
|
||||
$http.post('/account', this.model).then(
|
||||
onLoginOk,
|
||||
onLoginErr
|
||||
);
|
||||
};
|
||||
function onLoginOk (response) {
|
||||
self.loading = false;
|
||||
window.location = response.data.location +'?access_token='+ response.data.accessToken;
|
||||
}
|
||||
function onLoginErr(response) {
|
||||
self.loading = false;
|
||||
self.model.password = '';
|
||||
};
|
||||
function onLoginOk(response) {
|
||||
self.loading = false;
|
||||
window.location = response.data.location + '?access_token=' + response.data.accessToken;
|
||||
}
|
||||
function onLoginErr(response) {
|
||||
self.loading = false;
|
||||
self.model.password = '';
|
||||
|
||||
let message;
|
||||
let message;
|
||||
|
||||
switch(response.status) {
|
||||
case 401:
|
||||
message = 'Invalid credentials';
|
||||
break;
|
||||
case -1:
|
||||
message = 'Can\'t contact with server';
|
||||
break;
|
||||
default:
|
||||
message = 'Something went wrong';
|
||||
}
|
||||
|
||||
showMessage(message);
|
||||
}
|
||||
function showMessage(message) {
|
||||
let snackbar = $element.find('vn-snackbar').controller('vnSnackbar');
|
||||
snackbar.show({message: message});
|
||||
}
|
||||
switch (response.status) {
|
||||
case 401:
|
||||
message = 'Invalid credentials';
|
||||
break;
|
||||
case -1:
|
||||
message = 'Can\'t contact with server';
|
||||
break;
|
||||
default:
|
||||
message = 'Something went wrong';
|
||||
}
|
||||
|
||||
showMessage(message);
|
||||
}
|
||||
function showMessage(message) {
|
||||
let snackbar = $element.find('vn-snackbar').controller('vnSnackbar');
|
||||
snackbar.show({message: message});
|
||||
}
|
||||
}
|
||||
|
||||
module.config(['$httpProvider', function($httpProvider) {
|
||||
$httpProvider.defaults.useXDomain = true;
|
||||
delete $httpProvider.defaults.headers.common['X-Requested-With'];
|
||||
}
|
||||
$httpProvider.defaults.useXDomain = true;
|
||||
delete $httpProvider.defaults.headers.common['X-Requested-With'];
|
||||
}
|
||||
]);
|
||||
|
|
2
db.json
2
db.json
|
@ -18,7 +18,7 @@
|
|||
"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue": "{\"id\":\"NUf7o684TmteojFX9KmPOpaDLthjP5Def4wuy83Yjv31i43HHiWgV3FyBp6pX8Ue\",\"ttl\":1209600,\"created\":\"2016-11-21T11:06:11.113Z\",\"userId\":1}"
|
||||
},
|
||||
"Client": {
|
||||
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"1\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":2345,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46013\",\"mobile\":\"654654654\",\"dueDay\":10,\"gestdoc\":23452343,\"province\":\"2\",\"country\":\"1\",\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\"}",
|
||||
"12": "{\"name\":\"Verdnatura\",\"id\":12,\"fi\":\"B97367486\",\"salesPerson\":\"1\",\"telefono\":\"963242100\",\"socialName\":\"Verdnatura Levante SL\",\"active\":true,\"user\":\"verdnatura\",\"fax\":\"963242100\",\"phone\":\"963242101d\",\"email\":\"informatica@verdnatura.es\",\"surcharge\":true,\"cyc\":2345,\"credit\":1000,\"iban\":\"456\",\"street\":\"Avenida Espioca, 100\",\"city\":\"Silla\",\"postcode\":\"46013\",\"mobile\":\"654654654\",\"dueDay\":10,\"gestdoc\":23452343,\"province\":\"2\",\"country\":\"1\",\"modify\":\"BasicData\",\"navigate\":true,\"payMethod\":\"1\"}",
|
||||
"14": "{\"name\":\"Cliente 1\",\"id\":14,\"street\":\"Aaaaaaaaaa\",\"fi\":\"1234567890A\",\"socialName\":\"Cliente 1\",\"fax\":\"963242100\",\"dischargeDate\":\"01/01/2017\",\"telefono\":\"963242100\",\"salesPerson\":\"2\",\"email\":\"informatica@verdnatura.es\",\"city\":\"asdf\",\"postcode\":\"asdf\",\"phone\":\"asdf\",\"mobile\":\"asdf\",\"credit\":2345,\"cyc\":123,\"iban\":\"asdf\",\"dueDay\":345,\"gestdoc\":2435,\"surcharge\":true,\"navigate\":true}",
|
||||
"15": "{\"name\":\"afsdf\",\"fi\":\"12341234rasf\",\"socialName\":\"asdfasd\",\"dueDay\":5,\"id\":15,\"payMethod\":\"2\",\"salesPerson\":\"1\",\"modify\":\"BasicData\",\"iban\":\"sdfgsdfgsdfg\"}"
|
||||
},
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
"name": "ClientObservation",
|
||||
"description": "Notas de los clientes.",
|
||||
"base": "PersistedModel",
|
||||
"validateUpsert": true,
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "Number",
|
||||
"id": true,
|
||||
"description": "Identifier"
|
||||
},
|
||||
"text": {
|
||||
"type": "string",
|
||||
"description": "Fiscal indetifier"
|
||||
},
|
||||
"creationDate": {
|
||||
"type": "date",
|
||||
"description": "Fiscal indetifier"
|
||||
},
|
||||
"relations": {
|
||||
"salesPerson": {
|
||||
"type": "belongsTo",
|
||||
"model": "SalesPerson",
|
||||
"foreignKey": "salePersonId"
|
||||
},
|
||||
"client": {
|
||||
"type": "belongsTo",
|
||||
"model": "Client",
|
||||
"foreignKey": "clientId"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -59,5 +59,9 @@
|
|||
"Country": {
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
},
|
||||
"ClientObservation": {
|
||||
"dataSource": "db",
|
||||
"public": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue