Merge branch 'dev' of http://git.verdnatura.es/salix into dev

This commit is contained in:
Carlos Jimenez 2018-01-10 14:04:08 +01:00
commit 96a0b0dd3a
8 changed files with 80 additions and 50 deletions

View File

@ -11,7 +11,12 @@
<vn-title vn-one margin-large-bottom>Add Greuge</vn-title> <vn-title vn-one margin-large-bottom>Add Greuge</vn-title>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one margin-medium-right label="Amount" field="$ctrl.greuge.amount" type="number" vn-focus></vn-textfield> <vn-textfield vn-one margin-medium-right label="Amount" field="$ctrl.greuge.amount" type="number" vn-focus></vn-textfield>
<vn-date-picker vn-one label="Date" model="$ctrl.greuge.shipped"></vn-date-picker> <vn-date-picker vn-one
label="Date"
model="$ctrl.greuge.shipped"
ini-options="{enableTime: true, dateFormat: 'd-m-Y h:i', time_24hr: true}"
>
</vn-date-picker>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one margin-medium-right label="Comment" field="$ctrl.greuge.description"></vn-textfield> <vn-textfield vn-one margin-medium-right label="Comment" field="$ctrl.greuge.description"></vn-textfield>

View File

@ -5,7 +5,7 @@ class ClientGreugeCreate {
this.$ = $scope; this.$ = $scope;
this.$state = $state; this.$state = $state;
this.greuge = { this.greuge = {
shipped: $filter('date')(new Date(), 'yyyy-MM-dd') shipped: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm')
}; };
} }
onSubmit() { onSubmit() {

View File

@ -30,6 +30,7 @@ class DatePicker extends Component {
this._modelView = null; this._modelView = null;
this._model = undefined; this._model = undefined;
this._optionsChecked = false; this._optionsChecked = false;
this._waitingInit = 0;
this.hasFocus = false; this.hasFocus = false;
this.hasMouseIn = false; this.hasMouseIn = false;
componentHandler.upgradeElement($element[0].firstChild); componentHandler.upgradeElement($element[0].firstChild);
@ -39,12 +40,27 @@ class DatePicker extends Component {
return this._model; return this._model;
} }
set model(value) { set model(value) {
this._model = value; if (this._optionsChecked) {
if (value && !this.modelView) { this._waitingInit = 0;
let options = this._getOptions(); this._model = value;
let initialDateFormat = (options && options.dateFormat) ? options.dateFormat : 'Y-m-d'; if (value && !this.modelView) {
let format = this._formatFlat2Angular(initialDateFormat); let initialDateFormat = this.$translate.use() === 'es' ? 'd-m-Y' : 'Y-m-d';
this.modelView = this.$filter('date')(value, format); if (this.iniOptions.enableTime) {
initialDateFormat += ' H:i:s';
}
let format = this._formatFlat2Angular(initialDateFormat);
this._modelView = this.$filter('date')(new Date(value), format);
this.mdlUpdate();
}
} else if (this._waitingInit < 4) {
this._waitingInit++;
this.$timeout(() => {
this.model = value;
}, 250);
} else {
this.model = null;
this.modelView = '';
this._waitingInit = 0;
} }
} }
get modelView() { get modelView() {
@ -54,10 +70,9 @@ class DatePicker extends Component {
this._modelView = value; this._modelView = value;
this.input.value = value; this.input.value = value;
this._setModel(value); this._setModel(value);
this.$timeout(() => { this.mdlUpdate();
this.mdlUpdate();
}, 500);
} }
onClear() { onClear() {
this.modelView = null; this.modelView = null;
} }
@ -67,9 +82,11 @@ class DatePicker extends Component {
} }
} }
mdlUpdate() { mdlUpdate() {
let mdlField = this.element.firstChild.MaterialTextfield; this.$timeout(() => {
if (mdlField) let mdlField = this.element.firstChild.MaterialTextfield;
mdlField.updateClasses_(); if (mdlField)
mdlField.updateClasses_();
}, 500);
} }
_formatFlat2Angular(string) { // change string Flatpickr format to angular format (d-m-Y -> dd-MM-yyyy) _formatFlat2Angular(string) { // change string Flatpickr format to angular format (d-m-Y -> dd-MM-yyyy)
@ -193,6 +210,12 @@ class DatePicker extends Component {
this.vp = undefined; this.vp = undefined;
} }
$onChanges(objChange) {
if (objChange.iniOptions && objChange.iniOptions.currentValue) {
this.iniOptions = Object.assign(this.iniOptions, objChange.iniOptions.currentValue);
}
}
$onInit() { $onInit() {
this.initPicker(); this.initPicker();
} }

View File

@ -9,16 +9,9 @@
<div style="max-width: 70em; margin: 0 auto;"> <div style="max-width: 70em; margin: 0 auto;">
<vn-card> <vn-card>
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Create item</vn-title> <vn-title>New item</vn-title>
<vn-horizontal>
<vn-textfield vn-one label="Size" field="$ctrl.item.size" vn-focus></vn-textfield>
<vn-textfield vn-five label="Category" field="$ctrl.item.category"></vn-textfield>
</vn-horizontal>
<vn-horizontal>
<vn-textfield vn-one label="Stems" field="$ctrl.item.stems"></vn-textfield>
<vn-textfield vn-five label="Description" field="$ctrl.item.description"></vn-textfield>
</vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield vn-one label="Name" field="$ctrl.item.name" vn-focus></vn-textfield>
<vn-autocomplete vn-one <vn-autocomplete vn-one
url="/item/api/ItemTypes" url="/item/api/ItemTypes"
label="Type" label="Type"
@ -27,15 +20,21 @@
field="$ctrl.item.typeFk" field="$ctrl.item.typeFk"
> >
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal>
<vn-horizontal>
<vn-autocomplete vn-one <vn-autocomplete vn-one
url="/item/api/Inks" url="/item/api/Intrastats"
label="Ink" label="Intrastat"
show-field="name" show-field="description"
value-field="id" value-field="id"
field="$ctrl.item.inkFk" field="$ctrl.item.intrastatFk"
order="description ASC"
filter-search="{where: {description: {regexp: 'search'}} }"
> >
<tpl-item>{{$parent.$parent.item.description}}</tpl-item>
</vn-autocomplete> </vn-autocomplete>
<vn-textfield vn-one label="Relevancy" field="$ctrl.item.relevancy" type="number"></vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
@ -45,18 +44,10 @@
show-field="name" show-field="name"
value-field="id" value-field="id"
field="$ctrl.item.originFk" field="$ctrl.item.originFk"
> ></vn-autocomplete>
</vn-autocomplete> <vn-one></vn-one>
<vn-autocomplete vn-one
url="/item/api/Producers"
label="Producer"
show-field="name"
value-field="id"
field="$ctrl.item.producerFk"
>
</vn-autocomplete>
</vn-horizontal> </vn-horizontal>
</vn-vertical> </vn-vertical>
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>

View File

@ -1,16 +1,21 @@
import ngModule from '../module'; import ngModule from '../module';
class ItemCreate { class ItemCreate {
constructor() { constructor($scope, $state) {
this.item = {}; this.$ = $scope;
this.$state = $state;
this.item = {
relevancy: 0
};
} }
onSubmit() { onSubmit() {
this.$.watcher.submit().then( this.$.watcher.submit().then(
json => this.$state.go('item.card.basic', {id: json.data.id}) json => this.$state.go('item.card.data', {id: json.data.id})
); );
} }
} }
ItemCreate.$inject = ['$scope', '$state'];
ngModule.component('vnItemCreate', { ngModule.component('vnItemCreate', {
template: require('./item-create.html'), template: require('./item-create.html'),

View File

@ -4,5 +4,8 @@
"Category": "Categoría", "Category": "Categoría",
"Description": "Descripción", "Description": "Descripción",
"Size": "Tamaño", "Size": "Tamaño",
"Type": "Tipo" "Type": "Tipo",
"Name": "Nombre",
"Relevancy": "Relevancia",
"New item": "Nuevo artículo"
} }

View File

@ -18,9 +18,9 @@
} }
}, },
"relations": { "relations": {
"taxGroup": { "taxClass": {
"type": "belongsTo", "type": "belongsTo",
"model": "TaxGroup", "model": "TaxClass",
"foreignKey": "taxClassFk" "foreignKey": "taxClassFk"
}, },
"taxCode": { "taxCode": {

View File

@ -1,3 +1,6 @@
module.exports = function(Self) { module.exports = function(Self) {
require('../methods/item/filter.js')(Self); require('../methods/item/filter.js')(Self);
Self.validatesPresenceOf('name', {message: 'Cannot be blank'});
Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'});
}; };