This commit is contained in:
Javi Gallego 2017-01-17 10:59:27 +01:00
parent 05376e27c7
commit ede68e83b9
14 changed files with 160 additions and 94 deletions

View File

@ -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">

View File

@ -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';

View File

@ -8,8 +8,8 @@ export function factory() {
default: {
enabled: 'enabled',
icon: '',
label: '',
label: ''
}
}
};
}
module.factory(NAME, factory);

View File

@ -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);

View File

@ -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>

View File

@ -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);

View File

@ -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);

View File

@ -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>

View File

@ -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);

View File

@ -46,6 +46,9 @@
url: "/notes",
state: "clientCard.notes",
component: "vn-client-notes",
params: {
client: "card.client"
},
description: "Notas",
icon: "insert_drive_file"
}, {

View File

@ -6,8 +6,8 @@
<vn-textfield label="Usuario" class="padd-medium-top margin-medium-top" field="web.client.user" focus></vn-textfield>
</vn-vertical>
</vn-card>
<vn-vertical>
<vn-submit margin-small-top label="Guardar"></vn-submit>
<vn-vertical margin-small-top>
<vn-submit label="Guardar"></vn-submit>
</vn-vertical>
</form>
<vn-confirm-client client="web.client" client-old="web.clientOld" state="web.state"></vn-confirm-client>

View 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'];
}
]);

View File

@ -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"
}
}
}
}

View File

@ -59,5 +59,9 @@
"Country": {
"dataSource": "db",
"public": true
},
"ClientObservation": {
"dataSource": "db",
"public": true
}
}