summaryrefslogtreecommitdiff
path: root/views/newevent.handlebars
blob: b63b43cea61971503015ffd33ec6bc75e381d33b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
{{#if isPublic}}
  <h2>New public event</h2>
  <hr>
	<div class="alert alert-info mb-4 text-center" role="alert">
  	<i class="fas fa-exclamation-circle"></i> A public event is visible to anyone who knows the link.
	</div>
{{else if isPrivate}}
  <h2>New private event</h2>
  <hr>
  <p>A private event is only visible to those who know the <strong>event password</strong>.</p>
  <hr>
{{else if isOrganisation}}
  <h2>New organisation event</h2>
  <p>An organisation event is linked to an existing <strong>organisation</strong>. It can be made public, in which case it is visible to anyone who has the link, or private, in which case it is only visible to those who know the <strong>event password</strong>. </p>
  <hr>
{{else if isUnknownType}}
	<h2>New event</h2>
	<hr>
	<div class="alert alert-warning" role="alert">
		Event creation error: unknown event type. Please select an event type from the sidebar.
	</div>
{{else}}
 <h2>New event</h2>
 <hr>
  <div class="alert alert-warning" role="alert">
		Event creation error: unknown event type. Please select an event type from the sidebar.
	</div>
{{/if}}


{{#each errors}}
	<div class="alert alert-danger" role="alert">{{this.msg}}</div>
{{/each}}

<div class="container mb-4">
  <div class="row">
    <div class="col-sm-6 p-2">
      <button type="button" id="showNewEventFormButton" class="btn btn-lg btn-secondary w-100"><i class="fas fa-file"></i> Create a new event</button>
    </div>
    <div class="col-sm-6 p-2">
      <button type="button" id="showImportEventFormButton" class="btn btn-lg btn-secondary w-100"><i class="fas fa-file-import"></i> Import an existing event</button>
    </div>
  </div>
</div>

<div id="newEventFormContainer">
  {{#if isPublic}}
  	{{>neweventform}}
  {{else if isPrivate}}
  	{{>neweventform}}
  {{else if isOrganisation}}
  	{{>neweventform}}
  {{else}}
  {{/if}}
</div>

<div id="importEventFormContainer">
  {{>importeventform}}
</div>


	<script>
  $.validate({
    lang: 'en',
		errorElementClass: "is-invalid",
		errorMessageClass: "text-danger",
		successElementClass: "is-valid"
  });
  $(document).ready(function(){
    if ($('#icsImportControl')[0].files[0] != null){
      var file = $('#icsImportControl')[0].files[0].name;
      $('#icsImportControl').next('label').html('<i class="far fa-file-alt"></i> ' + file);
    }
    $('#eventStart').datepicker({
      language: 'en',
      minDate: new Date(),
      timepicker: true,
      dateFormat: 'd MM yyyy',
      dateTimeSeparator: ', ',
      onSelect: function(formattedDate, rawDate){
        $('#eventEnd').datepicker().data('datepicker').update('minDate', rawDate).clear();
      }
    });
    $('#eventEnd').datepicker({
      language: 'en',
      minDate: new Date(),
      timepicker: true,
      dateFormat: 'd MM yyyy',
      dateTimeSeparator: ', '
    });
    $("#showNewEventFormButton").click(function(){
      $("#showImportEventFormButton").removeClass("active");
      if ($("#newEventFormContainer").is(":visible")){
        $("#newEventFormContainer").slideUp("fast");
        $(this).removeClass("active");
      }
      else {
        $("#newEventFormContainer").slideDown("fast");
        $("#importEventFormContainer").slideUp("fast");
        $(this).addClass("active");
      }
    })
    $("#showImportEventFormButton").click(function(){
      $("#showNewEventFormButton").removeClass("active");
      if ($("#importEventFormContainer").is(":visible")){
        $("#importEventFormContainer").slideUp("fast");
        $(this).removeClass("active");
      }
      else {
        $("#importEventFormContainer").slideDown("fast");
        $("#newEventFormContainer").slideUp("fast");
        $(this).addClass("active");
      }
    })
    $('#icsImportControl').change(function(){
      var file = $('#icsImportControl')[0].files[0].name;
      $(this).next('label').html('<i class="far fa-file-alt"></i> ' + file);
    });
  })
	</script>