mirror of
https://github.com/fazo96/homework.git
synced 2025-01-10 12:14:22 +01:00
notes are now divided in pages
This commit is contained in:
parent
5a4ada291f
commit
50fff6b5e9
@ -14,4 +14,5 @@ mizzao:bootstrap-3
|
|||||||
spiderable
|
spiderable
|
||||||
kevohagan:sweetalert
|
kevohagan:sweetalert
|
||||||
accounts-twitter
|
accounts-twitter
|
||||||
|
fazo96:paginator
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ deps@1.0.5
|
|||||||
ejson@1.0.4
|
ejson@1.0.4
|
||||||
email@1.0.4
|
email@1.0.4
|
||||||
fastclick@1.0.1
|
fastclick@1.0.1
|
||||||
|
fazo96:paginator@0.1.0
|
||||||
follower-livedata@1.0.2
|
follower-livedata@1.0.2
|
||||||
geojson-utils@1.0.1
|
geojson-utils@1.0.1
|
||||||
html-tools@1.0.2
|
html-tools@1.0.2
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
# Homework - Client Side
|
# Homework - Client Side
|
||||||
version = "1.1.7"
|
version = "1.1.8"
|
||||||
# Utilities
|
# Utilities
|
||||||
tick = new Tracker.Dependency()
|
tick = new Tracker.Dependency()
|
||||||
Meteor.setInterval (-> tick.changed();), 15000
|
Meteor.setInterval (-> tick.changed();), 15000
|
||||||
|
|
||||||
notes = new Meteor.Collection "notes"
|
notes = new Meteor.Collection 'notes'
|
||||||
userSub = Meteor.subscribe 'user'
|
userSub = Meteor.subscribe 'user'
|
||||||
getUser = -> Meteor.user()
|
getUser = -> Meteor.user()
|
||||||
deleteAccount = ->
|
deleteAccount = ->
|
||||||
@ -76,8 +76,7 @@ guestController = RouteController.extend
|
|||||||
if amIValid() is no then Router.go 'verifyEmail' else Router.go 'notes'
|
if amIValid() is no then Router.go 'verifyEmail' else Router.go 'notes'
|
||||||
@next()
|
@next()
|
||||||
|
|
||||||
|
# Page Routing
|
||||||
|
|
||||||
Router.route '/',
|
Router.route '/',
|
||||||
name: 'home'
|
name: 'home'
|
||||||
template: 'homepage'
|
template: 'homepage'
|
||||||
@ -92,14 +91,9 @@ Router.route '/register', controller: guestController
|
|||||||
Router.route '/account', controller: loggedInController
|
Router.route '/account', controller: loggedInController
|
||||||
Router.route '/notes/:_id?',
|
Router.route '/notes/:_id?',
|
||||||
name: 'notes'
|
name: 'notes'
|
||||||
waitOn: -> Meteor.subscribe 'my-notes'
|
waitOn: -> Meteor.subscribe 'notes', no
|
||||||
data: -> notes.findOne _id: @params._id
|
data: -> notes.findOne _id: @params._id
|
||||||
controller: loggedInController
|
controller: loggedInController
|
||||||
Router.route '/archive/:_id?',
|
|
||||||
name: 'archive'
|
|
||||||
waitOn: -> @notes = Meteor.subscribe 'archive'
|
|
||||||
onStop: -> @notes.stop()
|
|
||||||
controller: loggedInController
|
|
||||||
Router.route '/verify/:token?',
|
Router.route '/verify/:token?',
|
||||||
name: 'verifyEmail'
|
name: 'verifyEmail'
|
||||||
template: 'verifyEmail'
|
template: 'verifyEmail'
|
||||||
@ -109,20 +103,26 @@ Router.route '/verify/:token?',
|
|||||||
else @render()
|
else @render()
|
||||||
onBeforeAction: ->
|
onBeforeAction: ->
|
||||||
if getUser()
|
if getUser()
|
||||||
if amIValid() then Router.go 'home'
|
if amIValid()
|
||||||
else Router.go 'home'
|
Router.go 'home'; @next()
|
||||||
# Automatic verification
|
else if @params.token? and @params.token isnt ""
|
||||||
if @params.token? and @params.token isnt ""
|
# Automatic verification
|
||||||
@render 'loading'
|
@render 'loading'
|
||||||
Accounts.verifyEmail @params.token, (err) =>
|
Accounts.verifyEmail @params.token, (err) =>
|
||||||
if err
|
if err
|
||||||
errCallback err; Router.go 'verifyEmail', token: @params.token
|
errCallback err; Router.go 'verifyEmail', token: @params.token
|
||||||
else
|
else
|
||||||
showErr type:'success', msg:'Verification complete'
|
showErr type:'success', msg:'Verification complete'
|
||||||
Router.go 'home'
|
Router.go 'home'
|
||||||
@next()
|
@next()
|
||||||
else @next()
|
else
|
||||||
Router.route '/(.*)', -> @render '404'
|
Router.go 'home'; @next()
|
||||||
|
Router.route '/archive/:_id?',
|
||||||
|
name: 'archive'
|
||||||
|
waitOn: -> @notes = Meteor.subscribe 'notes', yes
|
||||||
|
onStop: -> @notes.stop()
|
||||||
|
controller: loggedInController
|
||||||
|
Router.route '/(.*)', -> @render '404' # Catch-all route
|
||||||
|
|
||||||
# Client Templates
|
# Client Templates
|
||||||
|
|
||||||
@ -176,7 +176,13 @@ formattedDate = ->
|
|||||||
color = "warning" if dif is 1
|
color = "warning" if dif is 1
|
||||||
color = "danger" if dif < 1
|
color = "danger" if dif < 1
|
||||||
msg: moment.unix(@date).fromNow(), color: color
|
msg: moment.unix(@date).fromNow(), color: color
|
||||||
notelist = -> notes.find({ archived: no },{ sort: date: 1})
|
notePaginator = new Paginator(10)
|
||||||
|
notelist = ->
|
||||||
|
notePaginator.calibrate(notes.find(archived: no).count())
|
||||||
|
opt = notePaginator.queryOptions()
|
||||||
|
notes.find({ archived: no },{
|
||||||
|
sort: {date: 1}, skip: opt.skip, limit: opt.limit
|
||||||
|
})
|
||||||
Template.notelist.helpers
|
Template.notelist.helpers
|
||||||
notelist: -> notelist().fetch()
|
notelist: -> notelist().fetch()
|
||||||
active: ->
|
active: ->
|
||||||
@ -184,6 +190,8 @@ Template.notelist.helpers
|
|||||||
return @_id is Router.current().data()._id
|
return @_id is Router.current().data()._id
|
||||||
empty: -> notelist().count() is 0
|
empty: -> notelist().count() is 0
|
||||||
getDate: formattedDate
|
getDate: formattedDate
|
||||||
|
paginator: -> notePaginator
|
||||||
|
pageActive: -> if @active then "btn-primary" else "btn-default"
|
||||||
|
|
||||||
Template.notelist.events
|
Template.notelist.events
|
||||||
'click .close-note': -> notes.update @_id, $set: archived: yes
|
'click .close-note': -> notes.update @_id, $set: archived: yes
|
||||||
@ -194,18 +202,28 @@ Template.notelist.events
|
|||||||
title: template.find('#newNote').value
|
title: template.find('#newNote').value
|
||||||
content: "", date: no, archived: no, userId: Meteor.userId()
|
content: "", date: no, archived: no, userId: Meteor.userId()
|
||||||
template.find('#newNote').value = ""
|
template.find('#newNote').value = ""
|
||||||
|
'click .btn': -> notePaginator.page @index
|
||||||
|
|
||||||
# Archive
|
# Archive
|
||||||
archived = -> notes.find({ archived: yes },{ sort: date: 1})
|
archivePaginator = new Paginator(10)
|
||||||
|
archived = ->
|
||||||
|
archivePaginator.calibrate(notes.find(archived: yes).count())
|
||||||
|
opt = archivePaginator.queryOptions()
|
||||||
|
notes.find({archived: yes},{
|
||||||
|
sort: {date: 1}, limit: opt.limit, skip: opt.skip
|
||||||
|
})
|
||||||
Template.archivedlist.helpers
|
Template.archivedlist.helpers
|
||||||
empty: -> archived().count() is 0
|
empty: -> archived().count() is 0
|
||||||
getDate: formattedDate
|
getDate: formattedDate
|
||||||
archived: -> archived().fetch()
|
archived: -> archived().fetch()
|
||||||
|
paginator: -> archivePaginator
|
||||||
|
pageActive: -> if @active then "btn-primary" else "btn-default"
|
||||||
Template.archivedlist.events
|
Template.archivedlist.events
|
||||||
'click .close-note': -> notes.remove @_id
|
'click .close-note': -> notes.remove @_id
|
||||||
'click .note': -> notes.update @_id, $set: archived: no
|
'click .note': -> notes.update @_id, $set: archived: no
|
||||||
'click .clear': ->
|
'click .clear': ->
|
||||||
notes.remove item._id for item in Template.archivedlist.archived()
|
notes.remove item._id for item in Template.archivedlist.archived()
|
||||||
|
'click .btn': (e) -> archivePaginator.page @index
|
||||||
|
|
||||||
# Note Editor
|
# Note Editor
|
||||||
Template.editor.helpers
|
Template.editor.helpers
|
||||||
|
@ -153,6 +153,10 @@ input {
|
|||||||
margin-right: 10px
|
margin-right: 10px
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.paginator {
|
||||||
|
margin-bottom: 1em;
|
||||||
|
}
|
||||||
|
|
||||||
/* IDs */
|
/* IDs */
|
||||||
|
|
||||||
#ui-container {
|
#ui-container {
|
||||||
|
@ -43,6 +43,13 @@
|
|||||||
</a>
|
</a>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
{{#if paginator.show}}
|
||||||
|
<div align="center"><div class="btn-group paginator">
|
||||||
|
{{#each paginator.pages}}
|
||||||
|
<button type="button" class="btn {{pageActive}}">{{index}}</button>
|
||||||
|
{{/each}}
|
||||||
|
</div></div>
|
||||||
|
{{/if}}
|
||||||
{{#if empty}}
|
{{#if empty}}
|
||||||
<p class="lead" align="center">You don't have any notes, try adding a new one!</p>
|
<p class="lead" align="center">You don't have any notes, try adding a new one!</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
@ -67,6 +74,13 @@
|
|||||||
</a>
|
</a>
|
||||||
{{/each}}
|
{{/each}}
|
||||||
</div>
|
</div>
|
||||||
|
{{#if paginator.show}}
|
||||||
|
<div align="center"><div class="btn-group paginator">
|
||||||
|
{{#each paginator.pages}}
|
||||||
|
<button type="button" class="btn {{pageActive}}">{{index}}</button>
|
||||||
|
{{/each}}
|
||||||
|
</div></div>
|
||||||
|
{{/if}}
|
||||||
{{#if empty}}
|
{{#if empty}}
|
||||||
<p class="lead" align="center">Your archive is empty</p>
|
<p class="lead" align="center">Your archive is empty</p>
|
||||||
{{else}}
|
{{else}}
|
||||||
|
@ -19,12 +19,9 @@ userValidated = (user) ->
|
|||||||
Meteor.publish 'user', ->
|
Meteor.publish 'user', ->
|
||||||
Meteor.users.find @userId, fields: {dateformat: 1, username: 1}
|
Meteor.users.find @userId, fields: {dateformat: 1, username: 1}
|
||||||
# Publish user's notes to each user.
|
# Publish user's notes to each user.
|
||||||
Meteor.publish "my-notes", ->
|
Meteor.publish "notes", (archived) ->
|
||||||
if userValidated getUser(@userId)
|
if userValidated getUser(@userId)
|
||||||
notes.find userId: @userId, archived: no
|
notes.find userId: @userId, archived: archived
|
||||||
Meteor.publish "archive", ->
|
|
||||||
if userValidated getUser(@userId)
|
|
||||||
notes.find userId: @userId, archived: yes
|
|
||||||
|
|
||||||
# Custom new account default settings
|
# Custom new account default settings
|
||||||
Accounts.onCreateUser (options, user) ->
|
Accounts.onCreateUser (options, user) ->
|
||||||
|
Loading…
Reference in New Issue
Block a user