The field {{error}} is required.
+ {{/each}} +The field {{error}} is required.
+ {{/each}} +diff --git a/client/lib/sideNav.coffee b/client/lib/sideNav.coffee index ec93cf2a5f0..521625fdb3b 100644 --- a/client/lib/sideNav.coffee +++ b/client/lib/sideNav.coffee @@ -9,6 +9,15 @@ , 200 return + validate = -> + invalid = [] + sideNav.find("input.required").each -> + if not this.value.length + invalid.push $(this).prev("label").html() + if invalid.length + return invalid + return false; + toggleFlex = (status) -> if flexNav.opened or status? is -1 flexNav.opened = false @@ -47,5 +56,6 @@ getFlex: getFlex openFlex: openFlex closeFlex: closeFlex + validate: validate )() \ No newline at end of file diff --git a/client/stylesheets/base.less b/client/stylesheets/base.less index 3858e78ece6..78a6da2f87a 100644 --- a/client/stylesheets/base.less +++ b/client/stylesheets/base.less @@ -862,6 +862,9 @@ a.github-fork { } .input-line{ margin-bottom: 25px; + &:nth-last-child(1){ + margin-bottom: 0; + } label{ text-transform: uppercase; font-weight: 400; @@ -937,6 +940,19 @@ a.github-fork { padding-left: 8px; } } + .input-error{ + text-align: center; + color: #f09286; + font-size: 12px; + padding: 0; + text-align: left; + margin-bottom: -20px; + margin-top: -12px; + strong{ + display: block; + margin-bottom: 2px; + } + } .empty{ padding-left: 10px; font-size: 11px; diff --git a/client/views/app/sideNav/channelsFlex.coffee b/client/views/app/sideNav/channelsFlex.coffee index 06b45009e49..308a1106449 100644 --- a/client/views/app/sideNav/channelsFlex.coffee +++ b/client/views/app/sideNav/channelsFlex.coffee @@ -5,6 +5,9 @@ Template.channelsFlex.helpers name: -> return Template.instance().selectedUserNames[this.valueOf()] + error: -> + return Template.instance().error.get() + autocompleteSettings: -> return { limit: 10 @@ -52,23 +55,32 @@ Template.channelsFlex.events 'click .cancel-channel': (e, instance) -> SideNav.closeFlex() + 'keydown input[type="text"]': (e, instance) -> + Template.instance().error.set([]) + 'click .save-channel': (e, instance) -> - Meteor.call 'createChannel', instance.find('#channel-name').value, instance.selectedUsers.get(), (err, result) -> - if err - return toastr.error err.reason + err = SideNav.validate() + if not err + Meteor.call 'createChannel', instance.find('#channel-name').value, instance.selectedUsers.get(), (err, result) -> + if err + return toastr.error err.reason - SideNav.closeFlex() + SideNav.closeFlex() - instance.clearForm() + instance.clearForm() - Router.go 'room', { _id: result.rid } + Router.go 'room', { _id: result.rid } + else + Template.instance().error.set(err) Template.channelsFlex.onCreated -> instance = this instance.selectedUsers = new ReactiveVar [] instance.selectedUserNames = {} + instance.error = new ReactiveVar [] instance.clearForm = -> + instance.error.set([]) instance.selectedUsers.set([]) instance.find('#channel-name').value = '' instance.find('#channel-members').value = '' diff --git a/client/views/app/sideNav/channelsFlex.html b/client/views/app/sideNav/channelsFlex.html index 7c8de925f13..5052d31a59e 100644 --- a/client/views/app/sideNav/channelsFlex.html +++ b/client/views/app/sideNav/channelsFlex.html @@ -6,7 +6,7 @@
The field {{error}} is required.
+ {{/each}} +The field {{error}} is required.
+ {{/each}} +