client.phone section
gitea/salix/1928-client_phone This commit looks good
Details
gitea/salix/1928-client_phone This commit looks good
Details
This commit is contained in:
parent
9457ac5d78
commit
aab970e667
|
@ -14,5 +14,13 @@
|
|||
"description": {
|
||||
"type": "String"
|
||||
}
|
||||
},
|
||||
"acls": [
|
||||
{
|
||||
"accessType": "READ",
|
||||
"principalType": "ROLE",
|
||||
"principalId": "$everyone",
|
||||
"permission": "ALLOW"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
|
|
@ -205,23 +205,23 @@ INSERT INTO `vn`.`contactChannel`(`id`, `name`)
|
|||
(4, 'GCN Channel'),
|
||||
(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
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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),
|
||||
(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);
|
||||
(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, 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, 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, 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, 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, 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, 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, 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, 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, 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, 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`)
|
||||
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
|
||||
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, 1, CONCAT(name,'@mydomain.com'), NULL, 0, 1234567890, 0, 1, 1, 300, 1, 1,NULL, 10, 5, CURDATE(), 1
|
||||
FROM `account`.`role` `r`
|
||||
WHERE `r`.`hasLogin` = 1;
|
||||
|
||||
|
|
|
@ -50,8 +50,6 @@ export default {
|
|||
basicDataButton: 'vn-left-menu a[ui-sref="client.card.basicData"]',
|
||||
nameInput: 'vn-textfield[ng-model="$ctrl.client.name"] 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',
|
||||
salesPersonAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.salesPersonFk"]',
|
||||
channelAutocomplete: 'vn-autocomplete[ng-model="$ctrl.client.contactChannelFk"]',
|
||||
|
|
|
@ -27,10 +27,6 @@ describe('Client Edit basicData path', () => {
|
|||
.write(selectors.clientBasicData.nameInput, 'Ptonomy Wallace')
|
||||
.clearInput(selectors.clientBasicData.contactInput)
|
||||
.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)
|
||||
.write(selectors.clientBasicData.emailInput, 'PWallace@verdnatura.es')
|
||||
.autocompleteSearch(selectors.clientBasicData.channelAutocomplete, 'Rumors on the streets')
|
||||
|
@ -55,20 +51,6 @@ describe('Client Edit basicData path', () => {
|
|||
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() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(selectors.clientBasicData.emailInput, 'value');
|
||||
|
@ -108,10 +90,6 @@ describe('Client Edit basicData path', () => {
|
|||
.write(selectors.clientBasicData.nameInput, 'Ororo Munroe')
|
||||
.clearInput(selectors.clientBasicData.contactInput)
|
||||
.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)
|
||||
.write(selectors.clientBasicData.emailInput, 'Storm@verdnatura.es')
|
||||
.autocompleteSearch(selectors.clientBasicData.salesPersonAutocomplete, 'replenisherNick')
|
||||
|
@ -137,20 +115,6 @@ describe('Client Edit basicData path', () => {
|
|||
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() => {
|
||||
const result = await nightmare
|
||||
.waitToGetProperty(selectors.clientBasicData.emailInput, 'value');
|
||||
|
|
|
@ -60,6 +60,8 @@ module.exports = function(Self) {
|
|||
scope: {
|
||||
fields: ['id', 'name', 'active']
|
||||
}
|
||||
}, {
|
||||
relation: 'phones'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
|
|
@ -53,6 +53,9 @@ module.exports = Self => {
|
|||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
relation: 'phones'
|
||||
},
|
||||
{
|
||||
relation: 'country',
|
||||
scope: {
|
||||
|
|
|
@ -200,6 +200,11 @@
|
|||
"type": "hasOne",
|
||||
"model": "ClaimRatio",
|
||||
"foreignKey": "clientFk"
|
||||
},
|
||||
"phones": {
|
||||
"type": "hasMany",
|
||||
"model": "UserPhone",
|
||||
"foreignKey": "userFk"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -31,20 +31,6 @@
|
|||
info="You can save multiple emails">
|
||||
</vn-textfield>
|
||||
</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-autocomplete
|
||||
vn-one
|
||||
|
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -30,7 +30,7 @@ import './credit-insurance/index';
|
|||
import './credit-insurance/create';
|
||||
import './credit-insurance/insurance/index';
|
||||
import './credit-insurance/insurance/create';
|
||||
import './contact';
|
||||
import './phones';
|
||||
import './sample/index';
|
||||
import './sample/create';
|
||||
import './web-payment';
|
||||
|
|
|
@ -25,10 +25,6 @@
|
|||
label="Id"
|
||||
value="{{::client.id}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Phone"
|
||||
value="{{::client.phone | phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value
|
||||
label="Town/City"
|
||||
value="{{::client.city}}">
|
||||
|
|
|
@ -1,45 +1,48 @@
|
|||
<vn-crud-model
|
||||
url="UserPhoneTypes"
|
||||
data="phoneTypes"
|
||||
auto-load="true">
|
||||
</vn-crud-model>
|
||||
<vn-crud-model
|
||||
vn-id="model"
|
||||
url="ClientContacts"
|
||||
fields="['id', 'name', 'phone', 'clientFk']"
|
||||
link="{clientFk: $ctrl.$stateParams.id}"
|
||||
data="contacts"
|
||||
auto-load="true">
|
||||
url="UserPhones"
|
||||
data="$ctrl.phones">
|
||||
</vn-crud-model>
|
||||
<vn-watcher
|
||||
vn-id="watcher"
|
||||
data="contacts"
|
||||
form="form">
|
||||
data="$ctrl.phones">
|
||||
</vn-watcher>
|
||||
<form name="form" ng-submit="$ctrl.onSubmit()" class="vn-w-md">
|
||||
<vn-card class="vn-pa-lg">
|
||||
<vn-horizontal ng-repeat="contact in contacts">
|
||||
<vn-textfield
|
||||
<vn-horizontal ng-repeat="clientPhone in $ctrl.phones">
|
||||
<vn-autocomplete
|
||||
vn-one
|
||||
label="Name"
|
||||
ng-model="contact.name"
|
||||
rule="ClientContact">
|
||||
</vn-textfield>
|
||||
ng-model="clientPhone.typeFk"
|
||||
initial-data="clientPhone.typeFk"
|
||||
data ="phoneTypes"
|
||||
show-field="code"
|
||||
value-field="code"
|
||||
label="Type"
|
||||
vn-focus>
|
||||
</vn-autocomplete>
|
||||
<vn-textfield
|
||||
vn-one
|
||||
label="Phone"
|
||||
ng-model="contact.phone"
|
||||
rule="ClientContact"
|
||||
vn-focus>
|
||||
ng-model="clientPhone.phone">
|
||||
</vn-textfield>
|
||||
<vn-none>
|
||||
<vn-icon-button
|
||||
vn-tooltip="Remove contact"
|
||||
vn-tooltip="Remove phone"
|
||||
icon="delete"
|
||||
tabindex="-1"
|
||||
ng-click="model.remove($index)">
|
||||
ng-click="model.remove($index)"
|
||||
tabindex="-1">
|
||||
</vn-icon-button>
|
||||
</vn-none>
|
||||
</vn-horizontal>
|
||||
<vn-one>
|
||||
<vn-icon-button
|
||||
vn-bind="+"
|
||||
vn-tooltip="Add contact"
|
||||
vn-tooltip="Add phone"
|
||||
icon="add_circle"
|
||||
ng-click="$ctrl.add()">
|
||||
</vn-icon-button>
|
|
@ -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: '<'
|
||||
}
|
||||
});
|
|
@ -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);
|
||||
});
|
||||
});
|
||||
});
|
|
@ -26,7 +26,7 @@
|
|||
{"state": "client.card.webAccess", "icon": "cloud"},
|
||||
{"state": "client.card.mandate", "icon": "pan_tool"},
|
||||
{"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.webPayment", "icon": "icon-onlinepayment"},
|
||||
{"state": "client.card.dms.index", "icon": "cloud_upload"}
|
||||
|
@ -282,10 +282,10 @@
|
|||
"client": "$ctrl.client"
|
||||
}
|
||||
}, {
|
||||
"url": "/contact",
|
||||
"state": "client.card.contact",
|
||||
"component": "vn-client-contact",
|
||||
"description": "Contacts",
|
||||
"url": "/phones",
|
||||
"state": "client.card.phones",
|
||||
"component": "vn-client-phones",
|
||||
"description": "Client phones",
|
||||
"params": {
|
||||
"client": "$ctrl.client"
|
||||
}
|
||||
|
|
|
@ -12,11 +12,9 @@
|
|||
<vn-label-value label="Contact"
|
||||
value="{{$ctrl.summary.contact}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Phone"
|
||||
value="{{$ctrl.summary.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Mobile"
|
||||
value="{{$ctrl.summary.mobile}}">
|
||||
<vn-label-value ng-repeat = "phone in $ctrl.summary.phones"
|
||||
label="Phone"
|
||||
value="{{phone.phone}}">
|
||||
</vn-label-value>
|
||||
<vn-label-value label="Email" ellipsize="false"
|
||||
value="{{$ctrl.summary.email}}">
|
||||
|
|
Loading…
Reference in New Issue