Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix form when SLACK_CHANNELS contains only one entry #152

Merged
merged 1 commit into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lib/assets/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ var body = document.body;
var request = superagent;

// elements
var select = body.querySelector('select');
var input = body.querySelector('input');
var coc = body.querySelector('input[name=coc]');
var form = body.querySelector('form#invite');
var channel = form.elements['channel'];
var email = form.elements['email'];
var coc = form.elements['coc'];
var button = body.querySelector('button');

// remove loading state
Expand All @@ -18,8 +19,7 @@ body.addEventListener('submit', function(ev){
button.disabled = true;
button.className = '';
button.innerHTML = 'Please Wait';
var channel = select ? select.value : null;
invite(channel, coc && coc.checked ? 1 : 0, input.value, function(err, msg){
invite(channel.value, coc && coc.checked ? 1 : 0, email.value, function(err, msg){
if (err) {
button.removeAttribute('disabled');
button.className = 'error';
Expand Down
19 changes: 12 additions & 7 deletions lib/splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ export default function splash({ path, name, org, coc, logo, active, total, chan
]
: [dom('b.total', total), ' users are registered so far.']
),
dom('form',
// channel selection when there are multiple
channels && channels.length > 1 && dom('select.form-item name=channel',
channels.map(channel => {
return dom('option', { value: channel, text: channel });
})
dom('form id=invite',
channels && (
channels.length > 1
// channel selection when there are multiple
? dom('select.form-item name=channel',
channels.map(channel => {
return dom('option', { value: channel, text: channel });
})
)
// otherwise a fixed channel
: dom('input type=hidden name=channel', { value: channels[0] })
),
dom('input.form-item type=email placeholder=you@yourdomain.com '
dom('input.form-item type=email name=email placeholder=you@yourdomain.com '
+ (!iframe ? 'autofocus' : '')),
coc && dom('.coc',
dom('label',
Expand Down