client.phone section
gitea/salix/1928-client_phone This commit looks good Details

This commit is contained in:
Bernat Exposito Domenech 2019-12-17 09:11:28 +01:00
parent 9457ac5d78
commit aab970e667
17 changed files with 164 additions and 142 deletions

View File

@ -14,5 +14,13 @@
"description": { "description": {
"type": "String" "type": "String"
} }
},
"acls": [
{
"accessType": "READ",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
} }
]
} }

View File

@ -1 +1 @@
INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('UserPhone', '*', 'WRITE', 'ALLOW', 'ROLE', 'employee'); INSERT INTO `salix`.`ACL` (`model`, `property`, `accessType`, `permission`, `principalType`, `principalId`) VALUES ('UserPhone', '*', '*', 'ALLOW', 'ROLE', 'employee');

View File

@ -205,23 +205,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
(4, 'GCN Channel'), (4, 'GCN Channel'),
(5, 'The Newspaper'); (5, 'The Newspaper');
INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`phone`,`mobile`,`fax`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`cplusTerIdNifFk`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`) INSERT INTO `vn`.`client`(`id`,`name`,`fi`,`socialName`,`contact`,`street`,`city`,`postcode`,`fax`,`isRelevant`,`email`,`iban`,`dueDay`,`accountingAccount`,`isEqualizated`,`provinceFk`,`hasToInvoice`,`credit`,`countryFk`,`isActive`,`gestdocFk`,`quality`,`payMethodFk`,`created`,`isToBeMailed`,`contactChannelFk`,`hasSepaVnl`,`hasCoreVnl`,`hasCoreVnh`,`riskCalculated`,`clientTypeFk`,`mailAddress`,`cplusTerIdNifFk`,`hasToInvoiceByAddress`,`isTaxDataChecked`,`isFreezed`,`creditInsurance`,`isCreatedAsServed`,`hasInvoiceSimplified`,`salesPersonFk`,`isVies`,`eypbc`)
VALUES VALUES
(101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (101, 'Bruce Wayne', '84612325V', 'Batman', 'Alfred', '1007 Mountain Drive, Gotham', 'Silla', 46460, 333333333, 1, 'BruceWayne@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
(102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (102, 'Petter Parker', '87945234L', 'Spider man', 'Aunt May', '20 Ingram Street', 'Silla', 46460, 333333333, 1, 'PetterParker@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
(103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (103, 'Clark Kent', '06815934E', 'Super man', 'lois lane', '344 Clinton Street', 'Silla', 46460, 333333333, 1, 'ClarkKent@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 0, 19, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
(104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1), (104, 'Tony Stark', '06089160W', 'Iron man', 'Pepper Potts', '10880 Malibu Point', 'Silla', 46460, 333333333, 1, 'TonyStark@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 18, 0, 1),
(105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1), (105, 'Max Eisenhardt', '251628698', 'Magneto', 'Rogue', 'Unknown Whereabouts', 'Silla', 46460, 333333333, 1, 'MaxEisenhardt@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 8, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 18, 0, 1),
(106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'Evil hideout', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1), (106, 'DavidCharlesHaller', '53136686Q', 'Legion', 'Charles Xavier', 'Evil hideout', 'Silla', 46460, 333333333, 1, 'DavidCharlesHaller@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 0, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 0, NULL, 0, 0, 19, 0, 1),
(107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1), (107, 'Hank Pym', '09854837G', 'Ant man', 'Hawk', 'Anthill', 'Silla', 46460, 333333333, 1, 'HankPym@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1),
(108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1), (108, 'Charles Xavier', '22641921P', 'Professor X', 'Beast', '3800 Victory Pkwy, Cincinnati, OH 45207, USA', 'Silla', 46460, 333333333, 1, 'CharlesXavier@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 1, 1, NULL, 0, 0, 19, 0, 1),
(109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1), (109, 'Bruce Banner', '16104829E', 'Hulk', 'Black widow', 'Somewhere in New York', 'Silla', 46460, 333333333, 1, 'BruceBanner@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, 19, 0, 1),
(110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1), (110, 'Jessica Jones', '58282869H', 'Jessica Jones', 'Luke Cage', 'NYCC 2015 Poster', 'Silla', 46460, 333333333, 1, 'JessicaJones@mydomain.com', NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 1, NULL, 1, 1, 0, 0, NULL, 0, 0, NULL, 0, 1),
(111, 'Missing', NULL, 'Missing man', 'Anton', 'The space', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1), (111, 'Missing', NULL, 'Missing man', 'Anton', 'The space', 'Silla', 46460, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1),
(112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city', 'Silla', 46460, 1111111111, 222222222, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1); (112, 'Trash', NULL, 'Garbage man', 'Unknown name', 'New York city', 'Silla', 46460, 333333333, 1, NULL, NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1, NULL, 10, 5,CURDATE(), 1, 5, 1, 1, 1, '0000-00-00', 4, NULL, 1, 0, 1, 0, NULL, 1, 0, NULL, 0, 1);
INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `phone`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`) INSERT INTO `vn`.`client`(`id`, `name`, `fi`, `socialName`, `contact`, `street`, `city`, `postcode`, `isRelevant`, `email`, `iban`,`dueDay`,`accountingAccount`, `isEqualizated`, `provinceFk`, `hasToInvoice`, `credit`, `countryFk`, `isActive`, `gestdocFk`, `quality`, `payMethodFk`,`created`, `isTaxDataChecked`)
SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'SILLA', 46460, 623111111, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1 SELECT id, name, CONCAT(RPAD(CONCAT(id,9),8,id),'A'), CONCAT(name, 'Social'), CONCAT(name, 'Contact'), CONCAT(name, 'Street'), 'SILLA', 46460, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1
FROM `account`.`role` `r` FROM `account`.`role` `r`
WHERE `r`.`hasLogin` = 1; WHERE `r`.`hasLogin` = 1;

View File

@ -50,8 +50,6 @@ export default {
basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]', basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]',
nameInput: 'vn-textfield[ng-model="$ctrl.client.name"] input', nameInput: 'vn-textfield[ng-model="$ctrl.client.name"] input',
contactInput: 'vn-textfield[ng-model="$ctrl.client.contact"] input', contactInput: 'vn-textfield[ng-model="$ctrl.client.contact"] input',
phoneInput: 'vn-textfield[ng-model="$ctrl.client.phone"] input',
mobileInput: 'vn-textfield[ng-model="$ctrl.client.mobile"] input',
emailInput: 'vn-textfield[ng-model="$ctrl.client.email"] input', emailInput: 'vn-textfield[ng-model="$ctrl.client.email"] input',
salesPersonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]', salesPersonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
channelAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]', channelAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]',

View File

@ -27,10 +27,6 @@ describe('Client Edit basicData path', () => {
.write(selectors.clientBasicData.nameInput, 'Ptonomy Wallace') .write(selectors.clientBasicData.nameInput, 'Ptonomy Wallace')
.clearInput(selectors.clientBasicData.contactInput) .clearInput(selectors.clientBasicData.contactInput)
.write(selectors.clientBasicData.contactInput, 'David Haller') .write(selectors.clientBasicData.contactInput, 'David Haller')
.clearInput(selectors.clientBasicData.phoneInput)
.write(selectors.clientBasicData.phoneInput, '987654321')
.clearInput(selectors.clientBasicData.mobileInput)
.write(selectors.clientBasicData.mobileInput, '123456789')
.clearInput(selectors.clientBasicData.emailInput) .clearInput(selectors.clientBasicData.emailInput)
.write(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es') .write(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es')
.autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Rumors on the streets') .autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Rumors on the streets')
@ -55,20 +51,6 @@ describe('Client Edit basicData path', () => {
expect(result).toEqual('David Haller'); expect(result).toEqual('David Haller');
}); });
it('should confirm the landline phone number have been added', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientBasicData.phoneInput, 'value');
expect(result).toEqual('987654321');
});
it('should confirm the mobile phone number have been added', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientBasicData.mobileInput, 'value');
expect(result).toEqual('123456789');
});
it('should confirm the email have been edited', async() => { it('should confirm the email have been edited', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(selectors.clientBasicData.emailInput, 'value'); .waitToGetProperty(selectors.clientBasicData.emailInput, 'value');
@ -108,10 +90,6 @@ describe('Client Edit basicData path', () => {
.write(selectors.clientBasicData.nameInput, 'Ororo Munroe') .write(selectors.clientBasicData.nameInput, 'Ororo Munroe')
.clearInput(selectors.clientBasicData.contactInput) .clearInput(selectors.clientBasicData.contactInput)
.write(selectors.clientBasicData.contactInput, 'Black Panther') .write(selectors.clientBasicData.contactInput, 'Black Panther')
.clearInput(selectors.clientBasicData.phoneInput)
.write(selectors.clientBasicData.phoneInput, '123456789')
.clearInput(selectors.clientBasicData.mobileInput)
.write(selectors.clientBasicData.mobileInput, '987654321')
.clearInput(selectors.clientBasicData.emailInput) .clearInput(selectors.clientBasicData.emailInput)
.write(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es') .write(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es')
.autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'replenisherNick') .autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'replenisherNick')
@ -137,20 +115,6 @@ describe('Client Edit basicData path', () => {
expect(result).toEqual('Black Panther'); expect(result).toEqual('Black Panther');
}); });
it('should now confirm the landline phone number have been added', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientBasicData.phoneInput, 'value');
expect(result).toEqual('123456789');
});
it('should now confirm the mobile phone number have been added', async() => {
const result = await nightmare
.waitToGetProperty(selectors.clientBasicData.mobileInput, 'value');
expect(result).toEqual('987654321');
});
it('should now confirm the email have been edited', async() => { it('should now confirm the email have been edited', async() => {
const result = await nightmare const result = await nightmare
.waitToGetProperty(selectors.clientBasicData.emailInput, 'value'); .waitToGetProperty(selectors.clientBasicData.emailInput, 'value');

View File

@ -60,6 +60,8 @@ module.exports = function(Self) {
scope: { scope: {
fields: ['id', 'name', 'active'] fields: ['id', 'name', 'active']
} }
}, {
relation: 'phones'
} }
] ]
}); });

View File

@ -53,6 +53,9 @@ module.exports = Self => {
} }
} }
}, },
{
relation: 'phones'
},
{ {
relation: 'country', relation: 'country',
scope: { scope: {

View File

@ -200,6 +200,11 @@
"type": "hasOne", "type": "hasOne",
"model": "ClaimRatio", "model": "ClaimRatio",
"foreignKey": "clientFk" "foreignKey": "clientFk"
},
"phones": {
"type": "hasMany",
"model": "UserPhone",
"foreignKey": "userFk"
} }
} }
} }

View File

@ -31,20 +31,6 @@
info="You can save multiple emails"> info="You can save multiple emails">
</vn-textfield> </vn-textfield>
</vn-horizontal> </vn-horizontal>
<vn-horizontal>
<vn-textfield
vn-one
label="Phone"
ng-model="$ctrl.client.phone"
rule>
</vn-textfield>
<vn-textfield
vn-one
label="Mobile"
ng-model="$ctrl.client.mobile"
rule>
</vn-textfield>
</vn-horizontal>
<vn-horizontal> <vn-horizontal>
<vn-autocomplete <vn-autocomplete
vn-one vn-one

View File

@ -1,35 +0,0 @@
import ngModule from '../module';
class Controller {
constructor($scope, $stateParams, $translate) {
this.$scope = $scope;
this.$stateParams = $stateParams;
this.$translate = $translate;
}
add() {
this.$scope.model.insert({
clientFk: this.client.id,
name: this.$translate.instant('Phone'),
phone: null
});
}
onSubmit() {
this.$scope.watcher.check();
this.$scope.model.save().then(() => {
this.$scope.watcher.notifySaved();
this.$scope.model.refresh();
});
}
}
Controller.$inject = ['$scope', '$stateParams', '$translate'];
ngModule.component('vnClientContact', {
template: require('./index.html'),
controller: Controller,
bindings: {
client: '<'
}
});

View File

@ -30,7 +30,7 @@ import './credit-insurance/index';
import './credit-insurance/create'; import './credit-insurance/create';
import './credit-insurance/insurance/index'; import './credit-insurance/insurance/index';
import './credit-insurance/insurance/create'; import './credit-insurance/insurance/create';
import './contact'; import './phones';
import './sample/index'; import './sample/index';
import './sample/create'; import './sample/create';
import './web-payment'; import './web-payment';

View File

@ -25,10 +25,6 @@
label="Id" label="Id"
value="{{::client.id}}"> value="{{::client.id}}">
</vn-label-value> </vn-label-value>
<vn-label-value
label="Phone"
value="{{::client.phone | phone}}">
</vn-label-value>
<vn-label-value <vn-label-value
label="Town/City" label="Town/City"
value="{{::client.city}}"> value="{{::client.city}}">

View File

@ -1,45 +1,48 @@
<vn-crud-model
url="UserPhoneTypes"
data="phoneTypes"
auto-load="true">
</vn-crud-model>
<vn-crud-model <vn-crud-model
vn-id="model" vn-id="model"
url="ClientContacts" url="UserPhones"
fields="['id', 'name', 'phone', 'clientFk']" data="$ctrl.phones">
link="{clientFk: $ctrl.$stateParams.id}"
data="contacts"
auto-load="true">
</vn-crud-model> </vn-crud-model>
<vn-watcher <vn-watcher
vn-id="watcher" vn-id="watcher"
data="contacts" data="$ctrl.phones">
form="form">
</vn-watcher> </vn-watcher>
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md"> <form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
<vn-card class="vn-pa-lg"> <vn-card class="vn-pa-lg">
<vn-horizontal ng-repeat="contact in contacts"> <vn-horizontal ng-repeat="clientPhone in $ctrl.phones">
<vn-textfield <vn-autocomplete
vn-one vn-one
label="Name" ng-model="clientPhone.typeFk"
ng-model="contact.name" initial-data="clientPhone.typeFk"
rule="ClientContact"> data ="phoneTypes"
</vn-textfield> show-field="code"
value-field="code"
label="Type"
vn-focus>
</vn-autocomplete>
<vn-textfield <vn-textfield
vn-one vn-one
label="Phone" label="Phone"
ng-model="contact.phone" ng-model="clientPhone.phone">
rule="ClientContact"
vn-focus>
</vn-textfield> </vn-textfield>
<vn-none> <vn-none>
<vn-icon-button <vn-icon-button
vn-tooltip="Remove contact" vn-tooltip="Remove phone"
icon="delete" icon="delete"
tabindex="-1" ng-click="model.remove($index)"
ng-click="model.remove($index)"> tabindex="-1">
</vn-icon-button> </vn-icon-button>
</vn-none> </vn-none>
</vn-horizontal> </vn-horizontal>
<vn-one> <vn-one>
<vn-icon-button <vn-icon-button
vn-bind="+" vn-bind="+"
vn-tooltip="Add contact" vn-tooltip="Add phone"
icon="add_circle" icon="add_circle"
ng-click="$ctrl.add()"> ng-click="$ctrl.add()">
</vn-icon-button> </vn-icon-button>

View File

@ -0,0 +1,44 @@
import ngModule from '../module';
import Section from 'salix/components/section';
class Controller extends Section {
get client() {
return this._client;
}
set client(value) {
this._client = value;
if (value)
this.setLink(value);
}
setLink(value) {
this.$.$applyAsync(()=> {
this.$.model.link = {userFk: value.id};
this.$.model.refresh();
});
}
onSubmit() {
this.$.watcher.check();
return this.$.model.save().then(() => {
this.$.watcher.updateOriginalData();
this.$.watcher.notifySaved();
this.card.reload();
});
}
add() {
this.$.model.insert();
}
}
ngModule.component('vnClientPhones', {
template: require('./index.html'),
controller: Controller,
require: {card: '^vnClientCard'},
bindings: {
client: '<'
}
});

View File

@ -0,0 +1,50 @@
import './index';
import watcher from 'core/mocks/watcher';
describe('Component vnClientPhones', () => {
let controller;
let $element;
let $scope;
beforeEach(ngModule('client'));
beforeEach(angular.mock.inject(($componentController, $rootScope) => {
$scope = $rootScope.$new();
$element = angular.element('<div></div>');
$scope.watcher = watcher;
$scope.model = {
link: 1,
save: () => {}
};
controller = $componentController('vnClientPhones', {$element, $scope});
controller.card = {reload: () => {}};
}));
describe('setLink()', () => {
it('set the link in the model and refreshes it', () => {
spyOn(controller.$, '$applyAsync');
let value = {id: 106};
controller.setLink(value);
expect(controller.$.$applyAsync).toHaveBeenCalledWith(jasmine.any(Function));
});
});
describe('onSubmit()', () => {
it('should call watcher functions, reload the card and save the model', done => {
spyOn(controller.$.watcher, 'check');
spyOn(controller.$.model, 'save').and.returnValue(Promise.resolve());
spyOn(controller.$.watcher, 'updateOriginalData');
spyOn(controller.$.watcher, 'notifySaved');
spyOn(controller.card, 'reload');
controller.onSubmit();
controller.onSubmit().then(() => {
expect(controller.$.watcher.updateOriginalData).toHaveBeenCalledWith();
expect(controller.$.watcher.notifySaved).toHaveBeenCalledWith();
expect(controller.card.reload).toHaveBeenCalledWith();
done();
}).catch(done.fail);
});
});
});

View File

@ -26,7 +26,7 @@
{"state": "client.card.webAccess", "icon": "cloud"}, {"state": "client.card.webAccess", "icon": "cloud"},
{"state": "client.card.mandate", "icon": "pan_tool"}, {"state": "client.card.mandate", "icon": "pan_tool"},
{"state": "client.card.creditInsurance.index", "icon": "icon-solunion"}, {"state": "client.card.creditInsurance.index", "icon": "icon-solunion"},
{"state": "client.card.contact", "icon": "contact_phone"}, {"state": "client.card.phones", "icon": "contact_phone"},
{"state": "client.card.sample.index", "icon": "mail"}, {"state": "client.card.sample.index", "icon": "mail"},
{"state": "client.card.webPayment", "icon": "icon-onlinepayment"}, {"state": "client.card.webPayment", "icon": "icon-onlinepayment"},
{"state": "client.card.dms.index", "icon": "cloud_upload"} {"state": "client.card.dms.index", "icon": "cloud_upload"}
@ -282,10 +282,10 @@
"client": "$ctrl.client" "client": "$ctrl.client"
} }
}, { }, {
"url": "/contact", "url": "/phones",
"state": "client.card.contact", "state": "client.card.phones",
"component": "vn-client-contact", "component": "vn-client-phones",
"description": "Contacts", "description": "Client phones",
"params": { "params": {
"client": "$ctrl.client" "client": "$ctrl.client"
} }

View File

@ -12,11 +12,9 @@
<vn-label-value label="Contact" <vn-label-value label="Contact"
value="{{$ctrl.summary.contact}}"> value="{{$ctrl.summary.contact}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="Phone" <vn-label-value ng-repeat = "phone in $ctrl.summary.phones"
value="{{$ctrl.summary.phone}}"> label="Phone"
</vn-label-value> value="{{phone.phone}}">
<vn-label-value label="Mobile"
value="{{$ctrl.summary.mobile}}">
</vn-label-value> </vn-label-value>
<vn-label-value label="Email" ellipsize="false" <vn-label-value label="Email" ellipsize="false"
value="{{$ctrl.summary.email}}"> value="{{$ctrl.summary.email}}">