Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix into dev
gitea/salix/dev This commit has test failures Details

This commit is contained in:
Joan Sanchez 2019-09-18 10:35:49 +02:00
commit 86ef44c90d
17 changed files with 47 additions and 13 deletions

View File

@ -7,10 +7,10 @@ import './style.scss';
/**
* Input with option selector.
*
* @property {String} valueField The data field name that should be shown
* @property {String} showFiled The data field name that should be used as value
* @property {String} showFiled The data field name that should be shown
* @property {String} valueField The data field name that should be used as value
* @property {Array} data Static data for the autocomplete
* @property {Object} intialData A initial data to avoid the server request used to get the selection
* @property {Object} intialData An initial data to avoid the server request used to get the selection
* @property {Boolean} multiple Wether to allow multiple selection
* @property {Object} selection Current object selected
*

View File

@ -39,7 +39,7 @@ export default class Watcher extends Component {
throw new Error('URL parameter ommitted');
}
$onChanges(changes) {
$onChanges() {
if (this.data)
this.updateOriginalData();
}
@ -222,6 +222,15 @@ export default class Watcher extends Component {
this.setPristine();
}
loadOriginalData() {
Object.keys(this.data).forEach(key => {
delete this.data[key];
});
this.data = Object.assign(this.data, this.orgData);
this.setPristine();
}
copyInNewObject(data) {
let newCopy = {};
if (data && typeof data === 'object') {

View File

@ -249,4 +249,14 @@ describe('Component vnWatcher', () => {
});
});
});
describe(`loadOriginalData()`, () => {
it(`should iterate over the current data object, delete all properties then assign the ones from original data`, () => {
controller.data = {name: 'Bruce'};
controller.orgData = {name: 'Batman'};
controller.loadOriginalData();
expect(controller.data).toEqual(controller.orgData);
});
});
});

View File

@ -75,8 +75,7 @@
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save"
vn-acl="deliveryBoss">
</vn-submit>
<vn-submit label="Save" vn-acl="deliveryBoss"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -59,5 +59,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="$ctrl.$scope.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -43,7 +43,6 @@
<vn-horizontal>
<vn-autocomplete
vn-one
disabled="false"
field="$ctrl.client.salesPersonFk"
url="/client/api/Clients/activeWorkersWithRole"
show-field="nickname"
@ -53,9 +52,8 @@
label="Salesperson"
vn-acl="salesAssistant">
</vn-autocomplete>
<vn-autocomplete
<vn-autocomplete
vn-one
initial-data="$ctrl.client.contactChannel"
field="$ctrl.client.contactChannelFk"
url="/client/api/ContactChannels"
label="Channel">
@ -64,6 +62,7 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</fieldset>
</form>

View File

@ -11,4 +11,5 @@ You can save multiple emails: >-
Puede guardar varios correos electrónicos encadenándolos mediante comas
sin espacios, ejemplo: user@dominio.com, user2@dominio.com siendo el primer
correo electrónico el principal
Contact: Contacto
Contact: Contacto
Undo changes: Deshacer cambios

View File

@ -85,6 +85,7 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save" vn-acl="salesAssistant"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -128,8 +128,8 @@
</vn-horizontal>
</vn-card>
<vn-button-bar>
<vn-submit label="Save">
</vn-submit>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="$ctrl.$.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>
<vn-confirm

View File

@ -27,6 +27,7 @@
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button ng-if="$ctrl.canChangePassword" label="Change password" vn-dialog="change-pass"></vn-button>
<vn-button label="Undo changes" ng-if="$ctrl.$.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>
<vn-dialog

View File

@ -93,5 +93,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="$ctrl.$scope.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -42,5 +42,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -4,6 +4,12 @@
data="classes"
auto-load="true">
</vn-crud-model>
<vn-watcher
vn-id="watcher"
data="$ctrl.taxes"
form="form"
save="patch">
</vn-watcher>
<form name="form" ng-submit="$ctrl.submit()" compact>
<vn-card pad-large>
<vn-horizontal ng-repeat="tax in $ctrl.taxes track by $index">
@ -23,5 +29,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -67,5 +67,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -72,5 +72,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -32,5 +32,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="watcher.dataChanged()" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>

View File

@ -15,5 +15,6 @@
</vn-card>
<vn-button-bar>
<vn-submit label="Save"></vn-submit>
<vn-button label="Undo changes" ng-if="$ctrl.$scope.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar>
</form>