From 9f5395c8043e129f3dc6551d54c31e7ff038a471 Mon Sep 17 00:00:00 2001 From: Gerard Date: Thu, 13 Dec 2018 12:18:57 +0100 Subject: [PATCH] #801 Deprecar grid antiguo --- .../column-header/column-header.html | 23 ----- .../components/column-header/column-header.js | 56 ----------- .../column-header/column-header.spec.js | 94 ------------------- .../components/grid-header/grid-header.html | 1 - .../src/components/grid-header/grid-header.js | 27 ------ .../grid-header/grid-header.spec.js | 43 --------- .../src/components/grid-header/style.scss | 32 ------- client/core/src/components/grid/grid.js | 1 - client/core/src/components/grid/style.scss | 46 --------- client/core/src/components/index.js | 3 - 10 files changed, 326 deletions(-) delete mode 100644 client/core/src/components/column-header/column-header.html delete mode 100644 client/core/src/components/column-header/column-header.js delete mode 100644 client/core/src/components/column-header/column-header.spec.js delete mode 100644 client/core/src/components/grid-header/grid-header.html delete mode 100644 client/core/src/components/grid-header/grid-header.js delete mode 100644 client/core/src/components/grid-header/grid-header.spec.js delete mode 100644 client/core/src/components/grid-header/style.scss delete mode 100644 client/core/src/components/grid/grid.js delete mode 100644 client/core/src/components/grid/style.scss diff --git a/client/core/src/components/column-header/column-header.html b/client/core/src/components/column-header/column-header.html deleted file mode 100644 index df0a4caee..000000000 --- a/client/core/src/components/column-header/column-header.html +++ /dev/null @@ -1,23 +0,0 @@ -
- - - {{::$ctrl.text}} - - - - - - - -
\ No newline at end of file diff --git a/client/core/src/components/column-header/column-header.js b/client/core/src/components/column-header/column-header.js deleted file mode 100644 index dc32e7e49..000000000 --- a/client/core/src/components/column-header/column-header.js +++ /dev/null @@ -1,56 +0,0 @@ -import ngModule from '../../module'; - -export default class ColumnHeader { - constructor($attrs) { - this.order = undefined; - this.mouseIsOver = false; - this.orderLocked = ($attrs.orderLocked !== undefined); - } - onClick(event, order) { - if (!this.orderLocked) { - if (order) { - this.order = order; - } else if (this.order === 'ASC') { - this.order = 'DESC'; - } else { - this.order = 'ASC'; - } - this.gridHeader.selectColum(this); - } - if (event) - event.preventDefault(); - } - showArrow(type) { - if (this.orderLocked) - return false; - - let showArrow = (this.gridHeader && this.gridHeader.currentColumn && this.gridHeader.currentColumn.field === this.field && this.order === type); - let showOther = (this.gridHeader && this.gridHeader.currentColumn && this.gridHeader.currentColumn.field === this.field && this.order !== type); - if (type === 'DESC' && this.mouseIsOver && !showOther) { - showArrow = true; - } - return showArrow; - } - $onInit() { - if (this.defaultOrder && !this.orderLocked) { - this.order = this.defaultOrder; - this.onClick(); - } - } -} -ColumnHeader.$inject = ['$attrs']; - -ngModule.component('vnColumnHeader', { - template: require('./column-header.html'), - bindings: { - field: '@?', - text: '@?', - className: '@?', - defaultOrder: '@?' - }, - require: { - gridHeader: '^^vnGridHeader' - }, - controller: ColumnHeader, - transclude: true -}); diff --git a/client/core/src/components/column-header/column-header.spec.js b/client/core/src/components/column-header/column-header.spec.js deleted file mode 100644 index 2291094b3..000000000 --- a/client/core/src/components/column-header/column-header.spec.js +++ /dev/null @@ -1,94 +0,0 @@ -import './column-header.js'; - -describe('Component vnColumnHeader', () => { - let $componentController; - let controller; - let $event; - let $attrs; - - beforeEach(() => { - angular.mock.module('client'); - }); - - beforeEach(angular.mock.inject(_$componentController_ => { - $componentController = _$componentController_; - $event = { - preventDefault: () => {} - }; - $attrs = {}; - controller = $componentController('vnColumnHeader', {$attrs}); - })); - - describe('onClick()', () => { - it(`should change the ordenation to DESC (descendant) if it was ASC (ascendant)`, () => { - controller.gridHeader = {selectColum: () => {}}; - controller.order = 'ASC'; - controller.onClick($event); - - expect(controller.order).toEqual('DESC'); - }); - - it(`should change the ordenation to ASC (ascendant) if it wasnt ASC`, () => { - controller.gridHeader = {selectColum: () => {}}; - controller.order = 'DESC or any other value that might occur'; - controller.onClick($event); - - expect(controller.order).toEqual('ASC'); - }); - - it(`should call the selectColum() function after changing a value`, () => { - controller.gridHeader = {selectColum: () => {}}; - controller.order = 'Change me!'; - spyOn(controller.gridHeader, 'selectColum'); - controller.onClick($event); - - expect(controller.gridHeader.selectColum).toHaveBeenCalledWith(controller); - }); - }); - - describe('showArrow()', () => { - it(`should return true when the type is DESC and MouseIsOver`, () => { - controller.gridHeader = {selectColum: () => {}}; - controller.mouseIsOver = true; - let result = controller.showArrow('DESC'); - - expect(result).toEqual(true); - }); - - it(`should return true if many conditions are true`, () => { - controller.gridHeader = {currentColumn: {field: 'fields should be identical'}}; - controller.field = 'fields should be identical'; - controller.order = 'ASC'; - let result = controller.showArrow('ASC'); - - expect(result).toEqual(true); - }); - - it(`should return false without type being DESC or any other values being true`, () => { - controller.gridHeader = {currentColumn: {field: 'fields should be identical'}}; - controller.field = 'I am the controllers field'; - controller.order = 'ASC'; - let result = controller.showArrow('ASC'); - - expect(result).toEqual(false); - }); - }); - - describe('onInit()', () => { - it(`should never call onClick()`, () => { - spyOn(controller, 'onClick'); - controller.$onInit(); - - expect(controller.onClick).not.toHaveBeenCalledWith(); - }); - - it(`should define controllers order as per defaultOrder then call onClick()`, () => { - controller.defaultOrder = 'ASC'; - spyOn(controller, 'onClick'); - controller.$onInit(); - - expect(controller.order).toEqual('ASC'); - expect(controller.onClick).toHaveBeenCalledWith(); - }); - }); -}); diff --git a/client/core/src/components/grid-header/grid-header.html b/client/core/src/components/grid-header/grid-header.html deleted file mode 100644 index 02c0e4101..000000000 --- a/client/core/src/components/grid-header/grid-header.html +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/client/core/src/components/grid-header/grid-header.js b/client/core/src/components/grid-header/grid-header.js deleted file mode 100644 index 41d96602d..000000000 --- a/client/core/src/components/grid-header/grid-header.js +++ /dev/null @@ -1,27 +0,0 @@ -import ngModule from '../../module'; -import './style.scss'; - -export default class GridHeader { - constructor() { - this.currentColumn = undefined; - } - - selectColum(col) { - if (this.currentColumn && this.currentColumn.field != col.field) - this.currentColumn.order = undefined; - - this.currentColumn = col; - if (this.onOrder) - this.onOrder(this.currentColumn); - } - -} - -ngModule.component('vnGridHeader', { - template: require('./grid-header.html'), - transclude: true, - bindings: { - onOrder: '&?' - }, - controller: GridHeader -}); diff --git a/client/core/src/components/grid-header/grid-header.spec.js b/client/core/src/components/grid-header/grid-header.spec.js deleted file mode 100644 index 03294a348..000000000 --- a/client/core/src/components/grid-header/grid-header.spec.js +++ /dev/null @@ -1,43 +0,0 @@ -import './grid-header.js'; - -describe('Component vnGridHeader', () => { - let $componentController; - let controller; - - beforeEach(() => { - angular.mock.module('client'); - }); - - beforeEach(angular.mock.inject(_$componentController_ => { - $componentController = _$componentController_; - controller = $componentController('vnGridHeader', {}); - })); - - describe('selectColum()', () => { - it(`should set controller currentColumn to equal the argument received`, () => { - let col = {columnStuff: 'some stuff'}; - controller.selectColum(col); - - expect(controller.currentColumn).toEqual(col); - }); - - it(`should set controller currentColumn.order to undefined then set currentColumn to equal the argument received`, () => { - controller.currentColumn = {field: 'some field', order: 'ordered'}; - let col = {columnStuff: 'some stuff'}; - controller.selectColum(col); - - expect(controller.currentColumn.order).not.toBeDefined(); - expect(controller.currentColumn).toEqual(col); - }); - - it(`should set controller currentColumn.order to undefined then call onOrder passing currentColumn as argument`, () => { - controller.onOrder = () => {}; - spyOn(controller, 'onOrder'); - let col = {columnStuff: 'some stuff'}; - controller.selectColum(col); - - expect(controller.currentColumn).toEqual(col); - expect(controller.onOrder).toHaveBeenCalledWith(col); - }); - }); -}); diff --git a/client/core/src/components/grid-header/style.scss b/client/core/src/components/grid-header/style.scss deleted file mode 100644 index 9e8fccfab..000000000 --- a/client/core/src/components/grid-header/style.scss +++ /dev/null @@ -1,32 +0,0 @@ -@import "colors"; - -vn-grid-header { - border-bottom: 3px solid $lines; - font-weight: bold; - .orderly{ - text-align: center; - white-space: nowrap; - justify-content: center; - vn-none{ - min-width: 17px; - } - } - vn-icon{ - margin: 0; - padding: 0; - i { - padding: 0; - margin: -2px -17px 0 0; - opacity: 0.2; - cursor: pointer; - } - &.active { - i { - opacity: 1; - } - } - } - [min-none]{ - min-width: 60px; - } -} \ No newline at end of file diff --git a/client/core/src/components/grid/grid.js b/client/core/src/components/grid/grid.js deleted file mode 100644 index 423b033ce..000000000 --- a/client/core/src/components/grid/grid.js +++ /dev/null @@ -1 +0,0 @@ -import './style.scss'; diff --git a/client/core/src/components/grid/style.scss b/client/core/src/components/grid/style.scss deleted file mode 100644 index e2002a894..000000000 --- a/client/core/src/components/grid/style.scss +++ /dev/null @@ -1,46 +0,0 @@ -@import "effects"; - -.vn-grid { - border-collapse: collapse; - width: 100%; - - & > thead, - & > tbody, - & > tfoot { - tr { - td, th { - text-align: left; - padding: 10px; - - &[number]{ - text-align: right; - } - } - } - } - & > thead, & > tbody { - border-bottom: 3px solid $lines; - } - & > tbody > tr { - border-bottom: 1px solid $lines; - transition: background-color 200ms ease-in-out; - - &.clickable { - @extend %clickable; - } - &.success { - background-color: rgba(163, 209, 49, 0.3); - - &:hover { - background-color: rgba(163, 209, 49, 0.5); - } - } - &.warning { - background-color: rgba(247, 147, 30, 0.3); - - &:hover { - background-color: rgba(247, 147, 30, 0.5); - } - } - } -} \ No newline at end of file diff --git a/client/core/src/components/index.js b/client/core/src/components/index.js index b29c8e8ce..99c88b9b8 100644 --- a/client/core/src/components/index.js +++ b/client/core/src/components/index.js @@ -16,9 +16,6 @@ import './popover/popover'; import './autocomplete/autocomplete'; import './drop-down/drop-down'; import './menu/menu'; -import './column-header/column-header'; -import './grid-header/grid-header'; -import './grid/grid'; import './multi-check/multi-check'; import './date-picker/date-picker'; import './button/button';