Skip to content

Commit

Permalink
Merge pull request #437 from owncloud/add-n-fields
Browse files Browse the repository at this point in the history
Adding detailed name field with all structured elements including syn…
  • Loading branch information
irgendwie authored Jun 16, 2016
2 parents c83f7ca + 0cf6d0f commit 609c499
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 4 deletions.
4 changes: 4 additions & 0 deletions css/public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,10 @@ detailsitem.details-item-adr .icon-delete {
top: 57px;
left: 331px;
}
detailsitem.details-item-n .icon-delete {
top: 34px;
left: 331px;
}

detailsitem.details-item-email select {
margin-right: 0;
Expand Down
33 changes: 30 additions & 3 deletions js/components/detailsItem/detailsItem_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ angular.module('contactsApp')
ctrl.type = undefined;
ctrl.isPreferred = false;
ctrl.t = {
poBox : t('contacts', 'Post Office Box'),
postalCode : t('contacts', 'Postal Code'),
poBox : t('contacts', 'Post office box'),
postalCode : t('contacts', 'Postal code'),
city : t('contacts', 'City'),
state : t('contacts', 'State or province'),
country : t('contacts', 'Country'),
address: t('contacts', 'Address'),
newGroup: t('contacts', '(new group)')
newGroup: t('contacts', '(new group)'),
familyName: t('contacts', 'Last name'),
firstName: t('contacts', 'First name'),
additionalNames: t('contacts', 'Additional names'),
honorificPrefix: t('contacts', 'Prefix'),
honorificSuffix: t('contacts', 'Suffix')
};

ctrl.availableOptions = ctrl.meta.options || [];
Expand Down Expand Up @@ -54,6 +59,28 @@ angular.module('contactsApp')
ctrl.model.updateContact();
};

ctrl.updateDetailedName = function () {
var fn = '';
if (ctrl.data.value[3]) {
fn += ctrl.data.value[3] + ' ';
}
if (ctrl.data.value[1]) {
fn += ctrl.data.value[1] + ' ';
}
if (ctrl.data.value[2]) {
fn += ctrl.data.value[2] + ' ';
}
if (ctrl.data.value[0]) {
fn += ctrl.data.value[0] + ' ';
}
if (ctrl.data.value[4]) {
fn += ctrl.data.value[4];
}

ctrl.model.contact.fullName(fn);
ctrl.model.updateContact();
};

ctrl.getTemplate = function() {
var templateUrl = OC.linkTo('contacts', 'templates/detailItems/' + ctrl.meta.template + '.html');
return $templateRequest(templateUrl);
Expand Down
9 changes: 8 additions & 1 deletion js/services/vCardProperties.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ angular.module('contactsApp')
readableName: t('contacts', 'Nickname'),
template: 'text'
},
n: {
readableName: t('contacts', 'Detailed name'),
defaultValue: {
value:['', '', '', '', '']
},
template: 'n'
},
note: {
readableName: t('contacts', 'Notes'),
template: 'textarea'
Expand Down Expand Up @@ -108,7 +115,7 @@ angular.module('contactsApp')
},
'X-SOCIALPROFILE': {
multiple: true,
readableName: t('contacts', 'Social Network'),
readableName: t('contacts', 'Social network'),
template: 'text',
defaultValue: {
value:[''],
Expand Down
22 changes: 22 additions & 0 deletions templates/detailItems/n.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<label ng-if="ctrl.availableOptions.length === 0" for="details-{{ctrl.name}}">{{ctrl.meta.readableName}}</label>
<div>
<label for="details-honorificPrefix">{{ctrl.t.honorificPrefix}}</label>
<input type="text" id="details-honorificPrefix" name="honorificPrefix" ng-model="ctrl.data.value[3]" ng-model-options="{ debounce: 500 }" ng-change="ctrl.updateDetailedName()" value="" />
</div>
<div>
<label for="details-firstName">{{ctrl.t.firstName}}</label>
<input type="text" id="details-firstName" name="firstName" ng-model="ctrl.data.value[1]" ng-model-options="{ debounce: 500 }" ng-change="ctrl.updateDetailedName()" value="" />
</div>
<div>
<label for="details-additionalNames">{{ctrl.t.additionalNames}}</label>
<input type="text" id="details-additionalNames" name="additionalNames" ng-model="ctrl.data.value[2]" ng-model-options="{ debounce: 500 }" ng-change="ctrl.updateDetailedName()" value="" />
</div>
<div>
<label for="details-familyName">{{ctrl.t.familyName}}</label>
<input type="text" id="details-familyName" name="familyName" ng-model="ctrl.data.value[0]" ng-model-options="{ debounce: 500 }" ng-change="ctrl.updateDetailedName()" value="" />
</div>
<div>
<label for="details-honorificSuffix">{{ctrl.t.honorificSuffix}}</label>
<input type="text" id="details-honorificSuffix" name="honorificSuffix" ng-model="ctrl.data.value[4]" ng-model-options="{ debounce: 500 }" ng-change="ctrl.updateDetailedName()" value="" />
</div>
<button ng-click="ctrl.deleteField()" class="icon-delete" title="Delete"></button>

0 comments on commit 609c499

Please sign in to comment.