RSS Git Download  Clone
Raw Blame History
<!-- BEGIN [% component.name %] -->
[%# PROCESS dumper.tt dump = entry %]

[% INCLUDE alerts.tt # success & error messages %]

[%
  # set label to 'Edit' if next route is 'edit', otherwise 'Submit':
  SET label = vars.next_route.match('edit') ? 'Edit' : 'Submit';
  # disable input fields if next route is 'edit':
  SET disable_input = vars.next_route.match('edit') ? 1 : 0;
     # PROCESS dumper.tt dump = vars.hx_request.current_url;
     # PROCESS dumper.tt dump = vars.next_route;
     # PROCESS dumper.tt dump = disable_input;
%]

<div class="">
  <form hx-post="[% vars.hx_request.current_url _ vars.next_route %]"
        enctype="multipart/form-data" hx-target="#hx-container"
        id="[% vars.next_route.remove('/\d') %]">
    <div class="my-3">
      <!-- description -->
	  <div class="input-group flex-nowrap">
	    <span class="input-group-text col-md-2" id="description">Description</span>
	    <input type="text" class="form-control"
          [% IF entry.description %]value="[% entry.description %]"
               [% 'disabled' IF disable_input %]
          [% ELSE %]required="true"[% END %]
          aria-label="description" name="description" placeholder="">
      </div>
      <!-- category -->
	  <div class="input-group flex-nowrap">
	    <span class="input-group-text col-md-2" id="title">Category</span>
        <select name="category" class="form-control" id="category" required="true"
          [% 'disabled' IF disable_input %]>
          <option value="">--- select ---</option>
          [% FOREACH opt in dpw_categories.sort %]
            <option value="[% opt  %]" [% 'selected' IF entry.category.match(opt) %]>
              [% opt.ucfirst %]</option>
          [% END %]
        </select>
     </div>
    <!-- comment -->
	  <div class="input-group flex-nowrap">
	    <span class="input-group-text col-md-2" id="keywords">Comment</span>
		[% IF entry.comment.match('^http') AND NOT vars.is_edit %]
	     <span class="form-control disabled"><a href="[% entry.comment %]" target="_blank">
			[% entry.comment %]</a></span>
		[% ELSE %]
	    <input type="text" class="form-control" [% IF entry.comment %]
	      value="[% entry.comment %]" [% 'disabled' IF disable_input %]
        [% ELSE %]required="true"[% END %] aria-label="comment" name="comment"
        placeholder="" />
		[% END %]
	  </div>
      <!-- date -->
	  <div class="input-group flex-nowrap">
	    <span class="input-group-text col-md-2" id="date">Date</span>
        <input type="text" id="datepicker" class="form-control"
          [% IF entry.date %]value="[% entry.date %]"
               [% 'disabled' IF disable_input %]
          [% ELSE %]required="true"[% END %]
            name="date" placeholder="Select a date" />
		 <span class="input-group-text"><i class="bi bi-calendar"></i></span>
	  </div>
      <!-- file -->
	  <div class="input-group flex-nowrap">
	    <span class="input-group-text col-md-2" id="file">File</span>
			[% IF vars.next_route.match('update');
				IF params.replace_file %]
				  <input type="file" class="form-control" name="filename" id="formFile" />
				[% ELSE %]
					<input type="text" class="form-control" name="filename"
						value="[% entry.filename %]" readonly="readonly" id="filename" />
					<span class="input-group-text">
						<a hx-post="[% uri_for_section.dpw.edit %]/[% entry.id
                            %]?replace_file=1" hx-target="#hx-container">
						  <i class="bi bi-arrow-repeat"></i>
					  </a>
					</span>
				[% END %]
			[% ELSIF entry.size # display only, with a href (use .size in case no file) %]
			  <span class="form-control disabled">
					[% IF entry.filename %]
				  <a href="[% uri_for_section.dpw.download %]/[% entry.category %]/[% entry.filename %]"
					  target="_blank">[% entry.filename | uri %]</a>
					[% END %]
			  </span>
			[% ELSE # new entry %]
			  <input type="file" class="form-control" name="filename" id="formFile" />
			[% END %]
        </div>
      <!-- retained -->
  	  <div class="input-group flex-nowrap">
        <span class="input-group-text col-md-2" id="title">Retained</span>
      
        <span class="form-control">
          [% FOREACH opt IN [ 'y' 'n' ] %]
          <input type="radio" id="retained_[% opt %]" name="retained" value="[% opt %]"
            required="true" [% IF entry.retained.match(opt) %]checked="checked"[% END %]
            [% 'disabled' IF disable_input %]>
          <label for="retained_[% opt %]">[% opt | upper %]</label>
          <span class="m-3"></span>
          [% END %]
        </span>
      </div>
  </div>

     <div class="my-3">
      <button type="submit" class="btn btn-outline-primary">[% label %]</button>
      <button type="reset"  class="btn btn-outline-secondary">Clear</button>
    </div>
    </form>
  </div>

<div id="hx-container" class="container"></div>
<!-- END [% component.name %] -->