From 176e38c144983487934529e43e8c4c9ae4d5e469 Mon Sep 17 00:00:00 2001 From: Juan Ferrer Toribio Date: Mon, 16 Mar 2020 18:54:22 +0100 Subject: [PATCH] Merge fixes --- front/core/components/searchbar/searchbar.js | 1 + front/salix/components/section/index.js | 5 +++ modules/travel/front/index/index.html | 2 +- modules/travel/front/index/index.js | 13 ++------ modules/travel/front/index/index.spec.js | 3 +- modules/zone/front/index/index.html | 2 +- modules/zone/front/index/index.js | 34 +++----------------- 7 files changed, 17 insertions(+), 43 deletions(-) diff --git a/front/core/components/searchbar/searchbar.js b/front/core/components/searchbar/searchbar.js index 3ccc2a316..2e43afee2 100644 --- a/front/core/components/searchbar/searchbar.js +++ b/front/core/components/searchbar/searchbar.js @@ -199,6 +199,7 @@ export default class Searchbar extends Component { if (filter) { let oneResult = this.autoState && source != 'state' + && !angular.equals(filter, {}) && data && data.length == 1; diff --git a/front/salix/components/section/index.js b/front/salix/components/section/index.js index a0c7484b4..c34459147 100644 --- a/front/salix/components/section/index.js +++ b/front/salix/components/section/index.js @@ -7,6 +7,11 @@ export default class Section extends Component { super($element, $); this.element.classList.add('vn-section'); } + + stopEvent(event) { + event.preventDefault(); + event.stopImmediatePropagation(); + } } ngModule.vnComponent('vnSection', { diff --git a/modules/travel/front/index/index.html b/modules/travel/front/index/index.html index c819284c2..1cb176d13 100644 --- a/modules/travel/front/index/index.html +++ b/modules/travel/front/index/index.html @@ -22,7 +22,7 @@ - {{::travel.id}} diff --git a/modules/travel/front/index/index.js b/modules/travel/front/index/index.js index f6e7372ef..707f320cb 100644 --- a/modules/travel/front/index/index.js +++ b/modules/travel/front/index/index.js @@ -1,10 +1,7 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -export default class Controller { - constructor($) { - this.$ = $; - } - +export default class Controller extends Section { preview(event, travel) { this.stopEvent(event); this.travelSelected = travel; @@ -27,13 +24,7 @@ export default class Controller { }); this.$state.go('travel.create', {q: params}); } - - stopEvent(event) { - event.preventDefault(); - event.stopImmediatePropagation(); - } } -Controller.$inject = ['$scope']; ngModule.component('vnTravelIndex', { template: require('./index.html'), diff --git a/modules/travel/front/index/index.spec.js b/modules/travel/front/index/index.spec.js index 9f69a466c..e49100d67 100644 --- a/modules/travel/front/index/index.spec.js +++ b/modules/travel/front/index/index.spec.js @@ -13,7 +13,8 @@ describe('Travel Component vnTravelIndex', () => { beforeEach(angular.mock.inject(($componentController, $rootScope) => { let $scope = $rootScope.$new(); - controller = $componentController('vnTravelIndex', {$scope}); + let $element = angular.element('
'); + controller = $componentController('vnTravelIndex', {$element, $scope}); controller.$.summary = {show: jasmine.createSpy('show')}; })); diff --git a/modules/zone/front/index/index.html b/modules/zone/front/index/index.html index d85f53b46..64450e451 100644 --- a/modules/zone/front/index/index.html +++ b/modules/zone/front/index/index.html @@ -52,7 +52,7 @@ diff --git a/modules/zone/front/index/index.js b/modules/zone/front/index/index.js index aa69e30b6..9750a949f 100644 --- a/modules/zone/front/index/index.js +++ b/modules/zone/front/index/index.js @@ -1,50 +1,26 @@ import ngModule from '../module'; +import Section from 'salix/components/section'; -export default class Controller { - constructor($, $http, $state) { - this.$ = $; - this.$http = $http; - this.$state = $state; - } - - /** - * Opens a summary modal - * @param {Object} event - Event object - * @param {Object} zone - Selected item - */ +export default class Controller extends Section { preview(event, zone) { this.stopEvent(event); this.selectedZone = zone; this.$.summary.show(); } - /** - * Clones a zone and all its properties - * @param {Object} event - Event object - * @param {Object} zone - Selected item - */ clone(event, zone) { this.stopEvent(event); - this.selectedZone = zone; - this.$.clone.show(); + this.$.clone.show(zone); } - onCloneAccept() { - return this.$http.post(`Zones/${this.selectedZone.id}/clone`) + onCloneAccept(zone) { + return this.$http.post(`Zones/${zone.id}/clone`) .then(res => { - this.selectedZone = null; this.$state.go('zone.card.basicData', {id: res.data.id}); }); } - - stopEvent(event) { - event.preventDefault(); - event.stopImmediatePropagation(); - } } -Controller.$inject = ['$scope', '$http', '$state']; - ngModule.component('vnZoneIndex', { template: require('./index.html'), controller: Controller