diff --git a/client/client/src/greuge-create/greuge-create.html b/client/client/src/greuge-create/greuge-create.html index afdd01218..56cf9fafb 100644 --- a/client/client/src/greuge-create/greuge-create.html +++ b/client/client/src/greuge-create/greuge-create.html @@ -11,7 +11,12 @@ Add Greuge - + + diff --git a/client/client/src/greuge-create/greuge-create.js b/client/client/src/greuge-create/greuge-create.js index f3232f09c..3e8aa96a8 100644 --- a/client/client/src/greuge-create/greuge-create.js +++ b/client/client/src/greuge-create/greuge-create.js @@ -5,7 +5,7 @@ class ClientGreugeCreate { this.$ = $scope; this.$state = $state; this.greuge = { - shipped: $filter('date')(new Date(), 'yyyy-MM-dd') + shipped: $filter('date')(new Date(), 'yyyy-MM-dd HH:mm') }; } onSubmit() { diff --git a/client/core/src/datePicker/datePicker.js b/client/core/src/datePicker/datePicker.js index d01ce2a45..3a2e24307 100644 --- a/client/core/src/datePicker/datePicker.js +++ b/client/core/src/datePicker/datePicker.js @@ -30,6 +30,7 @@ class DatePicker extends Component { this._modelView = null; this._model = undefined; this._optionsChecked = false; + this._waitingInit = 0; this.hasFocus = false; this.hasMouseIn = false; componentHandler.upgradeElement($element[0].firstChild); @@ -39,12 +40,27 @@ class DatePicker extends Component { return this._model; } set model(value) { - this._model = value; - if (value && !this.modelView) { - let options = this._getOptions(); - let initialDateFormat = (options && options.dateFormat) ? options.dateFormat : 'Y-m-d'; - let format = this._formatFlat2Angular(initialDateFormat); - this.modelView = this.$filter('date')(value, format); + if (this._optionsChecked) { + this._waitingInit = 0; + this._model = value; + if (value && !this.modelView) { + let initialDateFormat = this.$translate.use() === 'es' ? 'd-m-Y' : 'Y-m-d'; + 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() { @@ -54,10 +70,9 @@ class DatePicker extends Component { this._modelView = value; this.input.value = value; this._setModel(value); - this.$timeout(() => { - this.mdlUpdate(); - }, 500); + this.mdlUpdate(); } + onClear() { this.modelView = null; } @@ -67,9 +82,11 @@ class DatePicker extends Component { } } mdlUpdate() { - let mdlField = this.element.firstChild.MaterialTextfield; - if (mdlField) - mdlField.updateClasses_(); + this.$timeout(() => { + let mdlField = this.element.firstChild.MaterialTextfield; + if (mdlField) + mdlField.updateClasses_(); + }, 500); } _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; } + $onChanges(objChange) { + if (objChange.iniOptions && objChange.iniOptions.currentValue) { + this.iniOptions = Object.assign(this.iniOptions, objChange.iniOptions.currentValue); + } + } + $onInit() { this.initPicker(); } diff --git a/client/item/src/create/item-create.html b/client/item/src/create/item-create.html index 9e8b35e35..1a489057d 100644 --- a/client/item/src/create/item-create.html +++ b/client/item/src/create/item-create.html @@ -9,16 +9,9 @@
- Create item - - - - - - - - + New item + - - - - + + + {{$parent.$parent.item.description}} + + + + + - - - - + > + + diff --git a/client/item/src/create/item-create.js b/client/item/src/create/item-create.js index 7723370e1..415e67c4f 100644 --- a/client/item/src/create/item-create.js +++ b/client/item/src/create/item-create.js @@ -1,16 +1,21 @@ import ngModule from '../module'; class ItemCreate { - constructor() { - this.item = {}; + constructor($scope, $state) { + this.$ = $scope; + this.$state = $state; + this.item = { + relevancy: 0 + }; } onSubmit() { 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', { template: require('./item-create.html'), diff --git a/client/item/src/locale/es.json b/client/item/src/locale/es.json index e51c46008..29c254448 100644 --- a/client/item/src/locale/es.json +++ b/client/item/src/locale/es.json @@ -4,5 +4,8 @@ "Category": "Categoría", "Description": "Descripción", "Size": "Tamaño", - "Type": "Tipo" + "Type": "Tipo", + "Name": "Nombre", + "Relevancy": "Relevancia", + "New item": "Nuevo artículo" } \ No newline at end of file diff --git a/services/item/common/models/intrastat.json b/services/item/common/models/intrastat.json index 53f8ce2f9..0ef5c5876 100644 --- a/services/item/common/models/intrastat.json +++ b/services/item/common/models/intrastat.json @@ -18,9 +18,9 @@ } }, "relations": { - "taxGroup": { + "taxClass": { "type": "belongsTo", - "model": "TaxGroup", + "model": "TaxClass", "foreignKey": "taxClassFk" }, "taxCode": { diff --git a/services/item/common/models/item.js b/services/item/common/models/item.js index 4c8019af3..2c193b587 100644 --- a/services/item/common/models/item.js +++ b/services/item/common/models/item.js @@ -1,3 +1,6 @@ module.exports = function(Self) { require('../methods/item/filter.js')(Self); + + Self.validatesPresenceOf('name', {message: 'Cannot be blank'}); + Self.validatesPresenceOf('originFk', {message: 'Cannot be blank'}); };