Socialify

Folder ..

Viewing citizens.ejs
168 lines (164 loc) • 5.0 KB

  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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
<!DOCTYPE html>
<html lang="en">
  <head>
    <%- include('partials/head') %>
    <style>
      .ui.menu {
        margin-top: 0;
      }
      .scrollY {
        max-height: calc(100vh - 8rem);
        margin-top: 1rem;
        overflow-y: scroll;
      }
      .ui.table thead tr:first-child > th {
        position: sticky !important;
        top: 0;
        z-index: 2;
      }
      .ui.table tfoot tr:first-child > th {
        position: sticky !important;
        bottom: 0;
        z-index: 2;
      }
    </style>
  </head>

  <body>
    <div class="ui modal edit">
      <i class="close icon"></i>
      <div class="header">Editing Citizen (<span id="citizen_id"></span>)</div>
      <div
        class="ui padded container segment"
        style="border: none; box-shadow: none"
      >
        <form class="ui form" method="post" onsubmit="editCitizen(event)">
          <div class="field">
            <label>Address</label>
            <input
              placeholder="Address"
              name="address"
              type="text"
              autocomplete="off"
              id="address"
            />
          </div>
          <div class="field">
            <label>Mobile Number</label>
            <input
              type="text"
              name="mobile_number"
              placeholder="Mobile Number"
              id="mobile_number"
            />
          </div>
          <div class="field">
            <label>Date of Birth</label>
            <input type="date" name="dob" placeholder="DOB" id="dob" />
          </div>
          <div class="field">
            <label>Marital Status</label>
            <select class="ui dropdown" id="marital_status">
              <option value="M">Married</option>
              <option value="UM">Unmarried</option>
            </select>
          </div>
          <div class="ui primary button" id="editCitizen">Submit</div>
          <div class="ui error message"></div>
        </form>
      </div>
    </div>

    <%- include('partials/navbar') %>

    <!-- Drop down for selecting limit -->
    <% if(citizens.length){ %>
    <div class="ui container">
      <div class="ui floating labeled icon dropdown button">
        <i class="list icon"></i>
        <span class="text">Items</span>
        <div class="menu">
          <div class="item" onclick="redirectToLimit(10)">10</div>
          <div class="item" onclick="redirectToLimit(25)">25</div>
          <div class="item" onclick="redirectToLimit(50)">50</div>
          <div class="item" onclick="redirectToLimit(100)">100</div>
        </div>
      </div>
    </div>
    <% } %>
    <% if(!citizens.length){ %>
      <h1 style="text-align: center;">No Data Found</h1>
    <% } %>
    <% if(citizens.length){ %>
    <div class="scrollY">
      <table class="ui selectable table">
        <thead>
          <tr>
            <th>First Name</th>
            <th>Last Name</th>
            <th>Address</th>
            <th>Mobile Number</th>
            <th>Date of Birth</th>
            <th>Gender</th>
            <th>Marital Status</th>
            <th>Village Name</th>
            <th></th>
          </tr>
        </thead>
        <tbody>
          <% for(var i=0; i < citizens.length; i++) { %>
          <tr>
            <td><%= citizens[i].first_name %></td>
            <td><%= citizens[i].last_name %></td>
            <td><%= citizens[i].address %></td>
            <td><%= citizens[i].mobile_num %></td>
            <td><%= citizens[i].dob %></td>
            <td><%= citizens[i].gender %></td>
            <td><%= citizens[i].marital_status %></td>
            <td><%= citizens[i].village_name %></td>
            <td>
              <div class="ui teal buttons">
                <div
                  class="ui button"
                  onclick="editCitizensRecord('<%=JSON.stringify(citizens[i])%>')"
                >
                  Edit
                </div>
                <div class="ui floating dropdown icon button">
                  <i class="dropdown icon"></i>
                  <div class="menu">
                    <div
                      class="item"
                      onclick="deleteCitizenRecord('<%= JSON.stringify(citizens[i])%>')"
                    >
                      <i class="delete icon"></i> Delete
                    </div>
                  </div>
                </div>
              </div>
            </td>
          </tr>
          <% } %>
        </tbody>
        <!-- Display a pagination -->
        <tfoot>
          <tr>
            <th colspan="9">
              <div class="ui right floated pagination menu">
                <a class="icon item" id="pageLeft">
                  <i class="left chevron disabled icon"></i>
                </a>

                <a class="icon item" id="pageRight">
                  <i class="right chevron disabled icon"></i>
                </a>
              </div>
            </th>
          </tr>
        </tfoot>
      </table>
    </div>
    <% } %>
  </body>
  <%- include('partials/scripts') %>
  <script>
    const count = "<%= count %>";
  </script>
  <script src="/citizens.js"></script>
</html>