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;"> <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="apps" id="apps" title="Applications"></vn-icon>
<vn-icon icon="notifications" title="Notifications"></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-icon icon="account_circle" title="Profile" style="font-size: 35px;"></vn-icon>
<!-- <!--
<vn-popover pad-medium for="apps"> <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, directive as RadioDirective} from './radio/radio';
export {NAME as RADIO_MDL, factory as radionMdl} from './radio/radio.mdl'; 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 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, directive as TextfieldDirective} from './textfield/textfield';
export {NAME as TEXTFIELD_MDL, factory as textfieldMdl} from './textfield/textfield.mdl'; export {NAME as TEXTFIELD_MDL, factory as textfieldMdl} from './textfield/textfield.mdl';
export {NAME as TEXTFIELD_BT, factory as textfieldBt} from './textfield/textfield.bt'; export {NAME as TEXTFIELD_BT, factory as textfieldBt} from './textfield/textfield.bt';

View File

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

View File

@ -8,9 +8,17 @@ export const NAME = util.getName(_NAME);
directive.$inject = [resolveFactory.NAME]; directive.$inject = [resolveFactory.NAME];
export function directive(resolve) { export function directive(resolve) {
return { return {
require: 'E', restrict: 'E',
template: function(_, attr) { template: function(_, attr) {
return resolve.getTemplate(_NAME, 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);
} }
}; };
} }

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'; import template from './textarea.mdl.html';
const _NAME = 'textarea'; const _NAME = 'textarea';
const DEFAULT_CLASS = ''; const DEFAULT_LABEL = 'textarea';
const DEFAULT_ROWS = 3;
export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK); export const NAME = util.getFactoryName(_NAME + constant.MATERIAL_DESIGN_FRAMEWORK);
@ -12,9 +14,10 @@ export function factory() {
return { return {
template: template, template: template,
default: { default: {
className: DEFAULT_CLASS, label: DEFAULT_LABEL,
} rows: DEFAULT_ROWS
} }
};
} }
_module.factory(NAME, factory); _module.factory(NAME, factory);

View File

@ -5,8 +5,7 @@ export const NAME = 'vnClientAddressesDataEdit';
export const COMPONENT = { export const COMPONENT = {
template: template, template: template,
controllerAs: 'addressData', controllerAs: 'addressData',
controller: function($http,$stateParams) controller: function($http, $stateParams) {
{
this.address = {}; this.address = {};
$http.get(`/client/api/Addresses/${$stateParams.addressId}`).then( $http.get(`/client/api/Addresses/${$stateParams.addressId}`).then(
json => this.address = json.data json => this.address = json.data
@ -18,11 +17,11 @@ export const COMPONENT = {
json => this.provinces = json.data json => this.provinces = json.data
); );
this.submit = function(){ this.submit = function() {
$http.put('/client/api/Addresses', this.address); $http.put('/client/api/Addresses', this.address);
};
} }
} };
}
COMPONENT.controller.$inject = ['$http' , '$stateParams']; COMPONENT.controller.$inject = ['$http', '$stateParams'];
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -2,13 +2,17 @@
<vn-card> <vn-card>
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Notas</vn-title> <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-vertical>
</vn-card> </vn-card>
<vn-submit margin-small-top label="Guardar"></vn-submit> <div margin-small-top>
<vn-card> <vn-submit label="Guardar"></vn-submit>
<vn-vertical pad-large margin-small-top> </div>
<vn-textfield label="Notas" field="notes.client.notes" padd-medium-top></vn-textfield> <vn-card margin-small-top>
</vn-vertical> <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> </vn-card>
</form> </form>

View File

@ -9,8 +9,16 @@ export const COMPONENT = {
client: '<' client: '<'
}, },
controller: function($http) { controller: function($http) {
this.notes = [];
this.submit = function() { 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 = "";
});
}; };
} }
}; };

View File

@ -46,6 +46,9 @@
url: "/notes", url: "/notes",
state: "clientCard.notes", state: "clientCard.notes",
component: "vn-client-notes", component: "vn-client-notes",
params: {
client: "card.client"
},
description: "Notas", description: "Notas",
icon: "insert_drive_file" 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-textfield label="Usuario" class="padd-medium-top margin-medium-top" field="web.client.user" focus></vn-textfield>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-vertical> <vn-vertical margin-small-top>
<vn-submit margin-small-top label="Guardar"></vn-submit> <vn-submit label="Guardar"></vn-submit>
</vn-vertical> </vn-vertical>
</form> </form>
<vn-confirm-client client="web.client" client-old="web.clientOld" state="web.state"></vn-confirm-client> <vn-confirm-client client="web.client" client-old="web.clientOld" state="web.state"></vn-confirm-client>

View File

@ -1,13 +1,13 @@
import {module} from '../module' import {module} from '../module';
import template from './login.html' import template from './login.html';
import style from './login.scss' import style from './login.scss';
export const COMPONENT = export const COMPONENT =
{ {
template: template, template: template,
controller: controller, controller: controller,
controllerAs: 'login' controllerAs: 'login'
}; };
module.component('vnLogin', COMPONENT); module.component('vnLogin', COMPONENT);
@ -17,21 +17,21 @@ function controller($http, $element) {
this.submit = function() { this.submit = function() {
let model = this.model; let model = this.model;
if(!(model && model.email && model.password)) { if (!(model && model.email && model.password)) {
showMessage('Please insert your email and password'); showMessage('Please insert your email and password');
return; return;
} }
this.loading = true; this.loading = true;
model.appId = window.location.href; model.appId = window.location.href;
$http.post('/account', this.model).then ( $http.post('/account', this.model).then(
onLoginOk, onLoginOk,
onLoginErr onLoginErr
); );
}; };
function onLoginOk (response) { function onLoginOk(response) {
self.loading = false; self.loading = false;
window.location = response.data.location +'?access_token='+ response.data.accessToken; window.location = response.data.location + '?access_token=' + response.data.accessToken;
} }
function onLoginErr(response) { function onLoginErr(response) {
self.loading = false; self.loading = false;
@ -39,7 +39,7 @@ function controller($http, $element) {
let message; let message;
switch(response.status) { switch (response.status) {
case 401: case 401:
message = 'Invalid credentials'; message = 'Invalid credentials';
break; break;
@ -61,5 +61,5 @@ function controller($http, $element) {
module.config(['$httpProvider', function($httpProvider) { module.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.useXDomain = true; $httpProvider.defaults.useXDomain = true;
delete $httpProvider.defaults.headers.common['X-Requested-With']; 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": { "Country": {
"dataSource": "db", "dataSource": "db",
"public": true "public": true
},
"ClientObservation": {
"dataSource": "db",
"public": true
} }
} }