Route refactor
gitea/salix/pipeline/head This commit looks good Details

This commit is contained in:
Joan Sanchez 2020-03-17 15:24:55 +01:00
parent 526a92fd32
commit 3cb98eaf5f
9 changed files with 20 additions and 61 deletions

View File

@ -1,19 +1,13 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
class Controller { class Controller extends Section {
constructor($scope, vnApp, $translate) {
this.$ = $scope;
this.vnApp = vnApp;
this.$translate = $translate;
}
onSubmit() { onSubmit() {
this.$.watcher.submit().then(() => { this.$.watcher.submit().then(() =>
this.card.reload(); this.card.reload()
}); );
} }
} }
Controller.$inject = ['$scope', 'vnApp', '$translate'];
ngModule.component('vnRouteBasicData', { ngModule.component('vnRouteBasicData', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,18 +1,13 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller { export default class Controller extends Section {
constructor($scope, $state) {
this.$scope = $scope;
this.$state = $state;
}
onSubmit() { onSubmit() {
this.$scope.watcher.submit().then( this.$.watcher.submit().then(
res => this.$state.go('route.card.summary', {id: res.data.id}) res => this.$state.go('route.card.summary', {id: res.data.id})
); );
} }
} }
Controller.$inject = ['$scope', '$state'];
ngModule.component('vnRouteCreate', { ngModule.component('vnRouteCreate', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -3,11 +3,8 @@ import Component from 'core/lib/component';
import './style.scss'; import './style.scss';
class Controller extends Component { class Controller extends Component {
constructor($element, $scope, $http, $timeout, $q) { constructor($element, $) {
super($element, $scope); super($element, $);
this.$timeout = $timeout;
this.$http = $http;
this.$q = $q;
this.route = null; this.route = null;
this._quicklinks = {}; this._quicklinks = {};
} }
@ -118,7 +115,6 @@ class Controller extends Component {
}); });
} }
} }
Controller.$inject = ['$element', '$scope', '$http', '$timeout', '$q'];
ngModule.component('vnRouteDescriptorPopover', { ngModule.component('vnRouteDescriptorPopover', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -2,8 +2,8 @@ import ngModule from '../module';
import Component from 'core/lib/component'; import Component from 'core/lib/component';
class Controller extends Component { class Controller extends Component {
constructor($element, $scope, $httpParamSerializer) { constructor($element, $, $httpParamSerializer) {
super($element, $scope); super($element, $);
this.$httpParamSerializer = $httpParamSerializer; this.$httpParamSerializer = $httpParamSerializer;
this.moreOptions = [ this.moreOptions = [

View File

@ -1,11 +1,7 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
export default class Controller { export default class Controller extends Section {
constructor($scope, vnToken) {
this.$ = $scope;
this.accessToken = vnToken.token;
}
showWorkerDescriptor(event, workerFk) { showWorkerDescriptor(event, workerFk) {
if (event.defaultPrevented) return; if (event.defaultPrevented) return;
event.preventDefault(); event.preventDefault();
@ -32,7 +28,6 @@ export default class Controller {
this.$.model.clear(); this.$.model.clear();
} }
} }
Controller.$inject = ['$scope', 'vnToken'];
ngModule.component('vnRouteIndex', { ngModule.component('vnRouteIndex', {
template: require('./index.html'), template: require('./index.html'),

View File

@ -1,15 +1,7 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
class Controller {
constructor($scope, $stateParams) {
this.$scope = $scope;
this.$stateParams = $stateParams;
}
}
Controller.$inject = ['$scope', '$stateParams'];
ngModule.component('vnRouteLog', { ngModule.component('vnRouteLog', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Section,
}); });

View File

@ -1,12 +1,8 @@
import ngModule from '../module'; import ngModule from '../module';
import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller { class Controller extends Section {
constructor($scope, $http) {
this.$http = $http;
this.$ = $scope;
}
set route(value) { set route(value) {
this._route = value; this._route = value;
if (value && value.id) if (value && value.id)
@ -47,8 +43,6 @@ class Controller {
} }
} }
Controller.$inject = ['$scope', '$http'];
ngModule.component('vnRouteSummary', { ngModule.component('vnRouteSummary', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,

View File

@ -9,7 +9,8 @@ describe('Route', () => {
beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => { beforeEach(angular.mock.inject(($componentController, _$httpBackend_) => {
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
controller = $componentController('vnRouteSummary'); const $element = angular.element('<vn-route-summary></vn-route-summary>');
controller = $componentController('vnRouteSummary', {$element});
controller.route = {id: 1}; controller.route = {id: 1};
})); }));

View File

@ -3,12 +3,6 @@ import Section from 'salix/components/section';
import './style.scss'; import './style.scss';
class Controller extends Section { class Controller extends Section {
constructor($element, $scope, $filter) {
super($element, $scope);
this.$filter = $filter;
}
get route() { get route() {
return this._route; return this._route;
} }
@ -200,8 +194,6 @@ class Controller extends Section {
} }
} }
Controller.$inject = ['$element', '$scope', '$filter'];
ngModule.component('vnRouteTickets', { ngModule.component('vnRouteTickets', {
template: require('./index.html'), template: require('./index.html'),
controller: Controller, controller: Controller,