This commit is contained in:
Bernat 2019-09-18 11:11:53 +02:00
commit 86d793b9ed
28 changed files with 157 additions and 46 deletions

View File

@ -33,8 +33,8 @@ export default {
taxNumber: `${components.vnTextfield}[name="fi"]`, taxNumber: `${components.vnTextfield}[name="fi"]`,
socialName: `${components.vnTextfield}[name="socialName"]`, socialName: `${components.vnTextfield}[name="socialName"]`,
street: `${components.vnTextfield}[name="street"]`, street: `${components.vnTextfield}[name="street"]`,
postcode: `vn-autocomplete[field="$ctrl.client.postcode"]`, postcode: `${components.vnTextfield}[name="postcode"]`,
city: `vn-autocomplete[field="$ctrl.client.city"]`, city: `${components.vnTextfield}[name="city"]`,
province: `vn-autocomplete[field="$ctrl.client.provinceFk"]`, province: `vn-autocomplete[field="$ctrl.client.provinceFk"]`,
country: `vn-autocomplete[field="$ctrl.client.countryFk"]`, country: `vn-autocomplete[field="$ctrl.client.countryFk"]`,
userName: `${components.vnTextfield}[name="userName"]`, userName: `${components.vnTextfield}[name="userName"]`,
@ -65,8 +65,8 @@ export default {
equalizationTaxCheckbox: 'vn-check[label="Is equalizated"] md-checkbox', equalizationTaxCheckbox: 'vn-check[label="Is equalizated"] md-checkbox',
acceptPropagationButton: 'vn-client-fiscal-data > vn-confirm button[response=ACCEPT]', acceptPropagationButton: 'vn-client-fiscal-data > vn-confirm button[response=ACCEPT]',
addressInput: `${components.vnTextfield}[name="street"]`, addressInput: `${components.vnTextfield}[name="street"]`,
postcodeAutocomplete: `vn-autocomplete[field="$ctrl.client.postcode"]`, postcodeInput: `${components.vnTextfield}[name="postcode"]`,
cityAutocomplete: `vn-autocomplete[field="$ctrl.client.city"]`, cityInput: `${components.vnTextfield}[name="city"]`,
provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]', provinceAutocomplete: 'vn-autocomplete[field="$ctrl.client.provinceFk"]',
countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]', countryAutocomplete: 'vn-autocomplete[field="$ctrl.client.countryFk"]',
activeCheckbox: 'vn-check[label="Active"] md-checkbox', activeCheckbox: 'vn-check[label="Active"] md-checkbox',
@ -100,8 +100,8 @@ export default {
defaultCheckboxInput: 'vn-check[label="Default"] md-checkbox', defaultCheckboxInput: 'vn-check[label="Default"] md-checkbox',
consigneeInput: `${components.vnTextfield}[name="nickname"]`, consigneeInput: `${components.vnTextfield}[name="nickname"]`,
streetAddressInput: `${components.vnTextfield}[name="street"]`, streetAddressInput: `${components.vnTextfield}[name="street"]`,
postcodeAutocomplete: `vn-autocomplete[field="$ctrl.address.postalCode"]`, postcodeInput: `${components.vnTextfield}[name="postalCode"]`,
cityAutocomplete: `vn-autocomplete[field="$ctrl.address.city"]`, cityInput: `${components.vnTextfield}[name="city"]`,
provinceAutocomplete: 'vn-autocomplete[field="$ctrl.address.provinceFk"]', provinceAutocomplete: 'vn-autocomplete[field="$ctrl.address.provinceFk"]',
agencyAutocomplete: 'vn-autocomplete[field="$ctrl.address.agencyModeFk"]', agencyAutocomplete: 'vn-autocomplete[field="$ctrl.address.agencyModeFk"]',
phoneInput: `${components.vnTextfield}[name="phone"]`, phoneInput: `${components.vnTextfield}[name="phone"]`,

View File

@ -53,7 +53,10 @@ describe('Client create path', () => {
.write(selectors.createClientView.name, 'Carol Danvers') .write(selectors.createClientView.name, 'Carol Danvers')
.write(selectors.createClientView.socialName, 'AVG tax') .write(selectors.createClientView.socialName, 'AVG tax')
.write(selectors.createClientView.street, 'Many places') .write(selectors.createClientView.street, 'Many places')
.autocompleteSearch(selectors.createClientView.postcode, '46000') .autocompleteSearch(selectors.createClientView.country, 'España')
.autocompleteSearch(selectors.createClientView.province, 'Province one')
.write(selectors.createClientView.city, 'Valencia')
.write(selectors.createClientView.postcode, '46000')
.clearInput(selectors.createClientView.email) .clearInput(selectors.createClientView.email)
.write(selectors.createClientView.email, 'incorrect email format') .write(selectors.createClientView.email, 'incorrect email format')
.waitToClick(selectors.createClientView.createButton) .waitToClick(selectors.createClientView.createButton)
@ -64,7 +67,7 @@ describe('Client create path', () => {
it(`should check for autocompleted city, province and country`, async() => { it(`should check for autocompleted city, province and country`, async() => {
const clientCity = await nightmare const clientCity = await nightmare
.waitToGetProperty(`${selectors.createClientView.city} input`, 'value'); .waitToGetProperty(`${selectors.createClientView.city}`, 'value');
const clientProvince = await nightmare const clientProvince = await nightmare
.waitToGetProperty(`${selectors.createClientView.province} input`, 'value'); .waitToGetProperty(`${selectors.createClientView.province} input`, 'value');

View File

@ -67,8 +67,12 @@ describe('Client Edit fiscalData path', () => {
.write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!') .write(selectors.clientFiscalData.fiscalIdInput, 'INVALID!')
.clearInput(selectors.clientFiscalData.addressInput) .clearInput(selectors.clientFiscalData.addressInput)
.write(selectors.clientFiscalData.addressInput, 'Somewhere edited') .write(selectors.clientFiscalData.addressInput, 'Somewhere edited')
.autocompleteSearch(selectors.clientFiscalData.cityAutocomplete, 'Valencia') .autocompleteSearch(selectors.clientFiscalData.countryAutocomplete, 'España')
.autocompleteSearch(selectors.clientFiscalData.postcodeAutocomplete, '46000') .autocompleteSearch(selectors.clientFiscalData.provinceAutocomplete, 'Province one')
.clearInput(selectors.clientFiscalData.cityInput)
.write(selectors.clientFiscalData.cityInput, 'Valencia')
.clearInput(selectors.clientFiscalData.postcodeInput)
.write(selectors.clientFiscalData.postcodeInput, '46000')
.waitToClick(selectors.clientFiscalData.activeCheckbox) .waitToClick(selectors.clientFiscalData.activeCheckbox)
.waitToClick(selectors.clientFiscalData.frozenCheckbox) .waitToClick(selectors.clientFiscalData.frozenCheckbox)
.waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox) .waitToClick(selectors.clientFiscalData.hasToInvoiceCheckbox)
@ -194,14 +198,14 @@ describe('Client Edit fiscalData path', () => {
it('should confirm the postcode have been edited', async() => { it('should confirm the postcode have been edited', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(`${selectors.clientFiscalData.postcodeAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientFiscalData.postcodeInput}`, 'value');
expect(result).toContain('46000'); expect(result).toContain('46000');
}); });
it('should confirm the city have been autocompleted', async() => { it('should confirm the city have been autocompleted', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(`${selectors.clientFiscalData.cityAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientFiscalData.cityInput}`, 'value');
expect(result).toEqual('Valencia'); expect(result).toEqual('Valencia');
}); });

View File

@ -24,7 +24,11 @@ describe('Client Add address path', () => {
const result = await nightmare const result = await nightmare
.waitToClick(selectors.clientAddresses.defaultCheckboxInput) .waitToClick(selectors.clientAddresses.defaultCheckboxInput)
.clearInput(selectors.clientAddresses.streetAddressInput) .clearInput(selectors.clientAddresses.streetAddressInput)
.autocompleteSearch(selectors.clientAddresses.postcodeAutocomplete, '46000') .autocompleteSearch(selectors.clientAddresses.provinceAutocomplete, 'Province one')
.clearInput(selectors.clientAddresses.cityInput)
.write(selectors.clientAddresses.cityInput, 'Valencia')
.clearInput(selectors.clientAddresses.postcodeInput)
.write(selectors.clientAddresses.postcodeInput, '46000')
.autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement') .autocompleteSearch(selectors.clientAddresses.agencyAutocomplete, 'Entanglement')
.write(selectors.clientAddresses.phoneInput, '999887744') .write(selectors.clientAddresses.phoneInput, '999887744')
.write(selectors.clientAddresses.mobileInput, '999887744') .write(selectors.clientAddresses.mobileInput, '999887744')
@ -36,14 +40,14 @@ describe('Client Add address path', () => {
it('should confirm the postcode have been edited', async() => { it('should confirm the postcode have been edited', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(`${selectors.clientAddresses.postcodeAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientAddresses.postcodeInput}`, 'value');
expect(result).toContain('46000'); expect(result).toContain('46000');
}); });
it('should confirm the city have been autocompleted', async() => { it('should confirm the city have been autocompleted', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(`${selectors.clientAddresses.cityAutocomplete} input`, 'value'); .waitToGetProperty(`${selectors.clientAddresses.cityInput}`, 'value');
expect(result).toEqual('Valencia'); expect(result).toEqual('Valencia');
}); });

View File

@ -7,10 +7,10 @@ import './style.scss';
/** /**
* Input with option selector. * 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 shown
* @property {String} showFiled The data field name that should be used as value * @property {String} valueField The data field name that should be used as value
* @property {Array} data Static data for the autocomplete * @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 {Boolean} multiple Wether to allow multiple selection
* @property {Object} selection Current object selected * @property {Object} selection Current object selected
* *

View File

@ -39,7 +39,7 @@ export default class Watcher extends Component {
throw new Error('URL parameter ommitted'); throw new Error('URL parameter ommitted');
} }
$onChanges(changes) { $onChanges() {
if (this.data) if (this.data)
this.updateOriginalData(); this.updateOriginalData();
} }
@ -222,6 +222,15 @@ export default class Watcher extends Component {
this.setPristine(); 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) { copyInNewObject(data) {
let newCopy = {}; let newCopy = {};
if (data && typeof data === 'object') { 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

@ -54,5 +54,6 @@
"Weekday cannot be blank": "Weekday cannot be blank", "Weekday cannot be blank": "Weekday cannot be blank",
"This ticket can not be modified": "This ticket can not be modified", "This ticket can not be modified": "This ticket can not be modified",
"You can't delete a confirmed order": "You can't delete a confirmed order", "You can't delete a confirmed order": "You can't delete a confirmed order",
"Value has an invalid format": "Value has an invalid format" "Value has an invalid format": "Value has an invalid format",
"The postcode doesn't exists. Ensure you put the correct format": "The postcode doesn't exists. Ensure you put the correct format"
} }

View File

@ -104,5 +104,8 @@
"You can't delete a confirmed order": "No puedes borrar un pedido confirmado", "You can't delete a confirmed order": "No puedes borrar un pedido confirmado",
"Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket", "Can't create stowaway for this ticket": "No se puede crear un polizon para este ticket",
"Value has an invalid format": "El valor tiene un formato incorrecto", "Value has an invalid format": "El valor tiene un formato incorrecto",
"Invalid quantity": "Cantidad invalida" "Invalid quantity": "Cantidad invalida",
"This postal code is not valid": "This postal code is not valid",
"is invalid": "is invalid",
"The postcode doesn't exists. Ensure you put the correct format": "El código postal no existe. Asegúrate de ponerlo con el formato correcto"
} }

View File

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

View File

@ -59,5 +59,6 @@
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save"></vn-submit> <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> </vn-button-bar>
</form> </form>

View File

@ -42,6 +42,21 @@ module.exports = Self => {
next(); next();
}); });
Self.validateAsync('postalCode', hasValidPostcode, {
message: `The postcode doesn't exists. Ensure you put the correct format`
});
async function hasValidPostcode(err, done) {
if (!this.postalCode)
return done();
const models = Self.app.models;
const postcode = await models.Postcode.findById(this.postalCode);
if (!postcode) err();
done();
}
// Helpers // Helpers
Self.observe('before save', async function(ctx) { Self.observe('before save', async function(ctx) {

View File

@ -160,6 +160,21 @@ module.exports = Self => {
return regexp.test(value); return regexp.test(value);
} }
Self.validateAsync('postCode', hasValidPostcode, {
message: `The postcode doesn't exists. Ensure you put the correct format`
});
async function hasValidPostcode(err, done) {
if (!this.postcode)
return done();
const models = Self.app.models;
const postcode = await models.Postcode.findById(this.postcode);
if (!postcode) err();
done();
}
Self.observe('before save', async function(ctx) { Self.observe('before save', async function(ctx) {
let changes = ctx.data || ctx.instance; let changes = ctx.data || ctx.instance;
let orgData = ctx.currentInstance; let orgData = ctx.currentInstance;

View File

@ -31,7 +31,11 @@
value-field="id" value-field="id"
label="Province"> label="Province">
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete vn-id="town" vn-one <vn-textfield vn-one
label="City"
field="$ctrl.address.city">
</vn-textfield>
<!-- <vn-autocomplete vn-id="town" vn-one
label="City" label="City"
url="/api/Towns" url="/api/Towns"
fields="['id', 'name']" fields="['id', 'name']"
@ -55,12 +59,16 @@
{{code}}, {{town.name}} - {{town.province.name}} {{code}}, {{town.name}} - {{town.province.name}}
({{town.province.country.country}}) ({{town.province.country.country}})
</tpl-item> </tpl-item>
</vn-autocomplete> </vn-autocomplete> -->
<vn-icon-button vn-auto margin-medium-v <vn-textfield vn-one
label="Postcode"
field="$ctrl.address.postalCode">
</vn-textfield>
<!-- <vn-icon-button vn-auto margin-medium-v
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()"> ng-click="postcode.open()">
</vn-icon-button> </vn-icon-button> -->
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete <vn-autocomplete

View File

@ -47,7 +47,11 @@
value-field="id" value-field="id"
label="Province"> label="Province">
</vn-autocomplete> </vn-autocomplete>
<vn-autocomplete vn-id="town" vn-one <vn-textfield vn-one
label="City"
field="$ctrl.address.city">
</vn-textfield>
<!-- <vn-autocomplete vn-id="town" vn-one
label="City" label="City"
url="/api/Towns" url="/api/Towns"
fields="['id', 'name']" fields="['id', 'name']"
@ -66,12 +70,16 @@
show-field="code" show-field="code"
value-field="code" value-field="code"
label="Postcode"> label="Postcode">
</vn-autocomplete> </vn-autocomplete> -->
<vn-icon-button vn-auto margin-medium-v <vn-textfield vn-one
label="Postcode"
field="$ctrl.address.postalCode">
</vn-textfield>
<!-- <vn-icon-button vn-auto margin-medium-v
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()"> ng-click="postcode.open()">
</vn-icon-button> </vn-icon-button> -->
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-one <vn-autocomplete vn-one

View File

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

View File

@ -12,3 +12,4 @@ You can save multiple emails: >-
sin espacios, ejemplo: user@dominio.com, user2@dominio.com siendo el primer sin espacios, ejemplo: user@dominio.com, user2@dominio.com siendo el primer
correo electrónico el principal correo electrónico el principal
Contact: Contacto Contact: Contacto
Undo changes: Deshacer cambios

View File

@ -85,6 +85,7 @@
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save" vn-acl="salesAssistant"></vn-submit> <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> </vn-button-bar>
</form> </form>

View File

@ -50,7 +50,11 @@
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-id="town" vn-one <vn-textfield vn-one
label="City"
field="$ctrl.client.city">
</vn-textfield>
<!-- <vn-autocomplete vn-id="town" vn-one
label="City" label="City"
url="/api/Towns" url="/api/Towns"
fields="['id', 'name']" fields="['id', 'name']"
@ -58,13 +62,17 @@
show-field="name" show-field="name"
value-field="name" value-field="name"
field="$ctrl.client.city"> field="$ctrl.client.city">
</vn-autocomplete> </vn-autocomplete> -->
<vn-icon-button vn-auto margin-medium-v <!-- <vn-icon-button vn-auto margin-medium-v
icon="add_circle" icon="add_circle"
vn-tooltip="New postcode" vn-tooltip="New postcode"
ng-click="postcode.open()"> ng-click="postcode.open()">
</vn-icon-button> </vn-icon-button> -->
<vn-autocomplete vn-one <vn-textfield vn-one
label="Postcode"
field="$ctrl.client.postcode">
</vn-textfield>
<!-- <vn-autocomplete vn-one
url="/api/Postcodes/location" url="/api/Postcodes/location"
fields="['code', 'townFk']" fields="['code', 'townFk']"
field="$ctrl.client.postcode" field="$ctrl.client.postcode"
@ -79,7 +87,7 @@
{{code}}, {{town.name}} - {{town.province.name}} {{code}}, {{town.name}} - {{town.province.name}}
({{town.province.country.country}}) ({{town.province.country.country}})
</tpl-item> </tpl-item>
</vn-autocomplete> </vn-autocomplete> -->
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-textfield <vn-textfield

View File

@ -47,7 +47,15 @@
</vn-autocomplete> </vn-autocomplete>
</vn-horizontal> </vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete vn-id="town" vn-one <vn-textfield vn-one
label="City"
field="$ctrl.client.city">
</vn-textfield>
<vn-textfield vn-one
label="Postcode"
field="$ctrl.client.postcode">
</vn-textfield>
<!-- <vn-autocomplete vn-id="town" vn-one
label="City" label="City"
url="/api/Towns" url="/api/Towns"
fields="['id', 'name']" fields="['id', 'name']"
@ -66,7 +74,7 @@
show-field="code" show-field="code"
value-field="code" value-field="code"
label="Postcode"> label="Postcode">
</vn-autocomplete> </vn-autocomplete> -->
</vn-horizontal> </vn-horizontal>
<vn-horizontal pad-small-v> <vn-horizontal pad-small-v>
<vn-check <vn-check
@ -120,8 +128,8 @@
</vn-horizontal> </vn-horizontal>
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save"> <vn-submit label="Save"></vn-submit>
</vn-submit> <vn-button label="Undo changes" ng-if="$ctrl.$.form.$dirty" ng-click="watcher.loadOriginalData()"></vn-button>
</vn-button-bar> </vn-button-bar>
</form> </form>
<vn-confirm <vn-confirm

View File

@ -27,6 +27,7 @@
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save"></vn-submit> <vn-submit label="Save"></vn-submit>
<vn-button ng-if="$ctrl.canChangePassword" label="Change password" vn-dialog="change-pass"></vn-button> <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> </vn-button-bar>
</form> </form>
<vn-dialog <vn-dialog

View File

@ -98,5 +98,6 @@
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save"></vn-submit> <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> </vn-button-bar>
</form> </form>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -15,5 +15,6 @@
</vn-card> </vn-card>
<vn-button-bar> <vn-button-bar>
<vn-submit label="Save"></vn-submit> <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> </vn-button-bar>
</form> </form>