-
- query_builder
-
clear
diff --git a/client/core/src/components/date-picker/date-picker.js b/client/core/src/components/date-picker/date-picker.js
index db5e59d6f..99715d717 100644
--- a/client/core/src/components/date-picker/date-picker.js
+++ b/client/core/src/components/date-picker/date-picker.js
@@ -3,240 +3,93 @@ import Component from '../../lib/component';
import Flatpickr from 'vendor/src/flatpickr';
import './style.scss';
-// equivalences to format date between flatpicker and angularjs
-export const formatEquivalence = {
- d: 'dd', // Day of the month, 2 digits with leading zeros (01 to 31)
- j: 'd', // Day of the month without leading zeros (1 to 31)
- m: 'MM', // Month in year, padded (01-12)
- n: 'M', // Month in year (1-12)
- y: 'yy', // A two digit representation of a year (00-99)
- Y: 'yyyy', // A full numeric representation of a year, 4 digits (1999 or 2003)
- H: 'HH', // Hour in AM/PM, padded (01-12)
- h: 'H', // Hour in AM/PM, (1-12)
- i: 'mm', // Minutes (00 to 59)
- s: 'ss' // Seconds (00 to 59)
-};
-
class DatePicker extends Component {
- constructor($element, $translate, $filter, $timeout, $attrs) {
- super($element);
+ constructor($element, $scope, $translate, $attrs) {
+ super($element, $scope);
this.input = $element[0].querySelector('input');
this.$translate = $translate;
- this.$filter = $filter;
- this.$timeout = $timeout;
this.$attrs = $attrs;
-
this.enabled = true;
this._modelView = null;
this._model = undefined;
- this._optionsChecked = false;
- this._waitingInit = 0;
- this.hasFocus = false;
+ this.dateValue = undefined;
this.hasMouseIn = false;
+ let locale = this.$translate.use();
+ this.defaultOptions = {
+ locale: locale,
+ dateFormat: locale == 'es' ? 'd-m-Y' : 'Y-m-d',
+ enableTime: false,
+ onValueUpdate: () => this.onValueUpdate()
+ };
+ this.userOptions = {};
+ this._iniOptions = this.defaultOptions;
+
componentHandler.upgradeElement($element[0].firstChild);
+ this.vp = new Flatpickr(this.input, this._iniOptions);
+ }
+
+ onValueUpdate() {
+ if (this.vp.selectedDates.length)
+ this.model = this.vp.selectedDates[0];
+ else
+ this.model = null;
+ this.$.$apply();
+ }
+
+ set iniOptions(value) {
+ this.userOptions = value;
+ let options = Object.assign({}, this.defaultOptions, value);
+ this._iniOptions = options;
+ this.isTimePicker = options.enableTime && options.noCalendar;
+
+ // TODO: When some properties change Flatpickr doesn't refresh the view
+ //for (let option in options)
+ // this.vp.set(option, options[option]);
+
+ if (this.vp) this.vp.destroy();
+ this.vp = new Flatpickr(this.input, this._iniOptions);
+ this.vp.setDate(this.dateValue);
+ this.mdlUpdate();
+ }
+
+ get iniOptions() {
+ return this.userOptions;
}
get model() {
return this._model;
}
- set model(value) {
- if (this._optionsChecked) {
- this._waitingInit = 0;
- this._model = value;
- if (value && !this.modelView) {
- let options = this._getOptions();
- let initialDateFormat;
- if (options && options.dateFormat) {
- initialDateFormat = options.dateFormat;
- } else {
- initialDateFormat = this.$translate.use() === 'es' ? 'd-m-Y' : 'Y-m-d';
- if (options.enableTime) {
- initialDateFormat += ' H:i:s';
- }
- }
- let format = this._formatFlat2Angular(initialDateFormat);
- this._modelView = this.$filter('date')(new Date(this._model), 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() {
- return this._modelView;
- }
- set modelView(value) {
- this._modelView = value;
- this.input.value = value;
- this._setModel(value);
+ set model(value) {
+ this._model = value;
+ this.dateValue = value ? new Date(value) : null;
+ this.vp.setDate(this.dateValue);
this.mdlUpdate();
}
+ get modelView() {
+ return this._modelView;
+ }
+
+ set modelView(value) {
+ this._modelView = value;
+ }
+
onClear() {
- this.modelView = null;
- }
- onClick() {
- if (this.vp) {
- this.vp.open();
- }
+ this.model = null;
}
+
mdlUpdate() {
- 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)
- let aux = string.split(/[ZT.,/ :-]/);
- let parts = [];
- aux.forEach(
- val => {
- parts.push(formatEquivalence[val]);
- }
- );
- if (string.indexOf(' ') !== -1 || string.indexOf('T') !== -1) { // datetime format
- let dates = parts.slice(0, 3).join('-');
- let hours = parts.slice(3, parts.length).join(':');
- return `${dates} ${hours}`.trim();
- } else if (string.indexOf(':') !== -1) { // only time format
- return parts.join(':');
- } // only date format
- return parts.join('-');
- }
-
- _string2BackFormat(value) {
- let formats = this.iniOptions.dateFormat.split(/[ZT.,/ :-]/);
- let aux = value.split(/[ZT.,/ :-]/);
- let date = {};
- formats.forEach(
- (k, i) => {
- if (k.toLowerCase() === 'y') {
- date.year = aux[i];
- } else if (k === 'm' || k === 'n') {
- date.month = aux[i];
- } else if (k === 'd' || k === 'j') {
- date.day = aux[i];
- } else if (k.toLowerCase() === 'h') {
- date.hour = aux[i];
- } else if (k === 'i') {
- date.minutes = aux[i];
- } else if (k === 's') {
- date.seccons = aux[i];
- }
- }
- );
-
- let dateStr = '';
- let hourStr = '';
-
- if (date.year && date.month && date.day) {
- dateStr = `${date.year}-${date.month}-${date.day}`;
- }
- if (date.hour) {
- hourStr = date.hour;
- if (date.minutes) {
- hourStr += ':' + date.minutes;
- } else {
- hourStr += ':00';
- }
- if (date.seccons) {
- hourStr += ':' + date.seccons;
- } else {
- hourStr += ':00';
- }
- }
- return `${dateStr} ${hourStr}`.trim();
- }
-
- _setModel(value) {
- let model;
- let options = this._getOptions();
- if (!value) {
- model = undefined;
- } else if (!options || (options.dateFormat && options.dateFormat.startsWith('Y-m-d'))) {
- model = value;
- } else {
- model = this._string2BackFormat(value);
- }
-
- if (this.model !== model) {
- this.model = model;
- }
- }
-
- _getOptions() {
- if (this.iniOptions && this._optionsChecked) {
- return this.iniOptions;
- } else if (!this.iniOptions) {
- this.iniOptions = {};
- }
-
- if (!this.iniOptions.locale)
- this.iniOptions.locale = this.$translate.use();
-
- if (!this.iniOptions.dateFormat)
- this.iniOptions.dateFormat = this.iniOptions.locale === 'es' ? 'd-m-Y' : 'Y-m-d';
- else if (this.iniOptions.dateFormat) {
- let format = this.iniOptions.dateFormat.split(/[ZT.,/ :-]/);
- if (format.length <= 1) {
- throw new Error(`Error: Invalid string format ${format}`);
- }
- format.forEach(
- val => {
- if (!formatEquivalence[val]) {
- throw new Error(`Error in dateFormat ${this.iniOptions.dateFormat}: is not like Flatpickr Formatting Token https://chmln.github.io/flatpickr/formatting/`);
- }
- }
- );
- }
-
- if (this.$attrs.hasOwnProperty('today')) {
- this.iniOptions.defaultDate = new Date();
- }
-
- this._optionsChecked = true;
- return this.iniOptions;
- }
-
- initPicker() {
- this.iniOptions = this._getOptions();
- this.isTimePicker = (this.iniOptions && this.iniOptions.enableTime && this.iniOptions.noCalendar);
- this.vp = new Flatpickr(this.input, this.iniOptions);
- if (this.iniOptions.defaultDate) {
- this.modelView = this.vp.formatDate(this.iniOptions.defaultDate, this.iniOptions.dateFormat);
- }
- }
- destroyPicker() {
- if (this.vp)
- this.vp.destroy();
- this.vp = undefined;
- }
-
- $onChanges(objChange) {
- if (objChange.iniOptions && objChange.iniOptions.currentValue) {
- this.iniOptions = Object.assign(this.iniOptions, objChange.iniOptions.currentValue);
- }
- }
-
- $onInit() {
- this.initPicker();
+ let mdlField = this.element.firstChild.MaterialTextfield;
+ if (mdlField)
+ mdlField.updateClasses_();
}
$onDestroy() {
- this.destroyPicker();
+ this.vp.destroy();
}
}
-DatePicker.$inject = ['$element', '$translate', '$filter', '$timeout', '$attrs'];
+DatePicker.$inject = ['$element', '$scope', '$translate', '$attrs'];
ngModule.component('vnDatePicker', {
template: require('./date-picker.html'),
diff --git a/client/core/src/components/date-picker/date-picker.spec.js b/client/core/src/components/date-picker/date-picker.spec.js
deleted file mode 100644
index 2be0c1eb4..000000000
--- a/client/core/src/components/date-picker/date-picker.spec.js
+++ /dev/null
@@ -1,47 +0,0 @@
-import './date-picker.js';
-
-describe('Component vnDatePicker', () => {
- let $componentController;
- let $filter;
- let $timeout;
- let $element;
- let $attrs;
- let $translate;
- let controller;
-
- beforeEach(() => {
- angular.mock.module('client');
- });
-
- beforeEach(angular.mock.inject((_$componentController_, _$filter_, _$timeout_, _$translate_) => {
- $componentController = _$componentController_;
- $filter = _$filter_;
- $timeout = _$timeout_;
- $element = angular.element(`
`);
- $translate = _$translate_;
- $attrs = {};
- controller = $componentController('vnDatePicker', {$element, $translate, $filter, $timeout, $attrs});
- }));
-
- describe('_formatFlat2Angular()', () => {
- it(`should format date from Y-m-d to yyyy-MM-dd`, () => {
- let formatedDate = controller._formatFlat2Angular(`Y-m-d`);
-
- expect(formatedDate).toBe('yyyy-MM-dd');
- });
-
- it(`should format date from d-m-Y to dd-MM-yyyy`, () => {
- let formatedDate = controller._formatFlat2Angular(`d-m-Y`);
-
- expect(formatedDate).toBe('dd-MM-yyyy');
- });
-
- it(`should split the given string into parts`, () => {
- controller.iniOptions = {dateFormat: 'd/m/Y'};
- controller._optionsChecked = true;
- controller.model = '2017-12-23';
-
- expect(controller.modelView).toBe('23-12-2017');
- });
- });
-});
diff --git a/client/core/src/components/date-picker/style.scss b/client/core/src/components/date-picker/style.scss
index 99f1cbc1b..1807e6949 100644
--- a/client/core/src/components/date-picker/style.scss
+++ b/client/core/src/components/date-picker/style.scss
@@ -1,3 +1,5 @@
+@import "colors";
+
vn-date-picker {
.mdl-chip__action {
position: absolute;
@@ -7,9 +9,18 @@ vn-date-picker {
margin: 22px 0px;
background-color: white;
}
+ .mdl-textfield {
+ width: 100%;
+ }
.material-icons {
font-size: 18px;
float: right;
margin-right: 5px;
}
+}
+
+.flatpickr-months .flatpickr-month,
+.flatpickr-weekdays,
+span.flatpickr-weekday {
+ background-color: $main-01;
}
\ No newline at end of file
diff --git a/client/core/src/components/drop-down/drop-down.js b/client/core/src/components/drop-down/drop-down.js
index bfe372b7d..c8b6c2a52 100755
--- a/client/core/src/components/drop-down/drop-down.js
+++ b/client/core/src/components/drop-down/drop-down.js
@@ -196,7 +196,7 @@ export default class DropDown extends Component {
}
let where = {};
- where[this.showField] = {regexp: search};
+ where[this.showField] = {like: `%${search}%`};
return where;
}
diff --git a/client/core/src/components/step-control/step-control.js b/client/core/src/components/step-control/step-control.js
index b655411d0..0ca1f0c46 100644
--- a/client/core/src/components/step-control/step-control.js
+++ b/client/core/src/components/step-control/step-control.js
@@ -16,12 +16,19 @@ export default class StepControl {
}
set currentState(state) {
- let isAllowed = true;
+ if (!this.onStepChange)
+ return this.$state.go(state);
- if (this.onStepChange)
- isAllowed = this.onStepChange({state});
+ let change = this.onStepChange({state});
- if (isAllowed)
+ if (typeof change === 'object' && change.then) {
+ return change.then(isAllowed => {
+ if (isAllowed)
+ this.$state.go(state);
+ });
+ }
+
+ if (change)
this.$state.go(state);
}
diff --git a/client/item/src/data/data.html b/client/item/src/data/data.html
index 507fdc2b2..d37fc0af1 100644
--- a/client/item/src/data/data.html
+++ b/client/item/src/data/data.html
@@ -51,6 +51,7 @@
field="$ctrl.item.expenceFk"
initial-data="$ctrl.item.expence">
+
diff --git a/client/item/src/data/locale/es.yml b/client/item/src/data/locale/es.yml
new file mode 100644
index 000000000..8efa03cd6
--- /dev/null
+++ b/client/item/src/data/locale/es.yml
@@ -0,0 +1 @@
+Reference: Referencia
\ No newline at end of file
diff --git a/client/locator/routes.json b/client/locator/routes.json
index b508fcc5f..0ea240bda 100644
--- a/client/locator/routes.json
+++ b/client/locator/routes.json
@@ -1,4 +1,4 @@
-{
+/* {
"module": "locator",
"name": "Locator",
"icon": "add_location",
@@ -11,4 +11,4 @@
"acl": ["developer"]
}
]
-}
\ No newline at end of file
+} */
\ No newline at end of file
diff --git a/client/modules.yml b/client/modules.yml
index cd51504b1..3ffb57dfc 100644
--- a/client/modules.yml
+++ b/client/modules.yml
@@ -2,9 +2,9 @@ auth: []
client: []
core: []
item: []
-locator: []
-production: []
+#locator: []
+#production: []
salix: []
-route: []
+#route: []
ticket: [item]
order: []
diff --git a/client/production/routes.json b/client/production/routes.json
index 159a80144..2df511b28 100644
--- a/client/production/routes.json
+++ b/client/production/routes.json
@@ -1,4 +1,4 @@
-{
+/* {
"module": "production",
"name": "Production",
"icon": "local_florist",
@@ -11,4 +11,4 @@
"acl": ["developer"]
}
]
-}
\ No newline at end of file
+} */
\ No newline at end of file
diff --git a/client/route/routes.json b/client/route/routes.json
index 9e7c48833..907a65b75 100644
--- a/client/route/routes.json
+++ b/client/route/routes.json
@@ -1,4 +1,4 @@
-{
+/* {
"module": "route",
"name": "Routes",
"icon" : "local_shipping",
@@ -65,4 +65,4 @@
}
}
]
-}
\ No newline at end of file
+} */
\ No newline at end of file
diff --git a/client/ticket/routes.json b/client/ticket/routes.json
index 577654d62..2d481ba72 100644
--- a/client/ticket/routes.json
+++ b/client/ticket/routes.json
@@ -71,6 +71,18 @@
"ticket": "$ctrl.data"
}
},
+ {
+ "url" : "/sale",
+ "state": "ticket.card.sale",
+ "component": "vn-ticket-sale",
+ "params": {
+ "ticket": "$ctrl.ticket"
+ },
+ "menu": {
+ "description": "Sale",
+ "icon": "icon-lines"
+ }
+ },
{
"url": "/observation",
"state": "ticket.card.observation",
@@ -141,7 +153,8 @@
"menu": {
"description": "Tracking",
"icon": "remove_red_eye"
- }
+ },
+ "acl": ["production"]
},
{
"url": "/edit",
@@ -159,18 +172,6 @@
"client": "$ctrl.client"
}
},
- {
- "url" : "/sale",
- "state": "ticket.card.sale",
- "component": "vn-ticket-sale",
- "params": {
- "ticket": "$ctrl.ticket"
- },
- "menu": {
- "description": "Sale",
- "icon": "icon-lines"
- }
- },
{
"url" : "/sale-checked",
"state": "ticket.card.saleChecked",
diff --git a/client/ticket/src/data/data.js b/client/ticket/src/data/data.js
index df67f2920..f2492fc6e 100644
--- a/client/ticket/src/data/data.js
+++ b/client/ticket/src/data/data.js
@@ -7,17 +7,21 @@ class Controller {
}
set ticket(data) {
+ if (!data) return;
+
this.data = Object.assign({}, data);
}
- onSubmit() {
- //post data
- alert('Data saved');
- console.log(this.data);
+ registerChild(child) {
+ this.child = child;
}
onStepChange(state) {
- return true;
+ return this.child.onStepChange(state);
+ }
+
+ onSubmit() {
+ this.child.onSubmit();
}
}
diff --git a/client/ticket/src/data/step-one/locale/es.yml b/client/ticket/src/data/step-one/locale/es.yml
new file mode 100644
index 000000000..fadbc2f54
--- /dev/null
+++ b/client/ticket/src/data/step-one/locale/es.yml
@@ -0,0 +1 @@
+There's no available agency for this landing date: No hay ninguna agencia disponible para la fecha de envío seleccionada
\ No newline at end of file
diff --git a/client/ticket/src/data/step-one/step-one.html b/client/ticket/src/data/step-one/step-one.html
index e5b8b2ce3..8db25398d 100644
--- a/client/ticket/src/data/step-one/step-one.html
+++ b/client/ticket/src/data/step-one/step-one.html
@@ -1,6 +1,6 @@