Merge fixes

This commit is contained in:
Juan Ferrer 2020-03-16 18:54:22 +01:00
parent 27eaa328e5
commit 176e38c144
7 changed files with 17 additions and 43 deletions

View File

@ -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;

View File

@ -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', {

View File

@ -22,7 +22,7 @@
</vn-tr>
</vn-thead>
<vn-tbody>
<a ng-repeat="travel in travels"
<a ng-repeat="travel in model.data"
class="clickable vn-tr search-result"
ui-sref="travel.card.summary({id: {{::travel.id}}})">
<vn-td number>{{::travel.id}}</vn-td>

View File

@ -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'),

View File

@ -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('<div></div>');
controller = $componentController('vnTravelIndex', {$element, $scope});
controller.$.summary = {show: jasmine.createSpy('show')};
}));

View File

@ -52,7 +52,7 @@
</vn-popup>
<vn-confirm
vn-id="clone"
on-accept="$ctrl.onCloneAccept()"
on-accept="$ctrl.onCloneAccept($data)"
question="Do you want to clone this zone?"
message="All it's properties will be copied">
</vn-confirm>

View File

@ -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