Skip to content

Commit

Permalink
Added a 'displayName' optional method in the 'IResource' interface + …
Browse files Browse the repository at this point in the history
…Use the 'displayName' method when available as text for the 'DAV:displayname' XML element in the PROPFIND response body
  • Loading branch information
AdrienCastex committed Jun 15, 2017
1 parent c3f8b6a commit c9812d6
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/resource/IResource.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ export interface IResource {
creationDate(callback: ReturnCallback<number>): any;
lastModifiedDate(callback: ReturnCallback<number>): any;
webName(callback: ReturnCallback<string>): any;
displayName?(callback: ReturnCallback<string>): any;
type(callback: ReturnCallback<ResourceType>): any;
}
5 changes: 4 additions & 1 deletion lib/server/commands/Propfind.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,10 @@ function default_1(arg, callback) {
}); });
});
displayValue('displayname', function () {
resource.webName(function (e, name) { return process.nextTick(function () {
var methodDisplayName = resource.webName;
if (resource.displayName)
methodDisplayName = resource.displayName;
methodDisplayName.bind(resource)(function (e, name) { return process.nextTick(function () {
if (!e)
tags.displayname.el.add(name ? name : '');
nbOut(e);
Expand Down
1 change: 1 addition & 0 deletions src/resource/IResource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,5 +71,6 @@ export interface IResource
creationDate(callback : ReturnCallback<number>)
lastModifiedDate(callback : ReturnCallback<number>)
webName(callback : ReturnCallback<string>)
displayName?(callback : ReturnCallback<string>)
type(callback : ReturnCallback<ResourceType>)
}
6 changes: 5 additions & 1 deletion src/server/commands/Propfind.ts
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,11 @@ export default function(arg : MethodCallArgs, callback)

displayValue('displayname', () =>
{
resource.webName((e, name) => process.nextTick(() => {
let methodDisplayName = resource.webName;
if(resource.displayName)
methodDisplayName = resource.displayName;

methodDisplayName.bind(resource)((e, name) => process.nextTick(() => {
if(!e)
tags.displayname.el.add(name ? name : '');
nbOut(e);
Expand Down

0 comments on commit c9812d6

Please sign in to comment.