diff --git a/front/core/components/crud-model/crud-model.js b/front/core/components/crud-model/crud-model.js index 4f3058305..0839881ab 100644 --- a/front/core/components/crud-model/crud-model.js +++ b/front/core/components/crud-model/crud-model.js @@ -207,8 +207,8 @@ export default class CrudModel extends ModelProxy { sendRequest(filter, append) { this.cancelRequest(); this.canceler = this.$q.defer(); - this.isRefreshing = !append; this.isPaging = append; + if (!append) this.status = 'loading'; let params = Object.assign( {filter}, @@ -221,9 +221,8 @@ export default class CrudModel extends ModelProxy { return this.$http.get(this._url, options).then( json => this.onRemoteDone(json, filter, append), - json => this.onRemoteError(json) + json => this.onRemoteError(json, append) ).finally(() => { - this.isRefreshing = false; this.isPaging = false; }); } @@ -243,7 +242,12 @@ export default class CrudModel extends ModelProxy { this.onRequestEnd(); } - onRemoteError(err) { + onRemoteError(err, append) { + if (!append) { + this.clear(); + this.status = 'error'; + } + this.onRequestEnd(); throw err; } diff --git a/front/core/components/data-viewer/index.html b/front/core/components/data-viewer/index.html index 1a5a76ef8..dd696fda3 100644 --- a/front/core/components/data-viewer/index.html +++ b/front/core/components/data-viewer/index.html @@ -1,22 +1,28 @@ -
+
+ model="$ctrl.model" + pad-medium-top>
+ enable="::true"> Enter a new search + + Ups! It seems there was an error + diff --git a/front/core/components/data-viewer/index.js b/front/core/components/data-viewer/index.js index 2ec61ee5a..1f967d94b 100644 --- a/front/core/components/data-viewer/index.js +++ b/front/core/components/data-viewer/index.js @@ -2,28 +2,22 @@ import ngModule from '../../module'; import './style.scss'; export default class DataViewer { - get computedData() { - return this.data || (this.model && this.model.data); - } - - get computedLoading() { - return this.isLoading || (this.model && this.model.isRefreshing); - } - - get hasData() { - let data = this.computedData; - return data && data.length; + get isReady() { + return this.status == 'ready'; } get status() { - if (this.hasData) - return null; - if (this.computedLoading) + if (this.model) + return this.model.status; + + if (this.isLoading) return 'loading'; - if (this.computedData) - return 'empty'; - else + if (!this.data) return 'clear'; + if (this.data.length) + return 'ready'; + else + return 'empty'; } } diff --git a/front/core/components/index.js b/front/core/components/index.js index 54f9f18f2..ff063ad24 100644 --- a/front/core/components/index.js +++ b/front/core/components/index.js @@ -26,7 +26,6 @@ import './card/card'; import './float-button/float-button'; import './step-control/step-control'; import './label-value/label-value'; -import './paging/paging'; import './pagination/pagination'; import './searchbar/searchbar'; import './scroll-up/scroll-up'; diff --git a/front/core/components/model-proxy/model-proxy.js b/front/core/components/model-proxy/model-proxy.js index 342841bda..1eaf749d5 100644 --- a/front/core/components/model-proxy/model-proxy.js +++ b/front/core/components/model-proxy/model-proxy.js @@ -57,6 +57,7 @@ export default class ModelProxy extends DataModel { constructor($element, $scope) { super($element, $scope); this.resetChanges(); + this.status = 'clear'; } get orgData() { @@ -90,6 +91,14 @@ export default class ModelProxy extends DataModel { set data(value) { this._data = value; + + if (value == null) + this.status = 'clear'; + else if (value.length) + this.status = 'ready'; + else + this.status = 'empty'; + this.emit('dataChange'); this.emit('dataUpdate'); } @@ -109,8 +118,12 @@ export default class ModelProxy extends DataModel { this.removed.push(item); this.isChanged = true; + if (!this.data.length) + this.status = 'empty'; + this.emit('rowRemove', index); this.emit('dataUpdate'); + if (this.autoSave) this.save(); } @@ -131,8 +144,11 @@ export default class ModelProxy extends DataModel { this.data.push(newRow); this.isChanged = true; + this.status = 'ready'; + this.emit('rowInsert', index); this.emit('dataUpdate'); + return index; } @@ -322,10 +338,10 @@ export class Paginable { } /** - * @type {Boolean} Whether the model is refreshing. + * @type {ready|loading|clear|empty|error} The current model status. */ - get isRefreshing() { - return false; + get status() { + return null; } /** diff --git a/front/core/components/pagination/pagination.html b/front/core/components/pagination/pagination.html index 9da15c002..5bc1b67f6 100644 --- a/front/core/components/pagination/pagination.html +++ b/front/core/components/pagination/pagination.html @@ -1,13 +1,12 @@ -
+
+ ng-if="$ctrl.model.isPaging" + enable="::true">
\ No newline at end of file diff --git a/front/core/components/pagination/style.scss b/front/core/components/pagination/style.scss index 0cacb53e3..2610bc502 100644 --- a/front/core/components/pagination/style.scss +++ b/front/core/components/pagination/style.scss @@ -3,7 +3,8 @@ vn-pagination { display: block; text-align: center; - & > div > vn-icon-button { + & > div > vn-icon-button { font-size: 2em; + padding: 0; } } \ No newline at end of file diff --git a/front/core/components/paging/paging.html b/front/core/components/paging/paging.html deleted file mode 100644 index 6e71f321d..000000000 --- a/front/core/components/paging/paging.html +++ /dev/null @@ -1,11 +0,0 @@ - - \ No newline at end of file diff --git a/front/core/components/paging/paging.js b/front/core/components/paging/paging.js deleted file mode 100644 index 850b9c722..000000000 --- a/front/core/components/paging/paging.js +++ /dev/null @@ -1,58 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; - -export default class Paging { - get numPages() { - return Math.ceil(this.numItems / this.numPerPage); - } - - constructor($http, $scope) { - this.$http = $http; - this.$scope = $scope; - this.where = this.filter; - this.numPerPage = null; - this.numItems = 0; - $scope.$watch('$ctrl.index.model.length', () => this.onModelUpdated()); - } - - $onChanges(changes) { - if (!this.index) return; - this.numPerPage = this.index.filter.size; - this.currentPage = this.index.filter.page; - if (changes.total) - this.numItems = changes.total.currentValue; - } - - onModelUpdated() { - let index = this.index; - let filter = index.filter; - - if (filter.page >= this.numPages && index.model.length >= this.numPerPage) - this.numItems = filter.page * filter.size + 1; - } - - onPageChange(page) { - this.index.filter.page = page; - if (typeof this.pageChange === 'undefined') { - this.index.accept(); - } else { - this.pageChange(); - } - } - $doCheck() { - if (this.index && this.index.filter && this.index.filter.page && this.index.filter.page != this.currentPage) { - this.currentPage = this.index.filter.page; - } - } -} -Paging.$inject = ['$http', '$scope']; - -ngModule.component('vnPaging', { - template: require('./paging.html'), - bindings: { - index: '<', - pageChange: '&?', - total: '<' - }, - controller: Paging -}); diff --git a/front/core/components/paging/paging.spec.js b/front/core/components/paging/paging.spec.js deleted file mode 100644 index 9f6023ff6..000000000 --- a/front/core/components/paging/paging.spec.js +++ /dev/null @@ -1,65 +0,0 @@ -import './paging.js'; - -describe('Component vnPaging', () => { - let $scope; - let controller; - - beforeEach(angular.mock.module('vnCore', $translateProvider => { - $translateProvider.translations('en', {}); - })); - - beforeEach(angular.mock.inject(($componentController, $rootScope) => { - $scope = $rootScope.$new(); - controller = $componentController('vnPaging', {$scope}); - })); - - describe('$onChanges()', () => { - it(`should define numberPage and currentPage based on index.filter properties`, () => { - controller.index = {filter: {size: 'something', page: 'something else'}}; - controller.$onChanges({index: 'simpleChange', currentValue: 'current value', previousValue: 'previous value'}); - - expect(controller.numPerPage).toBe(controller.index.filter.size); - expect(controller.currentPage).toEqual(controller.index.filter.page); - }); - - it(`should define numItems based on changes.total.currentValue`, () => { - controller.index = {filter: {size: 'something', page: 'something else'}}; - controller.$onChanges({total: {currentValue: 'current value'}}); - - expect(controller.numItems).toEqual('current value'); - }); - }); - - describe('onModelUpdated()', () => { - it(`should define controllers numItems as the result of page times size plus one`, () => { - controller.numPerPage = 2; - controller.index = { - filter: {size: 10, page: 10}, - model: ['one mother..', 'another model..', 'last model..'] - }; - controller.onModelUpdated(); - - expect(controller.numItems).toBe(101); - }); - }); - - describe('onPageChange()', () => { - it(`should call accept() since pageChange property is undefined`, () => { - controller.index = {accept: () => {}, filter: {page: 0}}; - spyOn(controller.index, 'accept'); - controller.onPageChange(100); - - expect(controller.index.accept).toHaveBeenCalledWith(); - }); - - it(`should call pageChange() since pageChange property isn't undefined`, () => { - controller.index = {accept: () => {}, filter: {page: 0}}; - controller.pageChange = true; - spyOn(controller, 'pageChange'); - controller.onPageChange(100); - - expect(controller.pageChange).toHaveBeenCalledWith(); - }); - }); -}); - diff --git a/front/core/components/paging/style.scss b/front/core/components/paging/style.scss deleted file mode 100644 index e88202e49..000000000 --- a/front/core/components/paging/style.scss +++ /dev/null @@ -1,40 +0,0 @@ -@import "variables"; - -vn-paging { - display: block; - text-align: center; - - ul { - box-shadow: 0 0 .4em $color-shadow; - background-color: #fff; - display: inline-block; - margin: 20px 0; - border-radius: .1em; - padding: 0; - } - li { - display: inline; - - &:first-child > a, - &:first-child > span { - margin-left: 0; - } - &.active > a { - background: $color-active; - color: #fff; - } - & > a, - & > span { - position: relative; - float: left; - padding: 6px 12px; - margin-left: -1px; - line-height: 1.42857143; - color: inherit; - text-decoration: none; - } - &:not(.active) > a:hover { - background-color: #ddd; - } - } -} diff --git a/front/core/components/popover/popover.js b/front/core/components/popover/popover.js index 8babe867d..be6546246 100644 --- a/front/core/components/popover/popover.js +++ b/front/core/components/popover/popover.js @@ -180,11 +180,8 @@ export default class Popover extends Component { onDocKeyDown(event) { if (event.defaultPrevented) return; - - if (event.keyCode == 27) { // Esc - event.preventDefault(); + if (event.code == 'Escape') this.hide(); - } } onMouseDown(event) { diff --git a/front/core/locale/es.yml b/front/core/locale/es.yml index 01a17aa48..1fcd12b98 100644 --- a/front/core/locale/es.yml +++ b/front/core/locale/es.yml @@ -24,6 +24,9 @@ Value should be %s characters long: El valor debe ser de %s carácteres de longi Value should have a length between %s and %s: El valor debe tener una longitud de entre %s y %s Value should have at least %s characters: El valor debe tener al menos %s carácteres Value should have at most %s characters: El valor debe tener un máximo de %s carácteres +Enter a new search: Introduce una nueva búsqueda +No results: Sin resultados +Ups! It seems there was an error: ¡Vaya! Parece que ha habido un error General search: Busqueda general January: Enero February: Febrero diff --git a/front/core/vendor.js b/front/core/vendor.js index 44d041ebe..ac4364feb 100644 --- a/front/core/vendor.js +++ b/front/core/vendor.js @@ -7,10 +7,6 @@ import 'angular-translate-loader-partial'; import '@uirouter/angularjs'; import 'mg-crud'; import 'oclazyload'; -/* -import 'angular-material'; -import 'angular-material/modules/scss/angular-material.scss'; -*/ import 'angular-moment'; export const ngDeps = [ @@ -18,7 +14,6 @@ export const ngDeps = [ 'ui.router', 'mgCrud', 'oc.lazyLoad', - // 'ngMaterial', 'angularMoment' ]; diff --git a/front/salix/locale/es.yml b/front/salix/locale/es.yml index 2056210e4..898728363 100644 --- a/front/salix/locale/es.yml +++ b/front/salix/locale/es.yml @@ -14,8 +14,6 @@ Push on applications menu: Para abrir un módulo pulsa en el menú de aplicacion Return to module index: Volver a la página principal del módulo What is new: Novedades de la versión Settings: Ajustes -Enter a new search: Introduce una nueva búsqueda -No results: Sin resultados # Actions diff --git a/modules/client/front/credit/index/locale/es.yml b/modules/client/front/credit/index/locale/es.yml index b4b5940cf..a15a1085f 100644 --- a/modules/client/front/credit/index/locale/es.yml +++ b/modules/client/front/credit/index/locale/es.yml @@ -1,3 +1,2 @@ Since : Desde -Employee : Empleado -No results: Sin resultados \ No newline at end of file +Employee : Empleado \ No newline at end of file diff --git a/modules/client/front/recovery/index/locale/es.yml b/modules/client/front/recovery/index/locale/es.yml index 5b21429f4..0cb5b3ed6 100644 --- a/modules/client/front/recovery/index/locale/es.yml +++ b/modules/client/front/recovery/index/locale/es.yml @@ -1,5 +1,4 @@ Since: Desde Employee: Empleado -No results: Sin resultados To: Hasta Finish that recovery period: Terminar el recobro \ No newline at end of file diff --git a/modules/item/front/locale/es.yml b/modules/item/front/locale/es.yml index c922656c4..c071d2c69 100644 --- a/modules/item/front/locale/es.yml +++ b/modules/item/front/locale/es.yml @@ -33,8 +33,6 @@ Remove niche: Quitar nicho Add barcode: Añadir código de barras Remove barcode: Quitar código de barras Buyer: Comprador -No results: Sin resultados -Enter a new search: Introduce una nueva búsqueda Tag: Etiqueta Worker: Trabajador Available: Disponible diff --git a/modules/order/front/catalog/index.js b/modules/order/front/catalog/index.js index a5d7ee968..758c56f0e 100644 --- a/modules/order/front/catalog/index.js +++ b/modules/order/front/catalog/index.js @@ -131,7 +131,7 @@ class Controller { } get isRefreshing() { - return this.$scope.model && this.$scope.model.isRefreshing; + return this.$scope.model && this.$scope.model.status == 'loading'; } } diff --git a/modules/order/front/locale/es.yml b/modules/order/front/locale/es.yml index 943606a47..0ada37bfd 100644 --- a/modules/order/front/locale/es.yml +++ b/modules/order/front/locale/es.yml @@ -3,8 +3,6 @@ Catalog: Catálogo from: desde results: resultados More than: Más de -No results: Sin resultados -Enter a new search: Introduce una nueva búsqueda Plant: Planta Flower: Flor Handmade: Confección