mirror of
https://github.com/fazo96/homework.git
synced 2025-01-09 12:10:08 +01:00
massive update to fix #20 and other small stuff
This commit is contained in:
parent
edf8ef22a6
commit
a23b02d39d
@ -10,5 +10,4 @@ natestrauser:font-awesome@4.1.0
|
||||
accounts-base
|
||||
accounts-password
|
||||
iron:router
|
||||
rajit:bootstrap3-datepicker
|
||||
|
||||
mrt:moment
|
||||
|
@ -39,11 +39,11 @@ minimongo@1.0.3
|
||||
mobile-status-bar@1.0.0
|
||||
mongo@1.0.5
|
||||
mrt:bootstrap-3@3.1.1-1
|
||||
mrt:moment@2.8.1
|
||||
natestrauser:font-awesome@4.2.0
|
||||
npm-bcrypt@0.7.7
|
||||
observe-sequence@1.0.2
|
||||
ordered-dict@1.0.0
|
||||
rajit:bootstrap3-datepicker@1.3.1
|
||||
random@1.0.0
|
||||
reactive-dict@1.0.2
|
||||
reactive-var@1.0.1
|
||||
|
@ -2,16 +2,13 @@
|
||||
homework_version = "1.0"
|
||||
# Utilities
|
||||
notes = new Meteor.Collection "notes"
|
||||
Meteor.subscribe 'user'
|
||||
getUser = -> Meteor.user()
|
||||
deleteAccount = ->
|
||||
Meteor.call 'deleteMe', (r) -> if r is yes then Router.go 'home'
|
||||
amIValid = ->
|
||||
return no unless getUser()
|
||||
return yes for mail in getUser().emails when mail.verified is yes; no
|
||||
daysUntil = (time) ->
|
||||
date = new Date time; now = new Date() #console.log date+" "+now
|
||||
now.setHours(0); now.setMinutes(0); now.setSeconds(0)
|
||||
(Math.floor ((date.getTime() - now.getTime()) / 1000 / 60 / 60) + 1) / 24
|
||||
|
||||
# Common Helpers for the Templates
|
||||
UI.registerHelper "loggingIn", -> Meteor.loggingIn()
|
||||
@ -103,8 +100,15 @@ Template.menu.events
|
||||
'click .go-archive': -> Router.go 'archive'
|
||||
|
||||
# Account Page
|
||||
Template.account.dateformat = -> getUser().dateformat
|
||||
Template.account.events
|
||||
'click #btn-logout': (e,template) -> Meteor.logout logoutCallback
|
||||
'click #reset-settings': (e,t) ->
|
||||
t.find('#set-date-format').value = "MM/DD/YYYY"
|
||||
'click #save-settings': (e,t) ->
|
||||
Meteor.users.update getUser()._id,
|
||||
$set: dateformat: t.find('#set-date-format').value
|
||||
showError msg: 'Settings saved', type: 'success'
|
||||
'click #btn-logout': -> Meteor.logout logoutCallback
|
||||
'click #btn-delete-me': -> deleteAccount()
|
||||
|
||||
# Notes list
|
||||
@ -113,22 +117,16 @@ Template.notelist.active = ->
|
||||
return @_id is Router.current().data()._id
|
||||
Template.notelist.empty = -> Template.notelist.notelist().length is 0
|
||||
Template.notelist.getDate = ->
|
||||
return unless @date; diff = daysUntil @date
|
||||
if diff <= 0 then return msg:"You missed it!", color: "danger"
|
||||
if diff is 1 then return msg:"Today", color: "warning"
|
||||
if diff is 2 then return msg:"Tomorrow", color: "info"
|
||||
msg: "due in "+diff+" days", color: "primary"
|
||||
return unless @date
|
||||
#dif = moment(@date, getUser().dateformat).diff(moment(), 'days')
|
||||
dif = moment.unix(@date).diff(moment(), 'days')
|
||||
color = "primary"
|
||||
color = "info" if dif < 7
|
||||
color = "warning" if dif is 1
|
||||
color = "danger" if dif < 1
|
||||
msg: moment.unix(@date).fromNow(), color: color
|
||||
Template.notelist.notelist = ->
|
||||
notes.find({ archived: no },{ sort: date: 1}).fetch()
|
||||
###
|
||||
return [] unless getUser() and Router.current and Router.current().path
|
||||
path = Router.current().path
|
||||
if path.startsWith '/note'
|
||||
return notes.find({ archived: no },{ sort: date: 1}).fetch()
|
||||
else if path.startsWith '/archive'
|
||||
return notes.find({ archived: yes },{ sort: date: 1}).fetch()
|
||||
else return []
|
||||
###
|
||||
Template.notelist.events
|
||||
'click .close-note': -> notes.update @_id, $set: archived: yes
|
||||
'click .edit-note': -> Router.go 'notes'
|
||||
@ -141,6 +139,7 @@ Template.notelist.events
|
||||
|
||||
# Archive
|
||||
Template.archivedlist.empty = -> Template.archivedlist.archived().length is 0
|
||||
Template.archivedlist.getDate = Template.notelist.getDate
|
||||
Template.archivedlist.archived = ->
|
||||
notes.find({ archived: yes },{ sort: date: 1}).fetch()
|
||||
Template.archivedlist.events =
|
||||
@ -151,20 +150,29 @@ Template.archivedlist.events =
|
||||
|
||||
# Note Editor
|
||||
Template.editor.note = -> Router.current().data()
|
||||
Template.editor.rendered = -> $('.date').datepicker
|
||||
weekStart: 1
|
||||
startDate: "today"
|
||||
todayBtn: "linked"
|
||||
Template.editor.formattedDate = ->
|
||||
return unless @date
|
||||
moment.unix(@date).format(getUser().dateformat)
|
||||
saveCurrentNote = (t,e) ->
|
||||
if e and e.keyCode isnt 13 then return
|
||||
dat = no
|
||||
if t.find('.date').value isnt ""
|
||||
dat = moment(t.find('.date').value,getUser().dateformat)
|
||||
if dat.isValid()
|
||||
dat = dat.unix()
|
||||
else
|
||||
dat = no; showError msg: 'Invalid date'
|
||||
t.find('.date').value = ""
|
||||
notes.update Router.current().data()._id,
|
||||
$set:
|
||||
title: t.find('.editor-title').value
|
||||
content: t.find('.area').value
|
||||
date: t.find('.date').value
|
||||
date: dat
|
||||
Template.editor.events
|
||||
'click .close-editor': -> Router.go 'notes'
|
||||
'click .save-editor': (e,t) -> saveCurrentNote t
|
||||
'click .set-date': (e,t) ->
|
||||
t.find('.date').value = moment().add(1,'days').format(getUser().dateformat)
|
||||
'keypress .title': (e,t) -> saveCurrentNote t, e
|
||||
|
||||
# Notifications (not used yet)
|
||||
@ -241,6 +249,7 @@ registerRequest = (e,template) ->
|
||||
Accounts.createUser {
|
||||
email: mail,
|
||||
password: pass
|
||||
dateformat: "MM/DD/YYYY"
|
||||
}, (err) -> if err then errCallback err else Router.go 'confirmEmail'
|
||||
catch err
|
||||
showError msg: err
|
||||
|
@ -21,6 +21,15 @@ input {
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
|
||||
#save-settings, #reset-settings {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
#set-date-format {
|
||||
max-width: 200px;
|
||||
}
|
||||
|
||||
.date {
|
||||
max-width: 250px;
|
||||
}
|
||||
@ -63,7 +72,6 @@ input {
|
||||
|
||||
.note-date{
|
||||
float:right;
|
||||
margin-top: -17px;
|
||||
}
|
||||
.note-desc {
|
||||
color: #999;
|
||||
@ -81,6 +89,13 @@ input {
|
||||
.edit-note {
|
||||
display: inline-block;
|
||||
margin-right: 10px;
|
||||
font-size: 18px;
|
||||
font-weight: bold;
|
||||
line-height: 1;
|
||||
color: #000;
|
||||
text-shadow: 0 1px 0 #fff;
|
||||
filter: alpha(opacity=20);
|
||||
opacity: .2;
|
||||
}
|
||||
|
||||
.editor-title { width: 70%; }
|
||||
@ -95,7 +110,7 @@ input {
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.save-editor {
|
||||
.save-editor, .set-date {
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
@ -104,7 +119,7 @@ input {
|
||||
}
|
||||
|
||||
.btn-ver {
|
||||
width:150px;
|
||||
width:115px;
|
||||
margin-top:20px;
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
{{#each notelist}}
|
||||
<a href="{{pathFor 'notes'}}" class="note list-group-item">
|
||||
<span class="note-content">
|
||||
{{#if active}}<a role="button" class="edit-note close">
|
||||
{{#if active}}<a role="button" class="edit-note">
|
||||
<i class="fa fa-pencil-square-o"></i>
|
||||
</a>{{/if}}
|
||||
<b>{{title}}</b> <span class="note-desc">{{content}}</span>
|
||||
@ -60,7 +60,7 @@
|
||||
<a href="{{pathFor 'archive'}}" class="note list-group-item">
|
||||
<span class="note-content">
|
||||
<b>{{title}}</b> <span class="note-desc">{{content}}</span>
|
||||
<!--<span class="note-date label label-{{getDate.color}}">{{getDate.msg}}</span>-->
|
||||
<span class="note-date label label-{{getDate.color}}">{{getDate.msg}}</span>
|
||||
</span>
|
||||
<button type="button" class="close-note close archive-close-note">
|
||||
<i class="fa fa-trash-o"></i></button>
|
||||
@ -90,8 +90,11 @@
|
||||
</div>
|
||||
<div align="center" class="panel-body">
|
||||
<textarea id="area" class="area form-control in-bt" rows="3" placeholder="...">{{content}}</textarea>
|
||||
<!--<input class="form-control date" value="{{date}}" placeholder="Due Date">-->
|
||||
<button type="button" class="btn btn-info save-editor">Save</button>
|
||||
<input class="form-control date" value="{{formattedDate}}" placeholder="Due Date">
|
||||
<button type="button" class="btn btn-warning set-date">
|
||||
<i class="fa fa-clock-o"></i> Do Today</button>
|
||||
<button type="button" class="btn btn-info save-editor">
|
||||
<i class="fa fa-upload"></i> Save</button>
|
||||
</div>
|
||||
</div>
|
||||
{{/if}}
|
||||
@ -143,6 +146,16 @@
|
||||
<template name="account">
|
||||
<div align="center">
|
||||
<h3 class="cool-header"><i class="fa fa-user fa-2x"></i><br>{{email}}</h3>
|
||||
{{> error}}
|
||||
<p class="lead">Settings</p>
|
||||
<p>You can choose the format used to write and read dates in the note list</p>
|
||||
<input type="text" class="form-control" id="set-date-format" placeholder="Date Format" value="{{dateformat}}">
|
||||
<div class="btn-group">
|
||||
<button type="button" id="save-settings" class="btn btn-primary">
|
||||
<i class="fa fa-upload"></i> Save</button>
|
||||
<button type="button" id="reset-settings" class="btn btn-warning">
|
||||
<i class="fa fa-cog"></i> Reset</button>
|
||||
</div>
|
||||
{{> menu}}
|
||||
<div class="btn-group btns-account">
|
||||
<button type="button" id="btn-logout" class="btn btn-warning">
|
||||
@ -163,17 +176,17 @@
|
||||
<p>Click the link inside the email we sent you or paste it here:</p>
|
||||
{{> error}}
|
||||
<input type="text" id="token-field" class="form-control" placeholder="Token" value="{{token}}">
|
||||
<div align="center" class="buttons">
|
||||
<div align="center" class="btn-group">
|
||||
<button type="button" class="btn btn-warning btn-ver" id="btn-resend">
|
||||
<i class="fa fa-refresh"></i> Resend</button>
|
||||
<button type="button" class="btn btn-success btn-ver" id="btn-verify">
|
||||
<i class="fa fa-check"></i> Verify Token</button>
|
||||
<i class="fa fa-check"></i> Verify</button>
|
||||
<button type="button" class="btn btn-danger btn-ver" id="btn-delete">
|
||||
<i class="fa fa-trash-o"></i> Delete Account</button>
|
||||
<br><button type="button" class="btn btn-primary btn-ver" id="btn-logout">
|
||||
<i class="fa fa-trash-o"></i> Delete</button>
|
||||
</div><br>
|
||||
<button type="button" class="btn btn-primary btn-ver" id="btn-logout">
|
||||
<i class="fa fa-sign-out"></i> Sign Out</button>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<!-- Notification list. It doesn't show anything unless there are notifications -->
|
||||
|
@ -15,6 +15,7 @@ userValidated = (user) ->
|
||||
return no unless user?
|
||||
return yes for mail in user.emails when mail.verified is yes; no
|
||||
|
||||
Meteor.publish 'user', -> Meteor.users.find @userId, fields: dateformat: 1
|
||||
# Publish user's notes to each user.
|
||||
Meteor.publish "my-notes", ->
|
||||
if userValidated getUser(@userId)
|
||||
@ -50,4 +51,9 @@ Meteor.methods
|
||||
{$set : { "resume.loginTokens" : [] } }, { multi: yes }
|
||||
return yes
|
||||
no
|
||||
version: -> "1.0" # Request server version number.
|
||||
Meteor.users.allow
|
||||
update: (id,doc,fields,mod) ->
|
||||
if fields[0] == 'dateformat' and fields.length == 1
|
||||
console.log mod
|
||||
return yes
|
||||
return no
|
||||
|
Loading…
Reference in New Issue
Block a user