Merge branch 'dev' of http://git.verdnatura.es/salix into dev

This commit is contained in:
Carlos Jimenez 2018-01-09 13:53:54 +01:00
commit 268162c3f7
6 changed files with 15 additions and 10 deletions

View File

@ -1,7 +1,7 @@
import {module} from '../module'; import {module} from '../module';
const isFullEmpty = item => { const isFullEmpty = item => {
return (!item && item !== 0 && item !== false) || (typeof item === 'object' && !Object.keys(item).length); return (item === null || item === undefined) || (typeof item === 'object' && !Object.keys(item).length);
}; };
export default isFullEmpty; export default isFullEmpty;

View File

@ -12,12 +12,13 @@ import isFullEmpty from '../lib/fullEmpty';
* properties are provided. * properties are provided.
*/ */
export default class Watcher extends Component { export default class Watcher extends Component {
constructor($element, $scope, $state, $transitions, $http, vnApp, $translate) { constructor($element, $scope, $state, $transitions, $http, vnApp, $translate, $attrs) {
super($element); super($element);
this.$scope = $scope; this.$scope = $scope;
this.$state = $state; this.$state = $state;
this.$http = $http; this.$http = $http;
this.$translate = $translate; this.$translate = $translate;
this.$attrs = $attrs;
this.vnApp = vnApp; this.vnApp = vnApp;
this.state = null; this.state = null;
@ -93,10 +94,10 @@ export default class Watcher extends Component {
(resolve, reject) => this.noChanges(reject) (resolve, reject) => this.noChanges(reject)
); );
} }
let changedData = getModifiedData(this.data, this.orgData); let changedData = (this.$attrs.save && this.$attrs.save.toLowerCase() === 'post') ? this.copyInNewObject(this.data) : getModifiedData(this.data, this.orgData);
if (this.save) { if (this.save) {
this.save.model = this.copyInNewObject(changedData); this.save.model = changedData; // this.copyInNewObject(changedData);
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
this.save.accept().then( this.save.accept().then(
json => this.writeData({data: json}, resolve), json => this.writeData({data: json}, resolve),
@ -194,7 +195,7 @@ export default class Watcher extends Component {
} }
} }
Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate']; Watcher.$inject = ['$element', '$scope', '$state', '$transitions', '$http', 'vnApp', '$translate', '$attrs'];
module.component('vnWatcher', { module.component('vnWatcher', {
template: require('./watcher.html'), template: require('./watcher.html'),

View File

@ -11,6 +11,7 @@ describe('Component vnWatcher', () => {
let vnApp; let vnApp;
let $translate; let $translate;
let controller; let controller;
let $attrs;
beforeEach(() => { beforeEach(() => {
angular.mock.module('client'); angular.mock.module('client');
@ -25,7 +26,10 @@ describe('Component vnWatcher', () => {
$transitions = _$transitions_; $transitions = _$transitions_;
$httpBackend = _$httpBackend_; $httpBackend = _$httpBackend_;
$translate = _$translate_; $translate = _$translate_;
controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate}); $attrs = {
save: "patch"
};
controller = $componentController('vnWatcher', {$scope, $element, $state, vnApp, $transitions, $httpBackend, $translate, $attrs});
})); }));
describe('$onInit()', () => { describe('$onInit()', () => {

View File

@ -21,7 +21,7 @@
"taxGroup": { "taxGroup": {
"type": "belongsTo", "type": "belongsTo",
"model": "TaxGroup", "model": "TaxGroup",
"foreignKey": "taxGroupFk" "foreignKey": "taxClassFk"
}, },
"taxCode": { "taxCode": {
"type": "belongsTo", "type": "belongsTo",

View File

@ -1,9 +1,9 @@
{ {
"name": "TaxGroup", "name": "TaxClass",
"base": "VnModel", "base": "VnModel",
"options": { "options": {
"mysql": { "mysql": {
"table": "taxGroup", "table": "taxClass",
"database": "vn" "database": "vn"
} }
}, },

View File

@ -42,7 +42,7 @@
"Intrastat": { "Intrastat": {
"dataSource": "vn" "dataSource": "vn"
}, },
"TaxGroup": { "TaxClass": {
"dataSource": "vn" "dataSource": "vn"
}, },
"TaxCode": { "TaxCode": {