ictgj-voting/templates/admin-editteam.html

343 lines
14 KiB
HTML
Raw Permalink Normal View History

2017-06-12 23:23:46 +00:00
{{ $uuid := .TemplateData.UUID }}
2017-04-21 18:17:18 +00:00
<div class="center">
2018-06-18 13:49:15 +00:00
<div class="team-management-buttons">
<h3>Team Management</h3>
2018-06-18 13:49:15 +00:00
<button id="edit-team-button" onclick="javascript:gotoTeamTab();" class="pure-button-toggle-first pure-button pure-button-primary">Team Details</button><br class="only-small" />
<button id="edit-game-button" onclick="javascript:gotoTeamGameTab();" class="pure-button-toggle-middle pure-button">Game Details</button><br class="only-small" />
<button id="edit-team-members-button" onclick="javascript:gotoTeamMemberTab();" class="pure-button-toggle-last pure-button">Team Members</button><br class="only-small" />
</div>
<div id="edit-team-tab" class="left">
2017-06-15 17:35:53 +00:00
<form class="pure-form pure-form-aligned" action="/admin/teams/{{ $uuid }}/save" method="POST">
<h3>Team Details</h3>
<fieldset>
<div class="left big-space">
<div class="pure-control-group">
<label class="control-label" for="teamname">Team Name</label>
<input id="teamname" name="teamname" value="{{ .TemplateData.Name }}" placeholder="Team Name">
</div>
</div>
2018-06-18 13:49:15 +00:00
<div class="pure-control-group team-management-buttons">
<a href="/admin/teams" class="pure-button pure-button-plain">Cancel</a>
<button type="submit" class="pure-button pure-button-primary">Update Team</button>
<button type="button" id="btnDeleteTeam" class="pure-button pure-button-error">Delete Team</button>
2017-06-15 17:35:53 +00:00
</div>
</fieldset>
</form>
</div>
2017-04-21 18:17:18 +00:00
<div id="edit-game-tab" class="left big-space hidden">
<form class="pure-form pure-form-aligned" action="/admin/games/{{ $uuid }}/save" method="POST">
<fieldset>
<a name="game" />
2017-06-15 17:35:53 +00:00
<h3>Team Game</h3>
<div class="pure-control-group">
<label class="control-label" for="gamename">Game Name</label>
<input id="gamename" name="gamename" value="{{ .TemplateData.Game.Name }}" placeholder="Game Name">
</div>
<div class="pure-control-group">
<label class="control-label" for="gamelink">Link</label>
<input id="gamelink" name="gamelink" value="{{ .TemplateData.Game.Link }}" placeholder="Game Link">
</div>
<div class="pure-control-group">
2017-06-15 17:35:53 +00:00
<label class="control-label" for="gamedesc">Description</label>
<textarea id="gamedesc" name="gamedesc" placeholder="Description...">{{ .TemplateData.Game.Description }}</textarea>
</div>
<div class="pure-control-group reset-pull">
<a href="/admin/teams/{{ $uuid }}" class="pull-left space pure-button pure-button-plain">Cancel</a>
<button type="submit" class="pull-right space pure-button pure-button-primary">Update Game</button>
2017-06-15 17:35:53 +00:00
</div>
</fieldset>
</form>
<div class="pure-control-group">
<label class="control-label">Screenshots</label>
<div class="center-all horizontal-scroll thumbnail-container" id="thumbnail-container">
{{ if not .TemplateData.Game.Screenshots }}
<a style="margin-top:40px;" class="center-all pure-button pure-button-primary" href="javascript:toggleUploadSSForm();">Upload Screenshot</a>
{{ else }}
{{ range $i, $v := .TemplateData.Game.Screenshots }}
<img data-teamid="{{ $uuid }}" data-ssid="{{ $v.UUID }}" class="thumbnail" alt="{{ $v.Description }}" src="data:image/{{$v.Filetype}};base64,{{ $v.Thumbnail }}" />
{{ end }}
{{ end }}
2017-04-21 18:17:18 +00:00
</div>
{{ if .TemplateData.Game.Screenshots }}
<div class="right">
<a id="toggleUploadSSFormBtn" class="pure-button pure-button-primary" href="javascript:toggleUploadSSForm();">Upload Screenshot</a>
2017-04-21 18:17:18 +00:00
</div>
{{ end }}
</div>
</div>
2017-06-08 20:43:11 +00:00
<div id="edit-team-members-tab" class="left hidden">
2017-06-15 17:35:53 +00:00
<h3>Team Members</h3>
<table class="center padding hide">
<thead>
<tr>
<th>Name</th>
2018-06-18 13:49:15 +00:00
<th class="only-large">Slack ID</th>
<th class="only-large">Twitter</th>
<th class="only-large">Email</th>
2017-06-15 17:35:53 +00:00
<th>Remove</th>
</tr>
</thead>
<tbody>
{{ range $i, $v := .TemplateData.Members }}
<tr>
<td>{{ $v.Name }}</td>
2018-06-18 13:49:15 +00:00
<td class="only-large">{{ $v.SlackId }}</td>
<td class="only-large">{{ $v.Twitter }}</td>
<td class="only-large">{{ $v.Email }}</td>
2017-06-15 17:35:53 +00:00
<td>
<form action="/admin/teams/{{ $uuid }}/deletemember" method="POST">
<input type="hidden" name="memberid" value="{{ $v.UUID }}"/>
<button type="submit" class="pure-button pure-button-error"><i class="fa fa-trash"></i></button>
</form>
</td>
</tr>
{{ end }}
<tr>
<td colspan="6">Add a new member</td>
</tr>
<tr>
<td colspan="6" class="padding">
<form class="pure-form" action="/admin/teams/{{ $uuid }}/savemember" method="POST">
<div class="pure-control-group">
<input id="newmembername" name="newmembername" value="" placeholder="Member Name" autofocus />
2017-06-12 23:23:46 +00:00
<input id="newmemberslackid" name="newmemberslackid" value="" placeholder="@SlackID" />
<input id="newmembertwitter" name="newmembertwitter" value="" placeholder="@Twitter" />
<input id="newmemberemail" name="newmemberemail" value="" placeholder="user@email.com" />
2017-06-15 17:35:53 +00:00
<button type="submit" class="pull-right space-sides pure-button pure-button-primary">Add</button>
</div>
</form>
</td>
</tr>
</tbody>
</table>
</div>
</div>
<div id="uploadscreenshotform" style="display:none;">
<h3>Upload Screenshot</h3>
<form class="pure-form pure-form-aligned" action="/admin/games/{{ $uuid }}/screenshotupload" method="POST" enctype="multipart/form-data">
<div class="pure-control-group" style="margin-bottom:50px;">
<input class="file" type="file" name="newssfile" multiple>
</div>
<a href="javascript:hideModal();" class="pull-left space-sides pure-button">Cancel</a>
<button type="submit" class="pull-right space-sides pure-button pure-button-primary">Add</button>
</form>
2017-04-21 18:17:18 +00:00
</div>
<div id="editscreenshotform" style="display:none;">
<div id="editss-container" class="pure-control-group" style="margin-bottom:50px;">
</div>
</div>
2017-04-21 18:17:18 +00:00
<script>
snack.listener(
{node:document.getElementById('btnDeleteTeam'),event:'click'},
function() {
showModal({
title: 'Delete Team',
2017-06-15 17:35:53 +00:00
subtitle: '({{ .TemplateData.Name }})',
2017-04-21 18:17:18 +00:00
body: 'Are you sure? This cannot be undone.',
buttons: [{
title:'Cancel',
position:'left',
click: hideModal
},{
title:'Delete',
position:'right',
class: 'pure-button-error',
2017-06-12 23:23:46 +00:00
href: '/admin/teams/{{ $uuid }}/delete'
2017-04-21 18:17:18 +00:00
}]
});
}
);
snack.listener(
{
node:document.getElementById('thumbnail-container'),
event:'click',
delegate: function(node) {
return node.getElementsByTagName('img');
}
},
function() {
showEditScreenShotModal(snack.wrap(this)[0]);
}
);
function showEditScreenShotModal(img) {
showModal({
title: 'Edit Screenshot',
bodyNode: img.cloneNode(true),
buttons: [
{ title: 'Delete', class: 'pure-button-error', position: 'right',
click: function() {
window.location = "/admin/games/{{ $uuid }}/screenshotdelete/"+img.dataset.ssid;
}
},
{ title: 'Cancel', class: 'pure-button', position: 'right', click: hideModal }
]
});
}
2017-06-15 17:35:53 +00:00
function toggleUploadSSForm() {
if(valuesChanged()) {
showModal({
title: 'Unsaved Changes',
subtitle: '',
body: "You've made some changes, but haven't saved them yet, if you continue they will be lost.",
buttons: [{
title: 'Cancel Changes',
class: 'pure-button-error',
click: function() {
revertChanges();
toggleUploadSSForm();
hideModal();
}
},{
title: 'Go Back',
class: 'pure-button-primary',
click: hideModal
}]
});
} else {
2017-07-25 16:16:46 +00:00
var uploadForm = document.getElementById('uploadscreenshotform').cloneNode(true);
showModal({
title: 'Upload Screenshot',
subtitle: '({{ .TemplateData.Name }})',
bodyNode: uploadForm
});
uploadForm.style.display="block";
document.getElementById('modal-body').style.height='165px';
}
}
function valuesChanged() {
// Check if Team Name changed
if(document.getElementById('teamname').value != '{{ .TemplateData.Name }}') { return true; }
// Check if Game Details changed
if(document.getElementById('gamename').value != '{{ .TemplateData.Game.Name }}') { return true; }
if(document.getElementById('gamelink').value != '{{ .TemplateData.Game.Link }}') { return true; }
if(scrubString(document.getElementById('gamedesc').value) != scrubString('{{ .TemplateData.Game.Description }}')) { return true; }
// Check if new member details have been entered
if(document.getElementById('newmembername').value != '') { return true; }
if(document.getElementById('newmemberslackid').value != '') { return true; }
if(document.getElementById('newmembertwitter').value != '') { return true; }
if(document.getElementById('newmemberemail').value != '') { return true; }
return false;
}
function scrubString(inp) {
inp = inp.replace(/\r\n/g, "");
inp = inp.replace(/\n/g, "");
return inp
}
function revertChanges() {
// Reset Team Name
document.getElementById('teamname').value = '{{ .TemplateData.Name }}';
// Reset Game Details
document.getElementById('gamename').value = '{{ .TemplateData.Game.Name }}';
document.getElementById('gamelink').value = '{{ .TemplateData.Game.Link }}';
document.getElementById('gamedesc').value = '{{ .TemplateData.Game.Description }}';
// Reset new member fields
document.getElementById('newmembername').value = '';
document.getElementById('newmemberslackid').value = '';
document.getElementById('newmembertwitter').value = '';
document.getElementById('newmemberemail').value = '';
}
function gotoTeamTab() {
if(valuesChanged()) {
showModal({
title: 'Unsaved Changes',
subtitle: '',
body: "You've made some changes, but haven't saved them yet, if you continue they will be lost.",
buttons: [{
title: 'Cancel Changes',
class: 'pure-button-error',
click: function() {
revertChanges();
gotoTeamTab();
hideModal();
}
},{
title: 'Go Back',
class: 'pure-button-primary',
click: hideModal
}]
});
} else {
document.getElementById('edit-team-button').classList.add('pure-button-primary');
document.getElementById('edit-game-button').classList.remove('pure-button-primary');
document.getElementById('edit-team-members-button').classList.remove('pure-button-primary');
document.getElementById('edit-team-tab').classList.remove('hidden');
document.getElementById('edit-game-tab').classList.add('hidden');
document.getElementById('edit-team-members-tab').classList.add('hidden');
}
}
function gotoTeamGameTab() {
if(valuesChanged()) {
showModal({
title: 'Unsaved Changes',
subtitle: '',
body: "You've made some changes, but haven't saved them yet, if you continue they will be lost.",
buttons: [{
title: 'Cancel Changes',
class: 'pure-button-error',
click: function() {
revertChanges();
gotoTeamGameTab();
hideModal();
}
},{
title: 'Go Back',
class: 'pure-button-primary',
click: hideModal
}]
});
} else {
document.getElementById('edit-team-button').classList.remove('pure-button-primary');
document.getElementById('edit-game-button').classList.add('pure-button-primary');
document.getElementById('edit-team-members-button').classList.remove('pure-button-primary');
document.getElementById('edit-team-tab').classList.add('hidden');
document.getElementById('edit-game-tab').classList.remove('hidden');
document.getElementById('edit-team-members-tab').classList.add('hidden');
}
}
function gotoTeamMemberTab() {
if(valuesChanged()) {
showModal({
title: 'Unsaved Changes',
subtitle: '',
body: "You've made some changes, but haven't saved them yet, if you continue they will be lost.",
buttons: [{
title: 'Cancel Changes',
class: 'pure-button-error',
click: function() {
revertChanges();
gotoTeamMemberTab();
hideModal();
}
},{
title: 'Go Back',
class: 'pure-button-primary',
click: hideModal
}]
});
} else {
document.getElementById('edit-team-button').classList.remove('pure-button-primary');
document.getElementById('edit-game-button').classList.remove('pure-button-primary');
document.getElementById('edit-team-members-button').classList.add('pure-button-primary');
document.getElementById('edit-team-tab').classList.add('hidden');
document.getElementById('edit-game-tab').classList.add('hidden');
document.getElementById('edit-team-members-tab').classList.remove('hidden');
}
}
if(window.location.hash == '#game') {
gotoTeamGameTab();
} else if(window.location.hash == '#members') {
gotoTeamMemberTab();
2017-06-15 17:35:53 +00:00
}
2017-04-21 18:17:18 +00:00
</script>