Skip to content

Commit cba853e

Browse files
committed
Demo app: minor changes
1 parent 1261270 commit cba853e

File tree

2 files changed

+24
-18
lines changed

2 files changed

+24
-18
lines changed

demo/client/listing/listing-row.jade

+15-13
Original file line numberDiff line numberDiff line change
@@ -44,18 +44,19 @@ template(name="listingRow")
4444
.file-name #{name}
4545
br
4646
.file-info
47-
if compare userId 'is' currentUser._id
48-
unless meta.secured
49-
span(title="{{#if meta.unlisted}}Unlisted{{else}}Visible to everyone{{/if}}")
50-
i.fa.fa-fw(class="fa-eye{{#if meta.unlisted}}-slash{{/if}}")
47+
if userId
48+
if compare userId 'is' currentUser._id
49+
unless meta.secured
50+
span(title="{{#if meta.unlisted}}Unlisted{{else}}Visible to everyone{{/if}}")
51+
i.fa.fa-fw(class="fa-eye{{#if meta.unlisted}}-slash{{/if}}")
52+
|  
53+
| ·
54+
|  
55+
span(title="{{#if meta.secured}}Only you can see this file{{else}}Publicity availble file{{/if}}")
56+
i.fa.fa-fw(class="fa-{{#unless meta.secured}}un{{/unless}}lock")
5157
|  
5258
| ·
5359
|  
54-
span(title="{{#if meta.secured}}Only you can see this file{{else}}Publicity availble file{{/if}}")
55-
i.fa.fa-fw(class="fa-{{#unless meta.secured}}un{{/unless}}lock")
56-
|  
57-
| ·
58-
|  
5960
span.file-size(title="File size") {{filesize size}}
6061
|  
6162
| ·
@@ -65,7 +66,8 @@ template(name="listingRow")
6566
| ·
6667
|  
6768
span.file-downloads(title="File was downloaded for #{meta.downloads} times") #{meta.downloads}
68-
if compare userId 'is' currentUser._id
69-
td.file-settings.width-1(data-show-settings)
70-
a(href="#" title="{{#if showSettings}}Close Settings{{else}}You owns this file: Edit Settings{{/if}}" class="{{#unless showSettings}}show-settings{{/unless}}")
71-
i.fa(class="fa-{{#if showSettings}}times{{else}}gear{{/if}}")
69+
if userId
70+
if compare userId 'is' currentUser._id
71+
td.file-settings.width-1(data-show-settings)
72+
a(href="#" title="{{#if showSettings}}Close Settings{{else}}You owns this file: Edit Settings{{/if}}" class="{{#unless showSettings}}show-settings{{/unless}}")
73+
i.fa(class="fa-{{#if showSettings}}times{{else}}gear{{/if}}")

demo/lib/files.collection.coffee

+9-5
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,19 @@ Collections.files = new FilesCollection
5555
collectionName: 'uploadedFiles'
5656
allowClientCode: true
5757
protected: (fileObj) ->
58-
if not fileObj.meta?.secured
59-
return true
60-
else if fileObj.meta?.secured and @userId is fileObj.userId
61-
return true
58+
if fileObj
59+
if not fileObj.meta?.secured
60+
return true
61+
else if fileObj.meta?.secured and @userId is fileObj.userId
62+
return true
6263
return false
6364
onBeforeRemove: (cursor) ->
6465
self = @
6566
res = cursor.map (file) ->
66-
return file?.userId is self.userId
67+
if file?.userId and _.isString file.userId
68+
return file.userId is self.userId
69+
else
70+
return false
6771
return !~res.indexOf false
6872
onBeforeUpload: ->
6973
return if @file.size <= 1024 * 1024 * 128 then true else "Max. file size is 128MB you've tried to upload #{filesize(@file.size)}"

0 commit comments

Comments
 (0)