diff --git a/client/client.coffee b/client/client.coffee index 36d35a0..e149215 100644 --- a/client/client.coffee +++ b/client/client.coffee @@ -40,6 +40,7 @@ share.notify = notify = (opt) -> opt.type ?= "danger" notification.set opt errCallback = (err) -> + return unless err if err.reason then notify msg: err.reason else notify msg: err Template.notifications.notification = -> notification.get() Template.notifications.events @@ -50,13 +51,20 @@ Template.layout.showSpinner = -> Template.home.ndocs = -> docs.find().count() Template.new.events 'click #new-btn': (e,t) -> - id = docs.insert + if t.find('#title').value is '' + return notify msg: 'please insert a title' + if t.find('#editor').value is '' + return notify msg: "can't create empty document" + docs.insert { title: t.find('#title').value text: t.find('#editor').value + showTitle: $('#show-title').is(':checked') dateCreated: moment().unix() - if id - Router.go 'doc', _id: id - else notify msg: 'document creation failed' + }, (err,id) -> + errCallback err + if id then Router.go 'doc', _id: id + +Template.doc.canEdit = -> "disabled" unless Meteor.user()._id is @owner Template.signup.events 'click #signup': (e,t) -> diff --git a/client/main.html b/client/main.html deleted file mode 100644 index a2e7e5f..0000000 --- a/client/main.html +++ /dev/null @@ -1,6 +0,0 @@ - - MarkCloud - - - - diff --git a/client/style.less b/client/style.less index 1d7ddab..cdfc407 100644 --- a/client/style.less +++ b/client/style.less @@ -19,6 +19,13 @@ } // Editor + +#title { + margin-bottom: 1em; +} +#editor { + margin-top: 1em; +} #new-btn { margin-top: 1em; } diff --git a/client/templates.html b/client/templates.html index cfde2b1..0057aa7 100644 --- a/client/templates.html +++ b/client/templates.html @@ -1,3 +1,10 @@ + + MarkCloud + + + + +