Correciones varias

This commit is contained in:
Juan Ferrer Toribio 2017-03-07 17:11:56 +01:00
parent 398ede37d0
commit 7059eadfc7
13 changed files with 43 additions and 51 deletions

View File

@ -7,3 +7,5 @@ rules:
max-len: 0 max-len: 0
eqeqeq: 0 eqeqeq: 0
operator-linebreak: 0 operator-linebreak: 0
radix: 0
guard-for-in: 0

View File

@ -10,7 +10,7 @@ class Controller {
}; };
} }
onSubmit() { onSubmit() {
this.$scope.watcher.submit().then ( this.$scope.watcher.submit().then(
() => this.$state.go('clientCard.addresses') () => this.$state.go('clientCard.addresses')
); );
} }
@ -22,5 +22,5 @@ export const COMPONENT = {
template: require('./index.html'), template: require('./index.html'),
controllerAs: 'addressData', controllerAs: 'addressData',
controller: Controller controller: Controller
} };
module.component(NAME, COMPONENT); module.component(NAME, COMPONENT);

View File

@ -6,7 +6,7 @@
data="addressData.address" data="addressData.address"
form="form"> form="form">
</vn-watcher> </vn-watcher>
<form name="form" ng-submit="addressData.onSubmit()" pad-medium> <form name="form" ng-submit="watcher.submitBack()" pad-medium>
<vn-card> <vn-card>
<vn-vertical pad-large> <vn-vertical pad-large>
<vn-title>Consignatario</vn-title> <vn-title>Consignatario</vn-title>

View File

@ -1,20 +1,13 @@
import {module} from '../module'; import {module} from '../module';
class Controller { class Controller {
constructor($scope, $window, $stateParams) { constructor($stateParams) {
this.$scope = $scope;
this.$window = $window;
this.address = { this.address = {
id: $stateParams.addressId id: $stateParams.addressId
}; };
} }
onSubmit() {
this.$scope.watcher.submit().then (
() => this.$window.history.back()
);
}
} }
Controller.$inject = ['$scope', '$window', '$stateParams']; Controller.$inject = ['$stateParams'];
export const NAME = 'vnAddressEdit'; export const NAME = 'vnAddressEdit';
export const COMPONENT = { export const COMPONENT = {

View File

@ -22,7 +22,7 @@
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Crear y continuar"></vn-submit> <vn-submit label="Crear y continuar"></vn-submit>
<vn-button label="Crear" ng-click="$ctrl.onCreate()"></vn-button> <vn-button label="Crear" ng-click="watcher.submitBack()"></vn-button>
</vn-button-bar> </vn-button-bar>
</div> </div>
</form> </form>

View File

@ -1,10 +1,9 @@
import {module} from '../module'; import {module} from '../module';
class Controller { class Controller {
constructor($scope, $state, $window) { constructor($scope, $state) {
this.$scope = $scope; this.$scope = $scope;
this.$state = $state; this.$state = $state;
this.$window = $window;
this.client = { this.client = {
active: true active: true
}; };
@ -14,13 +13,8 @@ class Controller {
json => this.$state.go('clientCard.basicData', {id: json.data.id}) json => this.$state.go('clientCard.basicData', {id: json.data.id})
); );
} }
onCreate() {
this.$scope.watcher.submit().then(
() => this.$window.history.back()
);
}
} }
Controller.$inject = ['$scope', '$state', '$window']; Controller.$inject = ['$scope', '$state'];
export const component = { export const component = {
template: require('./index.html'), template: require('./index.html'),

View File

@ -46,11 +46,27 @@ export default class Watcher extends Component {
); );
}); });
} }
/**
* Submits the data and goes back in the history.
*/
submitBack() {
this.submit().then(
() => this.window.history.back()
);
}
/**
* Submits the data to the server.
*
* @return {Promise} The http request promise
*/
submit() { submit() {
if (this.form && !this.form.$valid) { if (this.form) {
return new Promise( this.form.$setSubmitted();
(resolve, reject) => this.invalidForm(reject)
); if (!this.form.$valid)
return new Promise(
(resolve, reject) => this.invalidForm(reject)
);
} }
if (!this.dataChanged()) { if (!this.dataChanged()) {
return new Promise( return new Promise(

View File

@ -87,8 +87,7 @@ gulp.task('webpack-dev-server', ['spliting'], function(callback) {
chunks: false, chunks: false,
chunkModules: false chunkModules: false
} }
}) }).listen(8081, '0.0.0.0', function(err) {
.listen(8081, '0.0.0.0', function(err) {
if (err) throw new gutil.PluginError('webpack-dev-server', err); if (err) throw new gutil.PluginError('webpack-dev-server', err);
}); });
}); });
@ -100,14 +99,13 @@ var localeFiles = `./${srcDir}/**/locale/*.json`;
gulp.task('locales', function() { gulp.task('locales', function() {
var streams = []; var streams = [];
for (var mod in modules) { for (var mod in modules)
for (var lang of langs) { for (var lang of langs) {
var localeFiles = `./client/${mod}/**/locale/${lang}.json`; var localeFiles = `./client/${mod}/**/locale/${lang}.json`;
streams.push(gulp.src(localeFiles) streams.push(gulp.src(localeFiles)
.pipe(extend(`${lang}.json`)) .pipe(extend(`${lang}.json`))
.pipe(gulp.dest(`${buildDir}/locale/${mod}`))); .pipe(gulp.dest(`${buildDir}/locale/${mod}`)));
} }
}
return merge(streams); return merge(streams);
}); });

View File

@ -38,6 +38,7 @@
"gulp-extend": "^0.2.0", "gulp-extend": "^0.2.0",
"gulp-util": "^3.0.7", "gulp-util": "^3.0.7",
"gulp-wrap": "^0.13.0", "gulp-wrap": "^0.13.0",
"gulp-yaml": "^1.0.1",
"html-loader": "^0.4.4", "html-loader": "^0.4.4",
"merge-stream": "^1.0.1", "merge-stream": "^1.0.1",
"node-sass": "^3.11.0", "node-sass": "^3.11.0",

View File

@ -6,7 +6,6 @@ var express=require('express');
var path = require('path'); var path = require('path');
var app = module.exports = loopback(); var app = module.exports = loopback();
// modificado // modificado
app.set('view engine', 'ejs'); app.set('view engine', 'ejs');
app.set('views',path.join(__dirname,'../client')); app.set('views',path.join(__dirname,'../client'));
@ -14,10 +13,7 @@ app.use(loopback.static(path.resolve(__dirname, '../client')));
app.set('applications',require("./application.json")); app.set('applications',require("./application.json"));
// fin // fin
app.start = function() { app.start = function() {
// start the web server
return app.listen(function() { return app.listen(function() {
app.emit('started'); app.emit('started');
var baseUrl = app.get('url').replace(/\/$/, ''); var baseUrl = app.get('url').replace(/\/$/, '');
@ -29,12 +25,8 @@ app.start = function() {
}); });
}; };
// Bootstrap the application, configure models, datasources and middleware.
// Sub-apps like REST API are mounted via boot scripts.
boot(app, __dirname, function(err) { boot(app, __dirname, function(err) {
if (err) throw err; if (err) throw err;
// start the server if `$ node server.js`
if (require.main === module) if (require.main === module)
app.start(); app.start();
}); });

View File

@ -1,6 +1,4 @@
'use strict';
module.exports = function enableAuthentication(server) { module.exports = function enableAuthentication(server) {
// enable authentication //server.enableAuth();
// server.enableAuth();
}; };

View File

@ -1,8 +1,6 @@
'use strict';
module.exports = function(server) { module.exports = function(server) {
// Install a `/` route that returns server status var router = server.loopback.Router();
var router = server.loopback.Router(); router.get('/status', server.loopback.status());
router.get('/status', server.loopback.status()); server.use(router);
server.use(router);
}; };

View File

@ -1,11 +1,11 @@
export const $module = () => { export const $module = () => {
return new Promise(resolve => { return new Promise(resolve => {
require.ensure([], () => { require.ensure([], () => {
require('$module'); require('$module');
resolve('$module'); resolve('$module');
}, '$module'); }, '$module');
}); });
}; };
core.splitingRegister.register('$module', $module); core.splitingRegister.register('$module', $module);