<% layout('../layouts/main') -%> <%
script('https://cdn.ckeditor.com/4.11.1/full-all/ckeditor.js') %>

<!-- Select2 -->
<% stylesheet('/css/select2.min.css') %>

<!-- Select2 -->
<% script('/js/select2.full.min.js') %> <% block('custom_scripts', `
<script>
  function goBack() {
    window.history.back();
  }
  $(function() {
    //Initialize Select2 Elements
    $(".select2").select2();
  });
  $(function() {
    //Initialize Select2 Elements
    // $('.select2').select2()

    CKEDITOR.replace("description");
  });
</script>
`) %> <% block('custom_style', `
<style type="text/css">
  .select2-container--default
    .select2-selection--multiple
    .select2-selection__choice {
    background-color: #2a83a7;
    border: 1px solid #2a83a7;
  }
</style>
`) %>

<!-- Content Header (Page header) -->
<section class="content-header">
  <h1>
    Edit Description
    <!--<small>Preview</small>-->
  </h1>
  <ol class="breadcrumb">
    <li>
      <a href="/dashboard"><i class="fa fa-dashboard"></i> Home</a>
    </li>
    <li>
      <a href="<%= '/homestays/translate/'+doc.homestay._id %>"
        >Description List</a
      >
    </li>
    <li class="active">Edit</li>
  </ol>
</section>

<!-- Main content -->
<section class="content">
  <% if (Object.prototype.hasOwnProperty.call(flash, 'success')) { %>
  <div class="alert alert-success alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
    <%= flash.success %>
  </div>
  <% } %> <% if (Object.prototype.hasOwnProperty.call(flash, 'error')) { %>
  <div class="alert alert-danger alert-dismissible" role="alert">
    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
      <span aria-hidden="true">&times;</span>
    </button>
    <%= flash.error %>
  </div>
  <% } %>
  <div class="box box-primary">
    <form role="form" class="has-validation-callback" method="POST">
      <div class="box-header with-border">
        <h3 class="box-title">
          Edit Description for
          <strong>
            <%= doc.homestay.name || '' %> ( <%= doc.language.name || ''
            %>)</strong
          >
        </h3>
      </div>
      <!-- /.box-header -->
      <div class="box-body">
        <div class="row">
          <input
            name="homestay"
            value="<%= doc.homestay._id %>"
            type="hidden"
          />
          <div class="form-group col-md-12">
            <!-- <label>Description</label> -->
            <textarea
              name="description"
              id="description"
              class="form-control"
              rows="8"
              required
            >
<%= doc.description %></textarea
            >
          </div>
        </div>
      </div>
      <!-- /.row -->
      <div class="box-footer">
        <div class="pull-left">
          <p class="text-success"></p>
        </div>
        <div class="pull-right">
          <a onclick="goBack();" class="btn btn-primary" role="button"
            >Cancel</a
          >
          <input
            name="submit"
            value="Update"
            class="btn btn-primary"
            type="submit"
          />
        </div>
      </div>
      <!--<div class="box-footer">
          Visit <a href="https://select2.github.io/">Select2 documentation</a> for more examples and information about
          the plugin.
      </div>-->
    </form>
  </div>
  <!-- /.box -->
</section>
<!-- /.content -->
